simple-currency-converter 0.0.1 → 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: 8e68e48d2faa1fd17ce826fe1909bc3e77881eef
4
- data.tar.gz: 80544bac5ef6f55ab111a16fc809be853f0d3759
3
+ metadata.gz: 1ef25bed017eb67e05a35de531a8f47481138a72
4
+ data.tar.gz: 83503603d32c7f06fb98d587e99c8fdc260ab177
5
5
  SHA512:
6
- metadata.gz: c92a1480e598ef2093a91dc9a8571012a60d262dfeb5227ad3dd7c851b0f3457fd3db08e9774f92c212c544b33a4c936fcf2457b412a943402cb55049ff0804d
7
- data.tar.gz: 6ad95fd5a4386ffed3b03fe56e68dd0672617306c927fac4cd091f786d9dbb90d24e4a386ce4fec0d9a3895983c2584a137688ec6aea3348eff605e986accb38
6
+ metadata.gz: a145f93fd08862efb4b0e65516fd93cfaefbb501b42bbcc36b80258e4f97fa666ad208f628237a6c3bab6906a23a803a061475c36592ff7500b026923597d23b
7
+ data.tar.gz: 5e0da7de654267b8ea6a69b9868f5ae477716d07c8c8ad0a6432c18f2e8f00f3445a2f0cda32c5df8ec68977427b7dff5a7a133fb81da424e1a4b71b6a3ae4cd
@@ -0,0 +1,33 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
23
+
24
+ spec/dummy/db/*.sqlite3
25
+ spec/dummy/log/*.log
26
+ spec/dummy/tmp/
27
+ spec/dummy/.sass-cache
28
+ spec/dummy/.generators
29
+
30
+ .idea
31
+
32
+ *.iml
33
+ .rakeTasks
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ script: bundle exec rspec
3
+ rvm:
4
+ - 2.0.0
5
+ - 2.2.1
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in simple-currency-converter.gemspec
4
+ gemspec
@@ -0,0 +1,77 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ # directories %w(app lib config test spec features) \
6
+ # .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
7
+
8
+ ## Note: if you are using the `directories` clause above and you are not
9
+ ## watching the project directory ('.'), then you will want to move
10
+ ## the Guardfile to a watched dir and symlink it back, e.g.
11
+ #
12
+ # $ mkdir config
13
+ # $ mv Guardfile config/
14
+ # $ ln -s config/Guardfile .
15
+ #
16
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
17
+
18
+ # Note: The cmd option is now required due to the increasing number of ways
19
+ # rspec may be run, below are examples of the most common uses.
20
+ # * bundler: 'bundle exec rspec'
21
+ # * bundler binstubs: 'bin/rspec'
22
+ # * spring: 'bin/rspec' (This will use spring if running and you have
23
+ # installed the spring binstubs per the docs)
24
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
25
+ # * 'just' rspec: 'rspec'
26
+
27
+ guard :rspec, cmd: "bundle exec rspec" do
28
+ require "guard/rspec/dsl"
29
+ dsl = Guard::RSpec::Dsl.new(self)
30
+
31
+ # Feel free to open issues for suggestions and improvements
32
+
33
+ # RSpec files
34
+ rspec = dsl.rspec
35
+ watch(rspec.spec_helper) { rspec.spec_dir }
36
+ watch(rspec.spec_support) { rspec.spec_dir }
37
+ watch(rspec.spec_files)
38
+
39
+ # Ruby files
40
+ ruby = dsl.ruby
41
+ dsl.watch_spec_files_for(ruby.lib_files)
42
+
43
+ # Rails files
44
+ rails = dsl.rails(view_extensions: %w(erb haml slim))
45
+ dsl.watch_spec_files_for(rails.app_files)
46
+ dsl.watch_spec_files_for(rails.views)
47
+
48
+ watch(rails.controllers) do |m|
49
+ [
50
+ rspec.spec.("routing/#{m[1]}_routing"),
51
+ rspec.spec.("controllers/#{m[1]}_controller"),
52
+ rspec.spec.("acceptance/#{m[1]}")
53
+ ]
54
+ end
55
+
56
+ # Rails config changes
57
+ watch(rails.spec_helper) { rspec.spec_dir }
58
+ watch(rails.routes) { "#{rspec.spec_dir}/routing" }
59
+ watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
60
+
61
+ # Capybara features specs
62
+ watch(rails.view_dirs) { |m| rspec.spec.("features/#{m[1]}") }
63
+ watch(rails.layouts) { |m| rspec.spec.("features/#{m[1]}") }
64
+
65
+ # Turnip features and steps
66
+ watch(%r{^spec/acceptance/(.+)\.feature$})
67
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
68
+ Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
69
+ end
70
+ end
71
+
72
+ # Add files and commands to this file, like the example:
73
+ # watch(%r{file/path}) { `command(s)` }
74
+ #
75
+ guard :shell do
76
+ watch(/(.*).txt/) {|m| `tail #{m[0]}` }
77
+ end
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 47colborne
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 jeffli
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,18 @@
1
+ # simple-currency-converter
2
+ Provides a client to pull currency exchange rates from Yahoo web service for Ruby
3
+
4
+ [![Build Status](https://travis-ci.org/47colborne/simple-currency-converter.svg?branch=master)](https://travis-ci.org/47colborne/simple-currency-converter)
5
+ [![Code Climate](https://codeclimate.com/github/47colborne/simple-currency-converter/badges/gpa.svg)](https://codeclimate.com/github/47colborne/simple-currency-converter)
6
+
7
+ ### To install:
8
+
9
+ ``` ruby
10
+ gem "simple-currency-converter", git: "git@github.com:47colborne/simple-currency-converter.git"
11
+ ```
12
+
13
+ ### Tutorial/Example code:
14
+
15
+ ``` ruby
16
+ client = CurrencyClient.new
17
+ client.get_exchange_rate(:USD, :CAD) => 1.3267
18
+ ```
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,21 @@
1
+
2
+ module SimpleCurrencyConverter
3
+ class Client
4
+ def get_exchange_rate(from_currency, to_currency)
5
+ currency_name = from_currency.to_s + to_currency.to_s + '=X'
6
+ yahoo_query_url =
7
+ URI::HTTP.build(host:"download.finance.yahoo.com",path:"/d/quotes.csv", query:"s=#{currency_name}&f=l1d1t1&e=.csv")
8
+
9
+ response = Net::HTTP.get(yahoo_query_url)
10
+
11
+ unless response.nil?
12
+ parsed_response = response.split(',')
13
+ exchange_rate = parsed_response.first
14
+
15
+ exchange_rate == 'N/A' ? nil : exchange_rate.to_f
16
+ end
17
+ end
18
+ end
19
+ end
20
+
21
+ SimpleCurrencyConverter::Client
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ Gem::Specification.new do |s|
3
+ s.name = 'simple-currency-converter'
4
+ s.version = '0.0.6'
5
+ s.authors = ['RETAILCOMMON DEV (Scott Chu, Justine Jones, Jeff Li, Greg Ward)']
6
+ s.email = ['dev@retailcommon.com']
7
+ s.summary = 'Web client to retrieve currency exchange rates'
8
+ s.description = 'Web client to retrieve currency exchange rates'
9
+ s.homepage = 'http://yroo.com'
10
+ s.license = 'MIT'
11
+
12
+ s.files = `git ls-files -z`.split("\x0")
13
+ s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
14
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
15
+ s.require_paths = ['lib']
16
+
17
+ s.add_development_dependency 'bundler', '~> 1.6'
18
+ s.add_development_dependency 'rake'
19
+
20
+ s.add_development_dependency 'guard-rspec'
21
+ s.add_development_dependency 'guard-shell'
22
+ s.add_development_dependency 'rspec-rails'
23
+ s.add_development_dependency 'rspec-mocks'
24
+ s.add_development_dependency 'rspec-its'
25
+ end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ module SimpleCurrencyConverter
4
+ describe Client do
5
+ describe '#get_exchange_rate' do
6
+ let(:yahoo_uri_params) { {host:"download.finance.yahoo.com", path:"/d/quotes.csv", query:"s=CADUSD=X&f=l1d1t1&e=.csv"} }
7
+ let(:currency_client) { Client.new }
8
+
9
+ it 'should create the yahoo download link based on the given params' do
10
+ expect(URI::HTTP).to receive(:build).with(yahoo_uri_params)
11
+ allow(Net::HTTP).to receive(:get)
12
+ currency_client.get_exchange_rate(:CAD, :USD)
13
+ end
14
+
15
+ it 'should parse the returned csv record into a float' do
16
+ response = "0.7538,\"9/11/2015\",\"5:13pm\"\n"
17
+ allow(Net::HTTP).to receive(:get).and_return(response)
18
+
19
+ exchange_rate = currency_client.get_exchange_rate(:CAD, :USD)
20
+ expect(exchange_rate).to eq(0.7538)
21
+ end
22
+
23
+ it 'should return nil if no exchange rate is found' do
24
+ response = "N/A,N/A,N/A\n"
25
+ allow(Net::HTTP).to receive(:get).and_return(response)
26
+
27
+ exchange_rate = currency_client.get_exchange_rate(:non_existant_currency, :USD)
28
+ expect(exchange_rate).to be_nil
29
+ end
30
+ end
31
+ end
32
+ end
33
+
@@ -0,0 +1,102 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
4
+ # this file to always be loaded, without a need to explicitly require it in any
5
+ # files.
6
+ #
7
+ # Given that it is always loaded, you are encouraged to keep this file as
8
+ # light-weight as possible. Requiring heavyweight dependencies from this file
9
+ # will add to the boot time of your test suite on EVERY test run, even for an
10
+ # individual file that may not need all of that loaded. Instead, consider making
11
+ # a separate helper file that requires the additional dependencies and performs
12
+ # the additional setup, and require it from the spec files that actually need
13
+ # it.
14
+ #
15
+ # The `.rspec` file also contains a few flags that are not defaults but that
16
+ # users commonly want.
17
+ #
18
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
19
+
20
+
21
+ Dir[File.expand_path('../../lib/**/*.rb', __FILE__)].each do |file|
22
+ require file
23
+ end
24
+
25
+ RSpec.configure do |config|
26
+ # rspec-expectations config goes here. You can use an alternate
27
+ # assertion/expectation library such as wrong or the stdlib/minitest
28
+ # assertions if you prefer.
29
+ config.expect_with :rspec do |expectations|
30
+ # This option will default to `true` in RSpec 4. It makes the `description`
31
+ # and `failure_message` of custom matchers include text for helper methods
32
+ # defined using `chain`, e.g.:
33
+ # be_bigger_than(2).and_smaller_than(4).description
34
+ # # => "be bigger than 2 and smaller than 4"
35
+ # ...rather than:
36
+ # # => "be bigger than 2"
37
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
38
+ end
39
+
40
+ # rspec-mocks config goes here. You can use an alternate test double
41
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
42
+ config.mock_with :rspec do |mocks|
43
+ # Prevents you from mocking or stubbing a method that does not exist on
44
+ # a real object. This is generally recommended, and will default to
45
+ # `true` in RSpec 4.
46
+ mocks.verify_partial_doubles = true
47
+ end
48
+
49
+ # The settings below are suggested to provide a good initial experience
50
+ # with RSpec, but feel free to customize to your heart's content.
51
+ =begin
52
+ # These two settings work together to allow you to limit a spec run
53
+ # to individual examples or groups you care about by tagging them with
54
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
55
+ # get run.
56
+ config.filter_run :focus
57
+ config.run_all_when_everything_filtered = true
58
+
59
+ # Allows RSpec to persist some state between runs in order to support
60
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
61
+ # you configure your source control system to ignore this file.
62
+ config.example_status_persistence_file_path = "spec/examples.txt"
63
+
64
+ # Limits the available syntax to the non-monkey patched syntax that is
65
+ # recommended. For more details, see:
66
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
67
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
68
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
69
+ config.disable_monkey_patching!
70
+
71
+ # This setting enables warnings. It's recommended, but in some cases may
72
+ # be too noisy due to issues in dependencies.
73
+ config.warnings = true
74
+
75
+ # Many RSpec users commonly either run the entire suite or an individual
76
+ # file, and it's useful to allow more verbose output when running an
77
+ # individual spec file.
78
+ if config.files_to_run.one?
79
+ # Use the documentation formatter for detailed output,
80
+ # unless a formatter has already been configured
81
+ # (e.g. via a command-line flag).
82
+ config.default_formatter = 'doc'
83
+ end
84
+
85
+ # Print the 10 slowest examples and example groups at the
86
+ # end of the spec run, to help surface which specs are running
87
+ # particularly slow.
88
+ config.profile_examples = 10
89
+
90
+ # Run specs in random order to surface order dependencies. If you find an
91
+ # order dependency and want to debug it, you can fix the order by providing
92
+ # the seed, which is printed after each run.
93
+ # --seed 1234
94
+ config.order = :random
95
+
96
+ # Seed global randomization in this process using the `--seed` CLI option.
97
+ # Setting this allows you to use `--seed` to deterministically reproduce
98
+ # test failures related to randomization by passing the same `--seed` value
99
+ # as the one that triggered the failure.
100
+ Kernel.srand config.seed
101
+ =end
102
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple-currency-converter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
- - RETAILCOMMON DEV (Scott Chu, Justine Jones, Jeff Li)
7
+ - RETAILCOMMON DEV (Scott Chu, Justine Jones, Jeff Li, Greg Ward)
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-25 00:00:00.000000000 Z
11
+ date: 2016-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -114,7 +114,20 @@ email:
114
114
  executables: []
115
115
  extensions: []
116
116
  extra_rdoc_files: []
117
- files: []
117
+ files:
118
+ - ".gitignore"
119
+ - ".rspec"
120
+ - ".travis.yml"
121
+ - Gemfile
122
+ - Guardfile
123
+ - LICENSE
124
+ - LICENSE.txt
125
+ - README.md
126
+ - Rakefile
127
+ - lib/simple_currency_converter.rb
128
+ - simple-currency-converter.gemspec
129
+ - spec/currency_client_spec.rb
130
+ - spec/spec_helper.rb
118
131
  homepage: http://yroo.com
119
132
  licenses:
120
133
  - MIT
@@ -135,8 +148,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
148
  version: '0'
136
149
  requirements: []
137
150
  rubyforge_project:
138
- rubygems_version: 2.4.6
151
+ rubygems_version: 2.5.1
139
152
  signing_key:
140
153
  specification_version: 4
141
154
  summary: Web client to retrieve currency exchange rates
142
- test_files: []
155
+ test_files:
156
+ - spec/currency_client_spec.rb
157
+ - spec/spec_helper.rb