blockcypher-client 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: 3b261213992eff9f18aff58b6a330da9e83fb261
4
+ data.tar.gz: 7dbdbe0c9da75177f2769228a8a2991a720f0126
5
+ SHA512:
6
+ metadata.gz: 5a091672a0cb2fe2d449de35207f5ecfed8f875e4443e63d822a7a85bb083d7f85a2d2caf62b81368022a20d15f02551697fb2c98593b70d5f11364884b61e44
7
+ data.tar.gz: 5162dc47d7177219e5993177f4ca48c1f9bf21e63b294eca1fd1bed1c6a8b6523b1a24cbb21a98bebf304145ed2a6f734a80f55ef1c5f22cf13f25f4c2c15b98
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in blockcypher-client.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 simcap
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Blockcypher::Client
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'blockcypher-client'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install blockcypher-client
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it ( http://github.com/<my-github-username>/blockcypher-client/fork )
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.pattern = "test/**/*_test.rb"
6
+ t.libs << 'test'
7
+ end
8
+
9
+ task :default => :test
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'blockcypher/client'
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'blockcypher/client/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "blockcypher-client"
8
+ spec.version = Blockcypher::Client::VERSION
9
+ spec.authors = ["simcap"]
10
+ spec.email = ["simcap@fastmail.com"]
11
+ spec.summary = %q{Basic Ruby wrapper to interact with the Blockcypher API}
12
+ spec.description = %q{Basic Ruby wrapper to interact with the Blockcypher API}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "httpclient"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.5"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "minitest"
26
+ spec.add_development_dependency "pry"
27
+ end
@@ -0,0 +1,58 @@
1
+ require 'blockcypher/client/version'
2
+
3
+ require 'httpclient'
4
+ require 'json'
5
+
6
+ module Blockcypher
7
+ module Api
8
+
9
+ def transactions(txs_hash)
10
+ Call.new(base_uri).get("/txs/#{txs_hash}")
11
+ end
12
+ alias_method :txs, :transactions
13
+
14
+ def blocks(block_hash)
15
+ Call.new(base_uri).get("/blocks/#{block_hash}")
16
+ end
17
+
18
+ def address(add)
19
+ Call.new(base_uri).get("/addrs/#{add}")
20
+ end
21
+
22
+ def current
23
+ Call.new(base_uri).get
24
+ end
25
+ alias_method :status, :current
26
+
27
+ class Call
28
+
29
+ def initialize(base_uri)
30
+ @http = HTTPClient.new(base_url: base_uri.to_s)
31
+ end
32
+
33
+ def get(path = '')
34
+ parse_response(@http.get_content(path))
35
+ end
36
+
37
+ private
38
+
39
+ def parse_response(response)
40
+ JSON.parse(response)
41
+ end
42
+ end
43
+ end
44
+
45
+ class Client
46
+ include Api
47
+
48
+ attr_reader :base_uri
49
+
50
+ def initialize(options = {})
51
+ @chain = options[:chain] || :main
52
+ @coin = options[:coin] || :btc
53
+ @base_uri = URI("https://api.blockcypher.com/v1/#{@coin}/#{@chain}")
54
+ end
55
+
56
+ end
57
+
58
+ end
@@ -0,0 +1,5 @@
1
+ module Blockcypher
2
+ class Client
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,14 @@
1
+ require 'minitest_helper'
2
+
3
+ class AddressApiTest < MiniTest::Test
4
+
5
+ def test_get_address_details_for_main_btc
6
+ add = '1PuwQ6uWXNeGcEnLCAXmRJozdLZ9M4NWQ7'
7
+
8
+ client = Blockcypher::Client.new
9
+ json = client.address(add)
10
+
11
+ assert_equal add, json['address']
12
+ end
13
+
14
+ end
@@ -0,0 +1,15 @@
1
+ require 'minitest_helper'
2
+
3
+ class BlocksApiTest < MiniTest::Test
4
+
5
+ def test_get_blocks_details_for_main_btc
6
+ block = '000000000000000002f4d96fc5ab8705629fe4175bfe665afd4e5c19cab33663'
7
+
8
+ client = Blockcypher::Client.new
9
+ json = client.blocks(block)
10
+
11
+ assert_equal block, json['hash']
12
+ assert_equal 'BTC.main', json['chain']
13
+ end
14
+
15
+ end
@@ -0,0 +1,21 @@
1
+ require 'minitest_helper'
2
+
3
+ class CurrentApiTest < MiniTest::Test
4
+
5
+ def test_current_status_for_different_chains
6
+ client = Blockcypher::Client.new
7
+ assert_equal 'BTC.main', client.current['name']
8
+
9
+ client = Blockcypher::Client.new(chain: :test3)
10
+ assert_equal 'BTC.test3', client.current['name']
11
+ end
12
+
13
+ def test_current_status_for_different_coins
14
+ client = Blockcypher::Client.new(coin: :ltc)
15
+ assert_equal 'LTC.main', client.current['name']
16
+
17
+ client = Blockcypher::Client.new(coin: :uro)
18
+ assert_equal 'URO.main', client.current['name']
19
+ end
20
+
21
+ end
@@ -0,0 +1,14 @@
1
+ require 'minitest_helper'
2
+
3
+ class TransactionsApiTest < MiniTest::Test
4
+
5
+ def test_get_transaction_details_for_main_btc
6
+ txs ='709c306928f966918dfe4488acc44d222ae363792a090e8783eb03267ac200ad'
7
+
8
+ client = Blockcypher::Client.new
9
+ json = client.txs(txs)
10
+
11
+ assert_equal txs, json['hash']
12
+ end
13
+
14
+ end
@@ -0,0 +1,5 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'blockcypher/client'
3
+
4
+ require 'pry'
5
+ require 'minitest/autorun'
@@ -0,0 +1,12 @@
1
+ require 'minitest_helper'
2
+
3
+ class TestBlockcypher::Client < MiniTest::Unit::TestCase
4
+ def test_that_it_has_a_version_number
5
+ refute_nil ::Blockcypher::Client::VERSION
6
+ end
7
+
8
+ def test_false
9
+ assert false
10
+ raise 'Hell'
11
+ end
12
+ end
metadata ADDED
@@ -0,0 +1,137 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: blockcypher-client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - simcap
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httpclient
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.5'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.5'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: pry
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Basic Ruby wrapper to interact with the Blockcypher API
84
+ email:
85
+ - simcap@fastmail.com
86
+ executables:
87
+ - blockcypher-client
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - ".travis.yml"
93
+ - Gemfile
94
+ - LICENSE.txt
95
+ - README.md
96
+ - Rakefile
97
+ - bin/blockcypher-client
98
+ - blockcypher-client.gemspec
99
+ - lib/blockcypher/client.rb
100
+ - lib/blockcypher/client/version.rb
101
+ - test/integration/address_api_test.rb
102
+ - test/integration/blocks_api_test.rb
103
+ - test/integration/current_api_test.rb
104
+ - test/integration/transactions_api_test.rb
105
+ - test/minitest_helper.rb
106
+ - test/test_blockcypher/client.rb
107
+ homepage: ''
108
+ licenses:
109
+ - MIT
110
+ metadata: {}
111
+ post_install_message:
112
+ rdoc_options: []
113
+ require_paths:
114
+ - lib
115
+ required_ruby_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ requirements: []
126
+ rubyforge_project:
127
+ rubygems_version: 2.2.2
128
+ signing_key:
129
+ specification_version: 4
130
+ summary: Basic Ruby wrapper to interact with the Blockcypher API
131
+ test_files:
132
+ - test/integration/address_api_test.rb
133
+ - test/integration/blocks_api_test.rb
134
+ - test/integration/current_api_test.rb
135
+ - test/integration/transactions_api_test.rb
136
+ - test/minitest_helper.rb
137
+ - test/test_blockcypher/client.rb