sibit 0.3.1 → 0.4.0

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
  SHA256:
3
- metadata.gz: 2f80cc342ac38e79dc1fd04b6bf020fb650b7daf17403082afc90a92fee3732f
4
- data.tar.gz: bd83f713454e8a6b490b9a5d64982a51928e8a0511aa032bdbfec67a716027e1
3
+ metadata.gz: 662e8ffacbcc0e1aa2c0572b9bf1a8038773a92223726fcf286ee0be20fb0a0b
4
+ data.tar.gz: ab96954610ece8e418672c64201b13f6ce36a69830d6c961d5e1f7a2a1622e49
5
5
  SHA512:
6
- metadata.gz: 9021d4dc32b50715c33959e4dbd20a61e2051d0f95dd662581328242140568ad398f4a7af6bf296bede38dc55a5e397d55afc9528e3a2f6bba83388b4f141ee3
7
- data.tar.gz: 4438637556ea58c5a402f5048156f2d306d09748001a13ca5738d2589d1262795783eed810dff0473f20aa9c1ae4b8f6bff4829b4f52ab5b81e012150547b243
6
+ metadata.gz: 04a1b22d49ac9b8fd92b3a64d0db9abc818d56a066aa0aec30fe7fbf35898e580477f0bd716d9666e0444ad7a2b51e3ab77f5ea925c37314465c50b747fd08e0
7
+ data.tar.gz: 43c3158f0e98c9b3754ade613df2c3faccb60efdec932107c47e72039b0002f3455c975f42028692b6acc158082882a455745d61be3b58ec275554bcd5629e08
data/README.md CHANGED
@@ -24,7 +24,8 @@ something more complex, I would recommend using
24
24
  [bitcoin-ruby](https://github.com/lian/bitcoin-ruby) for Ruby and
25
25
  [Electrum](https://electrum.org/) as a GUI client.
26
26
 
27
- This is a Ruby gem, install it first:
27
+ This is a Ruby gem, install it first (if doesn't work, there are
28
+ some hints at the bottom of this page):
28
29
 
29
30
  ```bash
30
31
  $ gem install sibit
@@ -94,6 +95,20 @@ tx = sibit.pay(pkey, 10_000_000, 'XL', [address], target, change)
94
95
 
95
96
  Should work.
96
97
 
98
+ ## How to install
99
+
100
+ To install on a fresh Ubuntu 18:
101
+
102
+ ```
103
+ $ sudo apt-get update
104
+ $ sudo apt-get install -y ruby ruby-dev autoconf automake build-essential
105
+ $ sudo gem update --system
106
+ $ gem install rake --no-document
107
+ $ gem install sibit
108
+ ```
109
+
110
+ Should work. If it doesn't, submit an issue, I will try to help.
111
+
97
112
  ## How to contribute
98
113
 
99
114
  Read [these guidelines](https://www.yegor256.com/2014/04/15/github-guidelines.html).
data/lib/sibit/version.rb CHANGED
@@ -26,5 +26,5 @@
26
26
  # License:: MIT
27
27
  class Sibit
28
28
  # Current version of the library.
29
- VERSION = '0.3.1'
29
+ VERSION = '0.4.0'
30
30
  end
data/lib/sibit.rb CHANGED
@@ -44,6 +44,13 @@ class Sibit
44
44
  @log = log
45
45
  end
46
46
 
47
+ # Current price of 1 BTC.
48
+ def price(cur = 'USD')
49
+ h = get_json('https://blockchain.info/ticker')[cur.upcase]
50
+ raise "Unrecognized currency #{cur}" if h.nil?
51
+ h['15m']
52
+ end
53
+
47
54
  # Generates new Bitcon private key and returns in Hash160 format.
48
55
  def generate
49
56
  Bitcoin::Key.generate.priv
data/sibit.gemspec CHANGED
@@ -48,10 +48,10 @@ and Ruby 2.3+.'
48
48
  s.test_files = s.files.grep(%r{^(test|spec|features)/})
49
49
  s.rdoc_options = ['--charset=UTF-8']
50
50
  s.extra_rdoc_files = ['README.md', 'LICENSE.txt']
51
- s.add_runtime_dependency 'backtrace', '>=0.3'
51
+ s.add_runtime_dependency 'backtrace', '~> 0.3'
52
52
  s.add_runtime_dependency 'bitcoin', '0.2.0'
53
- s.add_runtime_dependency 'json', '>=2'
54
- s.add_runtime_dependency 'slop', '>=4.6'
53
+ s.add_runtime_dependency 'json', '~> 2'
54
+ s.add_runtime_dependency 'slop', '~> 4.6'
55
55
  s.add_development_dependency 'codecov', '0.1.10'
56
56
  s.add_development_dependency 'cucumber', '1.3.17'
57
57
  s.add_development_dependency 'debase', '0.2.2'
data/test/test_sibit.rb CHANGED
@@ -30,6 +30,16 @@ require_relative '../lib/sibit'
30
30
  # Copyright:: Copyright (c) 2019 Yegor Bugayenko
31
31
  # License:: MIT
32
32
  class TestSibit < Minitest::Test
33
+ def test_fetch_current_price
34
+ stub_request(
35
+ :get, 'https://blockchain.info/ticker'
36
+ ).to_return(status: 200, body: '{"USD" : {"15m" : 5160.04}}')
37
+ sibit = Sibit.new
38
+ price = sibit.price
39
+ assert(!price.nil?)
40
+ assert_equal(5160.04, price, price)
41
+ end
42
+
33
43
  def test_generate_key
34
44
  sibit = Sibit.new
35
45
  pkey = sibit.generate
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sibit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
@@ -14,14 +14,14 @@ dependencies:
14
14
  name: backtrace
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0.3'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.3'
27
27
  - !ruby/object:Gem::Dependency
@@ -42,28 +42,28 @@ dependencies:
42
42
  name: json
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '2'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '2'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: slop
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '4.6'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '4.6'
69
69
  - !ruby/object:Gem::Dependency