nicehash 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 42941706c1dc6a7be437ea7ce17f6eec2722e55368cdcec472672b97eae3aa12
4
+ data.tar.gz: cde3b3c5687dd87cb903d7270270d23bcbe0e52da1456d51311766c8ed6dd0e3
5
+ SHA512:
6
+ metadata.gz: 1baee996b42c5d22204220e282e8c2d90b942a9f0e0c844a5b00ea6d2db3f4df1e4d5e26c209d577e2bb5ddc4b1a156f4a2727414089c7959b91630440181700
7
+ data.tar.gz: 501bed2580681559cf6861f39b4c6caf496ef95a8cd575afc1f939ebec3407acd8f8d4db36cb9bc192c073be86fe6a9d7953f8197ec99c595fb5f9d85b3cb3e5
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.5.0
5
+ before_install: gem install bundler -v 1.16.1
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in nicehash.gemspec
6
+ gemspec
@@ -0,0 +1,66 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ nicehash (0.1.0)
5
+ faraday
6
+ faraday_middleware
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ coderay (1.1.2)
12
+ faraday (0.15.2)
13
+ multipart-post (>= 1.2, < 3)
14
+ faraday_middleware (0.12.2)
15
+ faraday (>= 0.7.4, < 1.0)
16
+ ffi (1.9.23)
17
+ formatador (0.2.5)
18
+ guard (2.14.2)
19
+ formatador (>= 0.2.4)
20
+ listen (>= 2.7, < 4.0)
21
+ lumberjack (>= 1.0.12, < 2.0)
22
+ nenv (~> 0.1)
23
+ notiffany (~> 0.0)
24
+ pry (>= 0.9.12)
25
+ shellany (~> 0.0)
26
+ thor (>= 0.18.1)
27
+ guard-compat (1.2.1)
28
+ guard-minitest (2.4.6)
29
+ guard-compat (~> 1.2)
30
+ minitest (>= 3.0)
31
+ listen (3.1.5)
32
+ rb-fsevent (~> 0.9, >= 0.9.4)
33
+ rb-inotify (~> 0.9, >= 0.9.7)
34
+ ruby_dep (~> 1.2)
35
+ lumberjack (1.0.13)
36
+ method_source (0.9.0)
37
+ minitest (5.11.3)
38
+ multipart-post (2.0.0)
39
+ nenv (0.3.0)
40
+ notiffany (0.1.1)
41
+ nenv (~> 0.1)
42
+ shellany (~> 0.0)
43
+ pry (0.11.3)
44
+ coderay (~> 1.1.0)
45
+ method_source (~> 0.9.0)
46
+ rake (10.5.0)
47
+ rb-fsevent (0.10.3)
48
+ rb-inotify (0.9.10)
49
+ ffi (>= 0.5.0, < 2)
50
+ ruby_dep (1.5.0)
51
+ shellany (0.0.1)
52
+ thor (0.20.0)
53
+
54
+ PLATFORMS
55
+ ruby
56
+
57
+ DEPENDENCIES
58
+ bundler (~> 1.16)
59
+ guard
60
+ guard-minitest
61
+ minitest (~> 5.0)
62
+ nicehash!
63
+ rake (~> 10.0)
64
+
65
+ BUNDLED WITH
66
+ 1.16.1
@@ -0,0 +1,6 @@
1
+ guard :minitest do
2
+ # with Minitest::Unit
3
+ watch(%r{^test/(.*)\/?(.*)_test\.rb$})
4
+ watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| "test/#{m[1]}#{m[2]}_test.rb" }
5
+ watch(%r{^test/test_helper\.rb$}) { 'test' }
6
+ end
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Katsuma Ito
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,39 @@
1
+ # Nicehash
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/nicehash`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'nicehash'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install nicehash
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ka2n/nicehash.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "nicehash"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,3 @@
1
+ require "nicehash/version"
2
+ require "nicehash/algo"
3
+ require "nicehash/client"
@@ -0,0 +1,53 @@
1
+ module Nicehash
2
+ module Algo
3
+ ALL = [
4
+ :scrypt,
5
+ :sha256,
6
+ :scryptnf,
7
+ :x11,
8
+ :x13,
9
+ :keccak,
10
+ :x15,
11
+ :nist5,
12
+ :neoscrypt,
13
+ :lyra2re,
14
+ :whirlpoolx,
15
+ :qubit,
16
+ :quark,
17
+ :axiom,
18
+ :lyra2rev2,
19
+ :scryptjanenf16,
20
+ :blake256r8,
21
+ :blake256r14,
22
+ :blake256r8vnl,
23
+ :hodl,
24
+ :daggerhashimoto,
25
+ :decred,
26
+ :cryptonight,
27
+ :lbry,
28
+ :equihash,
29
+ :pascal,
30
+ :x11gost,
31
+ :sia,
32
+ :blake2s,
33
+ :skunk,
34
+ :cryptonightv7,
35
+ ]
36
+
37
+ module ModuleMethods
38
+ def all
39
+ ALL
40
+ end
41
+
42
+ def from_id(id)
43
+ ALL[id]
44
+ end
45
+
46
+ def to_id(algo)
47
+ ALL.find_index(algo)
48
+ end
49
+ end
50
+
51
+ extend ModuleMethods
52
+ end
53
+ end
@@ -0,0 +1,53 @@
1
+ require 'faraday'
2
+ require 'faraday_middleware'
3
+
4
+ module Nicehash
5
+ class Client
6
+ def initialize(client: nil)
7
+ @client = client || Faraday.new('https://api.nicehash.com/api') do |conn|
8
+ conn.response :json, parser_options: { symbolize_names: true }
9
+ conn.adapter Faraday.default_adapter
10
+ end
11
+ end
12
+
13
+ def api
14
+ resp = rpc(nil)
15
+ Response.from_faraday_resp(resp)
16
+ end
17
+
18
+ def method_missing(name, *args, **kwargs)
19
+ resp = rpc(name.to_s.gsub('_', '.'), kwargs)
20
+ Response.from_faraday_resp(resp)
21
+ end
22
+
23
+ private
24
+
25
+ def rpc(method, **kwargs)
26
+ params = {}
27
+ params[:method] = method if method
28
+ params.merge! kwargs
29
+ @client.get '/api', params
30
+ end
31
+ end
32
+
33
+ class Response
34
+ attr_reader :method, :result, :error
35
+
36
+ def self.from_faraday_resp(resp)
37
+ body = resp.body
38
+ error = body&.dig(:result, :error)
39
+ result = error ? nil : body[:result]
40
+ self.new(body[:method], result, error)
41
+ end
42
+
43
+ def initialize(method, result = nil, error = nil)
44
+ @method = method
45
+ @result = result
46
+ @error = error
47
+ end
48
+
49
+ def ok?
50
+ @error == nil
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,3 @@
1
+ module Nicehash
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,32 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "nicehash/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "nicehash"
8
+ spec.version = Nicehash::VERSION
9
+ spec.authors = ["Katsuma Ito"]
10
+ spec.email = ["katsumai@gmail.com"]
11
+
12
+ spec.summary = %q{nicehas.com API Client}
13
+ spec.description = %q{Interact with nichash.com API}
14
+ spec.homepage = "https://github.com/ka2n/nicehash-ruby"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_dependency "faraday"
25
+ spec.add_dependency "faraday_middleware"
26
+
27
+ spec.add_development_dependency "bundler", "~> 1.16"
28
+ spec.add_development_dependency "rake", "~> 10.0"
29
+ spec.add_development_dependency "minitest", "~> 5.0"
30
+ spec.add_development_dependency "guard"
31
+ spec.add_development_dependency "guard-minitest"
32
+ end
metadata ADDED
@@ -0,0 +1,157 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nicehash
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Katsuma Ito
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-05-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
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: faraday_middleware
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.16'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.16'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: minitest
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '5.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '5.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: guard
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: guard-minitest
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: Interact with nichash.com API
112
+ email:
113
+ - katsumai@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".gitignore"
119
+ - ".travis.yml"
120
+ - Gemfile
121
+ - Gemfile.lock
122
+ - Guardfile
123
+ - LICENSE.txt
124
+ - README.md
125
+ - Rakefile
126
+ - bin/console
127
+ - bin/setup
128
+ - lib/nicehash.rb
129
+ - lib/nicehash/algo.rb
130
+ - lib/nicehash/client.rb
131
+ - lib/nicehash/version.rb
132
+ - nicehash.gemspec
133
+ homepage: https://github.com/ka2n/nicehash-ruby
134
+ licenses:
135
+ - MIT
136
+ metadata: {}
137
+ post_install_message:
138
+ rdoc_options: []
139
+ require_paths:
140
+ - lib
141
+ required_ruby_version: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ required_rubygems_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ requirements: []
152
+ rubyforge_project:
153
+ rubygems_version: 2.7.3
154
+ signing_key:
155
+ specification_version: 4
156
+ summary: nicehas.com API Client
157
+ test_files: []