blzrb 0.1.0

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: 351d1bb155a8161ce5f8c0dc0f3824ff1989451c0171efb8e616aba016c3f158
4
+ data.tar.gz: 382283e39673273d615d5978643cd97f73ec30c614fb39a5fcf81856f98983ed
5
+ SHA512:
6
+ metadata.gz: 6fb36b6bd44c4e3f50743bc05c22ce9443776920242135d5670a960919d647d9bae8b8b3e49620879c2a63a920c30481d59dcb53236690d9709ca0379bdd0c25
7
+ data.tar.gz: e127258b384113b02de38946c3ea6b5621d70725ecef22a2bb846909e5c22bc6ebf3a2e5547a5a6958d128856661bb7476cb0071fc9477b85d12c23358ed3da6
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.6.1
6
+ before_install: gem install bundler -v 2.1.4
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at mulengabowa53@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in bluzelle.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
7
+ gem "rspec", "~> 3.0"
8
+ gem "webmock"
9
+ gem "pry-rescue"
10
+ gem "pry-stack_explorer"
@@ -0,0 +1,105 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ blzrb (0.1.0)
5
+ bip_mnemonic
6
+ bitcoin-ruby
7
+ bitcoin-secp256k1
8
+ money-tree
9
+ openssl
10
+ rest-client
11
+
12
+ GEM
13
+ remote: https://rubygems.org/
14
+ specs:
15
+ addressable (2.7.0)
16
+ public_suffix (>= 2.0.2, < 5.0)
17
+ binding_of_caller (0.8.0)
18
+ debug_inspector (>= 0.0.1)
19
+ bip_mnemonic (0.0.4)
20
+ bitcoin-ruby (0.0.20)
21
+ eventmachine
22
+ ffi
23
+ scrypt
24
+ bitcoin-secp256k1 (0.5.2)
25
+ ffi (>= 1.9.25)
26
+ coderay (1.1.2)
27
+ crack (0.4.3)
28
+ safe_yaml (~> 1.0.0)
29
+ debug_inspector (0.0.3)
30
+ diff-lcs (1.3)
31
+ domain_name (0.5.20190701)
32
+ unf (>= 0.0.5, < 1.0.0)
33
+ eventmachine (1.2.7)
34
+ ffi (1.12.2)
35
+ ffi-compiler (1.0.1)
36
+ ffi (>= 1.0.0)
37
+ rake
38
+ hashdiff (1.0.1)
39
+ http-accept (1.7.0)
40
+ http-cookie (1.0.3)
41
+ domain_name (~> 0.5)
42
+ interception (0.5)
43
+ ipaddr (1.2.2)
44
+ method_source (1.0.0)
45
+ mime-types (3.3.1)
46
+ mime-types-data (~> 3.2015)
47
+ mime-types-data (3.2019.1009)
48
+ money-tree (0.10.0)
49
+ ffi
50
+ netrc (0.11.0)
51
+ openssl (2.1.2)
52
+ ipaddr
53
+ pry (0.13.1)
54
+ coderay (~> 1.1)
55
+ method_source (~> 1.0)
56
+ pry-rescue (1.5.0)
57
+ interception (>= 0.5)
58
+ pry (>= 0.12.0)
59
+ pry-stack_explorer (0.4.9.3)
60
+ binding_of_caller (>= 0.7)
61
+ pry (>= 0.9.11)
62
+ public_suffix (4.0.4)
63
+ rake (12.3.3)
64
+ rest-client (2.1.0)
65
+ http-accept (>= 1.7.0, < 2.0)
66
+ http-cookie (>= 1.0.2, < 2.0)
67
+ mime-types (>= 1.16, < 4.0)
68
+ netrc (~> 0.8)
69
+ rspec (3.9.0)
70
+ rspec-core (~> 3.9.0)
71
+ rspec-expectations (~> 3.9.0)
72
+ rspec-mocks (~> 3.9.0)
73
+ rspec-core (3.9.1)
74
+ rspec-support (~> 3.9.1)
75
+ rspec-expectations (3.9.1)
76
+ diff-lcs (>= 1.2.0, < 2.0)
77
+ rspec-support (~> 3.9.0)
78
+ rspec-mocks (3.9.1)
79
+ diff-lcs (>= 1.2.0, < 2.0)
80
+ rspec-support (~> 3.9.0)
81
+ rspec-support (3.9.2)
82
+ safe_yaml (1.0.5)
83
+ scrypt (3.0.7)
84
+ ffi-compiler (>= 1.0, < 2.0)
85
+ unf (0.1.4)
86
+ unf_ext
87
+ unf_ext (0.0.7.7)
88
+ webmock (3.8.3)
89
+ addressable (>= 2.3.6)
90
+ crack (>= 0.3.2)
91
+ hashdiff (>= 0.4.0, < 2.0.0)
92
+
93
+ PLATFORMS
94
+ ruby
95
+
96
+ DEPENDENCIES
97
+ blzrb!
98
+ pry-rescue
99
+ pry-stack_explorer
100
+ rake (~> 12.0)
101
+ rspec (~> 3.0)
102
+ webmock
103
+
104
+ BUNDLED WITH
105
+ 2.1.4
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Mulenga Bowa
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,56 @@
1
+ **blz-rb** is a Ruby library that can be used to access the Bluzelle database service.
2
+
3
+ # Installation
4
+
5
+ Add this line to your application's Gemfile:
6
+
7
+ ```ruby
8
+ gem 'bluzelle'
9
+ ```
10
+
11
+ And then execute:
12
+
13
+ $ bundle install
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install bluzelle
18
+
19
+ * [API docs](/docs/README.md)
20
+ * [Examples](/examples/README.md)
21
+
22
+ # Quickstart
23
+
24
+ In general, you must initialize blz-rb before calling any other functions. Do the following (using your own configuration parameters as applicable) to initialize:
25
+ ```ruby
26
+ require 'bluzelle'
27
+
28
+ bz = Bluzelle::Swarm::Client.new(
29
+ mnemonic: 'your mnemonic',
30
+ endpoint: 'your endpoint',
31
+ chain_id: 'your chain id',
32
+ uuid: 'your uuid',
33
+ )
34
+
35
+ bz.create 'somekey', 'somevalue', { 'gas_price': 10 }
36
+ puts bz.read 'somekey'
37
+ ```
38
+
39
+ ## Development
40
+
41
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
42
+
43
+ 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).
44
+
45
+ ## Contributing
46
+
47
+ Bug reports and pull requests are welcome on GitHub at https://github.com/mul53/bluzelle. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/mul53/bluzelle/blob/master/CODE_OF_CONDUCT.md).
48
+
49
+
50
+ ## License
51
+
52
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
53
+
54
+ ## Code of Conduct
55
+
56
+ Everyone interacting in the Bluzelle project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/mul53/bluzelle/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,36 @@
1
+ require_relative 'lib/bluzelle/version'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "blzrb"
5
+ spec.version = Bluzelle::VERSION
6
+ spec.authors = ["Mulenga Bowa"]
7
+ spec.email = ["mulengabowa53@gmail.com"]
8
+
9
+ spec.summary = "Ruby interface to the bluzelle service"
10
+ spec.description = "Ruby interface to the bluzelle service"
11
+ spec.homepage = "https://github.com/mul53/bluzelle"
12
+ spec.license = "MIT"
13
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
14
+
15
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = "https://github.com/mul53/bluzelle"
19
+ spec.metadata["changelog_uri"] = "https://github.com/mul53/bluzelle"
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
24
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ end
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_dependency 'bitcoin-ruby'
31
+ spec.add_dependency 'bitcoin-secp256k1'
32
+ spec.add_dependency 'money-tree'
33
+ spec.add_dependency 'bip_mnemonic'
34
+ spec.add_dependency 'openssl'
35
+ spec.add_dependency 'rest-client'
36
+ end
@@ -0,0 +1,153 @@
1
+ require 'bluzelle'
2
+
3
+ client = Bluzelle::Swarm::Client.new(
4
+ address: 'bluzelle1upsfjftremwgxz3gfy0wf3xgvwpymqx754ssu9',
5
+ mnemonic: 'around buzz diagram captain obtain detail salon mango muffin brother morning jeans display attend knife carry green dwarf vendor hungry fan route pumpkin car',
6
+ endpoint: 'testnet.public.bluzelle.com:1317',
7
+ chain_id: 'bluzelle',
8
+ uuid: '20fc19d4-7c9d-4b5c-9578-8cedd756e0ea'
9
+ )
10
+
11
+ gas_info = {
12
+ max_fee: '4000001'
13
+ }
14
+
15
+ puts "\n#version"
16
+ puts client.version
17
+
18
+ puts "\n#account"
19
+ puts client.account
20
+
21
+ puts "\n#delete_all"
22
+ client.delete_all gas_info
23
+
24
+ puts "\n#create"
25
+ puts 'creating key=db, value=redis'
26
+ client.create 'db', 'redis', gas_info
27
+ puts 'creating key=fs, value=ipfs'
28
+ client.create 'fs', 'ipfs', gas_info
29
+
30
+ puts "\n#read"
31
+ puts 'reading key=db'
32
+ puts "value=#{client.read 'db'}"
33
+ puts 'reading key=fs'
34
+ puts "value=#{client.read 'fs'}"
35
+
36
+ puts "\n#tx_read"
37
+ puts 'reading key=db'
38
+ puts "value = #{client.tx_read 'db', gas_info}"
39
+
40
+ puts "\n#update"
41
+ puts 'updating key=db, value=bluzelle'
42
+ client.update 'db', 'bluzelle', gas_info
43
+
44
+ puts "\n#read"
45
+ puts 'reading key=db'
46
+ puts "value=#{client.read 'db'}"
47
+
48
+ puts "\n#has"
49
+ puts 'has key=db'
50
+ puts client.has 'db'
51
+
52
+ puts "\n#tx_has"
53
+ puts 'has key=db'
54
+ puts client.tx_has 'db', gas_info
55
+
56
+ puts "\n#keys"
57
+ puts 'getting all keys'
58
+ puts client.keys
59
+
60
+ puts "\n#tx_keys"
61
+ puts 'getting all keys'
62
+ puts client.tx_keys gas_info
63
+
64
+ puts "\n#rename"
65
+ puts 'rename key=db to key=database'
66
+ client.rename 'db', 'database', gas_info
67
+
68
+ puts "\n#count"
69
+ puts 'number of keys'
70
+ puts client.count
71
+
72
+ puts "\n#tx_count"
73
+ puts 'number of keys'
74
+ puts client.tx_count gas_info
75
+
76
+ puts "\n#key_values"
77
+ puts 'getting all keys and values'
78
+ puts client.key_values
79
+
80
+ puts "\n#tx_key_values"
81
+ puts 'getting all keys and values'
82
+ puts client.tx_key_values gas_info
83
+
84
+ puts "\n#multi_update"
85
+ puts 'update key=database, value=mongodb | key=fs, value=unix'
86
+ puts client.multi_update([
87
+ { 'ey' => 'db', 'Value' => 'mongodb' },
88
+ { 'Key' => 'fs', 'Value' => 'unix' }
89
+ ], gas_info)
90
+
91
+ puts "\n#key_values"
92
+ puts 'getting all keys and values'
93
+ puts client.key_values
94
+
95
+ puts "\n#get_lease"
96
+ puts 'lease key=database'
97
+ puts client.get_lease 'database'
98
+
99
+ puts "\n#tx_get_lease"
100
+ puts 'lease key=database'
101
+ puts client.tx_get_lease 'database', gas_info
102
+
103
+ puts "\n#renew_lease"
104
+ puts 'renew key=database, lease=1day'
105
+ client.renew_lease 'database', { 'days': 1 }, gas_info
106
+
107
+ puts "\n#get_lease"
108
+ puts 'lease key=database'
109
+ puts client.get_lease 'database'
110
+
111
+ puts "\n#renew_lease"
112
+ puts 'renew key=database, lease=1week'
113
+ client.renew_lease 'database', { 'days': 7 }, gas_info
114
+
115
+ puts "\n#get_lease"
116
+ puts 'lease key=database'
117
+ puts client.get_lease 'database'
118
+
119
+ puts "\n#renew_lease"
120
+ puts 'renew key=database, lease=1month'
121
+ client.renew_lease 'database', { 'days': 30 }, gas_info
122
+
123
+ puts "\n#get_lease"
124
+ puts 'lease key=database'
125
+ puts client.get_lease 'database'
126
+
127
+ puts "\n#renew_lease"
128
+ puts 'renew key=database, lease=1year'
129
+ client.renew_lease 'database', { 'days': 365 }, gas_info
130
+
131
+ puts "\n#get_lease"
132
+ puts 'lease key=database'
133
+ puts client.get_lease 'database'
134
+
135
+ puts "\n#renew_all_lease"
136
+ puts 'renew all lease=7days'
137
+ client.renew_lease_all({ 'days': 7 }, gas_info)
138
+
139
+ puts "\n#get_lease"
140
+ puts 'lease key=database'
141
+ puts client.get_lease 'database'
142
+
143
+ puts "\n#get_lease"
144
+ puts 'lease key=fs'
145
+ puts client.get_lease 'fs'
146
+
147
+ puts "\n#get_n_shortest_leases"
148
+ puts 'get n leases'
149
+ puts client.get_n_shortest_leases 10
150
+
151
+ puts "\n#tx_get_n_shortest_leases"
152
+ puts 'get n leases'
153
+ puts client.tx_get_n_shortest_leases 10, gas_info