ipfs-http-client 0.3.1 → 0.3.2
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 +4 -4
- data/README.md +6 -0
- data/lib/ipfs-http-client/client.rb +4 -0
- data/lib/ipfs-http-client/commands.rb +1 -0
- data/lib/ipfs-http-client/commands/add.rb +1 -1
- data/lib/ipfs-http-client/commands/add_dir.rb +1 -1
- data/lib/ipfs-http-client/commands/base.rb +8 -3
- data/lib/ipfs-http-client/commands/cat.rb +1 -1
- data/lib/ipfs-http-client/commands/cat_to_file.rb +8 -8
- data/lib/ipfs-http-client/commands/ls.rb +1 -1
- data/lib/ipfs-http-client/commands/pin_add.rb +12 -0
- data/lib/ipfs-http-client/commands/pin_rm.rb +1 -1
- data/lib/ipfs-http-client/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97ed4c9f300ffd5bb88d81b7513bc935e7f8c71853abb3a2b0fe8bdceea8f231
|
4
|
+
data.tar.gz: 24efd4f57ced393ee7697613abd6028030dea104230cca081aca9cd1ea2a1bf1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22765703adbd70b6a305125254715ff572f0e3850d323bd172d396240410fc43e43de10ecf92054af0ffce2f9b4b8391682a48b86571e13b74914c4774917f95
|
7
|
+
data.tar.gz: 4224a928a062d2fc76bae4dbd77bb3d5989a55cd289dd9d9a36b12427ef1c4301e81621456018ac51daca914d0f3310c45024f315ce2c73b2f36f03098844d90
|
data/README.md
CHANGED
@@ -75,6 +75,12 @@ pry(main)> client.pin_rm "Qmbvkmk9LFsGneteXk3G7YLqtLVME566ho6ibaQZZVHaC9"
|
|
75
75
|
=> {"Pins"=>["Qmbvkmk9LFsGneteXk3G7YLqtLVME566ho6ibaQZZVHaC9"]}
|
76
76
|
```
|
77
77
|
|
78
|
+
### pin add
|
79
|
+
```
|
80
|
+
pry(main)> client.pin_add "Qmbvkmk9LFsGneteXk3G7YLqtLVME566ho6ibaQZZVHaC9"
|
81
|
+
=> {"Pins"=>["Qmbvkmk9LFsGneteXk3G7YLqtLVME566ho6ibaQZZVHaC9"]}
|
82
|
+
```
|
83
|
+
|
78
84
|
## Development
|
79
85
|
|
80
86
|
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.
|
@@ -4,7 +4,7 @@ module Ipfs
|
|
4
4
|
module Commands
|
5
5
|
class Add < Ipfs::Commands::Base
|
6
6
|
def self.call(client, file)
|
7
|
-
response =
|
7
|
+
response = request(client, "/add", {form: {file: HTTP::FormData::File.new(file)}})
|
8
8
|
parse(response.body)
|
9
9
|
end
|
10
10
|
end
|
@@ -6,12 +6,17 @@ require 'http/form_data'
|
|
6
6
|
|
7
7
|
module Ipfs
|
8
8
|
module Commands
|
9
|
+
class Error < StandardError; end
|
10
|
+
|
9
11
|
class Base
|
10
|
-
def self.
|
12
|
+
def self.request(client, path_with_query, args = nil)
|
11
13
|
url = "#{client.base_url}#{path_with_query}"
|
12
14
|
response = HTTP.get(*[url, args].compact)
|
13
|
-
|
14
|
-
|
15
|
+
if response.code >= 200 && response.code <= 299
|
16
|
+
response
|
17
|
+
else
|
18
|
+
raise Error, response.body
|
19
|
+
end
|
15
20
|
end
|
16
21
|
|
17
22
|
def self.parse(str)
|
@@ -4,15 +4,15 @@ module Ipfs
|
|
4
4
|
module Commands
|
5
5
|
class CatToFile < Ipfs::Commands::Base
|
6
6
|
def self.call(client, node, path)
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
ensure
|
14
|
-
file.close if file
|
7
|
+
response = request(client, "/cat?arg=#{node}")
|
8
|
+
|
9
|
+
begin
|
10
|
+
file = File.open(path, 'wb')
|
11
|
+
while (chunk = response.body.readpartial)
|
12
|
+
file.write chunk
|
15
13
|
end
|
14
|
+
ensure
|
15
|
+
file.close if file
|
16
16
|
end
|
17
17
|
|
18
18
|
true
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Ipfs
|
4
|
+
module Commands
|
5
|
+
class PinAdd < Ipfs::Commands::Base
|
6
|
+
def self.call(client, node, recursive: false)
|
7
|
+
response = request(client, "/pin/add?arg=#{node}&recursive=#{recursive}")
|
8
|
+
parse(response.body)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -4,7 +4,7 @@ module Ipfs
|
|
4
4
|
module Commands
|
5
5
|
class PinRm < Ipfs::Commands::Base
|
6
6
|
def self.call(client, node, recursive: false)
|
7
|
-
response =
|
7
|
+
response = request(client, "/pin/rm?arg=#{node}&recursive=#{recursive}")
|
8
8
|
parse(response.body)
|
9
9
|
end
|
10
10
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ipfs-http-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jingyang Liang
|
@@ -127,6 +127,7 @@ files:
|
|
127
127
|
- lib/ipfs-http-client/commands/cat.rb
|
128
128
|
- lib/ipfs-http-client/commands/cat_to_file.rb
|
129
129
|
- lib/ipfs-http-client/commands/ls.rb
|
130
|
+
- lib/ipfs-http-client/commands/pin_add.rb
|
130
131
|
- lib/ipfs-http-client/commands/pin_rm.rb
|
131
132
|
- lib/ipfs-http-client/version.rb
|
132
133
|
homepage: https://gitlab.com/persper/gitlab/ipfs-http-client
|