zold 0.31.10 → 0.32.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.
Files changed (222) hide show
  1. checksums.yaml +4 -4
  2. data/.0pdd.yml +2 -19
  3. data/.github/typos.toml +11 -0
  4. data/.github/workflows/actionlint.yml +5 -21
  5. data/.github/workflows/bashate.yml +25 -0
  6. data/.github/workflows/codecov.yml +11 -24
  7. data/.github/workflows/copyrights.yml +6 -21
  8. data/.github/workflows/hadolint.yml +14 -0
  9. data/.github/workflows/markdown-lint.yml +19 -0
  10. data/.github/workflows/pdd.yml +5 -20
  11. data/.github/workflows/rake.yml +8 -22
  12. data/.github/workflows/reuse.yml +19 -0
  13. data/.github/workflows/shellcheck.yml +19 -0
  14. data/.github/workflows/typos.yml +21 -0
  15. data/.github/workflows/xcop.yml +5 -20
  16. data/.github/workflows/yamllint.yml +5 -20
  17. data/.gitignore +9 -6
  18. data/.rubocop.yml +16 -20
  19. data/.ruby-version +1 -1
  20. data/.rultor.yml +6 -22
  21. data/Dockerfile +11 -27
  22. data/Gemfile +21 -33
  23. data/Gemfile.lock +181 -126
  24. data/Guardfile +0 -0
  25. data/INSTALL.md +80 -59
  26. data/LICENSE.txt +1 -1
  27. data/LICENSES/MIT.txt +21 -0
  28. data/README.md +183 -154
  29. data/REUSE.toml +40 -0
  30. data/Rakefile +4 -38
  31. data/bin/zold +7 -37
  32. data/cucumber.yml +2 -19
  33. data/deploy.sh +4 -22
  34. data/features/cli.feature +2 -0
  35. data/features/gem_package.feature +2 -0
  36. data/features/step_definitions/steps.rb +2 -19
  37. data/features/support/env.rb +2 -19
  38. data/fixtures/merge/asserts.rb +3 -19
  39. data/fixtures/merge/into_no_wallet/assert.rb +2 -19
  40. data/fixtures/merge/legacy_negatives_stay/assert.rb +2 -19
  41. data/fixtures/merge/legacy_negatives_stay/copies/0123456789abcdef/scores.zc +1 -1
  42. data/fixtures/merge/missed_wallets/0123456789abcdef.z +0 -2
  43. data/fixtures/merge/missed_wallets/assert.rb +2 -19
  44. data/fixtures/merge/missed_wallets/copies/0123456789abcdef/scores.zc +1 -1
  45. data/fixtures/merge/negative_overwriting/assert.rb +2 -19
  46. data/fixtures/merge/negatives_in_between/0123456789abcdef.z +0 -1
  47. data/fixtures/merge/negatives_in_between/assert.rb +2 -19
  48. data/fixtures/merge/negatives_in_between/copies/0123456789abcdef/2.zc +0 -1
  49. data/fixtures/merge/negatives_in_between/opts +1 -1
  50. data/fixtures/merge/random_expenses/assert.rb +2 -19
  51. data/fixtures/merge/random_expenses/opts +1 -1
  52. data/fixtures/merge/simple_case/assert.rb +2 -19
  53. data/fixtures/merge/simple_case/opts +1 -1
  54. data/fixtures/merge/unconfirmed_income/assert.rb +2 -19
  55. data/fixtures/scripts/_head.sh +16 -33
  56. data/fixtures/scripts/calculate-scores.sh +3 -20
  57. data/fixtures/scripts/distribute-wallet.sh +26 -43
  58. data/fixtures/scripts/print-helps.sh +5 -23
  59. data/fixtures/scripts/pull-on-start.sh +12 -29
  60. data/fixtures/scripts/push-and-pull.sh +10 -27
  61. data/fixtures/scripts/redeploy-on-upgrade.sh +18 -34
  62. data/fixtures/scripts/spread-wallets.sh +24 -40
  63. data/lib/zold/age.rb +3 -20
  64. data/lib/zold/amount.rb +3 -20
  65. data/lib/zold/cached_wallets.rb +3 -20
  66. data/lib/zold/commands/alias.rb +4 -21
  67. data/lib/zold/commands/args.rb +4 -21
  68. data/lib/zold/commands/calculate.rb +5 -22
  69. data/lib/zold/commands/clean.rb +6 -23
  70. data/lib/zold/commands/create.rb +5 -22
  71. data/lib/zold/commands/diff.rb +5 -22
  72. data/lib/zold/commands/fetch.rb +6 -23
  73. data/lib/zold/commands/invoice.rb +5 -22
  74. data/lib/zold/commands/list.rb +5 -22
  75. data/lib/zold/commands/merge.rb +7 -24
  76. data/lib/zold/commands/next.rb +5 -22
  77. data/lib/zold/commands/node.rb +4 -21
  78. data/lib/zold/commands/pay.rb +6 -23
  79. data/lib/zold/commands/propagate.rb +5 -22
  80. data/lib/zold/commands/pull.rb +5 -22
  81. data/lib/zold/commands/push.rb +5 -22
  82. data/lib/zold/commands/remote.rb +7 -24
  83. data/lib/zold/commands/remove.rb +5 -22
  84. data/lib/zold/commands/routines/audit.rb +4 -21
  85. data/lib/zold/commands/routines/gc.rb +6 -23
  86. data/lib/zold/commands/routines/reconcile.rb +5 -22
  87. data/lib/zold/commands/routines/reconnect.rb +4 -21
  88. data/lib/zold/commands/routines/retire.rb +4 -21
  89. data/lib/zold/commands/routines/spread.rb +5 -22
  90. data/lib/zold/commands/routines.rb +3 -20
  91. data/lib/zold/commands/show.rb +5 -22
  92. data/lib/zold/commands/taxes.rb +5 -22
  93. data/lib/zold/commands/thread_badge.rb +3 -20
  94. data/lib/zold/copies.rb +6 -25
  95. data/lib/zold/dir_items.rb +3 -20
  96. data/lib/zold/endless.rb +5 -22
  97. data/lib/zold/gem.rb +3 -20
  98. data/lib/zold/hands.rb +6 -23
  99. data/lib/zold/head.rb +4 -21
  100. data/lib/zold/hexnum.rb +3 -20
  101. data/lib/zold/http.rb +3 -20
  102. data/lib/zold/hungry_wallets.rb +6 -23
  103. data/lib/zold/id.rb +3 -20
  104. data/lib/zold/json_page.rb +5 -22
  105. data/lib/zold/key.rb +3 -20
  106. data/lib/zold/metronome.rb +5 -22
  107. data/lib/zold/node/async_entrance.rb +6 -23
  108. data/lib/zold/node/entrance.rb +7 -24
  109. data/lib/zold/node/farm.rb +5 -22
  110. data/lib/zold/node/farmers.rb +15 -32
  111. data/lib/zold/node/front.rb +6 -23
  112. data/lib/zold/node/journaled_pipeline.rb +8 -25
  113. data/lib/zold/node/nodup_entrance.rb +6 -23
  114. data/lib/zold/node/nospam_entrance.rb +6 -23
  115. data/lib/zold/node/pipeline.rb +6 -23
  116. data/lib/zold/node/safe_entrance.rb +4 -22
  117. data/lib/zold/node/soft_error.rb +3 -20
  118. data/lib/zold/node/spread_entrance.rb +5 -22
  119. data/lib/zold/node/sync_entrance.rb +5 -22
  120. data/lib/zold/node/trace.rb +3 -20
  121. data/lib/zold/patch.rb +6 -23
  122. data/lib/zold/prefixes.rb +3 -20
  123. data/lib/zold/remotes.rb +5 -22
  124. data/lib/zold/signature.rb +3 -20
  125. data/lib/zold/size.rb +3 -20
  126. data/lib/zold/sync_wallets.rb +5 -22
  127. data/lib/zold/tax.rb +4 -21
  128. data/lib/zold/thread_pool.rb +4 -21
  129. data/lib/zold/tree_wallets.rb +3 -20
  130. data/lib/zold/txn.rb +4 -21
  131. data/lib/zold/txns.rb +4 -21
  132. data/lib/zold/upgrades.rb +4 -21
  133. data/lib/zold/verbose_thread.rb +5 -22
  134. data/lib/zold/version.rb +4 -21
  135. data/lib/zold/version_file.rb +4 -21
  136. data/lib/zold/wallet.rb +6 -23
  137. data/lib/zold/wallets.rb +5 -23
  138. data/lib/zold.rb +3 -21
  139. data/resources/banned-wallets.log +6 -6
  140. data/test/commands/routines/test_audit.rb +3 -21
  141. data/test/commands/routines/test_gc.rb +3 -21
  142. data/test/commands/routines/test_reconcile.rb +3 -21
  143. data/test/commands/routines/test_reconnect.rb +3 -21
  144. data/test/commands/routines/test_retire.rb +3 -21
  145. data/test/commands/test_alias.rb +2 -20
  146. data/test/commands/test_calculate.rb +5 -23
  147. data/test/commands/test_clean.rb +5 -23
  148. data/test/commands/test_create.rb +6 -24
  149. data/test/commands/test_diff.rb +4 -22
  150. data/test/commands/test_fetch.rb +3 -21
  151. data/test/commands/test_invoice.rb +3 -21
  152. data/test/commands/test_list.rb +3 -21
  153. data/test/commands/test_merge.rb +12 -35
  154. data/test/commands/test_node.rb +3 -21
  155. data/test/commands/test_pay.rb +5 -23
  156. data/test/commands/test_propagate.rb +6 -24
  157. data/test/commands/test_pull.rb +4 -22
  158. data/test/commands/test_push.rb +3 -21
  159. data/test/commands/test_remote.rb +10 -28
  160. data/test/commands/test_remove.rb +7 -25
  161. data/test/commands/test_show.rb +3 -21
  162. data/test/commands/test_taxes.rb +5 -23
  163. data/test/fake_home.rb +5 -22
  164. data/test/node/fake_entrance.rb +3 -20
  165. data/test/node/fake_node.rb +5 -22
  166. data/test/node/test_async_entrance.rb +3 -21
  167. data/test/node/test_entrance.rb +7 -25
  168. data/test/node/test_farm.rb +15 -33
  169. data/test/node/test_farmers.rb +3 -21
  170. data/test/node/test_front.rb +22 -42
  171. data/test/node/test_nodup_entrance.rb +4 -22
  172. data/test/node/test_nospam_entrance.rb +6 -24
  173. data/test/node/test_safe_entrance.rb +3 -21
  174. data/test/node/test_spread_entrance.rb +4 -22
  175. data/test/node/test_sync_entrance.rb +4 -22
  176. data/test/node/test_trace.rb +4 -22
  177. data/test/test__helper.rb +32 -31
  178. data/test/test_age.rb +5 -23
  179. data/test/test_amount.rb +15 -34
  180. data/test/test_cached_wallets.rb +3 -21
  181. data/test/test_copies.rb +10 -28
  182. data/test/test_dir_items.rb +4 -22
  183. data/test/test_gem.rb +3 -21
  184. data/test/test_hands.rb +3 -21
  185. data/test/test_hexnum.rb +3 -21
  186. data/test/test_http.rb +9 -27
  187. data/test/test_hungry_wallets.rb +6 -24
  188. data/test/test_id.rb +10 -28
  189. data/test/test_json_page.rb +3 -21
  190. data/test/test_key.rb +5 -23
  191. data/test/test_metronome.rb +6 -24
  192. data/test/test_patch.rb +10 -28
  193. data/test/test_prefixes.rb +3 -21
  194. data/test/test_remotes.rb +17 -35
  195. data/test/test_signature.rb +3 -21
  196. data/test/test_size.rb +3 -21
  197. data/test/test_sync_wallets.rb +3 -21
  198. data/test/test_tax.rb +6 -24
  199. data/test/test_thread_pool.rb +6 -24
  200. data/test/test_tree_wallets.rb +4 -22
  201. data/test/test_txn.rb +3 -21
  202. data/test/test_upgrades.rb +3 -21
  203. data/test/test_verbose_thread.rb +6 -24
  204. data/test/test_version.rb +2 -20
  205. data/test/test_wallet.rb +15 -33
  206. data/test/test_wallets.rb +4 -22
  207. data/test/test_zold.rb +7 -25
  208. data/test/upgrades/test_delete_banned_wallets.rb +4 -22
  209. data/test/upgrades/test_protocol_up.rb +3 -21
  210. data/upgrades/2.rb +3 -20
  211. data/upgrades/delete_banned_wallets.rb +3 -20
  212. data/upgrades/move_wallets_into_tree.rb +3 -20
  213. data/upgrades/protocol_up.rb +3 -20
  214. data/upgrades/rename_foreign_wallets.rb +3 -20
  215. data/views/journal.haml +25 -0
  216. data/views/layout.haml +25 -0
  217. data/views/wallet.haml +25 -0
  218. data/zold.gemspec +5 -21
  219. metadata +33 -15
  220. data/.simplecov +0 -36
  221. data/lib/zold/log.rb +0 -139
  222. data/test/test_log.rb +0 -49
