zold 0.31.5 → 0.31.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (183) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/codecov.yml +20 -0
  3. data/.github/workflows/pdd.yml +11 -0
  4. data/.github/workflows/rake.yml +23 -0
  5. data/.github/workflows/xcop.yml +11 -0
  6. data/.rubocop.yml +9 -5
  7. data/.ruby-version +1 -1
  8. data/.rultor.yml +4 -5
  9. data/.simplecov +15 -19
  10. data/Dockerfile +1 -1
  11. data/Gemfile +13 -13
  12. data/Guardfile +1 -1
  13. data/README.md +0 -5
  14. data/Rakefile +1 -1
  15. data/bin/zold +1 -1
  16. data/features/step_definitions/steps.rb +5 -5
  17. data/features/support/env.rb +1 -1
  18. data/fixtures/merge/asserts.rb +1 -1
  19. data/fixtures/merge/into_no_wallet/assert.rb +1 -1
  20. data/fixtures/merge/legacy_negatives_stay/assert.rb +2 -2
  21. data/fixtures/merge/missed_wallets/assert.rb +2 -2
  22. data/fixtures/merge/negative_overwriting/assert.rb +1 -1
  23. data/fixtures/merge/negatives_in_between/assert.rb +2 -2
  24. data/fixtures/merge/random_expenses/assert.rb +2 -2
  25. data/fixtures/merge/simple_case/assert.rb +1 -1
  26. data/fixtures/merge/unconfirmed_income/assert.rb +1 -1
  27. data/lib/zold/age.rb +1 -1
  28. data/lib/zold/amount.rb +3 -3
  29. data/lib/zold/cached_wallets.rb +1 -1
  30. data/lib/zold/commands/args.rb +1 -1
  31. data/lib/zold/commands/calculate.rb +2 -2
  32. data/lib/zold/commands/clean.rb +1 -1
  33. data/lib/zold/commands/create.rb +6 -2
  34. data/lib/zold/commands/diff.rb +3 -3
  35. data/lib/zold/commands/fetch.rb +3 -3
  36. data/lib/zold/commands/invoice.rb +1 -1
  37. data/lib/zold/commands/list.rb +1 -1
  38. data/lib/zold/commands/merge.rb +4 -4
  39. data/lib/zold/commands/next.rb +1 -1
  40. data/lib/zold/commands/node.rb +3 -3
  41. data/lib/zold/commands/pay.rb +2 -2
  42. data/lib/zold/commands/propagate.rb +2 -2
  43. data/lib/zold/commands/pull.rb +1 -1
  44. data/lib/zold/commands/push.rb +1 -1
  45. data/lib/zold/commands/remote.rb +1 -1
  46. data/lib/zold/commands/remove.rb +1 -1
  47. data/lib/zold/commands/routines/audit.rb +7 -8
  48. data/lib/zold/commands/routines/gc.rb +1 -1
  49. data/lib/zold/commands/routines/reconcile.rb +1 -1
  50. data/lib/zold/commands/routines/reconnect.rb +1 -1
  51. data/lib/zold/commands/routines/retire.rb +1 -1
  52. data/lib/zold/commands/routines.rb +1 -1
  53. data/lib/zold/commands/show.rb +5 -6
  54. data/lib/zold/commands/taxes.rb +2 -2
  55. data/lib/zold/commands/thread_badge.rb +1 -1
  56. data/lib/zold/copies.rb +4 -4
  57. data/lib/zold/dir_items.rb +2 -2
  58. data/lib/zold/endless.rb +3 -5
  59. data/lib/zold/gem.rb +1 -1
  60. data/lib/zold/hands.rb +4 -4
  61. data/lib/zold/head.rb +1 -1
  62. data/lib/zold/hexnum.rb +1 -1
  63. data/lib/zold/http.rb +5 -4
  64. data/lib/zold/hungry_wallets.rb +2 -2
  65. data/lib/zold/id.rb +3 -5
  66. data/lib/zold/json_page.rb +2 -2
  67. data/lib/zold/key.rb +5 -5
  68. data/lib/zold/log.rb +7 -7
  69. data/lib/zold/metronome.rb +2 -2
  70. data/lib/zold/node/async_entrance.rb +9 -9
  71. data/lib/zold/node/entrance.rb +5 -5
  72. data/lib/zold/node/farm.rb +4 -4
  73. data/lib/zold/node/farmers.rb +2 -4
  74. data/lib/zold/node/front.rb +23 -19
  75. data/lib/zold/node/journaled_pipeline.rb +6 -6
  76. data/lib/zold/node/nodup_entrance.rb +1 -1
  77. data/lib/zold/node/nospam_entrance.rb +2 -2
  78. data/lib/zold/node/pipeline.rb +6 -6
  79. data/lib/zold/node/safe_entrance.rb +2 -2
  80. data/lib/zold/node/soft_error.rb +1 -1
  81. data/lib/zold/node/spread_entrance.rb +3 -3
  82. data/lib/zold/node/sync_entrance.rb +1 -1
  83. data/lib/zold/node/trace.rb +1 -1
  84. data/lib/zold/patch.rb +14 -15
  85. data/lib/zold/prefixes.rb +1 -1
  86. data/lib/zold/remotes.rb +4 -6
  87. data/lib/zold/signature.rb +1 -1
  88. data/lib/zold/size.rb +1 -1
  89. data/lib/zold/sync_wallets.rb +1 -1
  90. data/lib/zold/tax.rb +6 -4
  91. data/lib/zold/thread_pool.rb +3 -3
  92. data/lib/zold/tree_wallets.rb +1 -1
  93. data/lib/zold/txn.rb +26 -19
  94. data/lib/zold/txns.rb +1 -1
  95. data/lib/zold/upgrades.rb +2 -2
  96. data/lib/zold/verbose_thread.rb +2 -2
  97. data/lib/zold/version.rb +2 -2
  98. data/lib/zold/version_file.rb +1 -1
  99. data/lib/zold/wallet.rb +3 -3
  100. data/lib/zold/wallets.rb +6 -1
  101. data/lib/zold.rb +1 -1
  102. data/renovate.json +6 -0
  103. data/test/commands/routines/test_audit.rb +2 -2
  104. data/test/commands/routines/test_gc.rb +2 -2
  105. data/test/commands/routines/test_reconcile.rb +2 -2
  106. data/test/commands/routines/test_reconnect.rb +2 -2
  107. data/test/commands/routines/test_retire.rb +2 -2
  108. data/test/commands/test_alias.rb +1 -1
  109. data/test/commands/test_calculate.rb +1 -1
  110. data/test/commands/test_clean.rb +4 -4
  111. data/test/commands/test_create.rb +1 -1
  112. data/test/commands/test_diff.rb +5 -5
  113. data/test/commands/test_fetch.rb +21 -21
  114. data/test/commands/test_invoice.rb +1 -1
  115. data/test/commands/test_list.rb +1 -1
  116. data/test/commands/test_merge.rb +11 -11
  117. data/test/commands/test_node.rb +1 -1
  118. data/test/commands/test_pay.rb +4 -4
  119. data/test/commands/test_propagate.rb +1 -1
  120. data/test/commands/test_pull.rb +1 -1
  121. data/test/commands/test_push.rb +1 -1
  122. data/test/commands/test_remote.rb +2 -2
  123. data/test/commands/test_remove.rb +1 -1
  124. data/test/commands/test_show.rb +1 -1
  125. data/test/commands/test_taxes.rb +2 -2
  126. data/test/fake_home.rb +4 -3
  127. data/test/node/fake_entrance.rb +1 -1
  128. data/test/node/fake_node.rb +2 -2
  129. data/test/node/test_async_entrance.rb +6 -4
  130. data/test/node/test_entrance.rb +4 -4
  131. data/test/node/test_farm.rb +2 -2
  132. data/test/node/test_farmers.rb +1 -1
  133. data/test/node/test_front.rb +4 -4
  134. data/test/node/test_nodup_entrance.rb +2 -2
  135. data/test/node/test_nospam_entrance.rb +1 -1
  136. data/test/node/test_safe_entrance.rb +3 -3
  137. data/test/node/test_spread_entrance.rb +2 -2
  138. data/test/node/test_sync_entrance.rb +1 -1
  139. data/test/node/test_trace.rb +1 -1
  140. data/test/test__helper.rb +5 -4
  141. data/test/test_age.rb +2 -2
  142. data/test/test_amount.rb +1 -1
  143. data/test/test_cached_wallets.rb +3 -3
  144. data/test/test_copies.rb +6 -6
  145. data/test/test_dir_items.rb +2 -4
  146. data/test/test_gem.rb +1 -1
  147. data/test/test_hands.rb +1 -1
  148. data/test/test_hexnum.rb +1 -1
  149. data/test/test_http.rb +5 -5
  150. data/test/test_hungry_wallets.rb +1 -1
  151. data/test/test_id.rb +1 -1
  152. data/test/test_json_page.rb +1 -1
  153. data/test/test_key.rb +5 -5
  154. data/test/test_log.rb +1 -1
  155. data/test/test_metronome.rb +2 -1
  156. data/test/test_patch.rb +9 -9
  157. data/test/test_prefixes.rb +1 -1
  158. data/test/test_remotes.rb +2 -2
  159. data/test/test_signature.rb +1 -1
  160. data/test/test_size.rb +1 -1
  161. data/test/test_sync_wallets.rb +1 -1
  162. data/test/test_tax.rb +4 -4
  163. data/test/test_thread_pool.rb +1 -1
  164. data/test/test_tree_wallets.rb +1 -1
  165. data/test/test_txn.rb +2 -2
  166. data/test/test_upgrades.rb +4 -4
  167. data/test/test_verbose_thread.rb +1 -1
  168. data/test/test_wallet.rb +14 -14
  169. data/test/test_wallets.rb +1 -1
  170. data/test/test_zold.rb +2 -2
  171. data/test/upgrades/test_delete_banned_wallets.rb +1 -1
  172. data/test/upgrades/test_protocol_up.rb +1 -1
  173. data/upgrades/2.rb +1 -1
  174. data/upgrades/delete_banned_wallets.rb +2 -2
  175. data/upgrades/move_wallets_into_tree.rb +1 -1
  176. data/upgrades/protocol_up.rb +3 -3
  177. data/upgrades/rename_foreign_wallets.rb +2 -2
  178. data/zold.gemspec +21 -24
  179. metadata +40 -117
  180. data/.github/CODE_OF_CONDUCT.md +0 -76
  181. data/.github/CONTRIBUTING.md +0 -11
  182. data/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
  183. data/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
data/lib/zold/txn.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -53,8 +53,8 @@ module Zold
53
53
  REGEX_DETAILS = Regexp.new("^#{RE_DETAILS}$")
54
54
  private_constant :REGEX_DETAILS
55
55
 
56
- attr_reader :id, :date, :amount, :prefix, :bnf, :details, :sign
57
- attr_writer :sign, :amount, :bnf
56
+ attr_accessor :amount, :bnf, :sign
57
+ attr_reader :id, :date, :prefix, :details
58
58
 
59
59
  # Make a new object of this class (you must read the White Paper
60
60
  # in order to understand this class).
@@ -152,15 +152,19 @@ module Zold
152
152
 
153
153
  # Pattern to match the transaction from text
154
154
  PTN = Regexp.new(
155
- '^' + [
156
- '(?<id>[0-9a-f]{4})',
157
- '(?<date>[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z)',
158
- '(?<amount>[0-9a-f]{16})',
159
- "(?<prefix>#{RE_PREFIX})",
160
- '(?<bnf>[0-9a-f]{16})',
161
- "(?<details>#{RE_DETAILS})",
162
- '(?<sign>[A-Za-z0-9+/]+={0,3})?'
163
- ].join(';') + '$'
155
+ [
156
+ '^',
157
+ [
158
+ '(?<id>[0-9a-f]{4})',
159
+ '(?<date>[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z)',
160
+ '(?<amount>[0-9a-f]{16})',
161
+ "(?<prefix>#{RE_PREFIX})",
162
+ '(?<bnf>[0-9a-f]{16})',
163
+ "(?<details>#{RE_DETAILS})",
164
+ '(?<sign>[A-Za-z0-9+/]+={0,3})?'
165
+ ].join(';'),
166
+ '$'
167
+ ].join
164
168
  )
