sii_chile 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -26,22 +26,24 @@ module SIIChile
26
26
 
27
27
  data = Nokogiri::HTML(response.body)
28
28
 
29
+ actividades = data.xpath(XPATH_ACTIVIDADES)[1..-1].map do |node|
30
+ {
31
+ :giro => node.xpath('./td[1]/font').text.strip,
32
+ :codigo => node.xpath('./td[2]/font').text.strip.to_i,
33
+ :categoria => node.xpath('./td[3]/font').text.strip,
34
+ :afecta => node.xpath('./td[4]/font').text.strip == 'Si'
35
+ }
36
+ end rescue []
37
+
29
38
  {
30
39
  :rut => @rut.format,
31
40
  :razon_social => data.xpath(XPATH_RAZON_SOCIAL).text.strip,
32
- :actividades => data.xpath(XPATH_ACTIVIDADES)[1..-1].map do |node|
33
- {
34
- :giro => node.xpath('./td[1]/font').text.strip,
35
- :codigo => node.xpath('./td[2]/font').text.strip.to_i,
36
- :categoria => node.xpath('./td[3]/font').text.strip,
37
- :afecta => node.xpath('./td[4]/font').text.strip == 'Si'
38
- }
39
- end
41
+ :actividades => actividades
40
42
  }
41
- rescue Error => e
43
+ rescue StandardError => e
42
44
  {
43
45
  :rut => @rut.format,
44
- :error => e.mensage
46
+ :error => e.message
45
47
  }
46
48
  end
47
49
  end
data/lib/sii_chile/rut.rb CHANGED
@@ -30,7 +30,7 @@ module SIIChile
30
30
  digit, factor = *a
31
31
  r += digit.to_i * factor
32
32
  end
33
- all_codes[11 - partial_sum%11].to_s
33
+ all_codes[(11 - partial_sum%11)%11].to_s
34
34
  end
35
35
 
36
36
  def number_with_delimiter(delimiter='.')
@@ -1,3 +1,3 @@
1
1
  module SIIChile
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: sii_chile
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -88,7 +88,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
88
88
  version: '0'
89
89
  segments:
90
90
  - 0
91
- hash: -2214251905855754505
91
+ hash: 668395706914905858
92
92
  required_rubygems_version: !ruby/object:Gem::Requirement
93
93
  none: false
94
94
  requirements:
@@ -97,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
97
  version: '0'
98
98
  segments:
99
99
  - 0
100
- hash: -2214251905855754505
100
+ hash: 668395706914905858
101
101
  requirements: []
102
102
  rubyforge_project:
103
103
  rubygems_version: 1.8.23