ruby-safenet 0.5.3 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 65eb893168713c7f73eb4215b249373a0bbf2b6a
4
- data.tar.gz: 8c3409c023698747ec846be0f3af97ecca26ce84
3
+ metadata.gz: 3d00b02e91e4592ae3d4c4d63acad17734a812ce
4
+ data.tar.gz: fab4d08f04ad8519c8dbd9faa0373b189c000965
5
5
  SHA512:
6
- metadata.gz: 507e67bb1b94ef540de9ce2fddd16c827c2c26050afbf9db7e98c9ed225204eed87cd17aa9a5f8670c6becfec215ed83c0b93a844b031bbce31c8d67e1194e04
7
- data.tar.gz: 0781b391ce210bb7177a0cba85c54c89c39d62f1c28c31312d4f8e28706cbd6f2af09e3ed0a2ff656e791371c1f321afe066d30c6e142b54c1992fe64ccc6b1c
6
+ metadata.gz: c76956e645f5bc982a83727ecad71fa420a70c356f9b0f6da3199efdcea2247edabb6d92dbfa9c525510ce77367b4b482c52b3f2c09c71ca987444608a876b06
7
+ data.tar.gz: 36dcd18c48a2231cdfe92e9999493bab02ab77efabe01162f92e87eeb7cbe41dcbae1775c534d6734d15762185f9a49097f7299ccd59c9f77efddf3022329945
data/lib/safenet.rb CHANGED
@@ -98,7 +98,7 @@ module SafeNet
98
98
  #
99
99
  # Reference: https://maidsafe.readme.io/docs/auth
100
100
  #
101
- def auth()
101
+ def auth
102
102
  # entry point
103
103
  url = "#{@client.app_info[:launcher_server]}#{API_VERSION}/auth"
104
104
 
@@ -1009,13 +1009,24 @@ module SafeNet
1009
1009
 
1010
1010
  def read_or_create(name, contents = '', type = 500)
1011
1011
  sd = @client.sd.read(name)
1012
- if sd.is_a?(Hash) # doesn't exist
1012
+ if sd.is_a?(Hash) && (sd["errorCode"] == 404) # doesn't exist
1013
1013
  sd = contents
1014
1014
  @client.sd.create(name, sd, type)
1015
1015
  end
1016
+ sd
1017
+ end
1016
1018
 
1019
+ # create or update
1020
+ def set(name, contents = '', type = 500)
1021
+ sd = @client.sd.update(name, contents)
1022
+ if sd.is_a?(Hash) && (sd["errorCode"] == -22) # doesn't exist
1023
+ sd = @client.sd.create(name, contents)
1024
+ end
1017
1025
  sd
1018
1026
  end
1027
+
1028
+ # aliases
1029
+ alias_method :get, :read
1019
1030
  end
1020
1031
 
1021
1032
  class Immutable
@@ -1,3 +1,3 @@
1
1
  module Safenet
2
- VERSION = "0.5.3"
2
+ VERSION = "0.5.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-safenet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Loureiro
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-02-25 00:00:00.000000000 Z
11
+ date: 2017-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler