universa 0.3.1 → 0.3.2

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
  SHA256:
3
- metadata.gz: 7752fa8898467b2d9c15b36fbd2e42714190ba243adcd83ce8998b75ffc2cb91
4
- data.tar.gz: 45cccb4f84d884276a7d1dcb90d2ea45f7f51b5ec089588254c91dbd2cea6ae9
3
+ metadata.gz: 8bcc91f917cdd77fa909ad8b9224717144650012c4e81af41414560f820bcc8e
4
+ data.tar.gz: 79503f7a631b4772126fb48f4dd155e32170893a472a7ca56f27292d9757b844
5
5
  SHA512:
6
- metadata.gz: f6a88953548a26c93e2cc93ee4301185e5536f8aaa4a5801b76912a1e8b8bfb69bff4af6aa74085cbc1fef75969ccb6cb150bacb505ff30b6e62b160d4279e6f
7
- data.tar.gz: 7b715ea9610753ffd66306a81a3d1dcc4c691b9251fc172c1d10aafe18f1bb741962b90e63cad7523e75a0215e49de5d7c12f67fb9fd3fe826e50e5895eb8dde
6
+ metadata.gz: 89e22f1e4d1862cf6c949b7b1221dedb77a4218329af56af32dcdb2f97c95fca184cec156623ddba808bd6a8e38e149dd31d19c7122363422851260e7d03691f
7
+ data.tar.gz: 47c521fcd58fcb88e41525957bf882f37b6f8dd621ace5e4b24515709b6992e0f387e34f6494568112d948dc8cd6103e2fbddd4bb4e65fa057896c16fce68a03
@@ -113,8 +113,10 @@ module Universa
113
113
 
114
114
  end
115
115
 
116
+ # The connection to a single Universa node.
116
117
  class Connection
117
118
 
119
+ # Do not create it direcly, use {Client#random_connection}, {Client#random_connections} or {Client#[]} instead
118
120
  def initialize umi_client
119
121
  @client = umi_client
120
122
  end
@@ -53,7 +53,7 @@ module Universa
53
53
  #
54
54
  # @param [String] string_id id string representation, like from +hash_id_instance.to_s+. See {#to_s}.
55
55
  def self.from_string(string_id)
56
- string_id.force_encoding('utf-8').gsub('-','+').gsub('_','/')
56
+ string_id.force_encoding('utf-8').gsub('-', '+').gsub('_', '/')
57
57
  invoke_static 'with_digest', string_id
58
58
  end
59
59
 
@@ -80,7 +80,7 @@ module Universa
80
80
  # Could be decoded safely back with {HashId.from_string} but not (most likely) with JAVA API itself
81
81
  # @return [String] RFC3548 modified base64
82
82
  def to_url_safe_string
83
- Base64.encode64(get_digest).gsub(/\s/, '').gsub('/','_').gsub('+', '-')
83
+ Base64.encode64(get_digest).gsub(/\s/, '').gsub('/', '_').gsub('+', '-')
84
84
  end
85
85
 
86
86
  # To use it as a hash key_address.
@@ -94,6 +94,21 @@ module Universa
94
94
  self == other
95
95
  end
96
96
 
97
+ # Compare hashid with string representation, binary representation or another HashId instance
98
+ # automatically.
99
+ def == other
100
+ return false if other == nil
101
+ if other.is_a?(Universa::HashId)
102
+ super
103
+ else
104
+ if other.size == 96
105
+ bytes == other
106
+ else
107
+ to_s == other
108
+ end
109
+ end
110
+ end
111
+
97
112
  end
98
113
 
99
114
  # Universa contract adapter.
@@ -278,6 +293,13 @@ module Universa
278
293
  revoke
279
294
  end
280
295
 
296
+ # Ruby-style contracts equality.
297
+ def == other
298
+ return false if !other || !other.is_a?(Contract)
299
+ hash_id == other.hash_id
300
+ end
301
+
302
+
281
303
  end
282
304
 
283
305
  end
@@ -0,0 +1,41 @@
1
+ # THIS IS A WORK IN PROGRESS COULD VE CHANGED COMPLETELY, OR EVEN DROPPED. DO NOT USE!!!
2
+
3
+ =begin
4
+
5
+ U-Box is a special one-contract transactional filesystem-based storage to hold U packs. It is file based,
6
+ both file and extension are significant.
7
+
8
+ File name is:
9
+
10
+ <name>_<units>
11
+
12
+ where
13
+
14
+ - <name> is just a name of the pack. When unique name collides, <name> is appended with a serial <name><serial>.
15
+
16
+ extensions are:
17
+
18
+ .u - currently active U pack
19
+ .u1 - next U pack, exist while payment operation is in progress
20
+
21
+ .us file timestamp is used as FS lock flag. If it is newer than 45s, the ubox is considered locked. after it
22
+ the cleanup procedure should be performed.
23
+
24
+ UBox wallet contains various assets that could be used to pay for transactions:
25
+
26
+ - ~/.universa/ubox contains all U-packs available for the system
27
+
28
+ - ~/.universa/ubox/inbox could be used to put U-packs in .unicon formaat to be automatically imported
29
+
30
+ =end
31
+
32
+ require 'fileutils'
33
+
34
+ class UBox
35
+
36
+ def import contract: nil, path: "~/.universa/ubox"
37
+ @path = path
38
+ FileUtils.mkdir_p(path) unless File.exist?(path)
39
+ end
40
+
41
+ end
@@ -1,4 +1,4 @@
1
1
  module Universa
2
2
  # Current gem version
3
- VERSION = "0.3.1"
3
+ VERSION = "0.3.2"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: universa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - sergeych
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-04-22 00:00:00.000000000 Z
11
+ date: 2019-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: farcall
@@ -170,6 +170,7 @@ files:
170
170
  - lib/universa/string_utils.rb
171
171
  - lib/universa/tools.rb
172
172
  - lib/universa/u_settings.rb
173
+ - lib/universa/ubox.rb
173
174
  - lib/universa/umi.rb
174
175
  - lib/universa/version.rb
175
176
  - lib/universa/weak_reference.rb
@@ -193,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
193
194
  - !ruby/object:Gem::Version
194
195
  version: '0'
195
196
  requirements: []
196
- rubygems_version: 3.0.1
197
+ rubygems_version: 3.0.3
197
198
  signing_key:
198
199
  specification_version: 4
199
200
  summary: Expose Universa Java API to ruby