This repository has been archived by the owner on Feb 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
parser_diputados
executable file
·83 lines (69 loc) · 1.95 KB
/
parser_diputados
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env ruby
# encoding: utf-8
# == Synopsis
# parser_diputados is a utility that scrap and generate a JSON file from www.diputados.gov.ar
#
#
# == Examples
# parser_diputados
#
# Other examples:
# parser_diputados -o diputados.json
# parser_diputados | python -mjson.tool
#
# == Usage
# parser_diputados [options]
#
# For help use: parser_diputados -h
#
# == Options
# -h, --help Displays help message
# -o, --output FILENAME Save the output to a file
# -c, --[no-]cache Use cache if exist
#
# TODO - Group diputados by block
#
# == Author
# Alfredo Ramirez
# Martín Szyszlican
#
# == Copyright
# Copyright (c) 2014 Congreso Interactivo. Licensed under the MIT License:
# http://www.opensource.org/licenses/mit-license.php
$LOAD_PATH.unshift("#{File.dirname(__FILE__)}/lib")
require 'optparse'
require 'parser_diputados'
require 'parser_popit'
require 'popit'
options = {}
options[:cache] = true
optparse = OptionParser.new do |option_parser|
option_parser.banner = "Usage: parser_diputados [options]"
option_parser.on("-o", "--output FILENAME", "Save the output to a file") do |o|
options[:output] = o
end
option_parser.on("-c", "--[no-]cache", "Use cache") do |c|
options[:cache] = c
end
option_parser.on("-i n", "--instance=n", "Send every row this instance of the PopIt Api on popit.mysociety.org. Default legisladores-ar [INSTANCE]") do |instance|
options[:instance_name] = instance
end
option_parser.on("-u n", "--user=n", "API user [USERNAME]") do |user|
options[:api_user] = user
end
option_parser.on("-p n", "--password=n", "API password [PASSWORD]") do |pass|
options[:api_pass] = pass
end
end
optparse.parse!
if options[:instance_name]
#Initialize API
options[:api] = PopIt.new(
:instance_name => options[:instance_name],
:user => options[:api_user],
:password => options[:api_pass]
)
end
parser = ParserDiputados.new options
parser.run
exit 0