ruby-ares 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 50972475ce973dc631c0dc3ecd6f1dfac01f2e25
4
- data.tar.gz: fc170ac8e02fc2c9275535636241efca524df9d0
3
+ metadata.gz: c201f2b161757e4d716d9e352b40e7474cc614ea
4
+ data.tar.gz: 2f797901583b9f8f543ca0bba76a3fdbc8b83a27
5
5
  SHA512:
6
- metadata.gz: f63f5c44c5e7b5527ca65513a0c0240e2ee7ec8bc753317e7f0cb1f4e22f86f8a87441d6135123beab6419257b267d1371d13114b5c6935217855579e3f3b196
7
- data.tar.gz: 5adb94c1f6ba5734f22e57120599dd27c8f3e4ce3288a01860c4560e910cec3b22ed2d831c803fc0286cf28471ae337004d76f4f93d7b1c9455578eef40ce505
6
+ metadata.gz: 34d598af7286a11db71463c9965c82b5573df2a380aae548a80f92d3a95ea6cc7b8d1de8aa682028fc244d5f99207a54d743b8355378fdd6e8327d2d360eedf3
7
+ data.tar.gz: 8c79a206fad9496ebaf870ddc4c8778c7e0373f374e86e6ceab8d7262c40d7edc6ea19c147304fb0aaec421bbd660e2be408f99c127623912ef05c5d52ec79f2
@@ -0,0 +1,5 @@
1
+ # Changelog
2
+
3
+ ## 0.0.3
4
+
5
+ - Change to DARV BAS registry (with support of legal form)
data/README.md CHANGED
@@ -29,10 +29,10 @@ subject = RubyARES::Subject.get(74948440)
29
29
  ```
30
30
  And then:
31
31
  ```ruby
32
- subject => #<RubyARES::Subject:0x007fc691a77470 @ico="74948440", @ic="74948440", @dic=nil, @name="Josef Stříbný", @company=nil, @status="A", @addresses=[#<RubyARES::Address:0x007fc691a776a0 @id="10731009", @street="Nádražní", @postcode="74727", @city="Kobeřice", @city_part="Kobeřice", @house_number="721", @house_number_type="1", @orientational_number=nil>], @updated_at="2009-08-25">
32
+ subject => #<RubyARES::Subject:0x000000013ac2c0 @ico="74948440", @ic="74948440", @dic=nil, @name="Josef Stříbný", @company=nil, @status=nil, @addresses=[#<RubyARES::Address:0x000000013ac978 @id="406358731", @street="Nádražní", @postcode="74727", @city="Kobeřice", @city_part="Kobeřice", @house_number="721", @house_number_type="1", @orientational_number=nil>], @updated_at=nil, @legal_form="Fyzická osoba podnikající dle živnostenského zákona nezapsaná v obchodním rejstříku">
33
33
  subject.name => Josef Stříbný
34
34
  subject.ic => 74948440
35
- subject.address => #<RubyARES::Address:0x007fc691a776a0 @id="10731009", @street="Nádražní", @postcode="74727", @city="Kobeřice", @city_part="Kobeřice", @house_number="721", @house_number_type="1", @orientational_number=nil>
35
+ subject.address => #<RubyARES::Address:0x007fc691a776a0 @id="406358731", @street="Nádražní", @postcode="74727", @city="Kobeřice", @city_part="Kobeřice", @house_number="721", @house_number_type="1", @orientational_number=nil>
36
36
  ```
37
37
 
38
38
  ### Exceptions
@@ -43,4 +43,14 @@ If the connection to the ARES database can't be established ruby-ares raises `Ru
43
43
 
44
44
  ## License
45
45
 
46
- See LICENSE
46
+ ruby-ares is written and maintained by [Josef Strzibny](http://strzibny.name).
47
+
48
+ See LICENSE file.
49
+
50
+ ## Contributors
51
+
52
+ Contributions are welcome!
53
+
54
+ Here are the list of current contributors:
55
+
56
+ - Jindřich Skupa
data/Rakefile CHANGED
@@ -5,26 +5,7 @@ require 'rake/testtask'
5
5
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'lib'))
6
6
  require 'ruby-ares'
7
7
 
