openexchangerates 0.0.1

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e5ad184a4401e48b91d5f702cfad79640d5723d3
4
+ data.tar.gz: 9b7808468a8f66b03f80c6ae5c883b7f260d7c6c
5
+ SHA512:
6
+ metadata.gz: 83596f0c83b1cc258efcc56629d4437a1920431223f9c30e050dcc30f07d2229400d5920124fce4f51b5431bc00af5068292b1459fc500f71e0eaa9df7173f16
7
+ data.tar.gz: 8f382404e453ae87fe9370f79ac4bbaa0f0f62fdaed291bd48c803ab43cb663106994783fc60338121be8cad475e536b0e014b24c7a9baa0176139e4cfde5b3e
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ *.gem
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Alexander Popov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ 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, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,4 @@
1
+ openexchangerates
2
+ =================
3
+
4
+ Implementation API openexchangerates.org on Ruby
data/example.rb ADDED
@@ -0,0 +1,12 @@
1
+ require 'json'
2
+ require 'time'
3
+ require 'openexchangerates'
4
+
5
+ currency = OpenExchange.new('586ee899f7eb4f79861589a1f00a8630')
6
+ cur = JSON.parse(currency.get_latest)
7
+
8
+ cur_show = 'RUB'
9
+
10
+ puts "Latest update: #{Time.at(cur['timestamp'])}"
11
+ puts "1 USD = #{cur['rates'][cur_show]} \
12
+ (#{JSON.parse(currency.get_currencies)[cur_show]})"
@@ -0,0 +1,31 @@
1
+ require 'open-uri'
2
+
3
+ class OpenExchange
4
+ @@url = 'http://openexchangerates.org/api/'
5
+
6
+ def initialize(api_key)
7
+ @api_key = api_key
8
+ @user_agent = "Ruby/#{RUBY_VERSION}"
9
+ end
10
+
11
+ def set_userAgent(user_agent)
12
+ @user_agent = user_agent
13
+ end
14
+
15
+ def get_latest()
16
+ json = open("#{@@url}latest.json?app_id=#{@api_key}",
17
+ 'User-Agent' => @user_agent).read
18
+ return json
19
+ end
20
+
21
+ def get_old(date) # YYYY-MM-DD
22
+ json = open("#{@@url}historical/#{date}.json?app_id=#{@api_key}",
23
+ 'User-Agent' => @user_agent).read
24
+ end
25
+
26
+ def get_currencies()
27
+ json = open("#{@@url}currencies.json?app_id=#{@api_key}",
28
+ 'User-Agent' => @user_agent).read
29
+ return json
30
+ end
31
+ end
@@ -0,0 +1,14 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'openexchangerates'
3
+ s.version = '0.0.1'
4
+ s.date = '2012-12-06'
5
+ s.summary = 'Implementation API openexchangerates.org on Ruby'
6
+ s.description = 'Implementation API openexchangerates.org on Ruby'
7
+ s.authors = ['Alexander Popov']
8
+ s.email = ['iiiypuk@iiiypuk.me']
9
+ s.homepage = 'https://github.com/IIIypuk/openexchangerates'
10
+ s.license = 'MIT'
11
+
12
+ s.files = `git ls-files`.split("\n")
13
+ s.require_paths = ["lib"]
14
+ end
metadata ADDED
@@ -0,0 +1,50 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: openexchangerates
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Alexander Popov
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2012-12-06 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Implementation API openexchangerates.org on Ruby
14
+ email:
15
+ - iiiypuk@iiiypuk.me
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - .gitignore
21
+ - LICENSE
22
+ - README.md
23
+ - example.rb
24
+ - lib/openexchangerates.rb
25
+ - openexchangerates.gemspec
26
+ homepage: https://github.com/IIIypuk/openexchangerates
27
+ licenses:
28
+ - MIT
29
+ metadata: {}
30
+ post_install_message:
31
+ rdoc_options: []
32
+ require_paths:
33
+ - lib
34
+ required_ruby_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ required_rubygems_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ requirements: []
45
+ rubyforge_project:
46
+ rubygems_version: 2.1.11
47
+ signing_key:
48
+ specification_version: 4
49
+ summary: Implementation API openexchangerates.org on Ruby
50
+ test_files: []