momm 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3d4fcb3d9c4bd72a12fe00f385a990f5687cde25
4
- data.tar.gz: c7cdcb1425605cfcd312f86378bb43385ebd13ba
3
+ metadata.gz: 94e8df11708639f4efe46efce62df26f3828f893
4
+ data.tar.gz: 42b738fbed8e1abcf4fd9d230a75cf6068dda94a
5
5
  SHA512:
6
- metadata.gz: 2c1df21f53643262c53f47dd2bcec2b7e947c9f209a592d481e84dc0c0e952a14bb2a7f211b3197f7cc8836d1164ff5851543e9c3f4529cc4f4a25008923e439
7
- data.tar.gz: 176f324ad735b62a0931fa4e56399b12d0d0491165f1543e1814c48320e31022ecf089f3366283470510bb46f5196eae14d95556986ee194081d9a75b21a24f3
6
+ metadata.gz: cde56c7a6fe324b5e8e6998603a663a625e119cc6ca3858a482c62003702e3743aad5c1351e25878789711c6de359fb86f8e6d21c9fae3aa123b41850a7f8d07
7
+ data.tar.gz: 6b744408c973efa5246f98337ca9786da64f6646ce271493ffa9f2756d42d4a51049835f51f079c962b39437605719cc2f74b383f1afe2162ea70254c96f7385
@@ -0,0 +1,6 @@
1
+ Hi, I'm Change Log, not the podcast ;)
2
+
3
+ 0.0.6
4
+ ===
5
+
6
+ Improve the precision of exchange rate.
@@ -50,6 +50,11 @@ module Momm
50
50
  # the exchange rate
51
51
  #
52
52
  def exchange_rate(from, to, options = {})
53
+ origin_exchange_rate(from, to, options = {}).round(2)
54
+ end
55
+
56
+ # Exchange Rate without precision bound
57
+ def origin_exchange_rate(from, to, options = {})
53
58
  date = options[:date] || Date.today
54
59
  date = Date.parse(date) if date.is_a? String
55
60
 
@@ -70,12 +75,14 @@ module Momm
70
75
  set_rate(to, to_rate, date)
71
76
  set_rate(from, from_rate, date)
72
77
 
73
- return (to_rate / from_rate).round(2)
78
+ return (to_rate / from_rate)
74
79
  end
75
80
 
76
81
  0.0 / 0
77
82
  end
78
83
 
84
+ private :origin_exchange_rate
85
+
79
86
  # Exchange Money from one currency to another
80
87
  #
81
88
  # == Parameters
@@ -93,7 +100,7 @@ module Momm
93
100
  #
94
101
  def exchange(money, from, to, options= {})
95
102
  options[:date] ||= Date.today
96
- (money * exchange_rate(from, to, options)).round(2)
103
+ (origin_exchange_rate(from, to, options) * money).round(2)
97
104
  end
98
105
 
99
106
  # Delegate the get_rate method, if the target is missing
@@ -1,3 +1,3 @@
1
1
  module Momm
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -2,6 +2,6 @@ require 'spec_helper'
2
2
 
3
3
  describe 'momm version' do
4
4
  it 'should be correct' do
5
- Momm::VERSION.should == '0.0.5'
5
+ Momm::VERSION.should == '0.0.6'
6
6
  end
7
7
  end
@@ -22,7 +22,7 @@ describe Momm::Web do
22
22
  get '/query', money: 12, from: "GBP", to: "USD", date: "2014-3-10"
23
23
 
24
24
  expect(last_response).to be_ok
25
- expect(last_response.body).to eq("19.92")
25
+ expect(last_response.body).to eq("19.98")
26
26
  end
27
27
  end
28
28
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: momm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jingkai He
@@ -136,6 +136,7 @@ files:
136
136
  - README.md
137
137
  - Rakefile
138
138
  - bin/momm
139
+ - change_log.md
139
140
  - examples/rack_app/Gemfile
140
141
  - examples/rack_app/config.ru
141
142
  - examples/rails_app/.gitignore