data/views/wallet.haml CHANGED
@@ -1,3 +1,28 @@
1
+ -# SPDX-FileCopyrightText: Copyright (c) 2018-2025 Zerocracy
2
+ -# SPDX-License-Identifier: MIT
3
+
4
+ - # (The MIT License)
5
+ - #
6
+ - # Copyright (c) 2018-2025 Zerocracy
7
+ - #
8
+ - # Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ - # of this software and associated documentation files (the 'Software'), to deal
10
+ - # in the Software without restriction, including without limitation the rights
11
+ - # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ - # copies of the Software, and to permit persons to whom the Software is
13
+ - # furnished to do so, subject to the following conditions:
14
+ - #
15
+ - # The above copyright notice and this permission notice shall be included in all
16
+ - # copies or substantial portions of the Software.
17
+ - #
18
+ - # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ - # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ - # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ - # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ - # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ - # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ - # SOFTWARE.
25
+
1
26
  %p
2
27
  = wallet.network
3
28
  %br
data/zold.gemspec CHANGED
@@ -1,24 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2024 Zerocracy
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
 
@@ -46,7 +29,7 @@ It borrows the proof-of-work principle from Bitcoin, \
46
29
  and suggests a different architecture for digital wallet maintenance."
47
30
  s.authors = ['Yegor Bugayenko']