8
- gemspec = Gem::Specification.new do |s|
9
- s.name = 'ruby-ares'
10
- s.version = RubyARES::VERSION
11
- s.platform = Gem::Platform::RUBY
12
- s.summary = 'Gem for accesing business information from ARES database.'
13
- s.description = <<-EOF
14
- ARES is the Czech business database maintained by Ministry of Finance of the Czech Republic.
15
- This gem helps to retrieve data provided by this database.
16
- EOF
17
- s.licenses = ['GPLv3']
18
- s.author = 'Josef Strzibny'
19
- s.email = 'strzibny@strzibny.name'
20
- s.homepage = 'http://github.com/strzibny/ruby-ares'
21
- s.required_ruby_version = '>= 1.8.7'
22
- s.required_rubygems_version = '>= 1.8.0'
23
- s.files = FileList['README.md', 'Rakefile',
24
- 'lib/**/*.rb', 'test/**/test*.rb']
25
- s.add_runtime_dependency 'libxml-ruby'
26
- s.requirements << 'libxml2'
27
- end
8
+ gemspec = eval(File.open(File.join(File.dirname(__FILE__),'ruby-ares.gemspec')).read)
28
9
 
29
10
  Gem::PackageTask.new gemspec do |pkg|
30
11
  end
@@ -8,5 +8,5 @@ require 'ruby-ares/address'
8
8
  require 'ruby-ares/parser'
9
9
 
10
10
  module RubyARES
11
- VERSION = '0.0.2'
11
+ VERSION = '0.0.3'
12
12
  end
@@ -24,11 +24,10 @@ module RubyARES
24
24
  end
25
25
 
26
26
  def to_str
27
- @city_part = '' if @city == @city_part
28
27
  <<EOF
29
- #{self.street} #{self.street_number}
28
+ #{self.street.nil? ? self.city_part : self.street} #{self.street_number}
30
29
  #{self.postcode} #{self.city}
31
- #{self.city_part}
30
+ #{self.city_part == self.city ? "" : self.city_part}
32
31
  EOF
33
32
  end
34
33
 
@@ -9,8 +9,8 @@ module RubyARES
9
9
 
10
10
  def self.fetch_subject_xml(ic)
11
11
  # Get a subject info from ARES[http://wwwinfo.mfcr.cz/ares/]
12
- uri = URI('http://wwwinfo.mfcr.cz/cgi-bin/ares/darv_rzp.cgi')
13
- params = { :ico => ic, :ver => '1.0.4' }
12
+ uri = URI('http://wwwinfo.mfcr.cz/cgi-bin/ares/darv_bas.cgi')
13
+ params = { :ico => ic, :version => '1.0.3' }
14
14
  uri.query = URI.encode_www_form(params)
15
15
 
16
16
  begin
@@ -15,15 +15,15 @@ module RubyARES
15
15
  doc = self.parse_document xml
16
16
 
17
17
  # Basic info
18
- doc.find('//dtt:Zakladni_udaje').each do |node|
18
+ doc.find('//D:VBAS').each do |node|
19
19
  attrs = node.children()
20
20
 
21
21
  # Attributes of the subject
22
- @status = node.find('dtt:Stav').to_a[0].content unless node.find('dtt:Stav') == 0
23
- @updated_at = node.find('dtt:Datum_zmeny').to_a[0].content unless node.find('dtt:Datum_zmeny').to_a.size == 0
24
- @ic = node.find('dtt:ICO').to_a[0].content
25
- @dic = node.find('dtt:DIC').to_a[0].content unless node.find('dtt:DIC').to_a.size == 0
26
- @name = node.find('dtt:Obchodni_firma').to_a[0].content unless node.find('dtt:Obchodni_firma').to_a.size == 0
22
+ @status = node.find("D:ROR/D:SOR/D:SSU").to_a[0].content unless node.find('D:ROR/D:SOR/D:SSU').to_a.size == 0
23
+ @ic = node.find('D:ICO').to_a[0].content unless node.find('D:ICO').to_a.size == 0
24
+ @dic = node.find('D:DIC').to_a[0].content unless node.find('D:DIC').to_a.size == 0
25
+ @name = node.find('D:OF').to_a[0].content unless node.find('D:OF').to_a.size == 0
26
+ @legal_form = node.find('D:PF/D:NPF').to_a[0].content unless node.find('D:PF/D:NPF').to_a.size == 0
27
27
  end
28
28
 
29
29
  # Corresponding addresses
@@ -32,12 +32,12 @@ module RubyARES
32
32
  raise ParseError, "Can't parse the given document."
33
33
  end
34
34
 
35
- if doc.find('//dtt:Error').to_a.size > 0
35
+ if doc.find('//D:E').to_a.size > 0
36
36
  raise ARESDatabaseError, 'ARES returned an error.'
37
37
  end
38
38
 
39
39
  # Create and return subject
