spawnpoint 0.2.0 → 0.3.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: 6ae1f2aae6f8340c03f309364e62b1b78113eff6aab8fcd6ba61ba416cf028b7
4
- data.tar.gz: caa9708a4ff55754b5643f107a0bf09fb64b2e736da36986bc23c0babc46da89
3
+ metadata.gz: 74b63ddf3131da47ad830cf6f2a948e8d874420297465d3815406d0a7a8132d0
4
+ data.tar.gz: 75501b0a8498aa3ee93decaa33bd03605a598f9b1821eb8fa15ce0c1d0b9d38d
5
5
  SHA512:
6
- metadata.gz: bc35e776bfca6667e159e4d8b7a5d6f78378b26a0d4d8ffcd0ad0cae32cef918ae168ec247a39301606767d8df496ca3923c5cc9b5fac9ca28b5aebcbb7974e5
7
- data.tar.gz: aaf1371dea70274993ab2b3b10efdd2c777b05c6ae005cb703b2681e8d0f0d894a0048b34a167e8d2a40ccef9d4df004514fc374c52a5bb7de2c02f464d23228
6
+ metadata.gz: 4f895198fc61bc83bb47b86572ba5113b87cf018ecd73194f2406eb3e665703d4390a35a1cadf4b0fcb4b6bcadd32f0df9244994f09303cc94381cb7690c0d59
7
+ data.tar.gz: 95db91cebc3dacd2ee8766115dcd7121edcd7f4671d532fdfd7037326de84f22ee1722ccd7cbe7a592b47ab5c07c5ec2b407309bd2c7c76280ce62514d5b84ec
data/README.md CHANGED
@@ -94,7 +94,7 @@ is ready, they can use the Git command directly instead.
94
94
  | `spwn hop -- <branch> <file>` | `git restore --source <branch> -- <file>` | Bring a file back from another snapshot. |
95
95
  | `spwn upload` | `git push` | Send your snapshots to the shared project space. |
96
96
  | `spwn download` | `git pull` | Fetch new snapshots from the shared project space and combine them with yours. |
97
- | `spwn sync <lesson> --into <game>` | — | Copy lesson files into a game folder, replacing matching files when confirmed. |
97
+ | `spwn sync --target <game> --source <lesson>` | — | Copy lesson files into a game folder, replacing matching files when confirmed. |
98
98
  | `spwn rollback --into <game>` | — | Undo the most recent lesson sync: restore replaced files and remove newly copied files. |
99
99
 
100
100
  A few notes about the mapping:
@@ -123,8 +123,8 @@ students need while following a single-player course:
123
123
  - `spwn upload` — push to a remote.
124
124
  - `spwn download` — fetch and integrate from a remote.
125
125
  - `spwn init` — start a new project.
126
- - `spwn sync <lesson> --into <game>` — copy lesson files into a game folder. Use `--force` to
127
- replace matching files without asking.
126
+ - `spwn sync --target <game> --source <lesson>` — copy lesson files into a game folder. Use `--force` to
127
+ replace matching files without asking. The older form `spwn sync <lesson> --into <game>` still works.
128
128
  - `spwn rollback --into <game>` — undo the most recent sync. Files that existed before the sync
129
129
  are restored, files created by the sync are removed, and unrelated game files are left alone.
130
130
 
@@ -233,7 +233,7 @@ module Spawnpoint
233
233
  sync: {
234
234
  name: "sync",
235
235
  help: "Copy a lesson folder into your game folder. The first time a lesson touches a file that already exists in your game folder, spwn asks before replacing it. After you accept a file, later lessons upgrade that same file automatically, so asset updates get easier as you go.",
236
- usage: "spwn sync <lesson-folder> --into <game-folder> or spwn sync <lesson-folder> --into <game-folder> --force",
236
+ usage: "spwn sync --target <game-folder> --source <lesson-folder> [--force] or spwn sync <lesson-folder> --into <game-folder> [--force]",
237
237
  handler: ->(args) { require_relative "synchronizer"; Spawnpoint::Synchronizer.new.run(args) }
238
238
  },
