tributa 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0b65a76afc2954936f44f088e90fe757761e3e65f366e07eec20667dcc8c66b1
4
- data.tar.gz: 6647b485edd339c163f6fdb3d9cbc6030560c3710c3c92d26f662e958fb95385
3
+ metadata.gz: 168648ce147b91dcfd81733a7a73faffce8ffc628591fd4dcf414595488c4546
4
+ data.tar.gz: f0c267805bbfff7fa30c2a7c90e53c6c1576fc1b322114821339a233d8d14bd3
5
5
  SHA512:
6
- metadata.gz: 321be087252f7378c63eb3f709305d25f88c38c83a4864316a23c3af31b90920e46718fa5391772f3da3464b5e3ba7857b8cb7eca01bfb7580987897c8f1c11a
7
- data.tar.gz: ed51942f7e356c0b93611b3c79516e3863dc27040a6b81400e55104b734fa9e0cdee698379e7fcfef3c53035f233cdd0f93e842a42bfa4a7456b858634e7915c
6
+ metadata.gz: 5f6c9d09ef8fb66e28ff54a02fc19a00fb961f810dd106eea4fffa11b714869a0381217fb643e5862e95410772c312c093d771b42e2acdef669258479757d0b4
7
+ data.tar.gz: 901e53ea53069eb72321abc743f7ef6d195079e7e3be82e08851663af62df1face08c2844684f617adec2bba0f13f1794b31b6a1181ed3aa44f605c767f9a4eb
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tributa (0.1.0)
4
+ tributa (0.1.1)
5
5
  nokogiri
6
6
 
7
7
  GEM
@@ -2,37 +2,39 @@ require 'nokogiri'
2
2
  require_relative 'table'
3
3
  require_relative 'table/row'
4
4
 
5
- class Tributa::HtmlToTributaTableTransformer
6
- attr_reader :html
5
+ module Tributa
6
+ class HtmlToTributaTableTransformer
7
+ attr_reader :html
7
8
 
8
- def initialize(html)
9
- @html = html
10
- end
9
+ def initialize(html)
10
+ @html = html
11
+ end
11
12
 
12
- def to_tributa_table
13
- Tributa::Table.new(rows)
14
- end
13
+ def to_tributa_table
14
+ Tributa::Table.new(rows)
15
+ end
15
16
 
16
- private
17
+ private
17
18
 
18
- def nhtml
19
- @nhtml ||= Nokogiri::HTML(sanitize_html)
20
- end
19
+ def nhtml
20
+ @nhtml ||= Nokogiri::HTML(sanitize_html)
21
+ end
21
22
 
22
- def rows
23
- nokogiri_rows.map(&method(:to_tributa_table_row))
24
- end
23
+ def rows
24
+ nokogiri_rows.map(&method(:to_tributa_table_row))
25
+ end
25
26
 
26
- def nokogiri_rows
27
- nhtml.xpath('//table//tr')[2..]
28
- end
27
+ def nokogiri_rows
28
+ nhtml.xpath('//table//tr')[2..]
29
+ end
29
30
 
30
- def sanitize_html
31
- @sanitize_html ||= html[/<table class=.rahmen. width=.950.>(.*)<\/table><BR><BR>/i].gsub(/<br><br>$/i, '')
32
- end
31
+ def sanitize_html
32
+ @sanitize_html ||= html[/<table class=.rahmen. width=.950.>(.*)<\/table><BR><BR>/i].gsub(/<br><br>$/i, '')
33
+ end
33
34
 
34
- def to_tributa_table_row(nokogiri_row)
35
- values = nokogiri_row.xpath('td').map(&:text)
36
- Tributa::Table::Row.new(values)
35
+ def to_tributa_table_row(nokogiri_row)
36
+ values = nokogiri_row.xpath('td').map(&:text)
37
+ Tributa::Table::Row.new(values)
38
+ end
37
39
  end
38
40
  end
@@ -1,13 +1,15 @@
1
- class Tributa::Table::Row
2
- attr_reader :canton, :year, :community, :canton_rate, :community_rate, :reformed_rate, :catholic_rate
1
+ module Tributa
2
+ class Table::Row
3
+ attr_reader :canton, :year, :community, :canton_rate, :community_rate, :reformed_rate, :catholic_rate
3
4
 
4
- def initialize(columns = [])
5
- @canton,
6
- @year,
7
- @community,
8
- @canton_rate,
9
- @community_rate,
10
- @reformed_rate,
11
- @catholic_rate = columns
5
+ def initialize(columns = [])
6
+ @canton,
7
+ @year,
8
+ @community,
9
+ @canton_rate,
10
+ @community_rate,
11
+ @reformed_rate,
12
+ @catholic_rate = columns
13
+ end
12
14
  end
13
15
  end
data/lib/tributa/table.rb CHANGED
@@ -1,15 +1,17 @@
1
- class Tributa::Table
2
- attr_reader :rows
1
+ module Tributa
2
+ class Table
3
+ attr_reader :rows
3
4
 
4
- def initialize(rows)
5
- @rows = rows
6
- end
5
+ def initialize(rows)
6
+ @rows = rows
7
+ end
7
8
 
8
- def find_all_by(canton:, community:, year:)
9
- rows.find_all do |row|
10
- row.canton == canton &&
11
- row.community == community &&
12
- row.year == year.to_s
9
+ def find_all_by(canton:, community:, year:)
10
+ rows.find_all do |row|
11
+ row.canton == canton &&
12
+ row.community == community &&
13
+ row.year == year.to_s
14
+ end
13
15
  end
14
16
  end
15
17
  end
@@ -1,3 +1,3 @@
1
1
  module Tributa
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tributa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - mario