165
169
  private_constant :PTN
166
170
 
@@ -184,13 +188,16 @@ module Zold
184
188
  class CantParseTime < StandardError; end
185
189
 
186
190
  ISO8601 = Regexp.new(
187
- '^' + [
188
- '(?<year>\d{4})',
189
- '-(?<month>\d{2})',
190
- '-(?<day>\d{2})',
191
- 'T(?<hours>\d{2})',
192
- ':(?<minutes>\d{2})',
193
- ':(?<seconds>\d{2})Z'
191
+ [
192
+ '^',
193
+ [
194
+ '(?<year>\d{4})',
195
+ '-(?<month>\d{2})',
196
+ '-(?<day>\d{2})',
197
+ 'T(?<hours>\d{2})',
198
+ ':(?<minutes>\d{2})',
199
+ ':(?<seconds>\d{2})Z'
200
+ ].join
194
201
  ].join
195
202
  )
196
203
  private_constant :ISO8601
data/lib/zold/txns.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
data/lib/zold/upgrades.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -34,7 +34,7 @@ module Zold
34
34
  end
35
35
 
36
36
  def run
37
- Dir.glob("#{@directory}/*.rb").select { |f| f =~ /^(\d+)\.rb$/ }.sort.each do |script|
37
+ Dir.glob("#{@directory}/*.rb").grep(/^(\d+)\.rb$/).sort.each do |script|
38
38
  @version.apply(script)
39
39
  end
40
40
  command = @opts[:command]
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -36,7 +36,7 @@ module Zold
36
36
  @log = log
37
37
  end
38
38
 
39
- def run(safe = false)
39
+ def run(safe: false)
40
40
  Thread.current.report_on_exception = false
41
41
  yield
42
42
  rescue Errno::ENOMEM => e
data/lib/zold/version.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -25,7 +25,7 @@
25
25
  # Copyright:: Copyright (c) 2018 Yegor Bugayenko
26
26
  # License:: MIT
27
27
  module Zold
28
- VERSION = '0.31.5'
28
+ VERSION = '0.31.6'
29
29
  PROTOCOL = 2
30
30
  REPO = 'zold-io/zold'
31
31
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
data/lib/zold/wallet.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -114,7 +114,7 @@ module Zold
114
114
  raise "File '#{path}' already exists" if File.exist?(path) && !overwrite
115
115
  raise "Invalid network name '#{network}'" unless network =~ /^[a-z]{4,16}$/
116
116
  FileUtils.mkdir_p(File.dirname(path))
117
- IO.write(path, "#{network}\n#{PROTOCOL}\n#{id}\n#{pubkey.to_pub}\n\n")
117
+ File.write(path, "#{network}\n#{PROTOCOL}\n#{id}\n#{pubkey.to_pub}\n\n")
118
118
  @txns.flush
119
119
  @head.flush
120
120
  end
@@ -231,7 +231,7 @@ module Zold
231
231
  # in order to make sure two wallets with the same content are identical,
232
232
  # no matter whether they were formatted differently.
233
233
  def refurbish
234
- IO.write(path, (@head.fetch + [''] + @txns.fetch.map(&:to_s)).join("\n") + "\n")
234
+ File.write(path, "#{(@head.fetch + [''] + @txns.fetch.map(&:to_s)).join("\n")}\n")
235
235
  @txns.flush
236
236
  end
237
237
 
data/lib/zold/wallets.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -52,6 +52,11 @@ module Zold
52
52
  File.expand_path(@dir)
53
53
  end
54
54
 
55
+ # This wallet exists?
56
+ def exists?(id)
57
+ File.exist?(File.join(path, id.to_s + Wallet::EXT))
58
+ end
59
+
55
60
  # Returns the list of their IDs (as plain text)
56
61
  def all
57
62
  DirItems.new(path).fetch(recursive: false).select do |f|
data/lib/zold.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
data/renovate.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3
+ "extends": [
4
+ "config:base"
5
+ ]
6
+ }
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -24,7 +24,7 @@ require 'minitest/autorun'
24
24
  require 'tmpdir'
25
25
  require 'webmock/minitest'
26
26
  require_relative '../../test__helper'
27
- require_relative '../../../lib/zold/commands/routines/audit.rb'
27
+ require_relative '../../../lib/zold/commands/routines/audit'
28
28
 
29
29
  # Audit test.
30
30
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -24,7 +24,7 @@ require 'minitest/autorun'
24
24
  require_relative '../../test__helper'
25
25
  require_relative '../../fake_home'
26
26
  require_relative '../../../lib/zold/wallets'
27
- require_relative '../../../lib/zold/commands/routines/gc.rb'
27
+ require_relative '../../../lib/zold/commands/routines/gc'
28
28
 
29
29
  # Gc test.
30
30
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -25,7 +25,7 @@ require 'webmock/minitest'
25
25
  require_relative '../../test__helper'
26
26
  require_relative '../../fake_home'
27
27
  require_relative '../../../lib/zold/remotes'
28
- require_relative '../../../lib/zold/commands/routines/reconcile.rb'
28
+ require_relative '../../../lib/zold/commands/routines/reconcile'
29
29
 
30
30
  # Reconcile test.
31
31
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -25,7 +25,7 @@ require 'tmpdir'
25
25
  require 'webmock/minitest'
26
26
  require_relative '../../test__helper'