40
- return RubyARES::Subject.new(@ic, @dic, @name, @status, @addresses, @updated_at)
40
+ return RubyARES::Subject.new(@ic, @dic, @name, @status, @addresses, @updated_at, @legal_form)
41
41
  end
42
42
 
43
43
  protected
@@ -45,15 +45,15 @@ module RubyARES
45
45
  def self.find_addresses(doc)
46
46
  @addresses = []
47
47
 
48
- doc.find('//dtt:Adresa').each do |node|
49
- id = node.find('dtt:ID_adresy').to_a[0].content
50
- street = node.find('dtt:Nazev_ulice').to_a[0].content unless node.find('dtt:Nazev_ulice').to_a.size == 0
51
- postcode = node.find('dtt:PSC').to_a[0].content unless node.find('dtt:PSC').to_a.size == 0
52
- city = node.find('dtt:Nazev_obce').to_a[0].content unless node.find('dtt:Nazev_obce').to_a.size == 0
53
- city_part = node.find('dtt:Nazev_casti_obce').to_a[0].content unless node.find('dtt:Nazev_casti_obce').to_a.size == 0
54
- house_number = node.find('dtt:Cislo_domovni').to_a[0].content unless node.find('dtt:Cislo_domovni').to_a.size == 0
55
- house_number_type = node.find('dtt:Typ_cislo_domovni').to_a[0].content unless node.find('dtt:Typ_cislo_domovni').to_a.size == 0
56
- orientational_number = node.find('dtt:Cislo_orientacni').to_a[0].content unless node.find('dtt:Cislo_orientacni').to_a.size == 0
48
+ doc.find('//D:AA').each do |node|
49
+ id = node.find('D:IDA').to_a[0].content
50
+ street = node.find('D:NU').to_a[0].content unless node.find('D:NU').to_a.size == 0
51
+ postcode = node.find('D:PSC').to_a[0].content unless node.find('D:PSC').to_a.size == 0
52
+ city = node.find('D:N').to_a[0].content unless node.find('D:N').to_a.size == 0
53
+ city_part = node.find('D:NCO').to_a[0].content unless node.find('D:NCO').to_a.size == 0
54
+ house_number = node.find('D:CD').to_a[0].content unless node.find('D:CD').to_a.size == 0
55
+ house_number_type = node.find('D:TCD').to_a[0].content unless node.find('D:TCD').to_a.size == 0
56
+ orientational_number = node.find('D:CO').to_a[0].content unless node.find('D:CO').to_a.size == 0
57
57
 
58
58
  @addresses << RubyARES::Address.new(id, street, postcode, city, city_part,
59
59
  house_number, house_number_type, orientational_number)
@@ -10,6 +10,7 @@ module RubyARES
10
10
  :dic, # DIC
11
11
  :name, # Obchodni_firma
12
12
  :company, # alias for name
13
+ :legal_form,# Pravni forma
13
14
  :status, # Stav
14
15
  :addresses,
15
16
  :updated_at # Datum_zmeny
@@ -19,13 +20,14 @@ module RubyARES
19
20
  RubyARES::Parser.get_subject xml
20
21
  end
21
22
 
22
- def initialize(ic, dic, name, status, addresses, updated_at)
23
+ def initialize(ic, dic, name, status, addresses, updated_at, legal_form)
23
24
  @ic, @ico = ic, ic
24
25
  @dic = dic
25
26
  @name, @company = name
26
27
  @status = status
27
28
  @addresses = addresses
28
29
  @updated_at = updated_at
30
+ @legal_form = legal_form
29
31
  end
30
32
 
31
33
  def address
@@ -1,34 +1,50 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require 'test/unit'
3
+ require 'minitest/autorun'
4
4
  require 'helper'
5
5
  require 'ruby-ares'
6
6
 
7
- class RubyARESTest < Test::Unit::TestCase
7
+ class RubyARESTest < Minitest::Test
8
8
  def setup
9
9
  @subject = RubyARES::Parser.get_subject RubyARESTestHelper.subject_xml
10
10
  end
11
11
 
12
12
  def test_subject_address_house_number
13
- assert_equal '2178 1', "#{@subject.addresses[0].house_number} #{@subject.addresses[0].house_number_type}"
13
+ assert_equal '778 1', "#{@subject.addresses[0].house_number} #{@subject.addresses[0].house_number_type}"
14
14
  end
15
15
 
16
16
  def test_subject_address_street
