crossbelt-ipfs 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: 0464240a537a72da1d407b45770be652735a774b690d8d99c17b49359238daf3
4
+ data.tar.gz: 911d763f0e527018a90ab2a28b9f2382e82f5a5c335109267353a0f77f40c03b
5
+ SHA512:
6
+ metadata.gz: bde5711b5ae0f5d27db4a35b0c11aa4d11c3e83711ea41eece1c884c738023d7d5eb279806656dcf428f1183897082d78c9b01919d61936ceb7406f20cdbf011
7
+ data.tar.gz: 6307c19bae7e3388e7830b3c4c199a58a1bd096567dbe618871ef732521203ad05af632d93facf275de867fac251922a6913790b57432cd62e0401a4e36e9b93
@@ -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
@@ -0,0 +1,56 @@
1
+ image: "ruby:2.5"
2
+
3
+ variables:
4
+ CONTAINER_TEST_IMAGE: registry.gitlab.com/$CI_PROJECT_PATH:$CI_COMMIT_REF
5
+ CONTAINER_RELEASE_IMAGE: registry.gitlab.com/$CI_PROJECT_PATH:latest
6
+ CONTAINER_COMMIT_IMAGE: registry.gitlab.com/$CI_PROJECT_PATH:$CI_COMMIT_SHA
7
+ LANG: en_US.UTF-8
8
+ LANGUAGE: en_US.UTF-8
9
+
10
+ # Cache gems in between builds
11
+ cache:
12
+ paths:
13
+ - vendor/ruby
14
+
15
+ stages:
16
+ - build
17
+ - test
18
+
19
+ rubocop:
20
+ stage: test
21
+ script:
22
+ - bundle install -j $(nproc) --path vendor
23
+ - bundle exec rubocop
24
+
25
+ spec_tests_2_5:
26
+ stage: test
27
+ image: ruby:2.5
28
+ script:
29
+ - apt-get update && apt-get install -y lsof # required for testing
30
+ - gem install bundler --no-ri --no-rdoc
31
+ - bundle install -j $(nproc) --path vendor
32
+ - bundle exec rake spec
33
+ #allow_failure: true
34
+
35
+ spec_tests_2_6:
36
+ stage: test
37
+ allow_failure: true
38
+ variables:
39
+ RUBYOPT: '--jit --jit-verbose=1'
40
+ image: ruby:2.6.0-rc1
41
+ script:
42
+ - apt-get update && apt-get install -y lsof # required for testing
43
+ - gem install bundler --no-ri --no-rdoc
44
+ - bundle install -j $(nproc) --path vendor
45
+ - bundle exec rake spec
46
+
47
+ build_gem:
48
+ stage: build
49
+ script:
50
+ - gem install bundler --no-ri --no-rdoc
51
+ - bundle install -j $(nproc) --path vendor
52
+ - bundle exec rake build
53
+ artifacts:
54
+ paths:
55
+ - pkg/
56
+ expire_in: 2 week
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1 @@
1
+ inherit_from: .rubocop_todo.yml
@@ -0,0 +1,43 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2018-09-14 09:43:56 -0700 using RuboCop version 0.59.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 3
10
+ Metrics/AbcSize:
11
+ Max: 30
12
+
13
+ # Offense count: 5
14
+ # Configuration parameters: CountComments, ExcludedMethods.
15
+ # ExcludedMethods: refine
16
+ Metrics/BlockLength:
17
+ Max: 130
18
+
19
+ # Offense count: 2
20
+ # Configuration parameters: CountComments.
21
+ Metrics/ClassLength:
22
+ Max: 241
23
+
24
+ # Offense count: 9
25
+ # Configuration parameters: CountComments.
26
+ Metrics/MethodLength:
27
+ Max: 60
28
+
29
+ # Offense count: 4
30
+ Style/Documentation:
31
+ Exclude:
32
+ - 'lib/crossbelt/plugins/exporters/ipfs.rb'
33
+ - 'spec/**/*'
34
+ - 'test/**/*'
35
+ - 'lib/crossbelt/commands/rig/inventory.rb'
36
+ - 'lib/crossbelt/exporters/inventory_report.rb'
37
+ - 'lib/crossbelt/inventory.rb'
38
+
39
+ # Offense count: 83
40
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
41
+ # URISchemes: http, https
42
+ Metrics/LineLength:
43
+ Max: 233
@@ -0,0 +1 @@
1
+ 2.5.1
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.4
5
+ before_install: gem install bundler -v 1.16.2
@@ -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 opselite@protonmail.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 [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ group :development do
6
+ gem 'aruba'
7
+ gem 'bundler', '~> 1.15'
8
+ gem 'crossbelt-ipfs', path: '.'
9
+ gem 'pry'
10
+ gem 'rake', '~> 10.0'
11
+ gem 'rb-readline'
12
+ gem 'rspec', '~> 3.0'
13
+ gem 'rubocop'
14
+ gem 'simplecov'
15
+ end
16
+
17
+ # vendor the gem using 'bundle unpack --path vendor/gems/ipfs ipfs'
18
+ gem 'ipfs', path: 'vendor/gems/ipfs'
@@ -0,0 +1,127 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ crossbelt-ipfs (0.0.1)
5
+
6
+ PATH
7
+ remote: vendor/gems/ipfs
8
+ specs:
9
+ ipfs (0.2.1)
10
+ http (>= 3.0)
11
+
12
+ GEM
13
+ remote: https://rubygems.org/
14
+ specs:
15
+ addressable (2.5.2)
16
+ public_suffix (>= 2.0.2, < 4.0)
17
+ aruba (0.14.6)
18
+ childprocess (>= 0.6.3, < 0.10.0)
19
+ contracts (~> 0.9)
20
+ cucumber (>= 1.3.19)
21
+ ffi (~> 1.9.10)
22
+ rspec-expectations (>= 2.99)
23
+ thor (~> 0.19)
24
+ ast (2.4.0)
25
+ backports (3.11.4)
26
+ builder (3.2.3)
27
+ childprocess (0.9.0)
28
+ ffi (~> 1.0, >= 1.0.11)
29
+ coderay (1.1.2)
30
+ contracts (0.16.0)
31
+ cucumber (3.1.2)
32
+ builder (>= 2.1.2)
33
+ cucumber-core (~> 3.2.0)
34
+ cucumber-expressions (~> 6.0.1)
35
+ cucumber-wire (~> 0.0.1)
36
+ diff-lcs (~> 1.3)
37
+ gherkin (~> 5.1.0)
38
+ multi_json (>= 1.7.5, < 2.0)
39
+ multi_test (>= 0.1.2)
40
+ cucumber-core (3.2.0)
41
+ backports (>= 3.8.0)
42
+ cucumber-tag_expressions (~> 1.1.0)
43
+ gherkin (>= 5.0.0)
44
+ cucumber-expressions (6.0.1)
45
+ cucumber-tag_expressions (1.1.1)
46
+ cucumber-wire (0.0.1)
47
+ diff-lcs (1.3)
48
+ docile (1.3.1)
49
+ domain_name (0.5.20180417)
50
+ unf (>= 0.0.5, < 1.0.0)
51
+ ffi (1.9.25)
52
+ gherkin (5.1.0)
53
+ http (3.3.0)
54
+ addressable (~> 2.3)
55
+ http-cookie (~> 1.0)
56
+ http-form_data (~> 2.0)
57
+ http_parser.rb (~> 0.6.0)
58
+ http-cookie (1.0.3)
59
+ domain_name (~> 0.5)
60
+ http-form_data (2.1.1)
61
+ http_parser.rb (0.6.0)
62
+ jaro_winkler (1.5.1)
63
+ json (2.1.0)
64
+ method_source (0.9.0)
65
+ multi_json (1.13.1)
66
+ multi_test (0.1.2)
67
+ parallel (1.12.1)
68
+ parser (2.5.1.2)
69
+ ast (~> 2.4.0)
70
+ powerpack (0.1.2)
71
+ pry (0.11.3)
72
+ coderay (~> 1.1.0)
73
+ method_source (~> 0.9.0)
74
+ public_suffix (3.0.3)
75
+ rainbow (3.0.0)
76
+ rake (10.5.0)
77
+ rb-readline (0.5.5)
78
+ rspec (3.8.0)
79
+ rspec-core (~> 3.8.0)
80
+ rspec-expectations (~> 3.8.0)
81
+ rspec-mocks (~> 3.8.0)
82
+ rspec-core (3.8.0)
83
+ rspec-support (~> 3.8.0)
84
+ rspec-expectations (3.8.1)
85
+ diff-lcs (>= 1.2.0, < 2.0)
86
+ rspec-support (~> 3.8.0)
87
+ rspec-mocks (3.8.0)
88
+ diff-lcs (>= 1.2.0, < 2.0)
89
+ rspec-support (~> 3.8.0)
90
+ rspec-support (3.8.0)
91
+ rubocop (0.59.0)
92
+ jaro_winkler (~> 1.5.1)
93
+ parallel (~> 1.10)
94
+ parser (>= 2.5, != 2.5.1.1)
95
+ powerpack (~> 0.1)
96
+ rainbow (>= 2.2.2, < 4.0)
97
+ ruby-progressbar (~> 1.7)
98
+ unicode-display_width (~> 1.0, >= 1.0.1)
99
+ ruby-progressbar (1.10.0)
100
+ simplecov (0.16.1)
101
+ docile (~> 1.1)
102
+ json (>= 1.8, < 3)
103
+ simplecov-html (~> 0.10.0)
104
+ simplecov-html (0.10.2)
105
+ thor (0.20.0)
106
+ unf (0.1.4)
107
+ unf_ext
108
+ unf_ext (0.0.7.5)
109
+ unicode-display_width (1.4.0)
110
+
111
+ PLATFORMS
112
+ ruby
113
+
114
+ DEPENDENCIES
115
+ aruba
116
+ bundler (~> 1.15)
117
+ crossbelt-ipfs!
118
+ ipfs!
119
+ pry
120
+ rake (~> 10.0)
121
+ rb-readline
122
+ rspec (~> 3.0)
123
+ rubocop
124
+ simplecov
125
+
126
+ BUNDLED WITH
127
+ 1.16.2
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Corey Osman
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,43 @@
1
+ # Crossbelt::Inventory
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/crossbelt/inventory`. 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 'crossbelt-inventory'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install crossbelt-inventory
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 spec` 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/logicminds/crossbelt-inventory. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
+
41
+ ## Code of Conduct
42
+
43
+ Everyone interacting in the Crossbelt::Inventory project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/logicminds/crossbelt-inventory/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'crossbelt/inventory'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ 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,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'crossbelt/plugins/exporters/ipfs'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'crossbelt-ipfs'
9
+ spec.version = Crossbelt::Plugins::Exporters::Ipfs.version
10
+ spec.authors = ['Opselite']
11
+ spec.email = ['opselite@blockops.party']
12
+
13
+ spec.summary = 'IPFS crossbelt plugin'
14
+ spec.description = 'A crossbelt plugin that adds export and cli commands for IPFS '
15
+ spec.homepage = 'https://crossbelt.blockops.party'
16
+ spec.license = 'MIT'
17
+
18
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
19
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
20
+ # if spec.respond_to?(:metadata)
21
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
22
+ # else
23
+ # raise 'RubyGems 2.0 or newer is required to protect against ' \
24
+ # 'public gem pushes.'
25
+ # end
26
+
27
+ # Specify which files should be added to the gem when it is released.
28
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
29
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
30
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
31
+ end
32
+ spec.bindir = 'exe'
33
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
34
+ spec.require_paths = ['lib']
35
+ spec.add_development_dependency 'aruba', '~> 0.14.5'
36
+ spec.add_development_dependency 'bundler', '~> 1.15'
37
+ spec.add_development_dependency 'pry', '~> 0.11.3'
38
+ spec.add_development_dependency 'rake', '~> 10.0'
39
+ spec.add_development_dependency 'rb-readline', '~> 0.5.5'
40
+ spec.add_development_dependency 'rspec', '~> 3.0'
41
+ spec.add_development_dependency 'rubocop', '~> 0.55.0'
42
+ end
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH << File.join(File.dirname(File.dirname(File.dirname(File.dirname(__dir__)))), 'vendor/gems/ipfs/lib')
4
+ require 'ipfs/client'
5
+
6
+ module Crossbelt
7
+ module Plugins
8
+ module Exporters
9
+ class Ipfs
10
+ def self.type
11
+ 'exporter'
12
+ end
13
+
14
+ def self.version
15
+ '0.0.1'
16
+ end
17
+
18
+ def self.name
19
+ 'ipfs'
20
+ end
21
+
22
+ def self.description
23
+ 'Outputs data on IPFS file system'
24
+ end
25
+
26
+ def self.to_h
27
+ {
28
+ name: name,
29
+ type: type,
30
+ version: version,
31
+ desc: description
32
+ }
33
+ end
34
+
35
+ def self.export(file: nil, contents: nil)
36
+ raise ArgumentError unless file || contents
37
+
38
+ begin
39
+ if contents
40
+ file = Tempfile.new
41
+ File.write(file, contents)
42
+ end
43
+ new.add(file)
44
+ ensure
45
+ file.close if file.is_a?(Tempfile)
46
+ end
47
+ end
48
+
49
+ def client
50
+ @client ||= IPFS::Client.default
51
+ end
52
+
53
+ def pin_rm(node)
54
+ JSON.parse client.pin_rm(node)
55
+ end
56
+
57
+ def read(node)
58
+ client.cat(node)
59
+ end
60
+
61
+ def ls(node)
62
+ client.ls(node)
63
+ end
64
+
65
+ def add(file)
66
+ node = client.add(File.expand_path(file))
67
+ node.hashcode
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /.idea/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
11
+ /.ruby-version
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.3
4
+ before_install: gem install bundler -v 1.10.6
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ipfs.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Pierpaolo Frasa
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,88 @@
1
+ # IPFS API Bindings for Ruby
2
+
3
+ ![](https://ipfs.io/ipfs/QmQJ68PFMDdAsgCZvA1UVzzn18asVcf7HVvCDgpjiSCAse)
4
+
5
+ > This gem provides IPFS API bindings for Ruby, see [https://ipfs.io](https://ipfs.io).
6
+
7
+ **Work in progress.**
8
+
9
+ ## Installation
10
+ Requires Ruby >= 2.1, since it uses the new required keyword arguments syntax.
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem 'ipfs'
16
+ ```
17
+
18
+ And then execute:
19
+
20
+ $ bundle
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install ipfs
25
+
26
+ ## Usage
27
+ ### Initialize client
28
+
29
+ ```ruby
30
+ require 'ipfs/client'
31
+ client = IPFS::Client.new host: 'yourhost', port: 5001
32
+ ```
33
+
34
+ or:
35
+
36
+ ```ruby
37
+ require 'ipfs/client'
38
+ client = IPFS::Client.default # => uses localhost and port 5001
39
+ ```
40
+
41
+ ### ls
42
+
43
+ ```ruby
44
+ nodes = client.ls 'QmXqJAkSdP8e7TSXEeSRKoDY27G11ZwaFJGiKuNFWxpUZo'
45
+
46
+ nodes.each do |node|
47
+ # node is an instance of IPFS::Content::Node
48
+
49
+ puts node.hashcode
50
+
51
+ node.links.each do |link|
52
+ # link is an instance of IPFS::Content::Link
53
+
54
+ puts link.name
55
+ puts link.hashcode
56
+ puts link.size
57
+ end
58
+ end
59
+ ```
60
+
61
+ ### add
62
+ ```ruby
63
+ link = client.add 'myExampleFile.txt'
64
+ puts link.hashcode
65
+ # => QmaVwjMgqjBD25apiuVVnaDqU8SsiiREAAy3Amb1Bs2XHs
66
+ ```
67
+
68
+ ### cat
69
+ ```ruby
70
+ client.cat 'QmaVwjMgqjBD25apiuVVnaDqU8SsiiREAAy3Amb1Bs2XHs'
71
+ # => "This is some example content."
72
+ ```
73
+
74
+ ### pin rm
75
+ ```ruby
76
+ client.pin_rm 'QmaVwjMgqjBD25apiuVVnaDqU8SsiiREAAy3Amb1Bs2XHs', recursive: true
77
+ # => HTTP::Response
78
+ ```
79
+
80
+ ## Development
81
+
82
+ 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.
83
+
84
+ 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).
85
+
86
+ ## Contributing
87
+
88
+ Bug reports and pull requests are welcome on [GitHub](https://github.com/Fryie/ipfs-ruby).
@@ -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,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "ipfs"
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
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ipfs/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'ipfs'
8
+ spec.version = IPFS::VERSION
9
+ spec.authors = ['Pierpaolo Frasa']
10
+ spec.email = ['pfrasa@gmail.com']
11
+ spec.license = 'MIT'
12
+
13
+ spec.summary = 'IPFS API bindings'
14
+ spec.description = 'API bindings for the Interplanetary File System'
15
+ spec.homepage = 'https://ipfs.io'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = 'exe'
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.add_dependency 'http', '>= 3.0'
23
+
24
+ spec.add_development_dependency 'bundler', '~> 1.10'
25
+ spec.add_development_dependency 'rake', '~> 10.0'
26
+ spec.add_development_dependency 'byebug'
27
+ spec.add_development_dependency 'rspec'
28
+ spec.add_development_dependency 'webmock'
29
+ spec.add_development_dependency 'sinatra'
30
+ end
@@ -0,0 +1 @@
1
+ require "ipfs/version"
@@ -0,0 +1,43 @@
1
+ require 'ipfs/commands/ls'
2
+ require 'ipfs/commands/cat'
3
+ require 'ipfs/commands/add'
4
+ require 'ipfs/commands/pin_rm'
5
+
6
+ module IPFS
7
+ class Client
8
+ DEFAULT_HOST = 'http://localhost'.freeze
9
+ DEFAULT_PORT = 5001
10
+ API_VERSION = 'v0'.freeze
11
+
12
+ attr_reader :host, :port
13
+
14
+ def self.default
15
+ new(host: DEFAULT_HOST, port: DEFAULT_PORT)
16
+ end
17
+
18
+ def initialize(host:, port:)
19
+ @host = host
20
+ @port = port
21
+ end
22
+
23
+ def api_url
24
+ "#{host}:#{port}/api/#{API_VERSION}"
25
+ end
26
+
27
+ def ls(node)
28
+ Commands::LS.call self, node
29
+ end
30
+
31
+ def cat(node)
32
+ Commands::Cat.call self, node
33
+ end
34
+
35
+ def add(file)
36
+ Commands::Add.call self, file
37
+ end
38
+
39
+ def pin_rm(node, recursive: true)
40
+ Commands::PinRm.call self, node, recursive: recursive
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,31 @@
1
+ require 'http'
2
+ require 'http/form_data'
3
+ require 'json'
4
+ require 'ipfs/content/link'
5
+
6
+ module IPFS
7
+ module Commands
8
+ class Add
9
+ def self.call(client, file)
10
+ parse query(client, file)
11
+ end
12
+
13
+ private
14
+
15
+ def self.query(client, file)
16
+ form = multiform(file)
17
+ HTTP.get("#{client.api_url}/add?stream-channels=true",
18
+ body: form.to_s,
19
+ headers: { 'Content-Type' => form.content_type }).to_s
20
+ end
21
+
22
+ def self.multiform(file)
23
+ HTTP::FormData.create(file: HTTP::FormData::File.new(file))
24
+ end
25
+
26
+ def self.parse(response)
27
+ Content::Link.parse_single JSON.parse(response)
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,11 @@
1
+ require 'http'
2
+
3
+ module IPFS
4
+ module Commands
5
+ class Cat
6
+ def self.call(client, node)
7
+ HTTP.get("#{client.api_url}/cat?arg=#{node}&stream-channels=true").to_s
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,23 @@
1
+ require 'http'
2
+ require 'json'
3
+ require 'ipfs/content/node'
4
+
5
+ module IPFS
6
+ module Commands
7
+ class LS
8
+ def self.call(client, node)
9
+ parse query(client, node)
10
+ end
11
+
12
+ private
13
+
14
+ def self.query(client, node)
15
+ HTTP.get("#{client.api_url}/ls?arg=#{node}&stream-channels=true").to_s
16
+ end
17
+
18
+ def self.parse(response)
19
+ Content::Node.parse_array JSON.parse(response)['Objects']
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'http'
4
+ require 'json'
5
+
6
+ module IPFS
7
+ module Commands
8
+ class PinRm
9
+ # @return [HTTP::Response]
10
+ def self.call(client, node, recursive:)
11
+ HTTP.get "#{client.api_url}/pin/rm?arg=#{node}&recursive=#{recursive}"
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,23 @@
1
+ module IPFS
2
+ module Content
3
+ class Link
4
+ attr_reader :name, :hashcode, :size
5
+
6
+ def initialize(name:, hashcode:, size:)
7
+ @name = name
8
+ @hashcode = hashcode
9
+ @size = size
10
+ end
11
+
12
+ def self.parse_array(array)
13
+ array.map do |item|
14
+ parse_single(item)
15
+ end
16
+ end
17
+
18
+ def self.parse_single(item)
19
+ new name: item['Name'], hashcode: item['Hash'], size: item['Size']
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,20 @@
1
+ require 'ipfs/content/link'
2
+
3
+ module IPFS
4
+ module Content
5
+ class Node
6
+ attr_reader :hashcode, :links
7
+
8
+ def initialize(hashcode:, links:)
9
+ @hashcode = hashcode
10
+ @links = links
11
+ end
12
+
13
+ def self.parse_array(array)
14
+ array.map do |item|
15
+ new(hashcode: item['Hash'], links: Link.parse_array(item['Links']))
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,3 @@
1
+ module IPFS
2
+ VERSION = '0.2.1'
3
+ end
metadata ADDED
@@ -0,0 +1,178 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: crossbelt-ipfs
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Opselite
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-12-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: aruba
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.14.5
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.14.5
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.15'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.15'
41
+ - !ruby/object:Gem::Dependency
42
+ name: pry
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.11.3
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.11.3
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: rb-readline
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.5.5
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.5.5
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 0.55.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.55.0
111
+ description: 'A crossbelt plugin that adds export and cli commands for IPFS '
112
+ email:
113
+ - opselite@blockops.party
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".gitignore"
119
+ - ".gitlab-ci.yml"
120
+ - ".rspec"
121
+ - ".rubocop.yml"
122
+ - ".rubocop_todo.yml"
123
+ - ".ruby-version"
124
+ - ".travis.yml"
125
+ - CODE_OF_CONDUCT.md
126
+ - Gemfile
127
+ - Gemfile.lock
128
+ - LICENSE.txt
129
+ - README.md
130
+ - Rakefile
131
+ - bin/console
132
+ - bin/setup
133
+ - crossbelt_ipfs.gemspec
134
+ - lib/crossbelt/plugins/exporters/ipfs.rb
135
+ - vendor/gems/ipfs/.gitignore
136
+ - vendor/gems/ipfs/.rspec
137
+ - vendor/gems/ipfs/.travis.yml
138
+ - vendor/gems/ipfs/Gemfile
139
+ - vendor/gems/ipfs/LICENSE
140
+ - vendor/gems/ipfs/README.md
141
+ - vendor/gems/ipfs/Rakefile
142
+ - vendor/gems/ipfs/bin/console
143
+ - vendor/gems/ipfs/bin/setup
144
+ - vendor/gems/ipfs/ipfs.gemspec
145
+ - vendor/gems/ipfs/lib/ipfs.rb
146
+ - vendor/gems/ipfs/lib/ipfs/client.rb
147
+ - vendor/gems/ipfs/lib/ipfs/commands/add.rb
148
+ - vendor/gems/ipfs/lib/ipfs/commands/cat.rb
149
+ - vendor/gems/ipfs/lib/ipfs/commands/ls.rb
150
+ - vendor/gems/ipfs/lib/ipfs/commands/pin_rm.rb
151
+ - vendor/gems/ipfs/lib/ipfs/content/link.rb
152
+ - vendor/gems/ipfs/lib/ipfs/content/node.rb
153
+ - vendor/gems/ipfs/lib/ipfs/version.rb
154
+ homepage: https://crossbelt.blockops.party
155
+ licenses:
156
+ - MIT
157
+ metadata: {}
158
+ post_install_message:
159
+ rdoc_options: []
160
+ require_paths:
161
+ - lib
162
+ required_ruby_version: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ required_rubygems_version: !ruby/object:Gem::Requirement
168
+ requirements:
169
+ - - ">="
170
+ - !ruby/object:Gem::Version
171
+ version: '0'
172
+ requirements: []
173
+ rubyforge_project:
174
+ rubygems_version: 2.7.7
175
+ signing_key:
176
+ specification_version: 4
177
+ summary: IPFS crossbelt plugin
178
+ test_files: []