27
27
  require_relative '../../../lib/zold/remotes'
28
- require_relative '../../../lib/zold/commands/routines/reconnect.rb'
28
+ require_relative '../../../lib/zold/commands/routines/reconnect'
29
29
 
30
30
  # Reconnect test.
31
31
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -25,7 +25,7 @@ require 'tmpdir'
25
25
  require 'webmock/minitest'
26
26
  require_relative '../../test__helper'
27
27
  require_relative '../../../lib/zold/remotes'
28
- require_relative '../../../lib/zold/commands/routines/retire.rb'
28
+ require_relative '../../../lib/zold/commands/routines/retire'
29
29
 
30
30
  # Retire test.
31
31
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
@@ -51,6 +51,6 @@ class TestAlias < Zold::Test
51
51
  private
52
52
 
53
53
  def read_alias_file(home)
54
- IO.read(File.join(home.dir, 'aliases')).split(' ')
54
+ File.read(File.join(home.dir, 'aliases')).split
55
55
  end
56
56
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -37,8 +37,8 @@ class TestClean < Zold::Test
37
37
  FakeHome.new(log: test_log).run do |home|
38
38
  wallet = home.create_wallet
39
39
  copies = home.copies(wallet)
40
- copies.add('a1', 'host-1', 80, 1, time: Time.now - 26 * 60 * 60)
41
- copies.add('a2', 'host-2', 80, 2, time: Time.now - 26 * 60 * 60)
40
+ copies.add('a1', 'host-1', 80, 1, time: Time.now - (26 * 60 * 60))
41
+ copies.add('a2', 'host-2', 80, 2, time: Time.now - (26 * 60 * 60))
42
42
  Zold::Clean.new(wallets: home.wallets, copies: copies.root, log: test_log).run(['clean', wallet.id.to_s])
43
43
  assert(copies.all.empty?)
44
44
  end
@@ -63,7 +63,7 @@ class TestClean < Zold::Test
63
63
  FakeHome.new(log: test_log).run do |home|
64
64
  wallet = home.create_wallet
65
65
  copies = home.copies(wallet)
66
- copies.add(IO.read(wallet.path), 'host-2', 80, 2, time: Time.now)
66
+ copies.add(File.read(wallet.path), 'host-2', 80, 2, time: Time.now)
67
67
  Threads.new(20).assert do
68
68
  Zold::Clean.new(wallets: home.wallets, copies: copies.root, log: test_log).run(['clean'])
69
69
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -43,15 +43,15 @@ class TestDiff < Zold::Test
43
43
  FakeHome.new(log: test_log).run do |home|
44
44
  wallet = home.create_wallet
45
45
  first = home.create_wallet
46
- IO.write(first.path, IO.read(wallet.path))
46
+ File.write(first.path, File.read(wallet.path))
47
47
  second = home.create_wallet
