rate_man 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/lib/currency_duo.rb CHANGED
@@ -14,6 +14,7 @@ module RateMan
14
14
 
15
15
  def hash
16
16
  raise ArgumentError, "you must query google for the rate first" unless rate && raw
17
+ raise ArgumentError, "rate or raw is not correct rate : #{rate} raw : #{raw}" if ((rate == 0) || (raw == 0))
17
18
  {from_to: from + ':' + to,
18
19
  from_cur: [1, from],
19
20
  to_cur: [rate, to],
@@ -1,3 +1,3 @@
1
1
  module RateMan
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
data/lib/rate_man.rb CHANGED
@@ -25,8 +25,17 @@ module RateMan
25
25
  self.custom_search_id = nil
26
26
  end
27
27
 
28
+ def self.raw_response(from_cur, to_cur)
29
+ IO.read open(self.query_url(from_cur, to_cur))
30
+ end
31
+
28
32
  def self.query(from_cur, to_cur)
29
- JSON.parse(IO.read open(self.query_url(from_cur, to_cur)))['items'].first['snippet'].split('...').last.split(' ')
33
+ string = JSON.parse(RateMan.raw_response(from_cur, to_cur))['items'].first['snippet'].split('...')[1]
34
+ unless string =~ /\d EUR = \d*\.\d* CHF [-\+]?\d*\.\d* \([-\+]?\d*\.\d*\%\)/
35
+ puts string
36
+ raise ArgumentError, "incorrect json"
37
+ end
38
+ string.split(' ')
30
39
  end
31
40
 
32
41
  def self.get(from_cur, to_cur)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rate_man
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -53,7 +53,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
53
53
  version: '0'
54
54
  segments:
55
55
  - 0
56
- hash: -2505003282121064291
56
+ hash: 389294286417664307
57
57
  required_rubygems_version: !ruby/object:Gem::Requirement
58
58
  none: false
59
59
  requirements: