ruby-safenet 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -4
- data/lib/safenet.rb +24 -1
- data/lib/safenet/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 715ff6f246885377bf8dc67d3e51476966c2a39c
|
4
|
+
data.tar.gz: 426547e4d0a810938f6330b93a8c81c9d7dce252
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2012bfc016585980a254f1387c7f758fede3de626007846473a49c573768861c102369d19fe727a3777924fdde17cf61852a4a7ec70d02e80044985489b0e969
|
7
|
+
data.tar.gz: 1134b7912d810184d156990c8942be6bfa7dfdcedfddf9d8a0f2da099c6dd88803be00e7df535c37729d1f4bf4518019a738c2b11fa1c9516b0ba351978de5ea
|
data/README.md
CHANGED
@@ -52,16 +52,22 @@ end
|
|
52
52
|
```
|
53
53
|
|
54
54
|
## Structured Data (SD): **EMULATED**
|
55
|
-
SD
|
55
|
+
Although SD has not been officially implemented by MaidSafe yet, we provide a sub-module (sd) that emulates it.
|
56
56
|
All the information are stored in the Safe Network, through DNS/NFS sub-systems.
|
57
57
|
|
58
58
|
Example:
|
59
59
|
```ruby
|
60
|
-
my_client.sd.create(37267,
|
61
|
-
my_client.sd.get(37267,
|
62
|
-
my_client.sd.update(37267,
|
60
|
+
my_client.sd.create(37267, 11, "Hello World") # 37267 = id, 11 = tag_type
|
61
|
+
my_client.sd.get(37267, 11)
|
62
|
+
my_client.sd.update(37267, 11, "Hello World!")
|
63
|
+
|
64
|
+
my_client.raw.create("Hello World!") # => "861844d6704e8573fec34d967e20bcfef3d424cf48be04e6dc08f2bd58c729743371015ead891cc3cf1c9d34b49264b510751b1ff9e537937bc46b5d6ff4ecc8"
|
65
|
+
my_client.raw.create_from_file("/home/daniel/dog.jpg")
|
66
|
+
my_client.raw.get("861844d6704e8573fec34d967e20bcfef3d424cf48be04e6dc08f2bd58c729743371015ead891cc3cf1c9d34b49264b510751b1ff9e537937bc46b5d6ff4ecc8") # => "Hello World!"
|
63
67
|
```
|
64
68
|
|
69
|
+
Encryption and versioning are both not supported in this emulated version.
|
70
|
+
|
65
71
|
For more information see:
|
66
72
|
https://github.com/maidsafe/rfcs/blob/master/proposed/0028-launcher-low-level-api/0028-launcher-low-level-api.md
|
67
73
|
|
data/lib/safenet.rb
CHANGED
@@ -13,7 +13,7 @@ require "cgi" # CGI.escape method
|
|
13
13
|
module SafeNet
|
14
14
|
|
15
15
|
class Client
|
16
|
-
attr_reader :auth, :nfs, :dns, :sd, :app_info, :key_helper
|
16
|
+
attr_reader :auth, :nfs, :dns, :sd, :raw, :app_info, :key_helper
|
17
17
|
|
18
18
|
def initialize(options = {})
|
19
19
|
@app_info = defaults()
|
@@ -23,6 +23,7 @@ module SafeNet
|
|
23
23
|
@nfs = SafeNet::NFS.new(self)
|
24
24
|
@dns = SafeNet::DNS.new(self)
|
25
25
|
@sd = SafeNet::SD.new(self)
|
26
|
+
@raw = SafeNet::Raw.new(self)
|
26
27
|
end
|
27
28
|
|
28
29
|
def set_app_info(options = {})
|
@@ -596,4 +597,26 @@ module SafeNet
|
|
596
597
|
@client.dns.get_file_unauth("SD#{new_id}", "sd", "data.#{version}")
|
597
598
|
end
|
598
599
|
end
|
600
|
+
|
601
|
+
class Raw
|
602
|
+
def initialize(client_obj)
|
603
|
+
@client = client_obj
|
604
|
+
end
|
605
|
+
|
606
|
+
def create(contents)
|
607
|
+
id = Digest::SHA2.new(512).hexdigest(contents)
|
608
|
+
@client.sd.create(id, -1, contents)
|
609
|
+
id
|
610
|
+
end
|
611
|
+
|
612
|
+
def create_from_file(local_path)
|
613
|
+
id = Digest::SHA2.new(512).file(local_path).hexdigest
|
614
|
+
@client.sd.create(id, -1, File.read(local_path))
|
615
|
+
id
|
616
|
+
end
|
617
|
+
|
618
|
+
def get(id)
|
619
|
+
@client.sd.get(id, -1)
|
620
|
+
end
|
621
|
+
end
|
599
622
|
end
|
data/lib/safenet/version.rb
CHANGED