48
- IO.write(second.path, IO.read(wallet.path))
48
+ File.write(second.path, File.read(wallet.path))
49
49
  Zold::Pay.new(wallets: home.wallets, copies: home.dir, remotes: home.remotes, log: test_log).run(
50
50
  ['pay', wallet.id.to_s, "NOPREFIX@#{Zold::Id.new}", '14.95', '--force', '--private-key=fixtures/id_rsa']
51
51
  )
52
52
  copies = home.copies(wallet)
53
- copies.add(IO.read(first.path), 'host-1', 80, 5)
54
- copies.add(IO.read(second.path), 'host-2', 80, 5)
53
+ copies.add(File.read(first.path), 'host-1', 80, 5)
54
+ copies.add(File.read(second.path), 'host-2', 80, 5)
55
55
  diff = Zold::Diff.new(wallets: home.wallets, copies: copies.root, log: test_log).run(
56
56
  ['diff', wallet.id.to_s]
57
57
  )
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -47,13 +47,13 @@ class TestFetch < Zold::Test
47
47
  stub_request(:get, "http://localhost:4096/wallet/#{wallet.id}").to_return(
48
48
  status: 200,
49
49
  body: {
50
- 'score': Zold::Score::ZERO.to_h,
51
- 'size': 10_000,
52
- 'mtime': Time.now.utc.iso8601
50
+ score: Zold::Score::ZERO.to_h,
51
+ size: 10_000,
52
+ mtime: Time.now.utc.iso8601
53
53
  }.to_json
54
54
  )
55
55
  stub_request(:get, "http://localhost:4096/wallet/#{wallet.id}.bin")
56
- .to_return(status: 200, body: IO.read(wallet.path))
56
+ .to_return(status: 200, body: File.read(wallet.path))
57
57
  stub_request(:get, "http://localhost:81/wallet/#{wallet.id}").to_return(status: 404)
58
58
  remotes = home.remotes
59
59
  remotes.add('localhost', 4096)
@@ -75,24 +75,24 @@ class TestFetch < Zold::Test
75
75
  stub_request(:get, "http://localhost:4096/wallet/#{wallet_a.id}").to_return(
76
76
  status: 200,
77
77
  body: {
78
- 'score': Zold::Score::ZERO.to_h,
79
- 'size': 10_000,
80
- 'mtime': Time.now.utc.iso8601
78
+ score: Zold::Score::ZERO.to_h,
79
+ size: 10_000,
80
+ mtime: Time.now.utc.iso8601
81
81
  }.to_json
82
82
  )
83
83
  stub_request(:get, "http://localhost:4096/wallet/#{wallet_a.id}.bin")
84
- .to_return(status: 200, body: IO.read(wallet_a.path))
84
+ .to_return(status: 200, body: File.read(wallet_a.path))
85
85
  wallet_b = home.create_wallet
86
86
  stub_request(:get, "http://localhost:4096/wallet/#{wallet_b.id}").to_return(
87
87
  status: 200,
88
88
  body: {
89
- 'score': Zold::Score::ZERO.to_h,
90
- 'size': 10_000,
91
- 'mtime': Time.now.utc.iso8601
89
+ score: Zold::Score::ZERO.to_h,
90
+ size: 10_000,
91
+ mtime: Time.now.utc.iso8601
92
92
  }.to_json
93
93
  )
94
94
  stub_request(:get, "http://localhost:4096/wallet/#{wallet_b.id}.bin")
95
- .to_return(status: 200, body: IO.read(wallet_b.path))
95
+ .to_return(status: 200, body: File.read(wallet_b.path))
96
96
  remotes = home.remotes
97
97
  remotes.add('localhost', 4096)
98
98
  copies_a = home.copies(wallet_a)
@@ -118,13 +118,13 @@ class TestFetch < Zold::Test
118
118
  stub_request(:get, "http://localhost:4096/wallet/#{wallet.id}").to_return(
119
119
  status: 200,
120
120
  body: {
121
- 'score': Zold::Score::ZERO.to_h,
122
- 'size': 10_000,
123
- 'mtime': Time.now.utc.iso8601
121
+ score: Zold::Score::ZERO.to_h,
122
+ size: 10_000,
123
+ mtime: Time.now.utc.iso8601
124
124
  }.to_json
125
125
  )