17
- assert_equal 'Podvinný mlýn 6/2178', "#{@subject.addresses[0].street} #{@subject.addresses[0].street_number}"
17
+ assert_equal 'Budějovická 3a/778', "#{@subject.addresses[0].street} #{@subject.addresses[0].street_number}"
18
18
  end
19
19
 
20
20
  def test_subject_address_city
21
- assert_equal 'Praha Libeň', "#{@subject.addresses[0].city} #{@subject.addresses[0].city_part}"
21
+ assert_equal 'Praha Michle', "#{@subject.addresses[0].city} #{@subject.addresses[0].city_part}"
22
22
  end
23
23
 
24
24
  def test_subject_address_postcode
25
- assert_equal '19000', @subject.addresses[0].postcode
25
+ assert_equal '14000', @subject.addresses[0].postcode
26
26
  end
27
27
 
28
28
  def test_subject_name
29
29
  assert_equal 'Asseco Central Europe, a.s.', @subject.name
30
30
  end
31
31
 
32
+ def test_subject_dic
33
+ assert_equal 'CZ27074358', @subject.dic
34
+ end
35
+
36
+ def test_subject_ic
37
+ assert_equal '27074358', @subject.ic
38
+ end
39
+
40
+ def test_subject_legal_form
41
+ assert_equal 'Akciová společnost', @subject.legal_form
42
+ end
43
+
44
+ def test_subject_status
45
+ assert_equal 'Aktivní', @subject.status
46
+ end
47
+
32
48
  def test_number_of_subject_addresses
33
49
  assert_equal 1, @subject.addresses.size
34
50
  end
@@ -1,9 +1,9 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require 'test/unit'
3
+ require 'minitest/autorun'
4
4
  require 'ruby-ares/address'
5
5
 
6
- class RubyARESAddressTest < Test::Unit::TestCase
6
+ class RubyARESAddressTest < Minitest::Test
7
7
 
8
8
  def setup
9
9
  @address = RubyARES::Address.new(1, 'Kunzova', '10010', 'Brno', 'Královo pole', 1, 1, nil)
@@ -1,8 +1,8 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require 'test/unit'
3
+ require 'minitest/autorun'
4
4
  require 'ruby-ares/http'
5
5
 
6
- class RubyARESHTTPTest < Test::Unit::TestCase
6
+ class RubyARESHTTPTest < Minitest::Test
7
7
 
8
8
  end
@@ -1,13 +1,13 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require 'test/unit'
3
+ require 'minitest/autorun'
4
4
  require 'helper'
5
5
  require 'ruby-ares/parser'
6
6
 
7
- class RubyARESParserTest < Test::Unit::TestCase
7
+ class RubyARESParserTest < Minitest::Test
8
8
 
9
9
  def test_parser_should_fail
10
- assert_raise(RubyARES::Parser::ARESDatabaseError) {
10
+ assert_raises(RubyARES::Parser::ARESDatabaseError) {
11
11
  RubyARES::Parser.get_subject(RubyARESTestHelper.error_responce_xml)
12
12
  }
13
13
  end
@@ -1,8 +1,8 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require 'test/unit'
3
+ require 'minitest/autorun'
4
4
  require 'ruby-ares/subject'
5
5
 
6
- class RubyARESSubjectTest < Test::Unit::TestCase
6
+ class RubyARESSubjectTest < Minitest::Test
7
7
 
8
8
  end
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-ares
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josef Strzibny
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-15 00:00:00.000000000 Z
11
+ date: 2015-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: libxml-ruby
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  description: |2
@@ -32,6 +32,7 @@ executables: []
32
32
  extensions: []
33
33
  extra_rdoc_files: []
34
34
  files:
35
+ - CHANGELOG.md
35
36
  - README.md
36
37
  - Rakefile
37
38
  - lib/ruby-ares.rb
@@ -54,18 +55,18 @@ require_paths:
54
55
  - lib
55
56
  required_ruby_version: !ruby/object:Gem::Requirement
56
57
  requirements:
57
- - - '>='
58
+ - - ">="
58
59
  - !ruby/object:Gem::Version
59
60
  version: 1.8.7
60
61
  required_rubygems_version: !ruby/object:Gem::Requirement
61
62
  requirements:
62
- - - '>='
63
+ - - ">="
63
64
  - !ruby/object:Gem::Version
64
65
  version: 1.8.0
65
66
  requirements:
66
67
  - libxml2
67
68
  rubyforge_project:
68
- rubygems_version: 2.1.11
69
+ rubygems_version: 2.4.8
69
70
  signing_key:
70
71
  specification_version: 4
71
72
  summary: Gem for accesing business information from ARES database.