48
31
  s.email = 'yegor256@gmail.com'
49
- s.homepage = 'http://github.com/zold-io/zold'
32
+ s.homepage = 'https://github.com/zold-io/zold'
50
33
  s.post_install_message = "Thanks for installing Zold #{Zold::VERSION}!
51
34
  Study our White Paper: https://papers.zold.io/wp.pdf
52
35
  Read our blog posts: https://blog.zold.io
@@ -65,6 +48,7 @@ and suggests a different architecture for digital wallet maintenance."
65
48
  s.add_dependency 'get_process_mem', '~>0.2'
66
49
  s.add_dependency 'haml', '~>5.0'
67
50
  s.add_dependency 'json', '~>2.2'
51
+ s.add_dependency 'loog', '>0'
68
52
  s.add_dependency 'memory_profiler', '~>1.0'
69
53
  s.add_dependency 'mimic', '~>0.4'
70
54
  s.add_dependency 'openssl', '>=1.0'
@@ -79,5 +63,5 @@ and suggests a different architecture for digital wallet maintenance."
79
63
  s.add_dependency 'typhoeus', '~>1.3'
80
64
  s.add_dependency 'usagewatch_ext', '~>0.2'
81
65
  s.add_dependency 'zache', '~>0.12'
82
- s.add_dependency 'zold-score', '~>0.5'
66
+ s.add_dependency 'zold-score', '>0'
83
67
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zold
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.31.10
4
+ version: 0.32.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-07-16 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: backtrace
@@ -108,6 +107,20 @@ dependencies:
108
107
  - - "~>"
