baza.rb 0.4.0 → 0.5.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: 56c9306fec1c51c662d122a94bb3a04cb1bc1fca68e518fa43aa600dd93aac4e
4
- data.tar.gz: c7ecb9b7213285cbea8302070bbbe0d43800e1c0f2a81cdf2747a50013b390a5
3
+ metadata.gz: a4fb6929da01d8ec60b802d9bd8c3300456ff66144723496bbe60a11b1f67fad
4
+ data.tar.gz: 29db7120d95c442fcb529e9f1f1d8f3c7145baca1cf829cd011bdf6b6d6918bd
5
5
  SHA512:
6
- metadata.gz: 97b304210bef6e1c94db070044dbcc248b2f42d3982a5561eec155bd0c7f0040a7258c73cfb62b3ac6a2cf402ef6de9ef644cd41fe6311a0d10241ab2e68f8e9
7
- data.tar.gz: 0a28fccff243c7539117f37633607451c7efa94f13b93e2f2848f8e3e662ffa337a7fab4569ebcad9a6d96ccb4eca2cf5f0aed72112148439e0673759d985b6d
6
+ metadata.gz: 0212eb14782da74ea7ecbfa855e3a075e4639577f512ea12f98549451a7000a820a0bbb918f909f0eacde8c62593bc62910b7829a759ee989a2844e5def8fb20
7
+ data.tar.gz: 883fb08a189555e8abdb1800c2ab2d08229833945b11809930412d5da82890b23856122c9e2fe6c44f369db007a0dee4ebb3b51991a7ba4eedca261ec135b934
@@ -16,4 +16,4 @@ jobs:
16
16
  runs-on: ubuntu-24.04
17
17
  steps:
18
18
  - uses: actions/checkout@v4
19
- - uses: yegor256/copyrights-action@0.0.8
19
+ - uses: yegor256/copyrights-action@0.0.10
@@ -20,4 +20,4 @@ jobs:
20
20
  runs-on: ubuntu-24.04
21
21
  steps:
22
22
  - uses: actions/checkout@v4
23
- - uses: articulate/actions-markdownlint@v1
23
+ - uses: DavidAnson/markdownlint-cli2-action@v20.0.0
@@ -0,0 +1,19 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2024-2025 Zerocracy
2
+ # SPDX-License-Identifier: MIT
3
+ ---
4
+ # yamllint disable rule:line-length
5
+ name: typos
6
+ 'on':
7
+ push:
8
+ branches:
9
+ - master
10
+ pull_request:
11
+ branches:
12
+ - master
13
+ jobs:
14
+ typos:
15
+ timeout-minutes: 15
16
+ runs-on: ubuntu-24.04
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+ - uses: crate-ci/typos@v1.32.0
data/.gitignore CHANGED
@@ -1,10 +1,11 @@
1
- *.gem
2
- .DS_Store
3
1
  .bundle/
2
+ .DS_Store
4
3
  .idea/
5
4
  .yardoc/
5
+ *.gem
6
6
  coverage/
7
7
  doc/
8
8
  node_modules/
9
9
  rdoc/
10
10
  vendor/
11
+ .claude
data/.rubocop.yml CHANGED
@@ -52,3 +52,4 @@ Layout/MultilineAssignmentLayout:
52
52
  Enabled: true
53
53
  Naming/FileName:
54
54
  Enabled: false
55
+ require: []
data/Gemfile CHANGED
@@ -10,7 +10,6 @@ gem 'base64', '>0', require: false
10
10
  gem 'factbase', '>0', require: false
11
11
  gem 'minitest', '~>5.25', require: false
12
12
  gem 'minitest-reporters', '~>1.7', require: false
13
- gem 'net-ping', '~>2.0', require: false
14
13
  gem 'os', '>0', require: false
15
14
  gem 'qbash', '>0', require: false
16
15
  gem 'rake', '~>13.2', require: false
data/Gemfile.lock CHANGED
@@ -35,7 +35,7 @@ GEM
35
35
  tago (> 0)
36
36
  ethon (0.16.0)
37
37
  ffi (>= 1.15.0)
38
- factbase (0.9.10)
38
+ factbase (0.10.2)
39
39
  backtrace (~> 0.4)
