lbank 0.0.1 → 0.0.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.
@@ -0,0 +1,7 @@
1
+ rvm:
2
+ - 1.9.3
3
+ - 1.9.2
4
+ - jruby
5
+ - rbx
6
+ script: "bundle exec rake spec"
7
+
data/Gemfile CHANGED
@@ -1,8 +1,9 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in lbank.gemspec
4
3
  gemspec
5
4
 
5
+ gem 'rake'
6
+
6
7
  group :test do
7
8
  gem "rspec"
8
9
  end
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Lbank
2
2
 
3
+ [![Build Status](http://travis-ci.org/laurynas/lbank.png)](http://travis-ci.org/laurynas/lbank)
4
+
3
5
  Fetches currency rates from Lithuanian Central Bank website http://lbank.lt.
4
6
  Does currency conversion.
5
7
  Supports historic currency rates.
data/Rakefile CHANGED
@@ -1,2 +1,7 @@
1
1
  #!/usr/bin/env rake
2
2
  require "bundler/gem_tasks"
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new
6
+
7
+ task :default => :spec
@@ -15,7 +15,9 @@ module Lbank
15
15
  url = "#{SOURCE}?Y=%i&M=%i&D=%i&S=csv" % [ date.year, date.month, date.day ]
16
16
  rates = {}
17
17
 
18
- CSV.parse(open(url)).each do |row|
18
+ data = open(url).read
19
+
20
+ CSV.parse(data).each do |row|
19
21
  rates[row[1]] = row[2].to_i / row[3].to_f
20
22
  end
21
23
 
@@ -1,3 +1,3 @@
1
1
  module Lbank
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -13,10 +13,16 @@ describe Lbank do
13
13
 
14
14
  date = Date.new(2012, 8, 4)
15
15
 
16
- subject.convert_currency(10, 'LTL', 'EUR', date).round(2).should == 2.90
17
- subject.convert_currency(10, 'LTL', 'USD', date).round(2).should == 3.55
18
- subject.convert_currency(100, 'RUB', 'LTL', date).round(2).should == 8.68
19
- subject.convert_currency(100, 'RUB', 'USD', date).round(2).should == 3.08
16
+ round(subject.convert_currency(10, 'LTL', 'EUR', date)).should == 2.90
17
+ round(subject.convert_currency(10, 'LTL', 'USD', date)).should == 3.55
18
+ round(subject.convert_currency(100, 'RUB', 'LTL', date)).should == 8.68
19
+ round(subject.convert_currency(100, 'RUB', 'USD', date)).should == 3.08
20
+ end
21
+
22
+ private
23
+
24
+ def round(number, precision = 2)
25
+ ("%.#{precision}f" % number).to_f
20
26
  end
21
27
 
22
28
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lbank
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -20,6 +20,7 @@ extra_rdoc_files: []
20
20
  files:
21
21
  - .gitignore
22
22
  - .rspec
23
+ - .travis.yml
23
24
  - Gemfile
24
25
  - LICENSE
25
26
  - README.md