rbsx 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: e8aa24cd951d393c487724cbb25509342a70b63f
4
+ data.tar.gz: eab5718d3de05a94a3b201c3676af014ab56b041
5
+ SHA512:
6
+ metadata.gz: 07d360ca4d54cd45d468bfc446aa2969a23a34beadca21572a4dfeae1a12f8197421cd2691f9eb9ce813999f74845f3b4d6dd6e1c33d5867f7d9d0d2ab23bcca
7
+ data.tar.gz: 034ee24d343cd56c7bc1545070e089cf663b7f417563fd568eaaa15e06b72c7ec97ab715b398544d35c03212da9f3f54303d344f645d1da85743b996ff69bbb9
data/.gitignore ADDED
@@ -0,0 +1,23 @@
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
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
23
+ spec/config.yml
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ # 0.0.1
2
+
3
+ - Initial version
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rbsx.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Ramon Tayag
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,43 @@
1
+ # Rbsx
2
+
3
+ Ruby sx Wrapper
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'rbsx'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install rbsx
18
+
19
+ You need [sx](https://github.com/spesmilo/sx/) installed.
20
+
21
+ ## Usage
22
+
23
+ Configure it:
24
+
25
+ ```
26
+ Rbsx.configure do |c|
27
+ c.sx_path = "/path/to/sx"
28
+ end
29
+ ```
30
+
31
+ ```
32
+ rbsx = Rbsx.new(sx_path: "/path/to_sx") # you can optionally set the path here too
33
+ rbsx.bci_fetch_last_height # 32132131
34
+ ```
35
+
36
+ ## Contributing
37
+
38
+ 1. Fork it ( https://github.com/[my-github-username]/rbsx/fork )
39
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
40
+ 3. Copy `spec/config.yml.sample` to `spec/config.yml` and edit as necessary.
41
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
42
+ 4. Push to the branch (`git push origin my-new-feature`)
43
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,27 @@
1
+ module Rbsx
2
+ class Client
3
+
4
+ attr_accessor :sx_path
5
+
6
+ def initialize(sx_path: sx_path)
7
+ self.sx_path = sx_path
8
+ end
9
+
10
+ def bci_fetch_last_height
11
+ sx("bci-fetch-last-height").to_i
12
+ end
13
+
14
+ def sx(command)
15
+ full_command = [sx_path, command].join(" ")
16
+ `#{full_command}`
17
+ rescue Errno::ENOENT
18
+ fail(
19
+ SxNotFound, [
20
+ "sx path `#{sx_path}` does not seem to exist.",
21
+ "Please make sure that you can execute `#{full_command}`.",
22
+ ].join(" ")
23
+ )
24
+ end
25
+
26
+ end
27
+ end
@@ -0,0 +1,4 @@
1
+ module Rbsx
2
+ class RbsxError < StandardError; end
3
+ class SxNotFound < RbsxError; end
4
+ end
@@ -0,0 +1,3 @@
1
+ module Rbsx
2
+ VERSION = "0.0.1"
3
+ end
data/lib/rbsx.rb ADDED
@@ -0,0 +1,19 @@
1
+ require "active_support/core_ext/module/attribute_accessors"
2
+ require "active_support/core_ext/hash/indifferent_access"
3
+ require "rbsx/version"
4
+ require "rbsx/client"
5
+ require "rbsx/exceptions"
6
+
7
+ module Rbsx
8
+
9
+ mattr_accessor :sx_path
10
+
11
+ def self.new
12
+ Client.new(sx_path: self.sx_path)
13
+ end
14
+
15
+ def self.configure(&block)
16
+ yield self
17
+ end
18
+
19
+ end
data/rbsx.gemspec ADDED
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rbsx/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rbsx"
8
+ spec.version = Rbsx::VERSION
9
+ spec.authors = ["Ramon Tayag"]
10
+ spec.email = ["ramon.tayag@gmail.com"]
11
+ spec.summary = %q{Wrapper for sx}
12
+ spec.description = %q{Wrapper for sx Bitcoin command line utilities}
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_development_dependency "activesupport"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.6"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "rspec"
26
+ end
@@ -0,0 +1 @@
1
+ sx_path: "/usr/local/bin/sx"
@@ -0,0 +1,45 @@
1
+ require "spec_helper"
2
+
3
+ module Rbsx
4
+ describe Client do
5
+
6
+ describe "initialization" do
7
+ it "accepts sx_path" do
8
+ client = described_class.new(sx_path: "/path/to")
9
+ expect(client.sx_path).to eq "/path/to"
10
+ end
11
+ end
12
+
13
+ describe "#sx" do
14
+ it "executes the command with the sx_path" do
15
+ client = described_class.new(sx_path: "/sx")
16
+ expect(client).to receive(:`).with("/sx mycommand")
17
+ client.sx "mycommand"
18
+ end
19
+
20
+ context "given the wrong sx path" do
21
+ it "raises an error describing what might be wrong" do
22
+ client = described_class.new(sx_path: "/nonexistent")
23
+ expect { client.sx("help") }.to raise_error(
24
+ SxNotFound,
25
+ [
26
+ "sx path `/nonexistent` does not seem to exist.",
27
+ "Please make sure that you can execute `/nonexistent help`.",
28
+ ].join(" ")
29
+ )
30
+ end
31
+ end
32
+ end
33
+
34
+ describe "#bci_fetch_last_height" do
35
+ it "returns the result of `bci-fetch-last-height`" do
36
+ client = described_class.new
37
+ allow(client).to receive(:sx).with("bci-fetch-last-height").
38
+ and_return("12387237")
39
+ expect(client.bci_fetch_last_height).to eq 12387237
40
+ end
41
+ end
42
+
43
+
44
+ end
45
+ end
data/spec/rbsx_spec.rb ADDED
@@ -0,0 +1,32 @@
1
+ require "spec_helper"
2
+
3
+ describe Rbsx do
4
+
5
+ describe ".configure" do
6
+ it "yields Rbsx to set the configuration" do
7
+ Rbsx.configure do |c|
8
+ c.sx_path = "/path/to/sx"
9
+ end
10
+
11
+ expect(Rbsx.sx_path).to eq "/path/to/sx"
12
+ end
13
+ end
14
+
15
+ describe ".sx_path" do
16
+ it "is a setter/getter" do
17
+ Rbsx.sx_path = "a"
18
+ expect(Rbsx.sx_path).to eq "a"
19
+ end
20
+ end
21
+
22
+ describe ".new" do
23
+ it "returns an instance of Client" do
24
+ Rbsx.sx_path = "/sx/path"
25
+ client = double(Rbsx::Client)
26
+ allow(Rbsx::Client).to receive(:new).with(sx_path: "/sx/path").
27
+ and_return(client)
28
+ expect(described_class.new).to eq client
29
+ end
30
+ end
31
+
32
+ end
@@ -0,0 +1,17 @@
1
+ require "rbsx"
2
+ require "yaml"
3
+
4
+ SPEC_DIR = File.expand_path(File.join("../", __FILE__))
5
+ CONFIG = YAML.load_file("spec/config.yml").with_indifferent_access
6
+
7
+ RSpec.configure do |c|
8
+
9
+ c.before(:each) do
10
+ Rbsx.configure do |config|
11
+ config.sx_path = CONFIG.fetch(:sx_path)
12
+ end
13
+ end
14
+
15
+ c.order = "random"
16
+
17
+ end
metadata ADDED
@@ -0,0 +1,119 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rbsx
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ramon Tayag
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
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.6'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.6'
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: rspec
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
+ description: Wrapper for sx Bitcoin command line utilities
70
+ email:
71
+ - ramon.tayag@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - .gitignore
77
+ - CHANGELOG.md
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - lib/rbsx.rb
83
+ - lib/rbsx/client.rb
84
+ - lib/rbsx/exceptions.rb
85
+ - lib/rbsx/version.rb
86
+ - rbsx.gemspec
87
+ - spec/config.yml.sample
88
+ - spec/rbsx/client_spec.rb
89
+ - spec/rbsx_spec.rb
90
+ - spec/spec_helper.rb
91
+ homepage: ''
92
+ licenses:
93
+ - MIT
94
+ metadata: {}
95
+ post_install_message:
96
+ rdoc_options: []
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - '>='
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ requirements: []
110
+ rubyforge_project:
111
+ rubygems_version: 2.2.2
112
+ signing_key:
113
+ specification_version: 4
114
+ summary: Wrapper for sx
115
+ test_files:
116
+ - spec/config.yml.sample
117
+ - spec/rbsx/client_spec.rb
118
+ - spec/rbsx_spec.rb
119
+ - spec/spec_helper.rb