open-exchange-rates 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 23f67b81288b6230a19e17fc2647601a82f88465
4
+ data.tar.gz: e89d5faf88fbf4bb03fd0ab89c73407727d9a0bb
5
+ SHA512:
6
+ metadata.gz: 0ae307cd1f0cf56f7f6f475df62fcb472fbaa6037c7abf38cea7fa5ecefd2800901d765205ff83589b1aea9155f4c5782a3d5915ddf4d52448fc0802cbcf6202
7
+ data.tar.gz: 1b499fec27bf118b9389362c3c8bf5cd5430b2e2ab0027a611b93f973b3ac8aeef8ad0f18b10ca36399695e6066389219b3f50de87abd8dffdd40e7467ceaece
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /.idea
4
+ /Gemfile.lock
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
11
+ /vendor/bundle
12
+ /*.gem
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.2.2
5
+ - 2.2.3
6
+ before_install: gem install bundler -v 1.10.6
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in open_exchange_rates.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # OpenExchangeRates
2
+
3
+ Client library for talking to [Open Exchange Rates API](https://openexchangerates.org/documentation). Support one endpoint - [historical](https://openexchangerates.org/documentation#historical-data)
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'open-exchange-rates'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install open-exchange-rates
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Development
26
+
27
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake false` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
28
+
29
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
30
+
31
+ ## Contributing
32
+
33
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Ynnni/open-exchange-rates.
34
+
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "open-exchange-rates"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,7 @@
1
+ require "httparty"
2
+ require "open_exchange_rates/version"
3
+ require "open_exchange_rates/client"
4
+
5
+ module OpenExchangeRates
6
+
7
+ end
@@ -0,0 +1,18 @@
1
+ require "open_exchange_rates/client/connections"
2
+ require "open_exchange_rates/client/historical"
3
+
4
+ module OpenExchangeRates
5
+ class Client
6
+ include HTTParty
7
+ include Connections
8
+ include Historical
9
+
10
+ base_uri 'https://openexchangerates.org/api/'
11
+
12
+ def initialize(app_id = nil)
13
+ app_id ||= ENV['OPEN_EXCHANGE_RATES_APP_ID']
14
+ fail 'Please define your app_id, see https://github.com/Ynnni/open-exchange-rates' unless app_id
15
+ self.class.default_params app_id: app_id
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,19 @@
1
+ module OpenExchangeRates
2
+ class Client
3
+ module Connections
4
+ def get(path, options = {})
5
+ request :get, path, options
6
+ end
7
+
8
+ def request(http_method, path, options)
9
+ response = self.class.send http_method, path, { query: options }
10
+ data = response.parsed_response
11
+ parse_rates data
12
+ end
13
+
14
+ def parse_rates(data)
15
+ data['rates']
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,9 @@
1
+ module OpenExchangeRates
2
+ class Client
3
+ module Historical
4
+ def historical(date)
5
+ get "/historical/#{date.iso8601}.json"
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ module OpenExchangeRates
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'open_exchange_rates/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "open-exchange-rates"
8
+ spec.version = OpenExchangeRates::VERSION
9
+ spec.authors = ["Andrew Ostroumov"]
10
+ spec.email = ["andrew.ostroumov@gmail.com"]
11
+
12
+ spec.summary = %q{Ruby gem for Open Exchange Rates API}
13
+ spec.description = %q{Client library for talking to Open Exchange Rates API. }
14
+ spec.homepage = "https://github.com/Ynnni/open-exchange-rates"
15
+
16
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
17
+ # delete this section to allow pushing this gem to any host.
18
+ if spec.respond_to?(:metadata)
19
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
20
+ else
21
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
22
+ end
23
+
24
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ spec.bindir = "exe"
26
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
+ spec.require_paths = ["lib"]
28
+
29
+ spec.add_runtime_dependency "httparty"
30
+ spec.add_development_dependency "bundler", "~> 1.10"
31
+ spec.add_development_dependency "rake", "~> 10.0"
32
+ end
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: open-exchange-rates
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Andrew Ostroumov
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-08-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.10'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.10'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ description: 'Client library for talking to Open Exchange Rates API. '
56
+ email:
57
+ - andrew.ostroumov@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".travis.yml"
64
+ - Gemfile
65
+ - README.md
66
+ - Rakefile
67
+ - bin/console
68
+ - bin/setup
69
+ - lib/open-exchange-rates.rb
70
+ - lib/open_exchange_rates/client.rb
71
+ - lib/open_exchange_rates/client/connections.rb
72
+ - lib/open_exchange_rates/client/historical.rb
73
+ - lib/open_exchange_rates/version.rb
74
+ - open-exchange-rates.gemspec
75
+ homepage: https://github.com/Ynnni/open-exchange-rates
76
+ licenses: []
77
+ metadata:
78
+ allowed_push_host: https://rubygems.org
79
+ post_install_message:
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubyforge_project:
95
+ rubygems_version: 2.4.5.1
96
+ signing_key:
97
+ specification_version: 4
98
+ summary: Ruby gem for Open Exchange Rates API
99
+ test_files: []