239
239
 
@@ -30,11 +30,12 @@ module Spawnpoint
30
30
 
31
31
  unless lesson_folder
32
32
  puts "Usage:"
33
+ puts " spwn sync --target <game-folder> --source <lesson-folder>"
33
34
  puts " spwn sync <lesson-folder> --into <game-folder>"
34
- puts " spwn sync <lesson-folder> --into <game-folder> --force"
35
+ puts " add --force to replace existing files without asking"
35
36
  puts ""
36
37
  puts "Example:"
37
- puts " spwn sync 04-collectibles/starter --into ~/DragonRuby/mygame"
38
+ puts " spwn sync --target ~/DragonRuby/mygame --source 04-collectibles/starter"
38
39
  puts ""
39
40
  puts "The first time a lesson copies a file that already exists in your"
40
41
  puts "game folder, spwn asks before replacing it. After you accept a"
@@ -43,8 +44,8 @@ module Spawnpoint
43
44
  end
44
45
 
45
46
  unless into_folder
46
- puts "Oops: tell spwn where to copy the lesson with --into."
47
- puts "Example: spwn sync 04-collectibles/starter --into ~/DragonRuby/mygame"
47
+ puts "Oops: tell spwn where to copy the lesson with --target (or --into)."
48
+ puts "Example: spwn sync --target ~/DragonRuby/mygame --source 04-collectibles/starter"
48
49
  return 1
49
50
  end
50
51
 
@@ -195,9 +196,12 @@ module Spawnpoint
195
196
  while i < argv.length
196
197
  arg = argv[i]
197
198
  case arg
198
- when "--into"
199
+ when "--into", "--target"
199
200
  i += 1
200
201
  into_folder = argv[i]
202
+ when "--source"
203
+ i += 1
204
+ lesson_folder ||= argv[i]
201
205
  when "--force", "-f"
202
206
  force = true
203
207
  when /\A-/
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Spawnpoint
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
data/test/test_cli.rb CHANGED
@@ -17,7 +17,7 @@ class TestCli < Minitest::Test
17
17
 
18
18
  def test_version_flag_exits_zero
19
19
  out, = capture_io { Spawnpoint::CLI.run(["--version"]) }
20
- assert_includes out, "0.2.0"
20
+ assert_includes out, "0.3.0"
21
21
  end
22
22
 
23
23
  def test_unknown_command_exits_one
@@ -52,6 +52,21 @@ class TestSynchronizer < Minitest::Test
52
52
  assert_includes marker_paths, "main.rb"
53
53
  end
54
54
 
55
+ def test_accepts_target_and_source_flags
56
+ write(@lesson, "main.rb", "puts :hi")
57
+ capture_io { @status = Spawnpoint::Synchronizer.new.run(["--target", @game, "--source", @lesson]) }
58
+ assert_equal 0, @status
59
+ assert_equal "puts :hi", File.read(File.join(@game, "main.rb"))
60
+ assert_includes marker_paths, "main.rb"
61
+ end
62
+
63
+ def test_accepts_target_flag_with_positional_lesson
64
+ write(@lesson, "main.rb", "puts :hi")
65
+ capture_io { @status = Spawnpoint::Synchronizer.new.run([@lesson, "--target", @game]) }
66
+ assert_equal 0, @status
67
+ assert_equal "puts :hi", File.read(File.join(@game, "main.rb"))
68
+ end
69
+
55
70
  def test_force_replaces_existing_file
56
71
  write(@game, "main.rb", "old")
57
72
  write(@lesson, "main.rb", "new")
data/test/test_version.rb CHANGED
@@ -7,6 +7,6 @@ class TestVersion < Minitest::Test
7
7
  end
8
8
 
9
9
  def test_version_is_0_2_0
10
- assert_equal "0.2.0", Spawnpoint::VERSION
10
+ assert_equal "0.3.0", Spawnpoint::VERSION
11
11
  end
12
12
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spawnpoint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - bebekim