40
40
  decoor (~> 0.0)
41
41
  json (~> 2.7)
@@ -45,7 +45,7 @@ GEM
45
45
  others (~> 0.0)
46
46
  tago (~> 0.0)
47
47
  yaml (~> 0.3)
48
- faraday (2.12.2)
48
+ faraday (2.13.1)
49
49
  faraday-net_http (>= 2.0, < 3.5)
50
50
  json
51
51
  logger
@@ -55,19 +55,20 @@ GEM
55
55
  multipart-post (~> 2.0)
56
56
  faraday-net_http (3.4.0)
57
57
  net-http (>= 0.5.0)
58
- faraday-retry (2.3.0)
58
+ faraday-retry (2.3.1)
59
59
  faraday (~> 2.0)
60
- ffi (1.17.1-arm64-darwin)
61
- ffi (1.17.1-x64-mingw-ucrt)
62
- ffi (1.17.1-x86_64-darwin)
63
- ffi (1.17.1-x86_64-linux-gnu)
64
- hashdiff (1.1.2)
60
+ ffi (1.17.2-arm64-darwin)
61
+ ffi (1.17.2-x64-mingw-ucrt)
62
+ ffi (1.17.2-x86_64-darwin)
63
+ ffi (1.17.2-x86_64-linux-gnu)
64
+ hashdiff (1.2.0)
65
65
  iri (0.10.0)
66
- json (2.10.2)
67
- language_server-protocol (3.17.0.4)
66
+ json (2.12.2)
67
+ language_server-protocol (3.17.0.5)
68
68
  lint_roller (1.1.0)
69
69
  logger (1.7.0)
70
- loog (0.6.0)
70
+ loog (0.6.1)
71
+ logger (~> 1.0)
71
72
  minitest (5.25.5)
72
73
  minitest-reporters (1.7.1)
73
74
  ansi
@@ -77,24 +78,23 @@ GEM
77
78
  multipart-post (2.4.1)
78
79
  net-http (0.6.0)
79
80
  uri
80
- net-ping (2.0.8)
81
- nokogiri (1.18.7-arm64-darwin)
81
+ nokogiri (1.18.8-arm64-darwin)
82
82
  racc (~> 1.4)
83
- nokogiri (1.18.7-x64-mingw-ucrt)
83
+ nokogiri (1.18.8-x64-mingw-ucrt)
84
84
  racc (~> 1.4)
85
- nokogiri (1.18.7-x86_64-darwin)
85
+ nokogiri (1.18.8-x86_64-darwin)
86
86
  racc (~> 1.4)
87
- nokogiri (1.18.7-x86_64-linux-gnu)
87
+ nokogiri (1.18.8-x86_64-linux-gnu)
88
88
  racc (~> 1.4)
89
89
  os (1.1.4)
90
90
  others (0.0.3)
91
- parallel (1.26.3)
92
- parser (3.3.7.4)
91
+ parallel (1.27.0)
92
+ parser (3.3.8.0)
93
93
  ast (~> 2.4.1)
94
94
  racc
95
95
  prism (1.4.0)
96
- public_suffix (6.0.1)
97
- qbash (0.4.0)
96
+ public_suffix (6.0.2)
97
+ qbash (0.4.5)
98
98
  backtrace (> 0)
99
99
  elapsed (> 0)
100
100
  loog (> 0)
@@ -107,7 +107,7 @@ GEM
107
107
  regexp_parser (2.10.0)
108
108
  retries (0.0.5)
109
109
  rexml (3.4.1)
110
- rubocop (1.75.2)
110
+ rubocop (1.75.7)
111
111
  json (~> 2.3)
112
112
  language_server-protocol (~> 3.17.0.2)
113
113
  lint_roller (~> 1.1.0)
@@ -118,7 +118,7 @@ GEM
118
118
  rubocop-ast (>= 1.44.0, < 2.0)
119
119
  ruby-progressbar (~> 1.7)
120
120
  unicode-display_width (>= 2.4.0, < 4.0)
121
- rubocop-ast (1.44.0)
121
+ rubocop-ast (1.44.1)
122
122
  parser (>= 3.3.7.2)
123
123
  prism (~> 1.4)
