nbp 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 11b8d948615f3a6e328d23c4f2400566a07958050cdc5f8e2412b6cf015f9d13
4
+ data.tar.gz: 9be665ff1b18dab188e7f83e453887eb8bfa6e667850c377c393b235fa34d6b3
5
+ SHA512:
6
+ metadata.gz: edbe75e8285a4e6b54c5ad4e463a57a8351b09734b20440bfb71d64ae9e101c28e97240d3be213d539e1f4d3ebfbf3d0b7ef155b8057bafe942919b161c3df21
7
+ data.tar.gz: 7193f03b5b505bc1094a3e4509884651299a23cc5b4ce23b8b57fffc2c68dcdd46d00aec6f03d964fe1294140f8157c261da9fc249f8f295dc5c3275f8fedd44
@@ -1,7 +1,7 @@
1
1
  module Nbp
2
2
  class Table
3
3
  include HTTParty
4
- base_uri "http://nbp.pl/kursy/xml"
4
+ base_uri "https://www.nbp.pl/kursy/xml/"
5
5
 
6
6
  attr_reader :index
7
7
 
@@ -20,15 +20,15 @@ module Nbp
20
20
  def before(table_id)
21
21
  index.select { |id| index.index(id) < index.index(table_id) }
22
22
  end
23
-
23
+
24
24
  def self.index
25
- get("/dir.txt").split("\n")
25
+ get("/dir.txt").force_encoding('UTF-8').split("\r\n")
26
26
  end
27
-
27
+
28
28
  def self.index_of(type)
29
29
  index.select { |table_id| table_id.start_with?(type) }
30
30
  end
31
-
31
+
32
32
  def self.show(table_id)
33
33
  get("/#{table_id}.xml").parsed_response
34
34
  end
@@ -1,3 +1,3 @@
1
1
  module Nbp
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -18,6 +18,7 @@ Gem::Specification.new do |s|
18
18
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
19
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
20
  s.require_paths = ["lib"]
21
-
22
- s.add_dependency('httparty', '~> 0.6.1')
21
+
22
+ s.add_dependency('httparty', '>= 0.16.0')
23
+ s.add_development_dependency('pry')
23
24
  end
@@ -1,3 +1,4 @@
1
1
  require 'rubygems'
2
2
  require 'test/unit'
3
- require 'nbp'
3
+ require 'nbp'
4
+ require 'pry'
@@ -1,45 +1,23 @@
1
1
  require 'helper'
2
2
 
3
3
  class NbpTest < Test::Unit::TestCase
4
-
4
+
5
5
  def test_index_tables
6
6
  assert Nbp::Table.index.size > 0
7
- assert_equal "a001z020102", Nbp::Table.index.first
8
- end
9
-
10
- def test_show_table
11
- quote_a048z090310 = Nbp::Table.show("a048z090310")
12
- body = quote_a048z090310["tabela_kursow"]
13
-
14
- assert_equal "A", body["typ"]
15
- assert_equal "2009-03-10", body["data_publikacji"]
16
- assert_equal "48/A/NBP/2009", body["numer_tabeli"]
17
- assert_equal "09a048", body["uid"]
18
7
  end
19
8
 
20
9
  def test_tables_index_of_given_type
21
10
  table_a = Nbp::Table.new("A")
22
11
  table_b = Nbp::Table.new("B")
23
12
  table_c = Nbp::Table.new("C")
24
-
13
+
25
14
  assert table_a.index.size > 0
26
15
  assert table_b.index.size > 0
27
16
  assert table_c.index.size > 0
28
17
  end
29
-
18
+
30
19
  def test_latest_quote_of_given_type
31
20
  table_a = Nbp::Table.new("A")
32
21
  assert_equal "A", table_a.latest["tabela_kursow"]["typ"]
33
22
  end
34
-
35
- def test_list_quotes_before_given
36
- table_a = Nbp::Table.new("A")
37
- assert_equal 1817, table_a.before("a048z090310").size
38
- end
39
-
40
- def test_list_quotes_after_given
41
- table_a = Nbp::Table.new("A")
42
- assert table_a.after("a048z090310").size >= 473
43
- end
44
-
45
23
  end
metadata CHANGED
@@ -1,27 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nbp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
5
- prerelease:
4
+ version: 0.0.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Tomasz Mazur
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-02-27 00:00:00.000000000 Z
11
+ date: 2019-05-28 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: httparty
16
- requirement: &70308644224160 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
- - - ~>
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
- version: 0.6.1
19
+ version: 0.16.0
22
20
  type: :runtime
23
21
  prerelease: false
24
- version_requirements: *70308644224160
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 0.16.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
25
41
  description: Fetches currencies from nbp.pl
26
42
  email:
27
43
  - defkode@gmail.com
@@ -29,7 +45,7 @@ executables: []
29
45
  extensions: []
30
46
  extra_rdoc_files: []
31
47
  files:
32
- - .gitignore
48
+ - ".gitignore"
33
49
  - Gemfile
34
50
  - README
35
51
  - Rakefile
@@ -41,27 +57,26 @@ files:
41
57
  - test/nbp_test.rb
42
58
  homepage: http://rubygems.org/gems/nbp
43
59
  licenses: []
60
+ metadata: {}
44
61
  post_install_message:
45
62
  rdoc_options: []
46
63
  require_paths:
47
64
  - lib
48
65
  required_ruby_version: !ruby/object:Gem::Requirement
49
- none: false
50
66
  requirements:
51
- - - ! '>='
67
+ - - ">="
52
68
  - !ruby/object:Gem::Version
53
69
  version: '0'
54
70
  required_rubygems_version: !ruby/object:Gem::Requirement
55
- none: false
56
71
  requirements:
57
- - - ! '>='
72
+ - - ">="
58
73
  - !ruby/object:Gem::Version
59
74
  version: '0'
60
75
  requirements: []
61
76
  rubyforge_project: nbp
62
- rubygems_version: 1.8.11
77
+ rubygems_version: 2.7.6
63
78
  signing_key:
64
- specification_version: 3
79
+ specification_version: 4
65
80
  summary: Fetches currencies from nbp.pl
66
81
  test_files:
67
82
  - test/helper.rb