rails_currency 1.1 → 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.
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'rubygems'
2
2
  require 'hoe'
3
3
 
4
- Hoe.new('rails_currency', '1.1') do |p|
4
+ Hoe.new('rails_currency', '1.2') do |p|
5
5
  p.author = 'Naveen Joshi'
6
6
  p.email = 'joshinav@gmail.com'
7
7
  p.url = ''
@@ -12,29 +12,29 @@ end
12
12
  module RailsCurrency
13
13
  class RailsCurrencyError < StandardError
14
14
  end
15
-
15
+
16
16
  class InvalidAmountError < RailsCurrencyError
17
17
  end
18
-
18
+
19
19
  class UnknownCurrencyError < RailsCurrencyError
20
20
  end
21
-
21
+
22
22
  class ServerTimeoutError < RailsCurrencyError
23
23
  end
24
-
24
+
25
25
  class Convertor
26
26
  class << self
27
27
  def convert(amount, from, to)
28
28
  raise InvalidAmountError, "Only numeric value allowed" unless amount.is_a?(Numeric)
29
29
  raise UnknownCurrencyError, "Unknown Currency" unless CurrencyList.key?(from.to_sym) && CurrencyList.key?(to.to_sym)
30
-
30
+
31
31
  begin
32
32
  url = "#{CurrencyUrl}?Amount=#{amount}&From=#{from}&To=#{to}"
33
-
34
- timeout(30) do
33
+
34
+ timeout(30) do
35
35
  doc = open(url, Params) { |f| Hpricot(f) }
36
36
  result = doc.search("//table[@class='XEtbl_sub']/tr/td[@id='XEenlarge']/h2[@class='XE']")[2].inner_text
37
- result.scan(/\d+\.?\d+/).first.to_f
37
+ result.gsub(",", "").scan(/\d+\.?\d+/).first.to_f
38
38
  end
39
39
  rescue TimeoutError
40
40
  raise ServerTimeoutError, "Can't connect to server #{url}"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_currency
3
3
  version: !ruby/object:Gem::Version
4
- version: "1.1"
4
+ version: "1.2"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naveen Joshi