zold-score 0.4.6 → 0.6.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 +4 -4
- data/.0pdd.yml +3 -0
- data/.github/workflows/actionlint.yml +25 -0
- data/.github/workflows/codecov.yml +27 -0
- data/.github/workflows/copyrights.yml +19 -0
- data/.github/workflows/markdown-lint.yml +19 -0
- data/.github/workflows/pdd.yml +19 -0
- data/.github/workflows/rake.yml +28 -0
- data/.github/workflows/reuse.yml +19 -0
- data/.github/workflows/typos.yml +19 -0
- data/.github/workflows/xcop.yml +15 -0
- data/.github/workflows/yamllint.yml +19 -0
- data/.gitignore +9 -4
- data/.rubocop.yml +12 -2
- data/.rultor.yml +11 -12
- data/.simplecov +16 -37
- data/Gemfile +17 -20
- data/LICENSE.txt +1 -1
- data/LICENSES/MIT.txt +21 -0
- data/README.md +28 -24
- data/REUSE.toml +35 -0
- data/Rakefile +3 -29
- data/ext/score_suffix/ScoreSuffix.cpp +14 -27
- data/ext/score_suffix/extconf.rb +10 -22
- data/lib/zold/score.rb +28 -59
- data/renovate.json +6 -0
- data/test/test__helper.rb +33 -0
- data/test/zold/test_score.rb +17 -34
- data/zold-score.gemspec +7 -35
- metadata +29 -118
- data/.travis.yml +0 -20
- data/appveyor.yml +0 -39
|
@@ -1,32 +1,17 @@
|
|
|
1
|
-
// Copyright (c) 2018-
|
|
2
|
-
//
|
|
3
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
-
// of this software and associated documentation files (the 'Software'), to deal
|
|
5
|
-
// in the Software without restriction, including without limitation the rights
|
|
6
|
-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
-
// copies of the Software, and to permit persons to whom the Software is
|
|
8
|
-
// furnished to do so, subject to the following conditions:
|
|
9
|
-
//
|
|
10
|
-
// The above copyright notice and this permission notice shall be included in
|
|
11
|
-
// all copies or substantial portions of the Software.
|
|
12
|
-
//
|
|
13
|
-
// THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
-
// SOFTWARE.
|
|
1
|
+
// SPDX-FileCopyrightText: Copyright (c) 2018-2025 Zerocracy
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
20
3
|
|
|
21
4
|
#include <array>
|
|
22
5
|
#include <random>
|
|
23
6
|
#include <vector>
|
|
24
|
-
#include <openssl/
|
|
7
|
+
#include <openssl/evp.h>
|
|
25
8
|
#include <ruby.h>
|
|
26
9
|
#include <ruby/thread.h>
|
|
27
10
|
|
|
28
11
|
using namespace std;
|
|
29
12
|
|
|
13
|
+
const size_t SHA256_LEN = 32;
|
|
14
|
+
|
|
30
15
|
struct index_params {
|
|
31
16
|
string prefix;
|
|
32
17
|
int strength;
|
|
@@ -35,18 +20,20 @@ struct index_params {
|
|
|
35
20
|
};
|
|
36
21
|
|
|
37
22
|
static
|
|
38
|
-
array<uint8_t,
|
|
23
|
+
array<uint8_t, SHA256_LEN> sha256(const string &input)
|
|
39
24
|
{
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
25
|
+
array<uint8_t, SHA256_LEN> hash;
|
|
26
|
+
unsigned int len = 0;
|
|
27
|
+
EVP_MD_CTX *ctx = EVP_MD_CTX_new();
|
|
28
|
+
EVP_DigestInit_ex(ctx, EVP_sha256(), nullptr);
|
|
29
|
+
EVP_DigestUpdate(ctx, input.data(), input.size());
|
|
30
|
+
EVP_DigestFinal_ex(ctx, hash.data(), &len);
|
|
31
|
+
EVP_MD_CTX_free(ctx);
|
|
45
32
|
return hash;
|
|
46
33
|
}
|
|
47
34
|
|
|
48
35
|
static
|
|
49
|
-
bool check_hash(const array<uint8_t,
|
|
36
|
+
bool check_hash(const array<uint8_t, SHA256_LEN> &hash, int strength)
|
|
50
37
|
{
|
|
51
38
|
int current_strength = 0;
|
|
52
39
|
const auto rend = hash.rend();
|
data/ext/score_suffix/extconf.rb
CHANGED
|
@@ -1,33 +1,21 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Copyright (c) 2018-
|
|
4
|
-
#
|
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
# furnished to do so, subject to the following conditions:
|
|
11
|
-
#
|
|
12
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
# copies or substantial portions of the Software.
|
|
14
|
-
#
|
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
# SOFTWARE.
|
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2018-2025 Zerocracy
|
|
4
|
+
# SPDX-License-Identifier: MIT
|
|
22
5
|
|
|
23
6
|
require 'mkmf'
|
|
24
7
|
|
|
25
8
|
# rubocop:disable Style/GlobalVars
|
|
26
9
|
$warnflags = ''
|
|
27
10
|
$CXXFLAGS << ' -std=c++11 -Wno-deprecated-register'
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
11
|
+
|
|
12
|
+
dir_config('openssl')
|
|
13
|
+
pkg_config('openssl') || dir_config('openssl',
|
|
14
|
+
['/opt/homebrew/opt/openssl@3/include', '/usr/local/opt/openssl@3/include'],
|
|
15
|
+
['/opt/homebrew/opt/openssl@3/lib', '/usr/local/opt/openssl@3/lib'])
|
|
16
|
+
$CXXFLAGS.gsub!('-Wimplicit-int', '')
|
|
17
|
+
$CXXFLAGS.gsub!('-Wdeclaration-after-statement', '')
|
|
18
|
+
$CXXFLAGS.gsub!('-Wimplicit-function-declaration', '')
|
|
31
19
|
# rubocop:enable Style/GlobalVars
|
|
32
20
|
|
|
33
21
|
create_makefile 'score_suffix/score_suffix'
|
data/lib/zold/score.rb
CHANGED
|
@@ -1,24 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Copyright (c) 2018-
|
|
4
|
-
#
|
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
# furnished to do so, subject to the following conditions:
|
|
11
|
-
#
|
|
12
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
# copies or substantial portions of the Software.
|
|
14
|
-
#
|
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
# SOFTWARE.
|
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2018-2025 Zerocracy
|
|
4
|
+
# SPDX-License-Identifier: MIT
|
|
22
5
|
|
|
23
6
|
require 'openssl'
|
|
24
7
|
require 'score_suffix/score_suffix'
|
|
@@ -36,7 +19,7 @@ require 'time'
|
|
|
36
19
|
# {White Paper}[https://papers.zold.io/wp.pdf].
|
|
37
20
|
#
|
|
38
21
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
39
|
-
# Copyright:: Copyright (c) 2018-
|
|
22
|
+
# Copyright:: Copyright (c) 2018-2025 Zerocracy
|
|
40
23
|
# License:: MIT
|
|
41
24
|
module Zold
|
|
42
25
|
# Score
|
|
@@ -58,46 +41,30 @@ module Zold
|
|
|
58
41
|
attr_reader :time, :host, :port, :invoice, :suffixes, :strength, :created
|
|
59
42
|
|
|
60
43
|
# Makes a new object of the class.
|
|
61
|
-
def initialize(time: Time.now,
|
|
44
|
+
def initialize(host:, invoice:, time: Time.now, port: 4096, suffixes: [],
|
|
62
45
|
strength: Score::STRENGTH, created: Time.now)
|
|
63
46
|
raise 'Time can\'t be nil' if time.nil?
|
|
64
|
-
unless time.is_a?(Time)
|
|
65
|
-
raise "Time must be Time, while #{time.class.name} is provided"
|
|
66
|
-
end
|
|
47
|
+
raise "Time must be Time, while #{time.class.name} is provided" unless time.is_a?(Time)
|
|
67
48
|
@time = time
|
|
68
49
|
raise 'Host can\'t be nil' if host.nil?
|
|
69
|
-
unless /^[0-9a-z
|
|
70
|
-
raise "Host \"#{host}\" is in a wrong format"
|
|
71
|
-
end
|
|
50
|
+
raise "Host \"#{host}\" is in a wrong format" unless /^[0-9a-z.-]+$/.match?(host)
|
|
72
51
|
@host = host
|
|
73
52
|
raise 'Port can\'t be nil' if port.nil?
|
|
74
|
-
unless port.is_a?(Integer)
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
if port > 65_535
|
|
78
|
-
raise "Port must be less than 65535, while #{port} is provided"
|
|
79
|
-
end
|
|
80
|
-
unless port.positive?
|
|
81
|
-
raise "Port must be positive integer, while #{port} is provided"
|
|
82
|
-
end
|
|
53
|
+
raise "Port must be Integer, while #{port.class.name} is provided" unless port.is_a?(Integer)
|
|
54
|
+
raise "Port must be less than 65535, while #{port} is provided" if port > 65_535
|
|
55
|
+
raise "Port must be positive integer, while #{port} is provided" unless port.positive?
|
|
83
56
|
@port = port
|
|
84
57
|
raise 'Invoice can\'t be nil' if invoice.nil?
|
|
85
|
-
unless /^[a-zA-Z0-9]{8,32}@[a-f0-9]{16}$/.match?(invoice)
|
|
86
|
-
raise "Invoice \"#{invoice}\" is wrong"
|
|
87
|
-
end
|
|
58
|
+
raise "Invoice \"#{invoice}\" is wrong" unless /^[a-zA-Z0-9]{8,32}@[a-f0-9]{16}$/.match?(invoice)
|
|
88
59
|
@invoice = invoice
|
|
89
60
|
raise 'Suffixes can\'t be nil' if suffixes.nil?
|
|
90
61
|
raise 'Suffixes are not an array' unless suffixes.is_a?(Array)
|
|
91
62
|
@suffixes = suffixes
|
|
92
63
|
raise 'Strength can\'t be nil' if strength.nil?
|
|
93
|
-
unless strength.positive?
|
|
94
|
-
raise "Strength must be positive integer, while #{strength} is provided"
|
|
95
|
-
end
|
|
64
|
+
raise "Strength must be positive integer, while #{strength} is provided" unless strength.positive?
|
|
96
65
|
@strength = strength
|
|
97
66
|
raise 'Created can\'t be nil' if created.nil?
|
|
98
|
-
unless created.is_a?(Time)
|
|
99
|
-
raise "Created must be Time, while #{created.class.name} is provided"
|
|
100
|
-
end
|
|
67
|
+
raise "Created must be Time, while #{created.class.name} is provided" unless created.is_a?(Time)
|
|
101
68
|
@created = created
|
|
102
69
|
end
|
|
103
70
|
|
|
@@ -164,25 +131,27 @@ module Zold
|
|
|
164
131
|
# Parses it back from the text generated by <tt>to_s</tt>.
|
|
165
132
|
def self.parse(text)
|
|
166
133
|
raise 'Can\'t parse nil' if text.nil?
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
134
|
+
begin
|
|
135
|
+
parts = text.split(' ', 7)
|
|
136
|
+
raise 'Invalid score, not enough parts' if parts.length < 6
|
|
137
|
+
Score.new(
|
|
138
|
+
time: Time.at(parts[1].hex),
|
|
139
|
+
host: parts[2],
|
|
140
|
+
port: parts[3].hex,
|
|
141
|
+
invoice: "#{parts[4]}@#{parts[5]}",
|
|
142
|
+
suffixes: parts[6] ? parts[6].split : [],
|
|
143
|
+
strength: parts[0].to_i
|
|
144
|
+
)
|
|
145
|
+
rescue StandardError => e
|
|
146
|
+
raise CantParse, "#{e.message} in #{text.inspect}"
|
|
147
|
+
end
|
|
179
148
|
end
|
|
180
149
|
|
|
181
150
|
# Returns its crypto hash. Read the White Paper for more information.
|
|
182
151
|
def hash
|
|
183
152
|
raise 'Score has zero value, there is no hash' if @suffixes.empty?
|
|
184
153
|
@suffixes.reduce(prefix) do |pfx, suffix|
|
|
185
|
-
OpenSSL::Digest
|
|
154
|
+
OpenSSL::Digest.new('SHA256', "#{pfx} #{suffix}").hexdigest
|
|
186
155
|
end
|
|
187
156
|
end
|
|
188
157
|
|
|
@@ -217,7 +186,7 @@ module Zold
|
|
|
217
186
|
raise "Max can't be negative: #{max}" if max.negative?
|
|
218
187
|
Score.new(
|
|
219
188
|
time: @time, host: @host, port: @port, invoice: @invoice,
|
|
220
|
-
suffixes: @suffixes[0..[max, suffixes.count].min - 1],
|
|
189
|
+
suffixes: @suffixes[0..([max, suffixes.count].min - 1)],
|
|
221
190
|
strength: @strength
|
|
222
191
|
)
|
|
223
192
|
end
|
data/renovate.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2018-2025 Zerocracy
|
|
4
|
+
# SPDX-License-Identifier: MIT
|
|
5
|
+
|
|
6
|
+
$stdout.sync = true
|
|
7
|
+
|
|
8
|
+
require 'simplecov'
|
|
9
|
+
require 'simplecov-cobertura'
|
|
10
|
+
unless SimpleCov.running || ENV['PICKS']
|
|
11
|
+
SimpleCov.command_name('test')
|
|
12
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
|
|
13
|
+
[
|
|
14
|
+
SimpleCov::Formatter::HTMLFormatter,
|
|
15
|
+
SimpleCov::Formatter::CoberturaFormatter
|
|
16
|
+
]
|
|
17
|
+
)
|
|
18
|
+
SimpleCov.minimum_coverage 85
|
|
19
|
+
SimpleCov.minimum_coverage_by_file 60
|
|
20
|
+
SimpleCov.start do
|
|
21
|
+
add_filter 'test/'
|
|
22
|
+
add_filter 'vendor/'
|
|
23
|
+
add_filter 'target/'
|
|
24
|
+
track_files 'lib/**/*.rb'
|
|
25
|
+
track_files '*.rb'
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
require 'minitest/autorun'
|
|
30
|
+
require 'minitest/reporters'
|
|
31
|
+
require 'webmock/minitest'
|
|
32
|
+
Minitest::Reporters.use! [Minitest::Reporters::SpecReporter.new]
|
|
33
|
+
Minitest.load :minitest_reporter
|
data/test/zold/test_score.rb
CHANGED
|
@@ -1,24 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Copyright (c) 2018-
|
|
4
|
-
#
|
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
# furnished to do so, subject to the following conditions:
|
|
11
|
-
#
|
|
12
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
# copies or substantial portions of the Software.
|
|
14
|
-
#
|
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
# SOFTWARE.
|
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2018-2025 Zerocracy
|
|
4
|
+
# SPDX-License-Identifier: MIT
|
|
22
5
|
|
|
23
6
|
require 'minitest/autorun'
|
|
24
7
|
require 'minitest/hooks/test'
|
|
@@ -29,7 +12,7 @@ require_relative '../../lib/zold/score'
|
|
|
29
12
|
|
|
30
13
|
# Score test.
|
|
31
14
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
32
|
-
# Copyright:: Copyright (c) 2018-
|
|
15
|
+
# Copyright:: Copyright (c) 2018-2025 Zerocracy
|
|
33
16
|
# License:: MIT
|
|
34
17
|
class TestScore < Minitest::Test
|
|
35
18
|
include Minitest::Hooks
|
|
@@ -37,7 +20,7 @@ class TestScore < Minitest::Test
|
|
|
37
20
|
# We need this in order to make sure any test is faster than a minute. This
|
|
38
21
|
# should help spotting tests that hang out sometimes. The number of seconds
|
|
39
22
|
# to wait can be increased, but try to make it as little as possible,
|
|
40
|
-
# in order to catch problems
|
|
23
|
+
# in order to catch problems earlier.
|
|
41
24
|
def around
|
|
42
25
|
Timeout.timeout(10) do
|
|
43
26
|
super
|
|
@@ -60,17 +43,17 @@ class TestScore < Minitest::Test
|
|
|
60
43
|
host: 'localhost', port: 443, invoice: 'NOPREFIX@ffffffffffffffff',
|
|
61
44
|
suffixes: %w[A B C D E F G]
|
|
62
45
|
)
|
|
63
|
-
|
|
46
|
+
assert_equal(score, score.reduced(10))
|
|
64
47
|
end
|
|
65
48
|
|
|
66
49
|
def test_drops_to_zero_when_expired
|
|
67
50
|
score = Zold::Score.new(
|
|
68
|
-
time: Time.now - Zold::Score::BEST_BEFORE * 60 * 60,
|
|
51
|
+
time: Time.now - (Zold::Score::BEST_BEFORE * 60 * 60),
|
|
69
52
|
host: 'some-host', port: 9999, invoice: 'NOPREFIX@ffffffffffffffff',
|
|
70
53
|
strength: 50
|
|
71
54
|
).next
|
|
72
|
-
|
|
73
|
-
|
|
55
|
+
assert_predicate(score, :valid?)
|
|
56
|
+
refute_predicate(score, :expired?)
|
|
74
57
|
assert_equal(0, score.value)
|
|
75
58
|
end
|
|
76
59
|
|
|
@@ -81,7 +64,7 @@ class TestScore < Minitest::Test
|
|
|
81
64
|
suffixes: %w[xxx yyy zzz]
|
|
82
65
|
)
|
|
83
66
|
assert_equal(3, score.value)
|
|
84
|
-
|
|
67
|
+
refute_predicate(score, :valid?)
|
|
85
68
|
end
|
|
86
69
|
|
|
87
70
|
def test_prints_mnemo
|
|
@@ -112,7 +95,7 @@ class TestScore < Minitest::Test
|
|
|
112
95
|
ex = assert_raises(Zold::Score::CantParse) do
|
|
113
96
|
Zold::Score.parse(text)
|
|
114
97
|
end
|
|
115
|
-
|
|
98
|
+
assert_includes(ex.message, text, ex)
|
|
116
99
|
end
|
|
117
100
|
|
|
118
101
|
def test_prints_and_parses_zero_score
|
|
@@ -124,7 +107,7 @@ class TestScore < Minitest::Test
|
|
|
124
107
|
text = before.to_s.strip
|
|
125
108
|
after = Zold::Score.parse(text)
|
|
126
109
|
assert_equal(before.value, after.value)
|
|
127
|
-
|
|
110
|
+
refute_predicate(after, :expired?)
|
|
128
111
|
end
|
|
129
112
|
|
|
130
113
|
def test_finds_next_score
|
|
@@ -133,24 +116,24 @@ class TestScore < Minitest::Test
|
|
|
133
116
|
invoice: 'NOPREFIX@ffffffffffffffff', strength: 2
|
|
134
117
|
).next.next.next
|
|
135
118
|
assert_equal(3, score.value)
|
|
136
|
-
|
|
137
|
-
|
|
119
|
+
assert_predicate(score, :valid?)
|
|
120
|
+
refute_predicate(score, :expired?)
|
|
138
121
|
end
|
|
139
122
|
|
|
140
123
|
def test_dont_expire_correctly
|
|
141
124
|
score = Zold::Score.new(
|
|
142
|
-
time: Time.now - 10 * 60 * 60, host: 'localhost', port: 443,
|
|
125
|
+
time: Time.now - (10 * 60 * 60), host: 'localhost', port: 443,
|
|
143
126
|
invoice: 'NOPREFIX@ffffffffffffffff', strength: 2
|
|
144
127
|
).next.next.next
|
|
145
|
-
|
|
128
|
+
refute_predicate(score, :expired?)
|
|
146
129
|
end
|
|
147
130
|
|
|
148
131
|
def test_is_not_valid_if_time_is_in_future
|
|
149
132
|
score = Zold::Score.new(
|
|
150
|
-
time: Time.now + 60 * 60, host: 'localhost', port: 443,
|
|
133
|
+
time: Time.now + (60 * 60), host: 'localhost', port: 443,
|
|
151
134
|
invoice: 'NOPREFIX@ffffffffffffffff', strength: 2
|
|
152
135
|
)
|
|
153
|
-
|
|
136
|
+
refute_predicate(score, :valid?)
|
|
154
137
|
end
|
|
155
138
|
|
|
156
139
|
def test_correct_number_of_zeroes
|
data/zold-score.gemspec
CHANGED
|
@@ -1,53 +1,25 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Copyright (c) 2018-
|
|
4
|
-
#
|
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
# furnished to do so, subject to the following conditions:
|
|
11
|
-
#
|
|
12
|
-
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
# copies or substantial portions of the Software.
|
|
14
|
-
#
|
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
# SOFTWARE.
|
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2018-2025 Zerocracy
|
|
4
|
+
# SPDX-License-Identifier: MIT
|
|
22
5
|
|
|
23
6
|
require 'English'
|
|
24
7
|
Gem::Specification.new do |s|
|
|
25
|
-
s.
|
|
26
|
-
if s.respond_to? :required_rubygems_version=
|
|
27
|
-
s.required_rubygems_version = Gem::Requirement.new('>= 0')
|
|
28
|
-
end
|
|
29
|
-
s.rubygems_version = '2.2'
|
|
8
|
+
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
|
|
30
9
|
s.required_ruby_version = '>=2.5'
|
|
31
10
|
s.name = 'zold-score'
|
|
32
|
-
s.version = '0.
|
|
11
|
+
s.version = '0.6.0'
|
|
33
12
|
s.license = 'MIT'
|
|
34
13
|
s.summary = 'Zold score'
|
|
35
14
|
s.description = 'Score calculating Ruby Gem for Zold'
|
|
36
15
|
s.authors = ['Yegor Bugayenko']
|
|
37
16
|
s.email = 'yegor256@gmail.com'
|
|
38
|
-
s.homepage = '
|
|
17
|
+
s.homepage = 'https://github.com/zold-io/zold-score'
|
|
39
18
|
s.files = `git ls-files`.split($RS)
|
|
40
19
|
s.extensions = %w[ext/score_suffix/extconf.rb]
|
|
41
20
|
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
42
|
-
s.test_files = s.files.grep(%r{^(test|features)/})
|
|
43
21
|
s.rdoc_options = ['--charset=UTF-8']
|
|
44
22
|
s.extra_rdoc_files = ['README.md', 'LICENSE.txt']
|
|
45
|
-
s.
|
|
46
|
-
s.
|
|
47
|
-
s.add_development_dependency 'minitest-hooks', '1.5.0'
|
|
48
|
-
s.add_development_dependency 'rake-compiler', '1.0.4'
|
|
49
|
-
s.add_development_dependency 'rdoc', '4.3.0'
|
|
50
|
-
s.add_development_dependency 'rspec-rails', '3.8.1'
|
|
51
|
-
s.add_development_dependency 'rubocop', '0.62.0'
|
|
52
|
-
s.add_development_dependency 'rubocop-rspec', '1.31.0'
|
|
23
|
+
s.add_dependency 'openssl', '~>3.0'
|
|
24
|
+
s.metadata['rubygems_mfa_required'] = 'true'
|
|
53
25
|
end
|
metadata
CHANGED
|
@@ -1,159 +1,72 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: zold-score
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Yegor Bugayenko
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
|
-
name:
|
|
13
|
+
name: openssl
|
|
15
14
|
requirement: !ruby/object:Gem::Requirement
|
|
16
15
|
requirements:
|
|
17
|
-
- -
|
|
16
|
+
- - "~>"
|
|
18
17
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: 0
|
|
20
|
-
type: :
|
|
18
|
+
version: '3.0'
|
|
19
|
+
type: :runtime
|
|
21
20
|
prerelease: false
|
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
22
|
requirements:
|
|
24
|
-
- -
|
|
23
|
+
- - "~>"
|
|
25
24
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: 0
|
|
27
|
-
- !ruby/object:Gem::Dependency
|
|
28
|
-
name: minitest
|
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
|
30
|
-
requirements:
|
|
31
|
-
- - '='
|
|
32
|
-
- !ruby/object:Gem::Version
|
|
33
|
-
version: 5.11.3
|
|
34
|
-
type: :development
|
|
35
|
-
prerelease: false
|
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
-
requirements:
|
|
38
|
-
- - '='
|
|
39
|
-
- !ruby/object:Gem::Version
|
|
40
|
-
version: 5.11.3
|
|
41
|
-
- !ruby/object:Gem::Dependency
|
|
42
|
-
name: minitest-hooks
|
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
|
44
|
-
requirements:
|
|
45
|
-
- - '='
|
|
46
|
-
- !ruby/object:Gem::Version
|
|
47
|
-
version: 1.5.0
|
|
48
|
-
type: :development
|
|
49
|
-
prerelease: false
|
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
-
requirements:
|
|
52
|
-
- - '='
|
|
53
|
-
- !ruby/object:Gem::Version
|
|
54
|
-
version: 1.5.0
|
|
55
|
-
- !ruby/object:Gem::Dependency
|
|
56
|
-
name: rake-compiler
|
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
|
58
|
-
requirements:
|
|
59
|
-
- - '='
|
|
60
|
-
- !ruby/object:Gem::Version
|
|
61
|
-
version: 1.0.4
|
|
62
|
-
type: :development
|
|
63
|
-
prerelease: false
|
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
-
requirements:
|
|
66
|
-
- - '='
|
|
67
|
-
- !ruby/object:Gem::Version
|
|
68
|
-
version: 1.0.4
|
|
69
|
-
- !ruby/object:Gem::Dependency
|
|
70
|
-
name: rdoc
|
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
|
72
|
-
requirements:
|
|
73
|
-
- - '='
|
|
74
|
-
- !ruby/object:Gem::Version
|
|
75
|
-
version: 4.3.0
|
|
76
|
-
type: :development
|
|
77
|
-
prerelease: false
|
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
-
requirements:
|
|
80
|
-
- - '='
|
|
81
|
-
- !ruby/object:Gem::Version
|
|
82
|
-
version: 4.3.0
|
|
83
|
-
- !ruby/object:Gem::Dependency
|
|
84
|
-
name: rspec-rails
|
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
|
86
|
-
requirements:
|
|
87
|
-
- - '='
|
|
88
|
-
- !ruby/object:Gem::Version
|
|
89
|
-
version: 3.8.1
|
|
90
|
-
type: :development
|
|
91
|
-
prerelease: false
|
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
-
requirements:
|
|
94
|
-
- - '='
|
|
95
|
-
- !ruby/object:Gem::Version
|
|
96
|
-
version: 3.8.1
|
|
97
|
-
- !ruby/object:Gem::Dependency
|
|
98
|
-
name: rubocop
|
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
|
100
|
-
requirements:
|
|
101
|
-
- - '='
|
|
102
|
-
- !ruby/object:Gem::Version
|
|
103
|
-
version: 0.62.0
|
|
104
|
-
type: :development
|
|
105
|
-
prerelease: false
|
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
-
requirements:
|
|
108
|
-
- - '='
|
|
109
|
-
- !ruby/object:Gem::Version
|
|
110
|
-
version: 0.62.0
|
|
111
|
-
- !ruby/object:Gem::Dependency
|
|
112
|
-
name: rubocop-rspec
|
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
|
114
|
-
requirements:
|
|
115
|
-
- - '='
|
|
116
|
-
- !ruby/object:Gem::Version
|
|
117
|
-
version: 1.31.0
|
|
118
|
-
type: :development
|
|
119
|
-
prerelease: false
|
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
-
requirements:
|
|
122
|
-
- - '='
|
|
123
|
-
- !ruby/object:Gem::Version
|
|
124
|
-
version: 1.31.0
|
|
25
|
+
version: '3.0'
|
|
125
26
|
description: Score calculating Ruby Gem for Zold
|
|
126
27
|
email: yegor256@gmail.com
|
|
127
28
|
executables: []
|
|
128
29
|
extensions:
|
|
129
30
|
- ext/score_suffix/extconf.rb
|
|
130
31
|
extra_rdoc_files:
|
|
131
|
-
- README.md
|
|
132
32
|
- LICENSE.txt
|
|
33
|
+
- README.md
|
|
133
34
|
files:
|
|
134
35
|
- ".0pdd.yml"
|
|
135
36
|
- ".gitattributes"
|
|
37
|
+
- ".github/workflows/actionlint.yml"
|
|
38
|
+
- ".github/workflows/codecov.yml"
|
|
39
|
+
- ".github/workflows/copyrights.yml"
|
|
40
|
+
- ".github/workflows/markdown-lint.yml"
|
|
41
|
+
- ".github/workflows/pdd.yml"
|
|
42
|
+
- ".github/workflows/rake.yml"
|
|
43
|
+
- ".github/workflows/reuse.yml"
|
|
44
|
+
- ".github/workflows/typos.yml"
|
|
45
|
+
- ".github/workflows/xcop.yml"
|
|
46
|
+
- ".github/workflows/yamllint.yml"
|
|
136
47
|
- ".gitignore"
|
|
137
48
|
- ".pdd"
|
|
138
49
|
- ".rubocop.yml"
|
|
139
50
|
- ".rultor.yml"
|
|
140
51
|
- ".simplecov"
|
|
141
|
-
- ".travis.yml"
|
|
142
52
|
- Gemfile
|
|
143
53
|
- LICENSE.txt
|
|
54
|
+
- LICENSES/MIT.txt
|
|
144
55
|
- README.md
|
|
56
|
+
- REUSE.toml
|
|
145
57
|
- Rakefile
|
|
146
|
-
- appveyor.yml
|
|
147
58
|
- ext/score_suffix/ScoreSuffix.cpp
|
|
148
59
|
- ext/score_suffix/extconf.rb
|
|
149
60
|
- lib/zold/score.rb
|
|
61
|
+
- renovate.json
|
|
62
|
+
- test/test__helper.rb
|
|
150
63
|
- test/zold/test_score.rb
|
|
151
64
|
- zold-score.gemspec
|
|
152
|
-
homepage:
|
|
65
|
+
homepage: https://github.com/zold-io/zold-score
|
|
153
66
|
licenses:
|
|
154
67
|
- MIT
|
|
155
|
-
metadata:
|
|
156
|
-
|
|
68
|
+
metadata:
|
|
69
|
+
rubygems_mfa_required: 'true'
|
|
157
70
|
rdoc_options:
|
|
158
71
|
- "--charset=UTF-8"
|
|
159
72
|
require_paths:
|
|
@@ -169,9 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
169
82
|
- !ruby/object:Gem::Version
|
|
170
83
|
version: '0'
|
|
171
84
|
requirements: []
|
|
172
|
-
rubygems_version: 3.
|
|
173
|
-
|
|
174
|
-
specification_version: 2
|
|
85
|
+
rubygems_version: 3.6.9
|
|
86
|
+
specification_version: 4
|
|
175
87
|
summary: Zold score
|
|
176
|
-
test_files:
|
|
177
|
-
- test/zold/test_score.rb
|
|
88
|
+
test_files: []
|