coloredcoins 0.0.3 → 0.0.4

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: 5ff06df2a3869d6b48c15bd1bfa61955e4910393
4
- data.tar.gz: af62dad99c005945113dcfdedfd5e65b7fefcdb4
3
+ metadata.gz: 40f72c8e938e9f3342eef82b2056bbb8176fb433
4
+ data.tar.gz: ce500a133e9c5febfacd849ad05c41e19989c9ef
5
5
  SHA512:
6
- metadata.gz: cbfecf418c0d040f8e6778acf9ab24c0a43970afe6a1224ae792e98e36e702ff1fed7e063db70096e98f13b5bfa9630215c068a9eb785596c88e59de5b237f40
7
- data.tar.gz: a7535aefe05fb8632af482a3b52592a31e5de1be113718be45c1b6466ea4993d83cb596519aae446f9b455d8124be9b8ea1446d112a602f8571e727d9ef5f989
6
+ metadata.gz: 6667d99867bfb7cf98e6c6bcea8040eb8ab397209267d665b77980aa53a1b72ccb94ea50d11cd9c83ae0bf9d5dc1450224944168cd10208da25232aaa73d4936
7
+ data.tar.gz: 455537aab1c344785b7aff34a1eac41169f53800475da392c55425194970aa5c74fbded32825107037a48dbf0c5a6dbfec2018af12c9da6966129181fc4675d1
data/.travis.yml CHANGED
@@ -1,7 +1,6 @@
1
1
  language: ruby
2
2
  sudo: false
3
3
  rvm:
4
- - 1.9.3
5
4
  - 2.0
6
5
  - 2.1
7
6
  - 2.2
data/Gemfile CHANGED
@@ -9,4 +9,7 @@ group :development, :test do
9
9
  gem 'guard-rspec'
10
10
  gem 'guard-rubocop'
11
11
  gem 'terminal-notifier-guard'
12
+ # force gems for ruby <2.1.2
13
+ gem 'ruby_dep', '1.3.1'
14
+ gem 'listen', '3.0.8'
12
15
  end
data/lib/coloredcoins.rb CHANGED
@@ -34,6 +34,11 @@ module Coloredcoins
34
34
  end
35
35
 
36
36
  def self.method_missing(sym, *args, &block)
37
- api.send(sym, *args, &block)
37
+ return api.send(sym, *args, &block) if api.respond_to?(sym)
38
+ super
39
+ end
40
+
41
+ def self.respond_to_missing?(method_name, include_private = false)
42
+ api.respond_to?(method_name) || super
38
43
  end
39
44
  end
@@ -16,13 +16,17 @@ module Coloredcoins
16
16
  query :post, path, payload
17
17
  end
18
18
 
19
- def query(method, path, payload = {})
19
+ def query(method, path, payload = {}) # rubocop:disable Metrics/MethodLength
20
20
  uri = endpoint_uri(path)
21
21
  response = RestClient::Request.execute(
22
22
  method: method,
23
23
  url: uri,
24
- payload: payload,
25
- ssl_version: 'SSLv23'
24
+ payload: payload.to_json,
25
+ ssl_version: 'SSLv23',
26
+ headers: {
27
+ content_type: :json,
28
+ accept: :json
29
+ }
26
30
  )
27
31
  JSON.parse(response, symbolize_names: true)
28
32
  rescue RestClient::ExceptionWithResponse => e
@@ -32,9 +32,8 @@ module Coloredcoins
32
32
 
33
33
  def check
34
34
  raise ArgumentError, 'Set "m" before signing' unless multisig.m
35
- if !multisig.pub_keys && !multisig.redeem_script
36
- raise ArgumentError, 'Set "pub_keys" or "redeem_script" before signing'
37
- end
35
+ return true if multisig.pub_keys || multisig.redeem_script
36
+ raise ArgumentError, 'Set "pub_keys" or "redeem_script" before signing'
38
37
  end
39
38
  end
40
39
  end
@@ -1,3 +1,3 @@
1
1
  module Coloredcoins
2
- VERSION = '0.0.3'.freeze
2
+ VERSION = '0.0.4'.freeze
3
3
  end
@@ -7,8 +7,12 @@ describe Coloredcoins::Connection do
7
7
  {
8
8
  method: nil,
9
9
  url: "#{base_url}#{path}",
10
- payload: payload,
11
- ssl_version: 'SSLv23'
10
+ payload: payload.to_json,
11
+ ssl_version: 'SSLv23',
12
+ headers: {
13
+ content_type: :json,
14
+ accept: :json
15
+ }
12
16
  }
13
17
  end
14
18
 
@@ -0,0 +1,55 @@
1
+ describe Coloredcoins do
2
+ describe '#issue_asset' do
3
+ it 'should call the API' do
4
+ allow(Coloredcoins.api).to receive(:issue_asset)
5
+ Coloredcoins.issue_asset({})
6
+ expect(Coloredcoins.api).to have_received(:issue_asset)
7
+ end
8
+ end
9
+
10
+ describe '#send_asset' do
11
+ it 'should call the API' do
12
+ allow(Coloredcoins.api).to receive(:send_asset)
13
+ Coloredcoins.send_asset({})
14
+ expect(Coloredcoins.api).to have_received(:send_asset)
15
+ end
16
+ end
17
+
18
+ describe '#broadcast' do
19
+ it 'should call the API' do
20
+ allow(Coloredcoins.api).to receive(:broadcast)
21
+ Coloredcoins.broadcast('tx_hex')
22
+ expect(Coloredcoins.api).to have_received(:broadcast)
23
+ end
24
+ end
25
+
26
+ describe '#address_info' do
27
+ it 'should call the API' do
28
+ allow(Coloredcoins.api).to receive(:address_info)
29
+ Coloredcoins.address_info('address')
30
+ expect(Coloredcoins.api).to have_received(:address_info)
31
+ end
32
+ end
33
+
34
+ describe '#asset_holders' do
35
+ it 'should call the API' do
36
+ allow(Coloredcoins.api).to receive(:asset_holders)
37
+ Coloredcoins.asset_holders('asset_id')
38
+ expect(Coloredcoins.api).to have_received(:asset_holders)
39
+ end
40
+ end
41
+
42
+ describe '#asset_metadata' do
43
+ it 'should call the API' do
44
+ allow(Coloredcoins.api).to receive(:asset_metadata)
45
+ Coloredcoins.asset_metadata('asset_id', 'utxo')
46
+ expect(Coloredcoins.api).to have_received(:asset_metadata)
47
+ end
48
+ end
49
+
50
+ describe '#some_undifined_method' do
51
+ it 'should not call the API' do
52
+ expect { Coloredcoins.some_undifined_method }.to raise_error(NoMethodError)
53
+ end
54
+ end
55
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coloredcoins
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
  - Genaro Madrid
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-17 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: rest-client
@@ -186,6 +186,7 @@ files:
186
186
  - spec/coloredcoins/api_spec.rb
187
187
  - spec/coloredcoins/connection_spec.rb
188
188
  - spec/coloredcoins/multisig_tx_spec.rb
189
+ - spec/coloredcoins_spec.rb
189
190
  - spec/spec_helper.rb
190
191
  homepage: https://github.com/genaromadrid/coloredcoins-ruby
191
192
  licenses:
@@ -215,4 +216,5 @@ test_files:
215
216
  - spec/coloredcoins/api_spec.rb
216
217
  - spec/coloredcoins/connection_spec.rb
217
218
  - spec/coloredcoins/multisig_tx_spec.rb
219
+ - spec/coloredcoins_spec.rb
218
220
  - spec/spec_helper.rb