russian_central_bank 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +6 -1
- data/lib/russian_central_bank.rb +6 -5
- data/russian_central_bank.gemspec +1 -1
- metadata +3 -2
data/README.md
CHANGED
@@ -25,8 +25,10 @@ Or install it yourself as:
|
|
25
25
|
|
26
26
|
bank = Money::Bank::RussianCentralBank.new
|
27
27
|
|
28
|
-
# Load rates
|
28
|
+
# Load today's rates
|
29
29
|
bank.update_rates
|
30
|
+
# Or you can specify the date
|
31
|
+
bank.update_rates(3.days.ago)
|
30
32
|
|
31
33
|
Money.default_bank = bank
|
32
34
|
|
@@ -36,6 +38,9 @@ Or install it yourself as:
|
|
36
38
|
# Check last rates update
|
37
39
|
bank.rates_updated_at
|
38
40
|
|
41
|
+
# Check on which date rates were updated
|
42
|
+
bank.rates_updated_on
|
43
|
+
|
39
44
|
## Contributing
|
40
45
|
|
41
46
|
1. Fork it
|
data/lib/russian_central_bank.rb
CHANGED
@@ -7,7 +7,7 @@ class Money
|
|
7
7
|
|
8
8
|
CBR_SERVICE_URL = 'http://www.cbr.ru/DailyInfoWebServ/DailyInfo.asmx?WSDL'
|
9
9
|
|
10
|
-
|
10
|
+
attr_reader :rates_updated_at, :rates_updated_on
|
11
11
|
|
12
12
|
def flush_rates
|
13
13
|
@mutex.synchronize{
|
@@ -15,10 +15,11 @@ class Money
|
|
15
15
|
}
|
16
16
|
end
|
17
17
|
|
18
|
-
def update_rates
|
18
|
+
def update_rates(date = Date.today)
|
19
19
|
@mutex.synchronize{
|
20
|
-
update_parsed_rates(
|
20
|
+
update_parsed_rates exchange_rates(date)
|
21
21
|
@rates_updated_at = Time.now
|
22
|
+
@rates_updated_on = date
|
22
23
|
@rates
|
23
24
|
}
|
24
25
|
end
|
@@ -39,9 +40,9 @@ class Money
|
|
39
40
|
to_base_rate / from_base_rate
|
40
41
|
end
|
41
42
|
|
42
|
-
def exchange_rates
|
43
|
+
def exchange_rates(date)
|
43
44
|
client = Savon::Client.new(wsdl: CBR_SERVICE_URL)
|
44
|
-
response = client.call(:get_curs_on_date, message: {'On_date' =>
|
45
|
+
response = client.call(:get_curs_on_date, message: { 'On_date' => date.strftime('%Y-%m-%dT%H:%M:%S') })
|
45
46
|
response.body[:get_curs_on_date_response][:get_curs_on_date_result][:diffgram][:valute_data][:valute_curs_on_date]
|
46
47
|
end
|
47
48
|
|
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = 'russian_central_bank'
|
7
|
-
spec.version = '0.
|
7
|
+
spec.version = '0.2.0'
|
8
8
|
spec.authors = ['Ramil Mustafin']
|
9
9
|
spec.email = ['rommel.rmm@gmail.com']
|
10
10
|
spec.description = 'RussianCentralBank extends Money::Bank::VariableExchange and gives you access to the Central Bank of Russia currency exchange rates.'
|
metadata
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
name: russian_central_bank
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 0.2.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Ramil Mustafin
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-11-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -140,3 +140,4 @@ test_files:
|
|
140
140
|
- spec/spec_helper.rb
|
141
141
|
- spec/support/daily_rates.yml
|
142
142
|
- spec/support/helpers.rb
|
143
|
+
has_rdoc:
|