zold 0.0.8 → 0.1

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 (77) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE.md +12 -0
  3. data/.github/PULL_REQUEST_TEMPLATE.md +11 -0
  4. data/.rubocop.yml +9 -1
  5. data/.simplecov +2 -2
  6. data/.travis.yml +1 -1
  7. data/Gemfile +1 -1
  8. data/LICENSE.txt +1 -1
  9. data/Procfile +1 -1
  10. data/README.md +208 -101
  11. data/Rakefile +2 -1
  12. data/bin/zold +135 -54
  13. data/features/cli.feature +1 -1
  14. data/features/step_definitions/steps.rb +1 -1
  15. data/features/support/env.rb +1 -1
  16. data/fixtures/scripts/push-and-pull.sh +35 -0
  17. data/lib/zold.rb +2 -2
  18. data/lib/zold/amount.rb +10 -2
  19. data/lib/zold/commands/{send.rb → clean.rb} +16 -16
  20. data/lib/zold/commands/create.rb +7 -5
  21. data/lib/zold/commands/diff.rb +59 -0
  22. data/lib/zold/commands/fetch.rb +74 -0
  23. data/lib/zold/commands/{pull.rb → list.rb} +11 -17
  24. data/lib/zold/commands/merge.rb +50 -0
  25. data/lib/zold/commands/node.rb +94 -0
  26. data/lib/zold/commands/pay.rb +58 -0
  27. data/lib/zold/commands/{check.rb → propagate.rb} +19 -20
  28. data/lib/zold/commands/push.rb +12 -12
  29. data/lib/zold/commands/remote.rb +115 -0
  30. data/lib/zold/commands/{balance.rb → show.rb} +11 -7
  31. data/lib/zold/copies.rb +126 -0
  32. data/lib/zold/http.rb +70 -0
  33. data/lib/zold/id.rb +8 -3
  34. data/lib/zold/key.rb +2 -2
  35. data/lib/zold/log.rb +51 -2
  36. data/lib/zold/node/farm.rb +81 -0
  37. data/lib/zold/node/front.rb +94 -46
  38. data/lib/zold/patch.rb +58 -0
  39. data/lib/zold/remotes.rb +106 -0
  40. data/lib/zold/score.rb +101 -0
  41. data/lib/zold/signature.rb +48 -0
  42. data/lib/zold/version.rb +3 -3
  43. data/lib/zold/wallet.rb +87 -55
  44. data/lib/zold/wallets.rb +13 -6
  45. data/resources/remotes +1 -0
  46. data/test/commands/test_clean.rb +41 -0
  47. data/test/commands/test_create.rb +2 -2
  48. data/test/commands/test_diff.rb +61 -0
  49. data/test/commands/test_fetch.rb +65 -0
  50. data/test/commands/test_list.rb +42 -0
  51. data/test/commands/test_merge.rb +62 -0
  52. data/test/commands/test_node.rb +56 -0
  53. data/test/commands/{test_send.rb → test_pay.rb} +10 -11
  54. data/test/commands/test_remote.rb +60 -0
  55. data/test/commands/{test_balance.rb → test_show.rb} +6 -8
  56. data/test/node/fake_node.rb +73 -0
  57. data/test/node/test_farm.rb +34 -0
  58. data/test/node/test_front.rb +26 -57
  59. data/test/test__helper.rb +1 -1
  60. data/test/test_amount.rb +10 -2
  61. data/test/test_copies.rb +73 -0
  62. data/test/test_http.rb +42 -0
  63. data/test/test_id.rb +2 -2
  64. data/test/test_key.rb +10 -10
  65. data/test/test_patch.rb +59 -0
  66. data/test/test_remotes.rb +72 -0
  67. data/test/test_score.rb +79 -0
  68. data/test/test_signature.rb +45 -0
  69. data/test/test_wallet.rb +18 -35
  70. data/test/test_wallets.rb +14 -3
  71. data/test/test_zold.rb +52 -5
  72. data/zold.gemspec +5 -3
  73. metadata +92 -21
  74. data/CONTRIBUTING.md +0 -19
  75. data/views/index.haml +0 -6
  76. data/views/layout.haml +0 -26
  77. data/views/not_found.haml +0 -3
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2018 Zerocracy, Inc.
1
+ # Copyright (c) 2018 Yegor Bugayenko
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  # of this software and associated documentation files (the 'Software'), to deal
@@ -24,11 +24,11 @@ require_relative '../lib/zold/key.rb'
24
24
  require_relative '../lib/zold/id.rb'