109
108
  - !ruby/object:Gem::Version
110
109
  version: '2.2'
110
+ - !ruby/object:Gem::Dependency
111
+ name: loog
112
+ requirement: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">"
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ type: :runtime
118
+ prerelease: false
119
+ version_requirements: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">"
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
111
124
  - !ruby/object:Gem::Dependency
112
125
  name: memory_profiler
113
126
  requirement: !ruby/object:Gem::Requirement
@@ -308,16 +321,16 @@ dependencies:
308
321
  name: zold-score
309
322
  requirement: !ruby/object:Gem::Requirement
310
323
  requirements:
311
- - - "~>"
324
+ - - ">"
312
325
  - !ruby/object:Gem::Version
313
- version: '0.5'
326
+ version: '0'
314
327
  type: :runtime
315
328
  prerelease: false
316
329
  version_requirements: !ruby/object:Gem::Requirement
317
330
  requirements:
318
- - - "~>"
331
+ - - ">"
319
332
  - !ruby/object:Gem::Version
320
- version: '0.5'
333
+ version: '0'
321
334
  description: In the last few years digital currencies have successfully demonstrated
322
335
  their ability to become an alternative financial instrument in many different markets.
323
336
  Most of the technologies available at the moment are based on the principles of
@@ -332,16 +345,23 @@ executables:
332
345
  - zold