126
126
  stub_request(:get, "http://localhost:4096/wallet/#{wallet.id}.bin")
127
- .to_return(status: 200, body: IO.read(wallet.path))
127
+ .to_return(status: 200, body: File.read(wallet.path))
128
128
  remotes = home.remotes
129
129
  remotes.add('localhost', 4096)
130
130
  copies = home.copies(wallet)
@@ -142,13 +142,13 @@ class TestFetch < Zold::Test
142
142
  stub_request(:get, "http://localhost:4096/wallet/#{wallet.id}").to_return(
143
143
  status: 200,
144
144
  body: {
145
- 'score': Zold::Score::ZERO.to_h,
146
- 'size': 10_000,
147
- 'mtime': Time.now.utc.iso8601
145
+ score: Zold::Score::ZERO.to_h,
146
+ size: 10_000,
147
+ mtime: Time.now.utc.iso8601
148
148
  }.to_json
149
149
  )
150
150
  stub_request(:get, "http://localhost:4096/wallet/#{wallet.id}.bin")
151
- .to_return(status: 200, body: IO.read(wallet.path))
151
+ .to_return(status: 200, body: File.read(wallet.path))
152
152
  remotes = home.remotes
153
153
  remotes.add('localhost', 4096)
154
154
  copies = home.copies(wallet)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -46,15 +46,15 @@ class TestMerge < Zold::Test
46
46
  FakeHome.new(log: test_log).run do |home|
47
47
  wallet = home.create_wallet
48
48
  first = home.create_wallet
49
- IO.write(first.path, IO.read(wallet.path))
49
+ File.write(first.path, File.read(wallet.path))
50
50
  second = home.create_wallet
51
- IO.write(second.path, IO.read(wallet.path))
51
+ File.write(second.path, File.read(wallet.path))
52
52
  Zold::Pay.new(wallets: home.wallets, copies: home.dir, remotes: home.remotes, log: test_log).run(
53
53
  ['pay', wallet.id.to_s, "NOPREFIX@#{Zold::Id.new}", '14.95', '--force', '--private-key=fixtures/id_rsa']
54
54
  )
55
55
  copies = home.copies(wallet)
56
- copies.add(IO.read(first.path), 'host-1', 80, 5)
57
- copies.add(IO.read(second.path), 'host-2', 80, 5)
56
+ copies.add(File.read(first.path), 'host-1', 80, 5)
57
+ copies.add(File.read(second.path), 'host-2', 80, 5)
58
58
  modified = Zold::Merge.new(wallets: home.wallets, remotes: home.remotes, copies: copies.root, log: test_log).run(
59
59
  ['merge', wallet.id.to_s]
60
60
  )
@@ -67,7 +67,7 @@ class TestMerge < Zold::Test
67
67
  FakeHome.new(log: test_log).run do |home|
68
68
  wallet = home.create_wallet
69
69
  copies = home.copies(wallet)
70
- copies.add(IO.read(wallet.path), 'good-host', 80, 5)
70
+ copies.add(File.read(wallet.path), 'good-host', 80, 5)
71
71
  copies.add('some garbage', 'bad-host', 80, 5)