25
25
  require_relative '../lib/zold/wallet.rb'
26
26
  require_relative '../lib/zold/amount.rb'
27
- require_relative '../lib/zold/commands/send.rb'
27
+ require_relative '../lib/zold/commands/pay.rb'
28
28
 
29
29
  # Wallet test.
30
30
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
31
- # Copyright:: Copyright (c) 2018 Zerocracy, Inc.
31
+ # Copyright:: Copyright (c) 2018 Yegor Bugayenko
32
32
  # License:: MIT
33
33
  class TestWallet < Minitest::Test
34
34
  def test_adds_transaction
@@ -36,25 +36,9 @@ class TestWallet < Minitest::Test
36
36
  wallet = wallet(dir)
37
37
  amount = Zold::Amount.new(zld: 39.99)
38
38
  key = Zold::Key.new(file: 'fixtures/id_rsa')
39
- assert(
40
- wallet.version.zero?,
41
- "Wallet version #{wallet.version} is not equal to zero"
42
- )
43
39
  wallet.sub(amount, Zold::Id.new, key)
44
- assert(
45
- wallet.version == 1,
46
- "Wallet version #{wallet.version} is not equal to 1"
47
- )
48
40
  wallet.sub(amount, Zold::Id.new, key)
49
- assert(
50
- wallet.version == 2,
51
- "Wallet version #{wallet.version} is not equal to 2"
52
- )
53
41
  wallet.sub(amount, Zold::Id.new, key)