333
346
  extensions: []
334
347
  extra_rdoc_files:
335
- - README.md
336
348
  - LICENSE.txt
349
+ - README.md
337
350
  files:
338
351
  - ".0pdd.yml"
339
352
  - ".gitattributes"
353
+ - ".github/typos.toml"
340
354
  - ".github/workflows/actionlint.yml"
355
+ - ".github/workflows/bashate.yml"
341
356
  - ".github/workflows/codecov.yml"
342
357
  - ".github/workflows/copyrights.yml"
358
+ - ".github/workflows/hadolint.yml"
359
+ - ".github/workflows/markdown-lint.yml"
343
360
  - ".github/workflows/pdd.yml"
344
361
  - ".github/workflows/rake.yml"
362
+ - ".github/workflows/reuse.yml"
363
+ - ".github/workflows/shellcheck.yml"
364
+ - ".github/workflows/typos.yml"
345
365
  - ".github/workflows/xcop.yml"
346
366
  - ".github/workflows/yamllint.yml"
347
367
  - ".gitignore"
@@ -349,14 +369,15 @@ files:
349
369
  - ".rubocop.yml"
350
370
  - ".ruby-version"
351
371
  - ".rultor.yml"
352
- - ".simplecov"
353
372
  - Dockerfile
354
373
  - Gemfile
355
374
  - Gemfile.lock
356
375
  - Guardfile
357
376
  - INSTALL.md
358
377
  - LICENSE.txt
378
+ - LICENSES/MIT.txt
359
379
  - README.md
380
+ - REUSE.toml
360
381
  - Rakefile
361
382
  - bin/zold
362
383
  - cucumber.yml
@@ -478,7 +499,6 @@ files:
478
499
  - lib/zold/id.rb