124
124
  rubocop-minitest (0.38.0)
@@ -173,7 +173,6 @@ DEPENDENCIES
173
173
  factbase (> 0)
174
174
  minitest (~> 5.25)
175
175
  minitest-reporters (~> 1.7)
176
- net-ping (~> 2.0)
177
176
  os (> 0)
178
177
  qbash (> 0)
179
178
  rake (~> 13.2)
data/README.md CHANGED
@@ -11,7 +11,7 @@
11
11
  [![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/zerocracy/baza.rb/blob/master/LICENSE.txt)
12
12
  [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2Fzerocracy%2Fbaza.rb.svg?type=shield&issueType=license)](https://app.fossa.com/projects/git%2Bgithub.com%2Fzerocracy%2Fbaza.rb?ref=badge_shield&issueType=license)
13
13
 
14
- It's an client for [Zerocracy API](https://www.zerocracy.com), in Ruby.
14
+ It's a client for [Zerocracy API](https://www.zerocracy.com), in Ruby.
15
15
 
16
16
  ## How to contribute
17
17
 
data/REUSE.toml CHANGED
@@ -4,9 +4,16 @@
4
4
  version = 1
5
5
  [[annotations]]
6
6
  path = [
7
+ ".DS_Store",
8
+ ".gitattributes",
9
+ ".gitignore",
10
+ ".pdd",
7
11
  "**.json",
8
12
  "**.md",
9
13
  "**.txt",
14
+ "**/.DS_Store",
15
+ "**/.gitignore",
16
+ "**/.pdd",
10
17
  "**/*.csv",
11
18
  "**/*.jpg",
12
19
  "**/*.json",
@@ -16,15 +23,8 @@ path = [
16
23
  "**/*.svg",
17
24
  "**/*.txt",
18
25
  "**/*.vm",
19
- "**/.DS_Store",
20
- "**/.gitignore",
21
- "**/.pdd",
22
26
  "**/CNAME",
23
27
  "**/Gemfile.lock",
24
- ".DS_Store",
25
- ".gitattributes",
26
- ".gitignore",
27
- ".pdd",
28
28
  "Gemfile.lock",
29
29
  "README.md",
30
30
  "renovate.json",
data/Rakefile CHANGED
@@ -24,19 +24,23 @@ task default: %i[clean test picks rubocop yard]
24
24
 
25
25
  require 'rake/testtask'
26
26
  desc 'Run all unit tests'
27
- Rake::TestTask.new(:test) do |test|
27
+ Rake::TestTask.new(:test) do |t|
28
28
  Rake::Cleaner.cleanup_files(['coverage'])
29
- test.libs << 'lib' << 'test'
30
- test.pattern = 'test/**/test_*.rb'
31
- test.warning = true
32
- test.verbose = false
29
+ t.libs << 'lib' << 'test'
30
+ t.pattern = 'test/**/test_*.rb'
31
+ t.warning = true
32
+ t.verbose = false
33
+ t.options = ARGV.join(' ').match(/(?:^| )(-- .*)$/)
33
34
  end
34
35
 
35
36
  desc 'Run them via Ruby, one by one'
36
37
  task :picks do
37
38
  next if OS.windows?
38
39
  (Dir['test/**/*.rb'] + Dir['lib/**/*.rb']).each do |f|
39
- qbash("bundle exec ruby #{Shellwords.escape(f)}", log: $stdout, env: { 'RACK_ENV' => 'picks' })
40
+ qbash(
41
+ "bundle exec ruby #{Shellwords.escape(f)} -- --offline",
42
+ log: $stdout, env: { 'RACK_ENV' => 'picks' }
43
+ )
40
44
  end
41
45
  end
42
46
 
data/lib/baza-rb/fake.rb CHANGED
@@ -7,10 +7,16 @@ require 'factbase'
7
7
  require_relative '../baza-rb'
8
8
  require_relative 'version'
9
9
 
10
- # Fake interface to the API of zerocracy.com for testing.
10
+ # Fake implementation of the Zerocracy API client for testing.
11
11
  #
12
12
  # This class implements the same public interface as BazaRb but doesn't
13
- # make any network connections, instead returning predefined fake values.
13
+ # make any network connections. Instead, it returns predefined fake values
14
+ # and validates inputs to help catch errors during testing.
15
+ #
16
+ # @example Using in tests
17
+ # baza = BazaRb::Fake.new
18
+ # assert_equal 'torvalds', baza.whoami
19
+ # assert_equal 42, baza.push('test-job', 'data', [])
14
20
  #
15
21
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
16
22
  # Copyright:: Copyright (c) 2024-2025 Yegor Bugayenko
@@ -18,17 +24,17 @@ require_relative 'version'
18
24
  class BazaRb::Fake
19
25
  # Get GitHub login name of the logged in user.
20
26
  #
21
- # @return [String] GitHub nickname
27
+ # @return [String] Always returns 'torvalds' for testing
22
28
  def whoami
23
29
  'torvalds'
24
30
  end
25
31
 
26
32
  # Push factbase to the server.
27
33
  #
28
- # @param [String] name The name of the job on the server
29
- # @param [Bytes] data The data to push to the server (binary)
30
- # @param [Array<String>] meta List of metas, possibly empty
31
- # @return [Integer] Job ID on the server
34
+ # @param [String] name The unique name of the job on the server
35
+ # @param [String] data The binary data to push to the server
36
+ # @param [Array<String>] meta List of metadata strings to attach to the job
37
+ # @return [Integer] Always returns 42 as the fake job ID
32
38
  def push(name, data, meta)
33
39
  assert_name(name)
34
40
  raise 'The data must be non-empty' if data.empty?
@@ -39,16 +45,16 @@ class BazaRb::Fake
39
45
  # Pull factbase from the server.
40
46
  #
41
47
  # @param [Integer] id The ID of the job on the server
42
- # @return [Bytes] Binary data pulled
48
+ # @return [String] Returns an empty factbase export for testing
43
49
  def pull(id)
44
50
  assert_id(id)
45
51
  Factbase.new.export
46
52
  end
47
53
 
48
- # The job with this ID is finished already?
54
+ # Check if the job with this ID is finished already.
49
55
  #
50
56
  # @param [Integer] id The ID of the job on the server
51
- # @return [Boolean] TRUE if the job is already finished
57
+ # @return [Boolean] Always returns TRUE for testing
52
58
  def finished?(id)
53
59
  assert_id(id)
54
60
  true
@@ -117,13 +123,15 @@ class BazaRb::Fake
117
123
  true
118
124
  end
119
125
 
120
- # Place a single durable.
126
+ # Place a single durable file on the server.
121
127
  #
122
128
  # @param [String] jname The name of the job on the server
123
- # @param [String] file The file name
129
+ # @param [String] file The path to the file to upload
130
+ # @return [Integer] Always returns 42 as the fake durable ID
124
131
  def durable_place(jname, file)
125
132
  assert_name(jname)
126
133
  assert_file(file)
134
+ 42
127
135
  end
128
136
 
129
137
  # Save a single durable from local file to server.
@@ -162,18 +170,19 @@ class BazaRb::Fake
162
170
  assert_owner(owner)
163
171
  end
164
172
 
165
- # Get current balance, in Ƶ.
173
+ # Get current balance of the authenticated user.
166
174
  #
167
- # @return [Float] The balance, as float
175
+ # @return [Float] Always returns 3.14 zents for testing
168
176
  def balance
169
177
  3.14
170
178
  end
171
179
 
172
- # Transfer some funds to another user.
180
+ # Transfer funds to another user.
173
181
  #
174
- # @param [String] recipient GitHub name (e.g. "yegor256") of the recipient
175
- # @param [Float] amount The amount in Z/USDT (not zents!)
176
- # @param [String] summary The description of the payment
182
+ # @param [String] recipient GitHub username of the recipient
183
+ # @param [Float] amount The amount to transfer in ƶ (zents)
184
+ # @param [String] summary The description/reason for the payment
185
+ # @return [Integer] Always returns 42 as the fake receipt ID
177
186
  def transfer(recipient, amount, summary, *)
178
187
  raise "The recipient #{recipient.inspect} is not valid" unless recipient.match?(/^[a-zA-Z0-9-]+$/)
179
188
  raise "The amount #{amount} must be a Float" unless amount.is_a?(Float)
@@ -182,13 +191,13 @@ class BazaRb::Fake
182
191
  42
183
192
  end
184
193
 
185
- # Pay fee, while working with a job.
194
+ # Pay a fee associated with a job.
186
195
  #
187
- # @param [String] tab The tab of the fee (use "unknown" if not sure)
188
- # @param [Float] amount The amount in Z/USDT (not zents!)
189
- # @param [String] summary The description of the payment
190
- # @param [Integer] job The ID of the job
191
- # @return [Integer] Receipt ID
196
+ # @param [String] tab The category/type of the fee
197
+ # @param [Float] amount The fee amount in ƶ (zents)
198
+ # @param [String] summary The description/reason for the fee
199
+ # @param [Integer] job The ID of the job this fee is for
200
+ # @return [Integer] Always returns 42 as the fake receipt ID
192
201
  def fee(tab, amount, summary, job)
193
202
  raise 'The "tab" is nil' if tab.nil?
194
203
  raise "The amount #{amount} must be a Float" unless amount.is_a?(Float)
@@ -199,11 +208,11 @@ class BazaRb::Fake
199
208
  42
200
209
  end
201
210
 
202
- # Pop job from the server.
211
+ # Pop the next available job from the server's queue.
203
212
  #
204
- # @param [String] owner Who is acting (could be any text)
205
- # @param [String] zip The path to ZIP archive to take
206
- # @return [Boolean] TRUE if job taken, otherwise false
213
+ # @param [String] owner Identifier of who is taking the job
214
+ # @param [String] zip The local file path where the job's ZIP will be saved
215
+ # @return [Boolean] Always returns TRUE and creates an empty file
207
216
  def pop(owner, zip)
208
217
  assert_owner(owner)
209
218
  FileUtils.mkdir_p(File.dirname(zip))
@@ -211,22 +220,23 @@ class BazaRb::Fake
211
220
  true
212
221
  end
213
222
 
214
- # Submit a ZIP archive to finish a job.
223
+ # Submit a ZIP archive to finish a previously popped job.
215
224
  #
216
- # @param [Integer] id The ID of the job on the server
217
- # @param [String] zip The path to the ZIP file with the content of the archive
225
+ # @param [Integer] id The ID of the job to finish
226
+ # @param [String] zip The path to the ZIP file containing job results
218
227
  def finish(id, zip)
219
228
  assert_id(id)
220
229
  assert_file(zip)
221
230
  end
222
231
 
223
- # Enter a valve.
232
+ # Enter a valve to cache or retrieve a computation result.
224
233
  #
225
234
  # @param [String] name Name of the job
226
- # @param [String] badge Unique badge of the valve
227
- # @param [String] why The reason
228
- # @param [nil|Integer] job The ID of the job
229
- # @return [String] The result just calculated or retrieved
235
+ # @param [String] badge Unique identifier for this valve
236
+ # @param [String] why The reason/description for entering this valve
237
+ # @param [nil|Integer] job Optional job ID to associate with this valve
238
+ # @yield Block that computes the result
239
+ # @return [String] Always executes and returns the block's result
230
240
  def enter(name, badge, why, job)
231
241
  assert_name(name)
232
242
  raise "The badge '#{badge}' is not valid" unless badge.match?(/^[a-zA-Z0-9_-]+$/)
@@ -235,8 +245,9 @@ class BazaRb::Fake
235
245
  yield
236
246
  end
237
247
 
238
- # Get CSRF token from the server.
239
- # @return [String] The token for this user
248
+ # Get CSRF token from the server for authenticated requests.
249
+ #
250
+ # @return [String] Always returns 'fake-csrf-token' for testing
240
251
  def csrf
241
252
  'fake-csrf-token'
242
253
  end
@@ -10,8 +10,8 @@
10
10
  # other packages (thus failing the build).
11
11
  #
12
12
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
13
- # Copyright:: Copyright (c) 2024 Yegor Bugayenko
13
+ # Copyright:: Copyright (c) 2024-2025 Yegor Bugayenko
14
14
  # License:: MIT
15
15
  class BazaRb
16
- VERSION = '0.4.0'
16
+ VERSION = '0.5.0'
17
17
  end