54
- assert(
55
- wallet.version == 3,
56
- "Wallet version #{wallet.version} is not equal to 3"
57
- )
58
42
  assert(
59
43
  wallet.balance == amount.mul(-3),
60
44
  "#{wallet.balance} is not equal to #{amount.mul(-3)}"
@@ -62,6 +46,17 @@ class TestWallet < Minitest::Test
62
46
  end
63
47
  end
64
48
 
49
+ def test_adds_transaction_and_reads_back
50
+ Dir.mktmpdir 'test' do |dir|
51
+ wallet = wallet(dir)
52
+ amount = Zold::Amount.new(zld: 39.99)
53
+ key = Zold::Key.new(file: 'fixtures/id_rsa')
54
+ txn = wallet.sub(amount, Zold::Id.new, key)
55
+ wallet.add(txn)
56
+ assert(!Zold::Wallet.new(wallet.path).txns[0][:sign].end_with?("\n"))
57
+ end
58
+ end
59
+
65
60
  def test_initializes_it
66
61
  Dir.mktmpdir 'test' do |dir|
67
62
  pkey = Zold::Key.new(file: 'fixtures/id_rsa.pub')
@@ -84,12 +79,14 @@ class TestWallet < Minitest::Test
84
79
  wallet.add(
85
80
  id: 1,
86
81
  date: Time.now, amount: Zold::Amount.new(zld: 39.99),
87
- beneficiary: Zold::Id.new
82
+ bnf: Zold::Id.new,
83
+ details: '-'
88
84
  )
89
85
  wallet.add(
90
86
  id: 2,
91
87
  date: Time.now, amount: Zold::Amount.new(zld: 14.95),
92
- beneficiary: Zold::Id.new
88
+ bnf: Zold::Id.new,
89
+ details: '-'
93
90
  )
94
91
  sum = Zold::Amount::ZERO
95
92
  wallet.income do |t|
@@ -102,20 +99,6 @@ class TestWallet < Minitest::Test
102
99
  end
103
100
  end
104
101
 
105
- def test_checks_transaction
106
- Dir.mktmpdir 'test' do |dir|
107
- payer = wallet(dir)
108
- receiver = wallet(dir)
109
- amount = Zold::Amount.new(zld: 14.95)
110
- txn = Zold::Send.new(
111
- payer: payer, receiver: receiver,
112
- amount: amount,
113
- pvtkey: Zold::Key.new(file: 'fixtures/id_rsa')
114
- ).run
115
- assert payer.check(txn, amount, receiver.id)
116
- end
117
- end
118
-
119
102
  private
120
103
 
121
104
  def wallet(dir)
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2018 Zerocracy, Inc.
1
+ # Copyright (c) 2018 Yegor Bugayenko
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  # of this software and associated documentation files (the 'Software'), to deal
@@ -27,7 +27,7 @@ require_relative '../lib/zold/amount.rb'
27
27
 
28
28
  # Wallets test.
29
29
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
30
- # Copyright:: Copyright (c) 2018 Zerocracy, Inc.
30
+ # Copyright:: Copyright (c) 2018 Yegor Bugayenko
31
31
  # License:: MIT
32
32
  class TestWallets < Minitest::Test
33
33
  def test_adds_wallet
@@ -36,7 +36,18 @@ class TestWallets < Minitest::Test
36
36
  id = Zold::Id.new
37
37
  wallet = wallets.find(id)
38
38
  wallet.init(id, Zold::Key.new(file: 'fixtures/id_rsa.pub'))
39
- assert(wallets.total == 1, "#{wallets.total} is not equal to 1")
39
+ assert(wallets.all.count == 1, "#{wallets.all.count} is not equal to 1")
40
+ end
41
+ end
42
+
43
+ def test_lists_wallets
44
+ Dir.mktmpdir 'z1' do |dir|
45
+ wallets = Zold::Wallets.new(dir)
46
+ FileUtils.touch(File.join(dir, 'hello'))
47
+ id = Zold::Id.new
48
+ wallet = wallets.find(id)
49
+ wallet.init(id, Zold::Key.new(file: 'fixtures/id_rsa.pub'))
50
+ assert(wallets.all.count == 1, "#{wallets.all.count} is not equal to 1")
40
51
  end
41
52
  end
42
53
  end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2018 Zerocracy, Inc.
1
+ # Copyright (c) 2018 Yegor Bugayenko
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  # of this software and associated documentation files (the 'Software'), to deal
@@ -20,16 +20,63 @@
20
20
 
21
21
  require 'minitest/autorun'
22
22
  require 'tmpdir'
23
- require_relative '../lib/zold'
23
+ require 'English'
24
24
 
25
25
  # Zold main module test.
26
26
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
27
- # Copyright:: Copyright (c) 2018 Zerocracy, Inc.
27
+ # Copyright:: Copyright (c) 2018 Yegor Bugayenko
28
28
  # License:: MIT
29
29
  class TestZold < Minitest::Test
30
- def test_basic
30
+ def test_all_scripts
31
+ Dir.new('fixtures/scripts').each.select { |f| f =~ /\.sh$/ }.each do |f|
32
+ Dir.mktmpdir 'test' do |dir|
33
+ FileUtils.cp('fixtures/id_rsa.pub', dir)
34
+ FileUtils.cp('fixtures/id_rsa', dir)
35
+ script = File.join(dir, f)
36
+ FileUtils.cp("fixtures/scripts/#{f}", script)
37
+ bin = File.join(Dir.pwd, 'bin/zold')
38
+ Dir.chdir(dir) do
39
+ stdout = `/bin/bash #{f} #{bin} 2>&1`
40
+ unless $CHILD_STATUS.exitstatus.zero?
41
+ puts stdout
42
+ assert_equal($CHILD_STATUS.exitstatus, 0)
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+
49
+ def test_help
50
+ stdout = exec('--help')
51
+ assert(stdout.include?('Usage: zold'))
52
+ end
53
+
54
+ def test_show_version
55
+ stdout = exec('--version')
56
+ assert(stdout.include?('1.0.snapshot'))
57
+ end
58
+
59
+ def test_create_new_wallet
31
60
  Dir.mktmpdir 'test' do |dir|
32
- # tbd...
61
+ FileUtils.cp('fixtures/id_rsa.pub', dir)
62
+ FileUtils.cp('fixtures/id_rsa', dir)
63
+ stdout = exec(
64
+ '--private-key id_rsa --public-key id_rsa.pub --verbose --trace create',
65
+ dir
66
+ )
67
+ assert(stdout.include?('created at'))
68
+ end
69
+ end
70
+
71
+ private
72
+
73
+ def exec(tail, dir = Dir.pwd)
74
+ bin = File.expand_path(File.join(Dir.pwd, 'bin/zold'))
75
+ stdout = `cd #{dir} && #{bin} #{tail} 2>&1`
76
+ unless $CHILD_STATUS.exitstatus.zero?
77
+ puts stdout
78
+ assert_equal($CHILD_STATUS.exitstatus, 0)
33
79
  end
80
+ stdout
34
81
  end
35
82
  end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2018 Zerocracy, Inc.
1
+ # Copyright (c) 2018 Yegor Bugayenko
2
2
  #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  # of this software and associated documentation files (the 'Software'), to deal
@@ -45,16 +45,18 @@ Gem::Specification.new do |s|
45
45
  s.rdoc_options = ['--charset=UTF-8']
46
46
  s.extra_rdoc_files = ['README.md', 'LICENSE.txt']
47
47
  s.add_runtime_dependency 'cucumber', '1.3.17'
48
- s.add_runtime_dependency 'haml', '5.0.3'
48
+ s.add_runtime_dependency 'diffy', '3.2.0'
49
+ s.add_runtime_dependency 'facter', '2.5.1'
49
50
  s.add_runtime_dependency 'rainbow', '~>3.0'
50
51
  s.add_runtime_dependency 'rake', '12.0.0'
51
52
  s.add_runtime_dependency 'rubocop', '~>0.52.0'
52
53
  s.add_runtime_dependency 'rubocop-rspec', '1.5.1'
53
- s.add_runtime_dependency 'sinatra', '2.0.0'
54
+ s.add_runtime_dependency 'sinatra', '~>2.0.1'
54
55
  s.add_runtime_dependency 'slop', '~>4.4'
55
56
  s.add_runtime_dependency 'xcop', '~>0.5'
56
57
  s.add_development_dependency 'codecov', '0.1.10'
57
58
  s.add_development_dependency 'minitest', '5.5.0'
58
59
  s.add_development_dependency 'rdoc', '4.2.0'
59
60
  s.add_development_dependency 'rspec-rails', '3.1.0'
61
+ s.add_development_dependency 'webmock', '3.4.1'
60
62
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zold
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: '0.1'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-06 00:00:00.000000000 Z
11
+ date: 2018-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cucumber
@@ -25,19 +25,33 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.3.17
27
27
  - !ruby/object:Gem::Dependency
28
- name: haml
28
+ name: diffy
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 5.0.3
33
+ version: 3.2.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 5.0.3
40
+ version: 3.2.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: facter
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 2.5.1
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 2.5.1
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rainbow
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -98,16 +112,16 @@ dependencies:
98
112
  name: sinatra
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
- - - '='
115
+ - - "~>"
102
116
  - !ruby/object:Gem::Version
103
- version: 2.0.0
117
+ version: 2.0.1
104
118
  type: :runtime
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
108
- - - '='
122
+ - - "~>"
109
123
  - !ruby/object:Gem::Version
110
- version: 2.0.0
124
+ version: 2.0.1
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: slop
113
127
  requirement: !ruby/object:Gem::Requirement
@@ -192,6 +206,20 @@ dependencies:
192
206
  - - '='
193
207
  - !ruby/object:Gem::Version
194
208
  version: 3.1.0
209
+ - !ruby/object:Gem::Dependency
210
+ name: webmock
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - '='
214
+ - !ruby/object:Gem::Version
215
+ version: 3.4.1
216
+ type: :development
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - '='
221
+ - !ruby/object:Gem::Version
222
+ version: 3.4.1
195
223
  description: Non-blockchain cryptocurrency
196
224
  email: yegor256@gmail.com
197
225
  executables:
@@ -203,13 +231,14 @@ extra_rdoc_files:
203
231
  files:
204
232
  - ".0pdd.yml"
205
233
  - ".gitattributes"
234
+ - ".github/ISSUE_TEMPLATE.md"
235
+ - ".github/PULL_REQUEST_TEMPLATE.md"
206
236
  - ".gitignore"
207
237
  - ".pdd"
208
238
  - ".rubocop.yml"
209
239
  - ".rultor.yml"
210
240
  - ".simplecov"
211
241
  - ".travis.yml"
212
- - CONTRIBUTING.md
213
242
  - Gemfile
214
243
  - LICENSE.txt
215
244
  - Procfile
@@ -225,35 +254,62 @@ files:
225
254
  - features/support/env.rb
226
255
  - fixtures/id_rsa
227
256
  - fixtures/id_rsa.pub
257
+ - fixtures/scripts/push-and-pull.sh
228
258
  - lib/zold.rb
229
259
  - lib/zold/amount.rb
230
- - lib/zold/commands/balance.rb
231
- - lib/zold/commands/check.rb
260
+ - lib/zold/commands/clean.rb
232
261
  - lib/zold/commands/create.rb
233
- - lib/zold/commands/pull.rb
262
+ - lib/zold/commands/diff.rb
263
+ - lib/zold/commands/fetch.rb
264
+ - lib/zold/commands/list.rb
265
+ - lib/zold/commands/merge.rb
266
+ - lib/zold/commands/node.rb
267
+ - lib/zold/commands/pay.rb
268
+ - lib/zold/commands/propagate.rb
234
269
  - lib/zold/commands/push.rb
235
- - lib/zold/commands/send.rb
270
+ - lib/zold/commands/remote.rb
271
+ - lib/zold/commands/show.rb
272
+ - lib/zold/copies.rb
273
+ - lib/zold/http.rb
236
274
  - lib/zold/id.rb
237
275
  - lib/zold/key.rb
238
276
  - lib/zold/log.rb
277
+ - lib/zold/node/farm.rb
239
278
  - lib/zold/node/front.rb
279
+ - lib/zold/patch.rb
280
+ - lib/zold/remotes.rb
281
+ - lib/zold/score.rb
282
+ - lib/zold/signature.rb
240
283
  - lib/zold/version.rb
241
284
  - lib/zold/wallet.rb
242
285
  - lib/zold/wallets.rb
243
- - test/commands/test_balance.rb
286
+ - resources/remotes
287
+ - test/commands/test_clean.rb
244
288
  - test/commands/test_create.rb
245
- - test/commands/test_send.rb
289
+ - test/commands/test_diff.rb
290
+ - test/commands/test_fetch.rb
291
+ - test/commands/test_list.rb
292
+ - test/commands/test_merge.rb
293
+ - test/commands/test_node.rb
294
+ - test/commands/test_pay.rb
295
+ - test/commands/test_remote.rb
296
+ - test/commands/test_show.rb
297
+ - test/node/fake_node.rb
298
+ - test/node/test_farm.rb
246
299
  - test/node/test_front.rb
247
300
  - test/test__helper.rb
248
301
  - test/test_amount.rb
302
+ - test/test_copies.rb
303
+ - test/test_http.rb
249
304
  - test/test_id.rb
250
305
  - test/test_key.rb
306
+ - test/test_patch.rb
307
+ - test/test_remotes.rb
308
+ - test/test_score.rb
309
+ - test/test_signature.rb
251
310
  - test/test_wallet.rb
252
311
  - test/test_wallets.rb
253
312
  - test/test_zold.rb
254
- - views/index.haml
255
- - views/layout.haml
256
- - views/not_found.haml
257
313
  - zold.gemspec
258
314
  homepage: http://github.com/zerocracy/zold
259
315
  licenses:
@@ -285,14 +341,29 @@ test_files:
285
341
  - features/gem_package.feature
286
342
  - features/step_definitions/steps.rb
287
343
  - features/support/env.rb
288
- - test/commands/test_balance.rb
344
+ - test/commands/test_clean.rb
289
345
  - test/commands/test_create.rb
290
- - test/commands/test_send.rb
346
+ - test/commands/test_diff.rb
347
+ - test/commands/test_fetch.rb
348
+ - test/commands/test_list.rb
349
+ - test/commands/test_merge.rb
350
+ - test/commands/test_node.rb
351
+ - test/commands/test_pay.rb
352
+ - test/commands/test_remote.rb
353
+ - test/commands/test_show.rb
354
+ - test/node/fake_node.rb
355
+ - test/node/test_farm.rb
291
356
  - test/node/test_front.rb
292
357
  - test/test__helper.rb
293
358
  - test/test_amount.rb
359
+ - test/test_copies.rb
360
+ - test/test_http.rb
294
361
  - test/test_id.rb
295
362
  - test/test_key.rb
363
+ - test/test_patch.rb
364
+ - test/test_remotes.rb
365
+ - test/test_score.rb
366
+ - test/test_signature.rb
296
367
  - test/test_wallet.rb
297
368
  - test/test_wallets.rb
298
369
  - test/test_zold.rb
@@ -1,19 +0,0 @@
1
- Fork and clone the repository:
2
-
3
- ```
4
- git clone git@github.com:your-username/zold.git
5
- ```
6
-
7
- Make changes and run Rake:
8
-
9
- ```
10
- rake
11
- ```
12
-
13
- Commit changes, please add issue reference in commit message:
14
- `#<issue> <message>`
15
-
16
- Push changes to your fork and create a pull request.
17
-
18
- We will review your changes and apply them to the master branch shortly,
19
- provided they don't violate our quality standards.