479
500
  - lib/zold/json_page.rb
480
501
  - lib/zold/key.rb
481
- - lib/zold/log.rb
482
502
  - lib/zold/metronome.rb
483
503
  - lib/zold/node/async_entrance.rb
484
504
  - lib/zold/node/entrance.rb
@@ -567,7 +587,6 @@ files:
567
587
  - test/test_id.rb
568
588
  - test/test_json_page.rb
569
589
  - test/test_key.rb
570
- - test/test_log.rb
571
590
  - test/test_metronome.rb
572
591
  - test/test_patch.rb
573
592
  - test/test_prefixes.rb
@@ -596,12 +615,12 @@ files:
596
615
  - views/layout.haml
597
616
  - views/wallet.haml
598
617
  - zold.gemspec
599
- homepage: http://github.com/zold-io/zold
618
+ homepage: https://github.com/zold-io/zold
600
619
  licenses:
601
620
  - MIT
602
621
  metadata: {}
603
622
  post_install_message: |-
604
- Thanks for installing Zold 0.31.10!
623
+ Thanks for installing Zold 0.32.0!
605
624
  Study our White Paper: https://papers.zold.io/wp.pdf
606
625
  Read our blog posts: https://blog.zold.io
607
626
  Try ZLD online wallet at: https://wts.zold.io
@@ -623,8 +642,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
623
642
  - !ruby/object:Gem::Version
624
643
  version: '0'
625
644
  requirements: []
626
- rubygems_version: 3.4.10
627
- signing_key:
645
+ rubygems_version: 3.6.9
628
646
  specification_version: 4
629
647
  summary: A fast cryptocurrency for micro payments
630
648
  test_files: []
