zold-score 0.3.4 → 0.4.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bc8bc53e8775df93481fb2ab2f06f57a359e1afbf02a7fbaab819ae01e055a17
4
- data.tar.gz: ef6b9058b2a56cfdc66d59c9eb02f474db228de82dd4c33ad3bf1962e0ff9fae
3
+ metadata.gz: 6705ffd219a4069f1dd5bfcf53f79c919e682f351b1f2802acbe2dd33d4cb32b
4
+ data.tar.gz: d4e077c6705ef8bedbff3b920f0547d5c535e49d03b4b06bea4026bf13bfff0c
5
5
  SHA512:
6
- metadata.gz: 9eb3d24322a6de5d5c133d8d379fe55aeb250adbf9f85c89d5bfceb3757d56361de1849a13bb8aa39f84b4b5e3c3d3a1db490386d6e7e411e51dfcb81dfed08e
7
- data.tar.gz: 4357042ffebe3175e6b1f97391a52fff38d47aa069a9f729bf0a688a5321e97a3507fd59752c519ed5b53465764e3f2ded82d56ce9b5f8801a9647e194cb6017
6
+ metadata.gz: f338a0958b7be48d5ae3ef5ab1b433788fbcce2334773ec7deea50283bf595dbefbe2ab08b180192fb580a03dfada6d8018e06c183e7b1aa3ad0783a2278a454
7
+ data.tar.gz: b703969c9f94f564c8da37910c7bdc7a7cd72db7e8eacff4025e465a52f43c016aea73d49516b1ed7f6f6132e9fa93f7f5b9c72a0e1ec69c1e002a5f284aaca3
@@ -2,6 +2,7 @@ language: ruby
2
2
  rvm:
3
3
  - 2.3.1
4
4
  - 2.3.3
5
+ - 2.4.5
5
6
  cache: bundler
6
7
  branches:
7
8
  only:
@@ -46,7 +46,7 @@ module Zold
46
46
  # a node. If the number if too small, the values of the score will be
47
47
  # big and the amount of data to be transferred from node to node will
48
48
  # increase. The number is set empirically.
49
- STRENGTH = 7
49
+ STRENGTH = 8
50
50
 
51
51
  attr_reader :time, :host, :port, :invoice, :suffixes, :strength, :created
52
52
 
@@ -104,19 +104,6 @@ module Zold
104
104
  )
105
105
  end
106
106
 
107
- # Parses it back from the text generated by <tt>to_text</tt>.
108
- def self.parse_text(text)
109
- parts = text.split(' ', 7)
110
- Score.new(
111
- time: Time.at(parts[1].hex),
112
- host: parts[2],
113
- port: parts[3].hex,
114
- invoice: "#{parts[4]}@#{parts[5]}",
115
- suffixes: parts[6] ? parts[6].split(' ') : [],
116
- strength: parts[0].to_i
117
- )
118
- end
119
-
120
107
  # Returns its crypto hash. Read the White Paper for more information.
121
108
  def hash
122
109
  raise 'Score has zero value, there is no hash' if @suffixes.empty?
@@ -130,21 +117,6 @@ module Zold
130
117
  "#{value}:#{@time.strftime('%H%M')}"
131
118
  end
132
119
 
133
- # Converts it to a text, which is console friendly. You can parse it back
134
- # using <tt>parse_text()</tt>.
135
- def to_text
136
- pfx, bnf = @invoice.split('@')
137
- [
138
- @strength,
139
- @time.to_i.to_s(16),
140
- @host,
141
- @port.to_s(16),
142
- pfx,
143
- bnf,
144
- @suffixes.join(' ')
145
- ].join(' ')
146
- end
147
-
148
120
  # Converts it to a string. You can parse it back
149
121
  # using <tt>parse()</tt>.
150
122
  def to_s
@@ -104,31 +104,6 @@ class TestScore < Minitest::Test
104
104
  assert(ex.message.include?('Invalid score'), ex)
105
105
  end
106
106
 
107
- def test_prints_and_parses_text
108
- time = Time.now
109
- score = Zold::Score.parse_text(
110
- Zold::Score.new(
111
- time: time, host: 'a.example.com', port: 999, invoice: 'NOPREFIX@ffffffffffffffff',
112
- strength: 1
113
- ).next.next.next.to_text
114
- )
115
- assert_equal(3, score.value)
116
- assert_equal(score.time.utc.to_s, time.utc.to_s)
117
- assert_equal('a.example.com', score.host)
118
- assert_equal(999, score.port)
119
- end
120
-
121
- def test_prints_and_parses_text_zero_score
122
- time = Time.now
123
- score = Zold::Score.parse_text(
124
- Zold::Score.new(
125
- time: time, host: '192.168.0.1', port: 1, invoice: 'NOPREFIX@ffffffffffffffff', suffixes: []
126
- ).to_text
127
- )
128
- assert_equal(0, score.value)
129
- assert(!score.expired?)
130
- end
131
-
132
107
  def test_prints_and_parses_zero_score
133
108
  time = Time.now
134
109
  score = Zold::Score.parse(
@@ -27,7 +27,7 @@ Gem::Specification.new do |s|
27
27
  s.rubygems_version = '2.2'
28
28
  s.required_ruby_version = '>=2.3'
29
29
  s.name = 'zold-score'
30
- s.version = '0.3.4'
30
+ s.version = '0.4.0'
31
31
  s.license = 'MIT'
32
32
  s.summary = 'Zold score'
33
33
  s.description = 'Score calculating Ruby Gem for Zold'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zold-score
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-30 00:00:00.000000000 Z
11
+ date: 2018-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: codecov