sibit 0.25.1 → 0.26.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/Gemfile +18 -28
- data/Gemfile.lock +187 -0
- data/LICENSE.txt +1 -1
- data/LICENSES/MIT.txt +21 -0
- data/README.md +82 -60
- data/REUSE.toml +35 -0
- data/Rakefile +3 -29
- data/bin/sibit +7 -23
- data/cucumber.yml +3 -0
- data/features/cli.feature +2 -0
- data/features/gem_package.feature +4 -1
- data/features/step_definitions/steps.rb +2 -19
- data/features/support/env.rb +2 -19
- data/lib/sibit/bestof.rb +5 -22
- data/lib/sibit/bitcoin/base58.rb +50 -0
- data/lib/sibit/bitcoin/key.rb +87 -0
- data/lib/sibit/bitcoin/script.rb +58 -0
- data/lib/sibit/bitcoin/tx.rb +212 -0
- data/lib/sibit/bitcoin/txbuilder.rb +120 -0
- data/lib/sibit/bitcoinchain.rb +5 -22
- data/lib/sibit/blockchain.rb +5 -22
- data/lib/sibit/blockchair.rb +5 -22
- data/lib/sibit/btc.rb +6 -23
- data/lib/sibit/cex.rb +5 -22
- data/lib/sibit/cryptoapis.rb +5 -22
- data/lib/sibit/earn.rb +5 -21
- data/lib/sibit/error.rb +3 -20
- data/lib/sibit/fake.rb +3 -20
- data/lib/sibit/firstof.rb +5 -22
- data/lib/sibit/http.rb +3 -20
- data/lib/sibit/json.rb +6 -23
- data/lib/sibit/version.rb +4 -21
- data/lib/sibit.rb +31 -40
- data/logo.svg +1 -1
- data/sibit.gemspec +16 -32
- metadata +26 -47
- data/.0pdd.yml +0 -9
- data/.gitattributes +0 -7
- data/.github/workflows/codecov.yml +0 -21
- data/.github/workflows/pdd.yml +0 -15
- data/.github/workflows/rake.yml +0 -24
- data/.github/workflows/xcop.yml +0 -17
- data/.gitignore +0 -8
- data/.pdd +0 -7
- data/.rubocop.yml +0 -38
- data/.rultor.yml +0 -21
- data/.simplecov +0 -40
- data/lib/sibit/log.rb +0 -49
- data/renovate.json +0 -6
- data/test/test__helper.rb +0 -29
- data/test/test_bestof.rb +0 -62
- data/test/test_bitcoinchain.rb +0 -73
- data/test/test_blockchain.rb +0 -58
- data/test/test_blockchair.rb +0 -43
- data/test/test_btc.rb +0 -117
- data/test/test_cex.rb +0 -43
- data/test/test_cryptoapis.rb +0 -51
- data/test/test_fake.rb +0 -55
- data/test/test_firstof.rb +0 -62
- data/test/test_json.rb +0 -40
- data/test/test_live.rb +0 -138
- data/test/test_sibit.rb +0 -209
data/lib/sibit.rb
CHANGED
|
@@ -1,33 +1,20 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Copyright (c) 2019-
|
|
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) 2019-2025 Yegor Bugayenko
|
|
4
|
+
# SPDX-License-Identifier: MIT
|
|
22
5
|
|
|
23
|
-
require '
|
|
6
|
+
require 'loog'
|
|
24
7
|
require_relative 'sibit/version'
|
|
25
|
-
require_relative 'sibit/log'
|
|
26
8
|
require_relative 'sibit/blockchain'
|
|
9
|
+
require_relative 'sibit/bitcoin/base58'
|
|
10
|
+
require_relative 'sibit/bitcoin/key'
|
|
11
|
+
require_relative 'sibit/bitcoin/script'
|
|
12
|
+
require_relative 'sibit/bitcoin/tx'
|
|
13
|
+
require_relative 'sibit/bitcoin/txbuilder'
|
|
27
14
|
# Sibit main class.
|
|
28
15
|
#
|
|
29
16
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
30
|
-
# Copyright:: Copyright (c) 2019-
|
|
17
|
+
# Copyright:: Copyright (c) 2019-2025 Yegor Bugayenko
|
|
31
18
|
# License:: MIT
|
|
32
19
|
class Sibit
|
|
33
20
|
# Constructor.
|
|
@@ -46,9 +33,9 @@ class Sibit
|
|
|
46
33
|
#
|
|
47
34
|
# The +api+ argument can be an object or an array of objects. If an array
|
|
48
35
|
# is provided, we will make an attempt to try them one by one, until
|
|
49
|
-
# one of them
|
|
50
|
-
def initialize(log:
|
|
51
|
-
@log =
|
|
36
|
+
# one of them succeeds.
|
|
37
|
+
def initialize(log: Loog::NULL, api: Sibit::Blockchain.new(log: log))
|
|
38
|
+
@log = log
|
|
52
39
|
@api = api
|
|
53
40
|
end
|
|
54
41
|
|
|
@@ -58,18 +45,16 @@ class Sibit
|
|
|
58
45
|
@api.price(currency)
|
|
59
46
|
end
|
|
60
47
|
|
|
61
|
-
# Generates new
|
|
48
|
+
# Generates new Bitcoin private key and returns in Hash160 format.
|
|
62
49
|
def generate
|
|
63
50
|
key = Bitcoin::Key.generate.priv
|
|
64
51
|
@log.info("Bitcoin private key generated: #{key[0..8]}...")
|
|
65
52
|
key
|
|
66
53
|
end
|
|
67
54
|
|
|
68
|
-
# Creates
|
|
55
|
+
# Creates Bitcoin address using the private key in Hash160 format.
|
|
69
56
|
def create(pvt)
|
|
70
|
-
|
|
71
|
-
key.priv = pvt
|
|
72
|
-
key.addr
|
|
57
|
+
Bitcoin::Key.new(pvt).addr
|
|
73
58
|
end
|
|
74
59
|
|
|
75
60
|
# Gets the balance of the address, in satoshi.
|
|
@@ -116,7 +101,7 @@ class Sibit
|
|
|
116
101
|
def pay(amount, fee, sources, target, change, skip_utxo: [])
|
|
117
102
|
p = price('USD')
|
|
118
103
|
satoshi = satoshi(amount)
|
|
119
|
-
builder = Bitcoin::
|
|
104
|
+
builder = Bitcoin::TxBuilder.new
|
|
120
105
|
unspent = 0
|
|
121
106
|
size = 100
|
|
122
107
|
utxos = @api.utxos(sources.keys)
|
|
@@ -131,8 +116,8 @@ class Sibit
|
|
|
131
116
|
builder.input do |i|
|
|
132
117
|
i.prev_out(utxo[:hash])
|
|
133
118
|
i.prev_out_index(utxo[:index])
|
|
134
|
-
i.prev_out_script = utxo[:script]
|
|
135
|
-
address = Bitcoin::Script.new(utxo[:script]).
|
|
119
|
+
i.prev_out_script = script_hex(utxo[:script])
|
|
120
|
+
address = Bitcoin::Script.new(script_hex(utxo[:script])).address
|
|
136
121
|
i.signature_key(key(sources[address]))
|
|
137
122
|
end
|
|
138
123
|
size += 180
|
|
@@ -152,16 +137,16 @@ class Sibit
|
|
|
152
137
|
tx = builder.tx(
|
|
153
138
|
input_value: unspent,
|
|
154
139
|
leave_fee: true,
|
|
155
|
-
extra_fee: [f, Bitcoin
|
|
140
|
+
extra_fee: [f, Bitcoin::MIN_TX_FEE].max,
|
|
156
141
|
change_address: change
|
|
157
142
|
)
|
|
158
|
-
left = unspent - tx.outputs.
|
|
143
|
+
left = unspent - tx.outputs.sum(&:value)
|
|
159
144
|
@log.info("A new Bitcoin transaction #{tx.hash} prepared:
|
|
160
|
-
#{tx.in.count} input#{tx.in.count > 1
|
|
161
|
-
#{tx.inputs.map { |i| " in: #{i.prev_out.
|
|
162
|
-
#{tx.out.count} output#{tx.out.count > 1
|
|
163
|
-
#{tx.outputs.map { |o| "out: #{o.
|
|
164
|
-
Min tx fee: #{num(Bitcoin
|
|
145
|
+
#{tx.in.count} input#{'s' if tx.in.count > 1}:
|
|
146
|
+
#{tx.inputs.map { |i| " in: #{i.prev_out.unpack1('H*')}:#{i.prev_out_index}" }.join("\n ")}
|
|
147
|
+
#{tx.out.count} output#{'s' if tx.out.count > 1}:
|
|
148
|
+
#{tx.outputs.map { |o| "out: #{o.script_hex} / #{num(o.value, p)}" }.join("\n ")}
|
|
149
|
+
Min tx fee: #{num(Bitcoin::MIN_TX_FEE, p)}
|
|
165
150
|
Fee requested: #{num(f, p)} as \"#{fee}\"
|
|
166
151
|
Fee actually paid: #{num(left, p)}
|
|
167
152
|
Tx size: #{size} bytes
|
|
@@ -291,4 +276,10 @@ in block #{block} (by #{json[:provider]})")
|
|
|
291
276
|
def key(hash160)
|
|
292
277
|
Bitcoin::Key.new(hash160)
|
|
293
278
|
end
|
|
279
|
+
|
|
280
|
+
# Convert script to hex string if needed.
|
|
281
|
+
def script_hex(script)
|
|
282
|
+
return script if script.is_a?(String) && script.match?(/\A[0-9a-f]+\z/i)
|
|
283
|
+
script.unpack1('H*')
|
|
284
|
+
end
|
|
294
285
|
end
|
data/logo.svg
CHANGED
data/sibit.gemspec
CHANGED
|
@@ -1,24 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Copyright (c) 2019-
|
|
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) 2019-2025 Yegor Bugayenko
|
|
4
|
+
# SPDX-License-Identifier: MIT
|
|
22
5
|
|
|
23
6
|
require 'English'
|
|
24
7
|
|
|
@@ -34,22 +17,23 @@ Gem::Specification.new do |s|
|
|
|
34
17
|
s.version = Sibit::VERSION
|
|
35
18
|
s.license = 'MIT'
|
|
36
19
|
s.summary = 'Simple Bitcoin Client'
|
|
37
|
-
s.description =
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
20
|
+
s.description =
|
|
21
|
+
'This is a simple Bitcoin client, to use from command line ' \
|
|
22
|
+
'or from your Ruby app. You don\'t need to run any Bitcoin software, ' \
|
|
23
|
+
'no need to install anything, etc. All you need is just a command line ' \
|
|
24
|
+
'and Ruby 2.5+.'
|
|
41
25
|
s.authors = ['Yegor Bugayenko']
|
|
42
26
|
s.email = 'yegor256@gmail.com'
|
|
43
|
-
s.homepage = '
|
|
44
|
-
s.files = `git ls-files`.split($RS)
|
|
27
|
+
s.homepage = 'https://github.com/yegor256/sibit'
|
|
28
|
+
s.files = `git ls-files | grep -v -E '^(test/|\\.|renovate)'`.split($RS)
|
|
45
29
|
s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
46
30
|
s.rdoc_options = ['--charset=UTF-8']
|
|
47
31
|
s.extra_rdoc_files = ['README.md', 'LICENSE.txt']
|
|
48
|
-
s.
|
|
49
|
-
s.
|
|
50
|
-
s.
|
|
51
|
-
s.
|
|
52
|
-
s.
|
|
53
|
-
s.
|
|
54
|
-
s.
|
|
32
|
+
s.add_dependency 'backtrace', '~> 0.3'
|
|
33
|
+
s.add_dependency 'iri', '~> 0.5'
|
|
34
|
+
s.add_dependency 'json', '~> 2'
|
|
35
|
+
s.add_dependency 'loog', '~> 0.6'
|
|
36
|
+
s.add_dependency 'openssl', '>= 2.0'
|
|
37
|
+
s.add_dependency 'retriable_proxy', '~> 1.0'
|
|
38
|
+
s.add_dependency 'slop', '~> 4.6'
|
|
55
39
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sibit
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.26.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
13
|
name: backtrace
|
|
@@ -25,59 +24,59 @@ dependencies:
|
|
|
25
24
|
- !ruby/object:Gem::Version
|
|
26
25
|
version: '0.3'
|
|
27
26
|
- !ruby/object:Gem::Dependency
|
|
28
|
-
name:
|
|
27
|
+
name: iri
|
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
|
30
29
|
requirements:
|
|
31
|
-
- -
|
|
30
|
+
- - "~>"
|
|
32
31
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: 0.
|
|
32
|
+
version: '0.5'
|
|
34
33
|
type: :runtime
|
|
35
34
|
prerelease: false
|
|
36
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
36
|
requirements:
|
|
38
|
-
- -
|
|
37
|
+
- - "~>"
|
|
39
38
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: 0.
|
|
39
|
+
version: '0.5'
|
|
41
40
|
- !ruby/object:Gem::Dependency
|
|
42
|
-
name:
|
|
41
|
+
name: json
|
|
43
42
|
requirement: !ruby/object:Gem::Requirement
|
|
44
43
|
requirements:
|
|
45
44
|
- - "~>"
|
|
46
45
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: '
|
|
46
|
+
version: '2'
|
|
48
47
|
type: :runtime
|
|
49
48
|
prerelease: false
|
|
50
49
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
50
|
requirements:
|
|
52
51
|
- - "~>"
|
|
53
52
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: '
|
|
53
|
+
version: '2'
|
|
55
54
|
- !ruby/object:Gem::Dependency
|
|
56
|
-
name:
|
|
55
|
+
name: loog
|
|
57
56
|
requirement: !ruby/object:Gem::Requirement
|
|
58
57
|
requirements:
|
|
59
58
|
- - "~>"
|
|
60
59
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: '
|
|
60
|
+
version: '0.6'
|
|
62
61
|
type: :runtime
|
|
63
62
|
prerelease: false
|
|
64
63
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
64
|
requirements:
|
|
66
65
|
- - "~>"
|
|
67
66
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: '
|
|
67
|
+
version: '0.6'
|
|
69
68
|
- !ruby/object:Gem::Dependency
|
|
70
69
|
name: openssl
|
|
71
70
|
requirement: !ruby/object:Gem::Requirement
|
|
72
71
|
requirements:
|
|
73
|
-
- - "
|
|
72
|
+
- - ">="
|
|
74
73
|
- !ruby/object:Gem::Version
|
|
75
74
|
version: '2.0'
|
|
76
75
|
type: :runtime
|
|
77
76
|
prerelease: false
|
|
78
77
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
78
|
requirements:
|
|
80
|
-
- - "
|
|
79
|
+
- - ">="
|
|
81
80
|
- !ruby/object:Gem::Version
|
|
82
81
|
version: '2.0'
|
|
83
82
|
- !ruby/object:Gem::Dependency
|
|
@@ -116,23 +115,15 @@ executables:
|
|
|
116
115
|
- sibit
|
|
117
116
|
extensions: []
|
|
118
117
|
extra_rdoc_files:
|
|
119
|
-
- README.md
|
|
120
118
|
- LICENSE.txt
|
|
119
|
+
- README.md
|
|
121
120
|
files:
|
|
122
|
-
- ".0pdd.yml"
|
|
123
|
-
- ".gitattributes"
|
|
124
|
-
- ".github/workflows/codecov.yml"
|
|
125
|
-
- ".github/workflows/pdd.yml"
|
|
126
|
-
- ".github/workflows/rake.yml"
|
|
127
|
-
- ".github/workflows/xcop.yml"
|
|
128
|
-
- ".gitignore"
|
|
129
|
-
- ".pdd"
|
|
130
|
-
- ".rubocop.yml"
|
|
131
|
-
- ".rultor.yml"
|
|
132
|
-
- ".simplecov"
|
|
133
121
|
- Gemfile
|
|
122
|
+
- Gemfile.lock
|
|
134
123
|
- LICENSE.txt
|
|
124
|
+
- LICENSES/MIT.txt
|
|
135
125
|
- README.md
|
|
126
|
+
- REUSE.toml
|
|
136
127
|
- Rakefile
|
|
137
128
|
- bin/sibit
|
|
138
129
|
- cucumber.yml
|
|
@@ -142,6 +133,11 @@ files:
|
|
|
142
133
|
- features/support/env.rb
|
|
143
134
|
- lib/sibit.rb
|
|
144
135
|
- lib/sibit/bestof.rb
|
|
136
|
+
- lib/sibit/bitcoin/base58.rb
|
|
137
|
+
- lib/sibit/bitcoin/key.rb
|
|
138
|
+
- lib/sibit/bitcoin/script.rb
|
|
139
|
+
- lib/sibit/bitcoin/tx.rb
|
|
140
|
+
- lib/sibit/bitcoin/txbuilder.rb
|
|
145
141
|
- lib/sibit/bitcoinchain.rb
|
|
146
142
|
- lib/sibit/blockchain.rb
|
|
147
143
|
- lib/sibit/blockchair.rb
|
|
@@ -154,29 +150,13 @@ files:
|
|
|
154
150
|
- lib/sibit/firstof.rb
|
|
155
151
|
- lib/sibit/http.rb
|
|
156
152
|
- lib/sibit/json.rb
|
|
157
|
-
- lib/sibit/log.rb
|
|
158
153
|
- lib/sibit/version.rb
|
|
159
154
|
- logo.svg
|
|
160
|
-
- renovate.json
|
|
161
155
|
- sibit.gemspec
|
|
162
|
-
|
|
163
|
-
- test/test_bestof.rb
|
|
164
|
-
- test/test_bitcoinchain.rb
|
|
165
|
-
- test/test_blockchain.rb
|
|
166
|
-
- test/test_blockchair.rb
|
|
167
|
-
- test/test_btc.rb
|
|
168
|
-
- test/test_cex.rb
|
|
169
|
-
- test/test_cryptoapis.rb
|
|
170
|
-
- test/test_fake.rb
|
|
171
|
-
- test/test_firstof.rb
|
|
172
|
-
- test/test_json.rb
|
|
173
|
-
- test/test_live.rb
|
|
174
|
-
- test/test_sibit.rb
|
|
175
|
-
homepage: http://github.com/yegor256/sibit
|
|
156
|
+
homepage: https://github.com/yegor256/sibit
|
|
176
157
|
licenses:
|
|
177
158
|
- MIT
|
|
178
159
|
metadata: {}
|
|
179
|
-
post_install_message:
|
|
180
160
|
rdoc_options:
|
|
181
161
|
- "--charset=UTF-8"
|
|
182
162
|
require_paths:
|
|
@@ -192,8 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
192
172
|
- !ruby/object:Gem::Version
|
|
193
173
|
version: '0'
|
|
194
174
|
requirements: []
|
|
195
|
-
rubygems_version: 3.
|
|
196
|
-
signing_key:
|
|
175
|
+
rubygems_version: 3.6.9
|
|
197
176
|
specification_version: 4
|
|
198
177
|
summary: Simple Bitcoin Client
|
|
199
178
|
test_files: []
|
data/.0pdd.yml
DELETED
data/.gitattributes
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: codecov
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- master
|
|
7
|
-
jobs:
|
|
8
|
-
codecov:
|
|
9
|
-
runs-on: ubuntu-22.04
|
|
10
|
-
steps:
|
|
11
|
-
- uses: actions/checkout@v4
|
|
12
|
-
- uses: ruby/setup-ruby@v1
|
|
13
|
-
with:
|
|
14
|
-
ruby-version: 2.7
|
|
15
|
-
- run: bundle update
|
|
16
|
-
- run: bundle exec rake
|
|
17
|
-
- uses: codecov/codecov-action@v4.0.0-beta.3
|
|
18
|
-
with:
|
|
19
|
-
token: ${{ secrets.CODECOV_TOKEN }}
|
|
20
|
-
file: coverage/.resultset.json
|
|
21
|
-
fail_ci_if_error: true
|
data/.github/workflows/pdd.yml
DELETED
data/.github/workflows/rake.yml
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: rake
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- master
|
|
7
|
-
pull_request:
|
|
8
|
-
branches:
|
|
9
|
-
- master
|
|
10
|
-
jobs:
|
|
11
|
-
test:
|
|
12
|
-
name: test
|
|
13
|
-
strategy:
|
|
14
|
-
matrix:
|
|
15
|
-
os: [ubuntu-20.04]
|
|
16
|
-
ruby: [2.7, 3.1]
|
|
17
|
-
runs-on: ${{ matrix.os }}
|
|
18
|
-
steps:
|
|
19
|
-
- uses: actions/checkout@v4
|
|
20
|
-
- uses: ruby/setup-ruby@v1
|
|
21
|
-
with:
|
|
22
|
-
ruby-version: ${{ matrix.ruby }}
|
|
23
|
-
- run: bundle update
|
|
24
|
-
- run: bundle exec rake
|
data/.github/workflows/xcop.yml
DELETED
data/.gitignore
DELETED
data/.pdd
DELETED
data/.rubocop.yml
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
AllCops:
|
|
2
|
-
NewCops: enable
|
|
3
|
-
Exclude:
|
|
4
|
-
- 'assets/**/*'
|
|
5
|
-
DisplayCopNames: true
|
|
6
|
-
TargetRubyVersion: 2.5
|
|
7
|
-
SuggestExtensions: false
|
|
8
|
-
|
|
9
|
-
Gemspec/RequireMFA:
|
|
10
|
-
Enabled: false
|
|
11
|
-
Style/ClassAndModuleChildren:
|
|
12
|
-
Enabled: false
|
|
13
|
-
Layout/LineLength:
|
|
14
|
-
Max: 100
|
|
15
|
-
Layout/EndOfLine:
|
|
16
|
-
EnforcedStyle: lf
|
|
17
|
-
Metrics/CyclomaticComplexity:
|
|
18
|
-
Max: 20
|
|
19
|
-
Metrics/MethodLength:
|
|
20
|
-
Enabled: false
|
|
21
|
-
Layout/MultilineMethodCallIndentation:
|
|
22
|
-
Enabled: false
|
|
23
|
-
Metrics/ParameterLists:
|
|
24
|
-
Max: 6
|
|
25
|
-
Metrics/ClassLength:
|
|
26
|
-
Max: 250
|
|
27
|
-
Metrics/AbcSize:
|
|
28
|
-
Enabled: false
|
|
29
|
-
Metrics/BlockLength:
|
|
30
|
-
Max: 100
|
|
31
|
-
Metrics/PerceivedComplexity:
|
|
32
|
-
Max: 20
|
|
33
|
-
Style/MultilineTernaryOperator:
|
|
34
|
-
Enabled: false
|
|
35
|
-
Layout/EmptyLineAfterGuardClause:
|
|
36
|
-
Enabled: false
|
|
37
|
-
Lint/OrAssignmentToConstant:
|
|
38
|
-
Enabled: false
|
data/.rultor.yml
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
docker:
|
|
2
|
-
image: yegor256/rultor-image:1.22.0
|
|
3
|
-
assets:
|
|
4
|
-
rubygems.yml: yegor256/home#assets/rubygems.yml
|
|
5
|
-
install: |
|
|
6
|
-
rvm default 2.7.6 && source /usr/local/rvm/scripts/rvm
|
|
7
|
-
gem install pdd
|
|
8
|
-
pdd -f /dev/null
|
|
9
|
-
bundle install --no-color "--gemfile=$(pwd)/Gemfile"
|
|
10
|
-
release:
|
|
11
|
-
script: |-
|
|
12
|
-
bundle exec rake clean test rubocop copyright
|
|
13
|
-
sed -i "s/0\.0\.0/${tag}/g" lib/sibit/version.rb
|
|
14
|
-
git add lib/sibit/version.rb
|
|
15
|
-
git commit -m "version set to ${tag}"
|
|
16
|
-
gem build sibit.gemspec
|
|
17
|
-
chmod 0600 ../rubygems.yml
|
|
18
|
-
gem push *.gem --config-file ../rubygems.yml
|
|
19
|
-
merge:
|
|
20
|
-
script: |-
|
|
21
|
-
bundle exec rake clean test rubocop copyright
|
data/.simplecov
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Copyright (c) 2019-2023 Yegor Bugayenko
|
|
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.
|
|
22
|
-
|
|
23
|
-
if Gem.win_platform?
|
|
24
|
-
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
|
25
|
-
SimpleCov::Formatter::HTMLFormatter
|
|
26
|
-
]
|
|
27
|
-
SimpleCov.start do
|
|
28
|
-
add_filter '/test/'
|
|
29
|
-
add_filter '/features/'
|
|
30
|
-
end
|
|
31
|
-
else
|
|
32
|
-
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
|
|
33
|
-
[SimpleCov::Formatter::HTMLFormatter]
|
|
34
|
-
)
|
|
35
|
-
SimpleCov.start do
|
|
36
|
-
add_filter '/test/'
|
|
37
|
-
add_filter '/features/'
|
|
38
|
-
minimum_coverage 60
|
|
39
|
-
end
|
|
40
|
-
end
|
data/lib/sibit/log.rb
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# Copyright (c) 2019-2023 Yegor Bugayenko
|
|
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.
|
|
22
|
-
|
|
23
|
-
# The log.
|
|
24
|
-
#
|
|
25
|
-
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
|
26
|
-
# Copyright:: Copyright (c) 2019-2023 Yegor Bugayenko
|
|
27
|
-
# License:: MIT
|
|
28
|
-
class Sibit
|
|
29
|
-
# Log.
|
|
30
|
-
class Log
|
|
31
|
-
# Constructor.
|
|
32
|
-
#
|
|
33
|
-
# You may provide the log you want to see the messages in. If you don't
|
|
34
|
-
# provide anything, the console will be used. The object you provide
|
|
35
|
-
# has to respond to the method +info+ or +puts+ in order to receive logging
|
|
36
|
-
# messages.
|
|
37
|
-
def initialize(log = $stdout)
|
|
38
|
-
@log = log
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def info(msg)
|
|
42
|
-
if @log.respond_to?(:info)
|
|
43
|
-
@log.info(msg)
|
|
44
|
-
elsif @log.respond_to?(:puts)
|
|
45
|
-
@log.puts(msg)
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|