rubitcoin 0.0.3 → 0.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 894a2c1e3537f7e22797e0e1d6d73e4bab6e486e
4
- data.tar.gz: 10f364b27d1c85f106cba467391ada58522f5811
3
+ metadata.gz: e4c70a7f466c5ad1e9e5cab985dc79c46321b906
4
+ data.tar.gz: 1e2b8f02ca31a1646e7a078b614edeae8ad64e2a
5
5
  SHA512:
6
- metadata.gz: baf301e0f0ba9dcd96efb30990f36f5b058e3166c41396ad88a8858ff73b24a26484446c4857e29439f86c3e552fee9bdd45116c6cd51768035717e9e4e1b67c
7
- data.tar.gz: 1f358f3650c74564b80bea8965de8cf31869b442d1905f3dc08a2e8505edaf2fc155e8752b8cf886fa770c42eb5219fe2e471646de14cf1fa1eab8574bd1aa78
6
+ metadata.gz: 0d3d5558ec4862bae302fc94947206e84e8f83a9231f1dfe0ad064332e9c5108da6721a012aa30293938a4cc19d0bf773feb1fded04f8971d8aaeca32ffa2350
7
+ data.tar.gz: 0cbd5b9c30c008096ebc24366e667c5fd5c8e22cafef60c3d10983d16e557d6109859baf76efc982386a4eb016f272c34cea4a1973d48e4b12148b0c37b48f6d
data/README.md CHANGED
@@ -23,12 +23,26 @@ Or install it yourself as:
23
23
  ```rb
24
24
  require 'rubitcoin'
25
25
 
26
+ # USD is default currency.
26
27
  Rubitcoin.fetch
27
- #=> {:high=>223.15, :last=>208.39, :timestamp=>1421461371.0, :bid=>207.95, :vwap=>210.62, :volume=>32705.34241534, :low=>198.04, :ask=>208.21}
28
+ #=> {:high=>220.0, :low=>196.0, :avg=>208.0, :vol=>4663985.33289, :vol_cur=>22407.9454, :last=>210.01, :buy=>210.01, :sell=>209.925, :updated=>1421464571.0}
28
29
 
29
30
  Rubitcoin.high
30
31
  #=> 223.15
31
32
 
33
+ Rubitcoin.last
34
+ #=> 222.15
35
+
36
+ Rubitcoin.fetch(:rur)
37
+ #=> {:high=>15120.05664, :low=>13800.0, :avg=>14460.02832, :vol=>5735982.89998, :vol_cur=>394.4822, :last=>14600.0, :buy=>14640.0, :sell=>14445.4708, :updated=>1421464501.0}
38
+
39
+ Rubitcoin.high(:rur)
40
+ #=> 15120.05664
41
+
42
+ # Rubitcoin.call is alias to Rubitcoin.fetch
43
+ Rubitcoin.(:eur)
44
+ #=> {:high=>193.09383, :low=>173.13251, :avg=>183.11317, :vol=>21602.3727, :vol_cur=>117.53392, :last=>184.96301, :buy=>184.96301, :sell=>183.09709, :updated=>1421465049.0}
45
+ ....
32
46
  ```
33
47
  ## Contributing
34
48
 
data/bin/rubitcoin ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubitcoin'
4
+ require 'awesome_print'
5
+
6
+ loop do
7
+ ap Rubitcoin.fetch
8
+ sleep 1
9
+ end
@@ -1,3 +1,3 @@
1
1
  class Rubitcoin
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/lib/rubitcoin.rb CHANGED
@@ -1,14 +1,17 @@
1
1
  require 'open-uri'
2
2
  require 'json'
3
- require 'pry'
3
+
4
4
  class Rubitcoin
5
- END_POINT = "https://btc-e.com/api/3/ticker"
5
+ END_POINT = "https://btc-e.com/api/3/ticker"
6
+ ATTRIBUTES = %w|high low avg vol vol_cur last buy sell updated|
7
+
6
8
  class << self
7
9
  def fetch(currency=:usd)
8
10
  Hash.[] raw_fetch(currency).map { |k, v| [k.to_sym, v.to_f] }
9
11
  end
12
+ alias call fetch
10
13
 
11
- %w|high low avg vol vol_cur last buy sell updated|.each do |mth|
14
+ ATTRIBUTES.each do |mth|
12
15
  define_method(mth) do |currency=:usd|
13
16
  raw_fetch(currency)[mth].to_f
14
17
  end
data/rubitcoin.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  # coding: utf-8
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'Rubitcoin/version'
4
+ require 'rubitcoin/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "rubitcoin"
@@ -18,6 +18,8 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
+ spec.add_dependency "awesome_print"
22
+
21
23
  spec.add_development_dependency "bundler", "~> 1.7"
22
24
  spec.add_development_dependency "rake", "~> 10.0"
23
25
  spec.add_development_dependency "minitest"
@@ -1,4 +1,4 @@
1
1
  $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
- require 'Rubitcoin'
2
+ require 'rubitcoin'
3
3
 
4
4
  require 'minitest/autorun'
@@ -24,4 +24,8 @@ class TestRubitcoin < MiniTest::Unit::TestCase
24
24
  assert_instance_of Float, Rubitcoin.sell(:rur)
25
25
  assert_instance_of Float, Rubitcoin.updated(:rur)
26
26
  end
27
+
28
+ def test_call_mth
29
+ assert_instance_of Hash, Rubitcoin.fetch(:eur)
30
+ end
27
31
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubitcoin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - gogotanaka
@@ -10,6 +10,20 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2015-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: awesome_print
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'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -55,7 +69,8 @@ dependencies:
55
69
  description: " Fetch bitcoin ticker simple."
56
70
  email:
57
71
  - mail@tanakakazuki.com
58
- executables: []
72
+ executables:
73
+ - rubitcoin
59
74
  extensions: []
60
75
  extra_rdoc_files: []
61
76
  files:
@@ -65,11 +80,12 @@ files:
65
80
  - LICENSE.txt
66
81
  - README.md
67
82
  - Rakefile
83
+ - bin/rubitcoin
68
84
  - lib/rubitcoin.rb
69
85
  - lib/rubitcoin/version.rb
70
86
  - rubitcoin.gemspec
71
87
  - test/minitest_helper.rb
72
- - test/test_Rubitcoin.rb
88
+ - test/test_rubitcoin.rb
73
89
  homepage: ''
74
90
  licenses:
75
91
  - MIT
@@ -96,4 +112,4 @@ specification_version: 4
96
112
  summary: Fetch bitcoin ticker simple.
97
113
  test_files:
98
114
  - test/minitest_helper.rb
99
- - test/test_Rubitcoin.rb
115
+ - test/test_rubitcoin.rb