72
72
  modified = Zold::Merge.new(wallets: home.wallets, remotes: home.remotes, copies: copies.root, log: test_log).run(
73
73
  ['merge', wallet.id.to_s]
@@ -80,7 +80,7 @@ class TestMerge < Zold::Test
80
80
  FakeHome.new(log: test_log).run do |home|
81
81
  wallet = home.create_wallet(Zold::Id::ROOT)
82
82
  copies = home.copies(wallet)
83
- copies.add(IO.read(wallet.path), 'good-host', 80, 5)
83
+ copies.add(File.read(wallet.path), 'good-host', 80, 5)
84
84
  key = Zold::Key.new(file: 'fixtures/id_rsa')
85
85
  wallet.sub(Zold::Amount.new(zld: 9.99), "NOPREFIX@#{Zold::Id.new}", key)
86
86
  Zold::Merge.new(wallets: home.wallets, remotes: home.remotes, copies: copies.root, log: test_log).run(
@@ -94,10 +94,10 @@ class TestMerge < Zold::Test
94
94
  FakeHome.new(log: test_log).run do |home|
95
95
  main = home.create_wallet
96
96
  remote = home.create_wallet
97
- IO.write(remote.path, IO.read(main.path))
97
+ File.write(remote.path, File.read(main.path))
98
98
  remote.add(Zold::Txn.new(1, Time.now, Zold::Amount.new(zld: 11.0), 'NOPREFIX', Zold::Id.new, 'fake'))
99
99
  copies = home.copies(main)
100
- copies.add(IO.read(remote.path), 'fake-host', 80, 0)
100
+ copies.add(File.read(remote.path), 'fake-host', 80, 0)
101
101
  Zold::Merge.new(wallets: home.wallets, remotes: home.remotes, copies: copies.root, log: test_log).run(
102
102
  ['merge', main.id.to_s, '--no-baseline']
103
103
  )
@@ -112,13 +112,13 @@ class TestMerge < Zold::Test
112
112
  Dir.mktmpdir do |dir|
113
113
  FileUtils.cp_r(File.join('fixtures/merge', "#{f}/."), dir)
114
114
  scores = File.join(dir, "copies/0123456789abcdef/scores#{Zold::Copies::EXT}")
115
- IO.write(scores, IO.read(scores).gsub(/NOW/, Time.now.utc.iso8601))
115
+ File.write(scores, File.read(scores).gsub('NOW', Time.now.utc.iso8601))
116
116
  FileUtils.cp('fixtures/merge/asserts.rb', dir)
117
117
  wallets = Zold::Wallets.new(dir)
118
118
  copies = File.join(dir, 'copies')
119
119
  remotes = Zold::Remotes.new(file: File.join(dir, 'remotes'))
120
120
  Zold::Merge.new(wallets: wallets, remotes: remotes, copies: copies, log: test_log).run(
121
- %w[merge 0123456789abcdef] + IO.read(File.join(dir, 'opts')).split("\n")
121
+ %w[merge 0123456789abcdef] + File.read(File.join(dir, 'opts')).split("\n")
122
122
  )
123
123
  Dir.chdir(dir) do
124
124
  require File.join(dir, 'assert.rb')
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -88,9 +88,9 @@ class TestPay < Zold::Test
88
88
  wallet = home.create_wallet
89
89
  amount = Zold::Amount.new(zld: 2.0)
90
90
  Tempfile.open do |f|
91
- pem = IO.read('fixtures/id_rsa')
91
+ pem = File.read('fixtures/id_rsa')
92
92
  keygap = pem[100..120]
93
- IO.write(f, pem.gsub(keygap, '*' * keygap.length))
93
+ File.write(f, pem.gsub(keygap, '*' * keygap.length))
94
94
  Zold::Pay.new(wallets: home.wallets, copies: home.dir, remotes: home.remotes, log: test_log).run(
95
95
  [
96
96
  'pay', '--force', "--private-key=#{Shellwords.escape(f.path)}",
@@ -189,7 +189,7 @@ class TestPay < Zold::Test
189
189
  wallet.add(
190
190
  Zold::Txn.new(
191
191
  i + 1,
192
- Time.now - 24 * 60 * 60 * 365 * 300,
192
+ Time.now - (24 * 60 * 60 * 365 * 300),
193
193
  fund,
194
194
  'NOPREFIX', Zold::Id.new, '-'
195
195
  )
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2018-2023 Zerocracy, Inc.
3
+ # Copyright (c) 2018-2023 Zerocracy
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -95,7 +95,7 @@ class TestRemote < Zold::Test
95
95
  )
96
96
  stub_request(:get, 'https://rubygems.org/api/v1/versions/zold/latest.json').to_return(
97
97
  status: 200,
98
- body: '{"version": "9.9.9", "repo": "' + Zold::REPO + '"}'
98
+ body: "{\"version\": \"9.9.9\", \"repo\": \"#{Zold::REPO}\"}"
99
99
  )
100
100
  log = TestLogger.new
101
101
  cmd = Zold::Remote.new(remotes: remotes, log: log)