From 74f9e535f1d9dc69bb227ea4ae017586ae266efe Mon Sep 17 00:00:00 2001 From: Mauro Berlanda Date: Mon, 21 Mar 2016 12:16:39 +0100 Subject: [PATCH] added bin tab --- .bundle/config | 2 ++ Gemfile.lock | 3 --- bin/bundler | 16 ++++++++++++++++ bin/byebug | 16 ++++++++++++++++ bin/nokogiri | 16 ++++++++++++++++ lib/agenzia_entrate/ae_scraper.rb | 9 +++++---- lib/istat/parse_from_log.rb | 2 +- 7 files changed, 56 insertions(+), 8 deletions(-) create mode 100644 .bundle/config create mode 100755 bin/bundler create mode 100755 bin/byebug create mode 100755 bin/nokogiri diff --git a/.bundle/config b/.bundle/config new file mode 100644 index 0000000..e66ea7b --- /dev/null +++ b/.bundle/config @@ -0,0 +1,2 @@ +--- +BUNDLE_BIN: bin diff --git a/Gemfile.lock b/Gemfile.lock index d8ca48e..65b83e4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -16,6 +16,3 @@ DEPENDENCIES byebug nokogiri test-unit - -BUNDLED WITH - 1.10.6 diff --git a/bin/bundler b/bin/bundler new file mode 100755 index 0000000..72c62ec --- /dev/null +++ b/bin/bundler @@ -0,0 +1,16 @@ +#!/usr/bin/env ruby +# +# This file was generated by Bundler. +# +# The application 'bundler' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require 'pathname' +ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +require 'rubygems' +require 'bundler/setup' + +load Gem.bin_path('bundler', 'bundler') diff --git a/bin/byebug b/bin/byebug new file mode 100755 index 0000000..168cef3 --- /dev/null +++ b/bin/byebug @@ -0,0 +1,16 @@ +#!/usr/bin/env ruby +# +# This file was generated by Bundler. +# +# The application 'byebug' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require 'pathname' +ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +require 'rubygems' +require 'bundler/setup' + +load Gem.bin_path('byebug', 'byebug') diff --git a/bin/nokogiri b/bin/nokogiri new file mode 100755 index 0000000..d55f84b --- /dev/null +++ b/bin/nokogiri @@ -0,0 +1,16 @@ +#!/usr/bin/env ruby +# +# This file was generated by Bundler. +# +# The application 'nokogiri' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require 'pathname' +ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +require 'rubygems' +require 'bundler/setup' + +load Gem.bin_path('nokogiri', 'nokogiri') diff --git a/lib/agenzia_entrate/ae_scraper.rb b/lib/agenzia_entrate/ae_scraper.rb index 6b96b9b..9176cd1 100644 --- a/lib/agenzia_entrate/ae_scraper.rb +++ b/lib/agenzia_entrate/ae_scraper.rb @@ -10,14 +10,15 @@ class AeScraper HOME_URL = 'https://telematici.agenziaentrate.gov.it/VerificaCF/Scegli.do?parameter=verificaCfPf' USER_AGENT = 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:44.0) Gecko/20100101 Firefox/44.0' BASE_URL = 'https://telematici.agenziaentrate.gov.it/VerificaCF/AjaxOptionListComuni.do?prov=' - + class << self + def execute cities = [] province_list.each do |prov, name| cities << cities_list(prov, name) end - + cities end def province_list @@ -37,13 +38,13 @@ def province_list def cities_list prov, prov_name result = [] url = BASE_URL + prov - cities = open(HOME_URL, "User-Agent" => USER_AGENT ){|f| f.read} + cities = open(url, "User-Agent" => USER_AGENT ){|f| f.read} doc = Nokogiri::XML(cities) doc.css('comuneImpl').each do |comune| result << AeCity.new(comune.css(name="dizione").text, comune.css(name="codCat").text, prov, prov_name) end + result end - end end \ No newline at end of file diff --git a/lib/istat/parse_from_log.rb b/lib/istat/parse_from_log.rb index bdb5a96..b8dbbda 100644 --- a/lib/istat/parse_from_log.rb +++ b/lib/istat/parse_from_log.rb @@ -5,7 +5,7 @@ class CapLog attr_reader :list - ROOT = File.expand_path("..", File.join(File.dirname(__FILE__))) + ROOT = File.expand_path("../..", File.join(File.dirname(__FILE__))) def initialize file_name file = File.open(File.join(ROOT, 'data', file_name)).read