exchange-nbkr 0.1.1 → 0.1.2

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
  SHA1:
3
- metadata.gz: 82719dac6fd3873a7f1ed44b6816d17061c82a9f
4
- data.tar.gz: a4d49d32d558cb77a085a16ce1c469474c8735ca
3
+ metadata.gz: ecf1a3e8274c0b7f055faed5e9c25dbb4d217639
4
+ data.tar.gz: a1336b8aa93d293a4cbebd402609cdddc461919d
5
5
  SHA512:
6
- metadata.gz: b056ee3949d540de2f185a03c2ce2feaad8dc59fee15cea64980486df07ce2eff04c36b3c95539779ccc17dc4dd2c1daeec88d3aad84f13fa5961bcda7f99052
7
- data.tar.gz: 19ae66a4f1a59c11963af04b77777897cc5d4d5553641193f26dd4bb213ab711be2a9884ef318048f8117c04d6b152831861f3916735962bd13942e5c72d82cc
6
+ metadata.gz: be4f9b7d345e5a429199a6e404e78d5333533a0619260224d913369f6eb0c881cb74a0a625f8c655a8f0f65ae8b8cc60e0cedbc4b0ba66e70ef257a7f02accfe
7
+ data.tar.gz: d0dca114e5541fcb9c5634e2858c972910a502750acb83c23844b8c2ee8ec0cbcbc926cf583a58acb50d95458b7efd0c5e67eae62893346ab57a20790f9adbed
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
- # Exchange::Nbkr
1
+ # [National Bank of Kyrgyzstan](http://nbkr.kg) API adapter for [exchange gem](https://github.com/beatrichartz/exchange)
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/exchange/nbkr`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ It also has [valuta.kg](http://valuta.kg) fallback adapter.
6
4
 
7
5
  ## Installation
8
6
 
@@ -26,7 +24,7 @@ Setup exchange to use NBKR(National Bank of Kyrgyzstan) currency rates provider.
26
24
 
27
25
  ```ruby
28
26
  Exchange.configuration = Exchange::Configuration.new do |c|
29
- c.api.subclass = :nbkr
27
+ c.api.subclass = :nbkr # or :valuta_kg
30
28
  end
31
29
  ```
32
30
 
@@ -44,7 +42,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
44
42
 
45
43
  ## Contributing
46
44
 
47
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/exchange-nbkr.
45
+ Bug reports and pull requests are welcome on GitHub at https://github.com/sharshenov/exchange-nbkr.
48
46
 
49
47
 
50
48
  ## License
@@ -0,0 +1,29 @@
1
+ module Exchange
2
+ module ExternalAPI
3
+
4
+ class ValutaKg < XML
5
+
6
+ API_URL = "http://m.valuta.kg/api/"
7
+
8
+ CURRENCIES = %I(kgs usd eur rub kzt uzs cny gbp)
9
+
10
+ def update opts={}
11
+ time = helper.assure_time(opts[:at], default: :now)
12
+
13
+ Call.new(API_URL, at: time, format: :xml) do |result|
14
+ @base = :kgs
15
+
16
+ @rates = result.search('currency').map do |c|
17
+ [
18
+ c.at("title_alias").text.downcase.to_sym,
19
+ (1 / BigDecimal.new(c.at('buy_rate').text.sub(',', '.')))
20
+ ]
21
+ end.to_h.merge({ kgs: 1 })
22
+
23
+ @timestamp = Date.today.to_time.to_i
24
+ end
25
+ end
26
+
27
+ end
28
+ end
29
+ end
@@ -1,6 +1,7 @@
1
1
  require "exchange"
2
2
  require "exchange/nbkr/version"
3
3
  require "exchange/external_api/nbkr"
4
+ require "exchange/external_api/valuta_kg"
4
5
 
5
6
  module Exchange
6
7
  module Nbkr
@@ -1,5 +1,5 @@
1
1
  module Exchange
2
2
  module Nbkr
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exchange-nbkr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rustam Sharshenov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-08-29 00:00:00.000000000 Z
11
+ date: 2016-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: exchange
@@ -56,6 +56,7 @@ files:
56
56
  - exchange-nbkr.gemspec
57
57
  - lib/exchange-nbkr.rb
58
58
  - lib/exchange/external_api/nbkr.rb
59
+ - lib/exchange/external_api/valuta_kg.rb
59
60
  - lib/exchange/nbkr.rb
60
61
  - lib/exchange/nbkr/version.rb
61
62
  homepage: https://github.com/sharshenov/exchange-nbkr