data/.simplecov DELETED
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- #
4
- # Copyright (c) 2018-2024 Zerocracy
5
- #
6
- # Permission is hereby granted, free of charge, to any person obtaining a copy
7
- # of this software and associated documentation files (the 'Software'), to deal
8
- # in the Software without restriction, including without limitation the rights
9
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- # copies of the Software, and to permit persons to whom the Software is
11
- # furnished to do so, subject to the following conditions:
12
- #
13
- # The above copyright notice and this permission notice shall be included in all
14
- # copies or substantial portions of the Software.
15
- #
16
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
19
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- # SOFTWARE.
23
-
24
- SimpleCov.formatter = if Gem.win_platform?
25
- SimpleCov::Formatter::MultiFormatter[
26
- SimpleCov::Formatter::HTMLFormatter
27
- ]
28
- else
29
- SimpleCov::Formatter::MultiFormatter.new(
30
- [SimpleCov::Formatter::HTMLFormatter]
31
- )
32
- end
33
- SimpleCov.start do
34
- add_filter '/test/'
35
- add_filter '/features/'
36
- end
data/lib/zold/log.rb DELETED
@@ -1,139 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Copyright (c) 2018-2024 Zerocracy
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
- require 'logger'
24
- require 'rainbow'
25
-
26
- # Zold module.
27
- # Author:: Yegor Bugayenko (yegor256@gmail.com)
28
- # Copyright:: Copyright (c) 2018-2024 Zerocracy
29
- # License:: MIT
30
- module Zold
31
- # Logging facilities.
32
- #
33
- # There are a few logging classes, which can be used depending on what
34
- # you want a user to see. There are three logging levels: INFO, ERROR,
35
- # and DEBUG. In "quiet" mode the user won't see anything. This logging
36
- # mode is used only for testing, when we don't want to see absolutely
37
- # anything in the console. In order to turn off logging entirely, see
38
- # how we configure it in test__helper.rb
39
- #
40
- # The default "regular" logging mode is what a user gets when he/she runs
41
- # the gem in commmand line without any specific flags. In that case,
42
- # the user will see only INFO and ERROR messages.
43
- #
44
- # In a "verbose" mode the user will see everything, including DEBUG
45
- # messages. The user turns this mode by using --verbose command line argument.
46
- #
47
- module Log
48
- def self.colored(text, severity)
49
- case severity
50
- when 'ERROR', 'FATAL'
51
- return Rainbow(text).red
52
- when 'DEBUG'
53
- return Rainbow(text).yellow
54
- end
55
- text
56
- end
57
-
58
- # Compact formatter
59
- COMPACT = proc do |severity, _time, _target, msg|
60
- prefix = ''
61
- case severity
62
- when 'ERROR', 'FATAL'
63
- prefix = 'E: '
64
- when 'DEBUG'
65
- prefix = 'D: '
66
- end
67
- "#{colored(prefix, severity)}#{msg.to_s.rstrip.gsub("\n", "\n#{' ' * prefix.length}")}\n"
68
- end
69
-
70
- # Short formatter
71
- SHORT = proc do |_severity, _time, _target, msg|
72
- "#{msg.to_s.rstrip}\n"
73
- end
74
-
75
- # Full formatter
76
- FULL = proc do |severity, time, _target, msg|
77
- format(
78
- "%<time>s %<severity>5s %<msg>s\n",
79
- time: time.utc.iso8601,
80
- severity: colored(severity, severity),
81
- msg: msg.to_s.rstrip
82
- )
83
- end
84
-
85
- # No logging at all
86
- NULL = Logger.new($stdout)
87
- NULL.level = Logger::UNKNOWN
88
- NULL.freeze
89
-
90
- # Everything, including debug
91
- VERBOSE = Logger.new($stdout)
92
- VERBOSE.level = Logger::DEBUG
93
- VERBOSE.formatter = COMPACT
94
- VERBOSE.freeze
95
-
96
- # Info and errors, no debug info
97
- REGULAR = Logger.new($stdout)
98
- REGULAR.level = Logger::INFO
99
- REGULAR.formatter = COMPACT
100
- REGULAR.freeze
101
-
102
- # Errors only
103
- ERRORS = Logger.new($stdout)
104
- ERRORS.level = Logger::ERROR
105
- ERRORS.formatter = COMPACT
106
- ERRORS.freeze
107
-
108
- # Tee logger.
109
- class Tee
110
- def initialize(first, second)
111
- @first = first
112
- @second = second
113
- end
114
-
115
- def debug(msg)
116
- @first.debug(msg)
117
- @second.debug(msg)
118
- end
119
-
120
- def debug?
121
- @first.debug? || @second.debug?
122
- end
123
-
124
- def info(msg)
125
- @first.info(msg)
126
- @second.info(msg)
127
- end
128
-
129
- def info?
130
- @first.info? || @second.info?
131
- end
132
-
133
- def error(msg)
134
- @first.error(msg)
135
- @second.error(msg)
136
- end
137
- end
138
- end
139
- end
data/test/test_log.rb DELETED
@@ -1,49 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Copyright (c) 2018-2024 Zerocracy
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
- require 'minitest/autorun'
24
- require 'threads'
25
- require_relative 'test__helper'
26
- require_relative '../lib/zold/log'
27
-
28
- # Log test.
29
- # Author:: Yegor Bugayenko (yegor256@gmail.com)
30
- # Copyright:: Copyright (c) 2018-2024 Zerocracy
31
- # License:: MIT
32
- class TestLog < Zold::Test
33
- def test_prints_from_many_threads
34
- Threads.new(20).assert do
35
- fake_log.debug("This is debug\nand it is multi\nline")
36
- fake_log.info('This is info')
37
- fake_log.error('This is error')
38
- end
39
- end
40
-
41
- def test_prints_with_various_formatters
42
- log = Zold::Log::VERBOSE.dup
43
- log.formatter = Zold::Log::FULL
44
- log.debug("This is info\nand it is multi\nline")
45
- log.debug('Works fine?')
46
- log.debug(true)
47
- log.debug(1)
48
- end
49
- end