ggem 1.9.4 → 1.10.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ggem.gemspec +9 -7
- data/lib/ggem/cli.rb +8 -7
- data/lib/ggem/cli/commands.rb +51 -45
- data/lib/ggem/gem.rb +7 -6
- data/lib/ggem/gemspec.rb +20 -10
- data/lib/ggem/git_repo.rb +2 -1
- data/lib/ggem/template.rb +12 -8
- data/lib/ggem/template_file/gemspec.erb +5 -3
- data/lib/ggem/template_file/gitignore.erb +1 -0
- data/lib/ggem/template_file/l.yml.erb +8 -0
- data/lib/ggem/template_file/rubocop.yml.erb +3 -0
- data/lib/ggem/template_file/ruby-version.erb +1 -1
- data/lib/ggem/template_file/t.yml.erb +6 -0
- data/lib/ggem/version.rb +1 -1
- data/test/support/cmd_tests_helpers.rb +7 -7
- data/test/support/gem1/gem1.gemspec +3 -4
- data/test/support/gem2/gem2.gemspec +3 -4
- data/test/support/name_set.rb +6 -3
- data/test/system/ggem_tests.rb +8 -5
- data/test/unit/cli_tests.rb +73 -50
- data/test/unit/gemspec_tests.rb +11 -6
- data/test/unit/git_repo_tests.rb +9 -7
- metadata +27 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a5b24f85358ff0b1cb28b4cabef0e7a9f63fd1d346f9bbcbf2df18583d262de
|
4
|
+
data.tar.gz: 3921c12a953ac0ff424f4a2ed31dc8f769afffab63583e9c19fb46534ca862b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0bf74c663ff6cb2616513e47cefa3222008684a7cc721bcbbcfbc1a12005bbae1e676e050869d075822ed9bc7c882a24451abcdf726c22608e2f851ed55356db
|
7
|
+
data.tar.gz: 1772c3e5507211a54e7d89dd7ec76a5ecd3a9bcec34af7fdf46f3a5782a18f3b53bf00b84801a5ac6617fd4ea3ea63ba04e4c02355a2a79a9ca113e9ff5e8eaf
|
data/ggem.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
|
-
# -*- encoding: utf-8 -*-
|
4
4
|
lib = File.expand_path("../lib", __FILE__)
|
5
5
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
6
6
|
require "ggem/version"
|
@@ -10,20 +10,22 @@ Gem::Specification.new do |gem|
|
|
10
10
|
gem.version = GGem::VERSION
|
11
11
|
gem.authors = ["Kelly Redding", "Collin Redding"]
|
12
12
|
gem.email = ["kelly@kellyredding.com", "collin.redding@me.com"]
|
13
|
-
gem.summary =
|
14
|
-
gem.description =
|
13
|
+
gem.summary = '"Juh Gem", baby! (a gem utility CLI)'
|
14
|
+
gem.description = '"Juh Gem", baby! (a gem utility CLI)'
|
15
15
|
gem.homepage = "http://github.com/redding/ggem"
|
16
16
|
gem.license = "MIT"
|
17
17
|
|
18
|
-
gem.files
|
18
|
+
gem.files = `git ls-files | grep "^[^.]"`.split($INPUT_RECORD_SEPARATOR)
|
19
|
+
|
19
20
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
20
21
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
21
22
|
gem.require_paths = ["lib"]
|
22
23
|
|
23
24
|
gem.required_ruby_version = "~> 2.5"
|
24
25
|
|
25
|
-
gem.add_development_dependency("
|
26
|
+
gem.add_development_dependency("much-style-guide", ["~> 0.6.0"])
|
27
|
+
gem.add_development_dependency("assert", ["~> 2.19.5"])
|
26
28
|
|
27
|
-
gem.add_dependency("much-
|
28
|
-
gem.add_dependency("scmd",
|
29
|
+
gem.add_dependency("much-mixin", ["~> 0.2.4"])
|
30
|
+
gem.add_dependency("scmd", ["~> 3.0.4"])
|
29
31
|
end
|
data/lib/ggem/cli.rb
CHANGED
@@ -5,6 +5,7 @@ require "ggem/cli/clirb"
|
|
5
5
|
require "ggem/cli/commands"
|
6
6
|
|
7
7
|
module GGem; end
|
8
|
+
|
8
9
|
class GGem::CLI
|
9
10
|
COMMANDS = CommandSet.new{ |unknown| InvalidCommand.new(unknown) }.tap do |c|
|
10
11
|
c.add(GenerateCommand, "generate", "g")
|
@@ -16,7 +17,7 @@ class GGem::CLI
|
|
16
17
|
end
|
17
18
|
|
18
19
|
def self.run(args)
|
19
|
-
|
20
|
+
new.run(args)
|
20
21
|
end
|
21
22
|
|
22
23
|
def initialize(kernel = nil, stdout = nil, stderr = nil)
|
@@ -34,16 +35,16 @@ class GGem::CLI
|
|
34
35
|
@stdout.puts cmd.help
|
35
36
|
rescue CLIRB::VersionExit
|
36
37
|
@stdout.puts GGem::VERSION
|
37
|
-
rescue CLIRB::Error, ArgumentError, InvalidCommandError =>
|
38
|
-
display_debug(
|
39
|
-
@stderr.puts "#{
|
38
|
+
rescue CLIRB::Error, ArgumentError, InvalidCommandError => ex
|
39
|
+
display_debug(ex)
|
40
|
+
@stderr.puts "#{ex.message}\n\n"
|
40
41
|
@stdout.puts cmd.help
|
41
42
|
@kernel.exit 1
|
42
43
|
rescue CommandExitError
|
43
44
|
@kernel.exit 1
|
44
|
-
rescue
|
45
|
-
@stderr.puts "#{
|
46
|
-
@stderr.puts
|
45
|
+
rescue => ex
|
46
|
+
@stderr.puts "#{ex.class}: #{ex.message}"
|
47
|
+
@stderr.puts ex.backtrace.join("\n")
|
47
48
|
@kernel.exit 1
|
48
49
|
end
|
49
50
|
@kernel.exit 0
|
data/lib/ggem/cli/commands.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "ggem/cli/clirb"
|
4
|
-
require "much-
|
4
|
+
require "much-mixin"
|
5
5
|
|
6
6
|
module GGem; end
|
7
|
+
|
7
8
|
class GGem::CLI
|
8
9
|
InvalidCommandError = Class.new(ArgumentError)
|
9
10
|
CommandExitError = Class.new(RuntimeError)
|
@@ -16,12 +17,14 @@ class GGem::CLI
|
|
16
17
|
@clirb = CLIRB.new
|
17
18
|
end
|
18
19
|
|
19
|
-
def new
|
20
|
+
def new
|
21
|
+
self
|
22
|
+
end
|
20
23
|
|
21
24
|
def run(argv)
|
22
25
|
@clirb.parse!([@name, argv].flatten.compact)
|
23
26
|
raise CLIRB::HelpExit if @name.to_s.empty?
|
24
|
-
raise InvalidCommandError, "`#{
|
27
|
+
raise InvalidCommandError, "`#{name}` is not a command."
|
25
28
|
end
|
26
29
|
|
27
30
|
def help
|
@@ -33,14 +36,16 @@ class GGem::CLI
|
|
33
36
|
end
|
34
37
|
|
35
38
|
module ValidCommand
|
36
|
-
include
|
39
|
+
include MuchMixin
|
37
40
|
|
38
|
-
|
41
|
+
mixin_instance_methods do
|
39
42
|
def initialize(&clirb_build)
|
40
43
|
@clirb = CLIRB.new(&clirb_build)
|
41
44
|
end
|
42
45
|
|
43
|
-
def clirb
|
46
|
+
def clirb
|
47
|
+
@clirb
|
48
|
+
end
|
44
49
|
|
45
50
|
def run(argv, stdout = nil, stderr = nil)
|
46
51
|
@clirb.parse!(argv)
|
@@ -55,9 +60,9 @@ class GGem::CLI
|
|
55
60
|
end
|
56
61
|
|
57
62
|
module NotifyCmdCommand
|
58
|
-
include
|
63
|
+
include MuchMixin
|
59
64
|
|
60
|
-
|
65
|
+
mixin_instance_methods do
|
61
66
|
private
|
62
67
|
|
63
68
|
def notify(success_msg, &cmd_block)
|
@@ -66,7 +71,7 @@ class GGem::CLI
|
|
66
71
|
end
|
67
72
|
|
68
73
|
def cmd(&cmd_block)
|
69
|
-
cmd,
|
74
|
+
cmd, _status, output = cmd_block.call
|
70
75
|
if ENV["DEBUG"]
|
71
76
|
@stdout.puts cmd
|
72
77
|
@stdout.puts output
|
@@ -76,14 +81,14 @@ class GGem::CLI
|
|
76
81
|
end
|
77
82
|
|
78
83
|
module GitRepoCommand
|
79
|
-
include
|
84
|
+
include MuchMixin
|
80
85
|
|
81
|
-
|
86
|
+
mixin_included do
|
82
87
|
include ValidCommand
|
83
88
|
include NotifyCmdCommand
|
84
89
|
end
|
85
90
|
|
86
|
-
|
91
|
+
mixin_instance_methods do
|
87
92
|
def initialize(*args)
|
88
93
|
super
|
89
94
|
|
@@ -96,8 +101,8 @@ class GGem::CLI
|
|
96
101
|
def notify(*args, &block)
|
97
102
|
begin
|
98
103
|
super
|
99
|
-
rescue GGem::GitRepo::CmdError =>
|
100
|
-
@stderr.puts
|
104
|
+
rescue GGem::GitRepo::CmdError => ex
|
105
|
+
@stderr.puts ex.message
|
101
106
|
raise CommandExitError
|
102
107
|
end
|
103
108
|
end
|
@@ -114,9 +119,9 @@ class GGem::CLI
|
|
114
119
|
require "ggem/gem"
|
115
120
|
path = GGem::Gem.new(Dir.pwd, @clirb.args.first).save!.path
|
116
121
|
@stdout.puts "created gem in #{path}"
|
117
|
-
rescue GGem::Gem::NoNameError =>
|
122
|
+
rescue GGem::Gem::NoNameError => ex
|
118
123
|
error = ArgumentError.new("GEM-NAME must be provided")
|
119
|
-
error.set_backtrace(
|
124
|
+
error.set_backtrace(ex.backtrace)
|
120
125
|
raise error
|
121
126
|
end
|
122
127
|
|
@@ -132,28 +137,28 @@ class GGem::CLI
|
|
132
137
|
"Usage: ggem generate [options] GEM-NAME\n\n" \
|
133
138
|
"Options: #{@clirb}\n" \
|
134
139
|
"Description:\n" \
|
135
|
-
" #{
|
140
|
+
" #{summary}"
|
136
141
|
end
|
137
142
|
end
|
138
143
|
|
139
144
|
module GemspecCommand
|
140
|
-
include
|
145
|
+
include MuchMixin
|
141
146
|
|
142
|
-
|
147
|
+
mixin_included do
|
143
148
|
include ValidCommand
|
144
149
|
include NotifyCmdCommand
|
145
150
|
end
|
146
151
|
|
147
|
-
|
152
|
+
mixin_instance_methods do
|
148
153
|
def initialize(*args)
|
149
154
|
super
|
150
155
|
|
151
156
|
require "ggem/gemspec"
|
152
157
|
begin
|
153
158
|
@spec = GGem::Gemspec.new(Dir.pwd)
|
154
|
-
rescue GGem::Gemspec::NotFoundError =>
|
159
|
+
rescue GGem::Gemspec::NotFoundError => ex
|
155
160
|
error = ArgumentError.new("There are no gemspecs at #{Dir.pwd}")
|
156
|
-
error.set_backtrace(
|
161
|
+
error.set_backtrace(ex.backtrace)
|
157
162
|
raise error
|
158
163
|
end
|
159
164
|
end
|
@@ -163,8 +168,8 @@ class GGem::CLI
|
|
163
168
|
def notify(*args, &block)
|
164
169
|
begin
|
165
170
|
super
|
166
|
-
rescue GGem::Gemspec::CmdError =>
|
167
|
-
@stderr.puts
|
171
|
+
rescue GGem::Gemspec::CmdError => ex
|
172
|
+
@stderr.puts ex.message
|
168
173
|
raise CommandExitError
|
169
174
|
end
|
170
175
|
end
|
@@ -190,7 +195,7 @@ class GGem::CLI
|
|
190
195
|
"Usage: ggem build [options]\n\n" \
|
191
196
|
"Options: #{@clirb}\n" \
|
192
197
|
"Description:\n" \
|
193
|
-
" #{
|
198
|
+
" #{summary}"
|
194
199
|
end
|
195
200
|
end
|
196
201
|
|
@@ -219,7 +224,7 @@ class GGem::CLI
|
|
219
224
|
"Usage: ggem install [options]\n\n" \
|
220
225
|
"Options: #{@clirb}\n" \
|
221
226
|
"Description:\n" \
|
222
|
-
" #{
|
227
|
+
" #{summary}"
|
223
228
|
end
|
224
229
|
end
|
225
230
|
|
@@ -249,22 +254,22 @@ class GGem::CLI
|
|
249
254
|
"Usage: ggem push [options]\n\n" \
|
250
255
|
"Options: #{@clirb}\n" \
|
251
256
|
"Description:\n" \
|
252
|
-
" #{
|
257
|
+
" #{summary}"
|
253
258
|
end
|
254
259
|
end
|
255
260
|
|
256
261
|
module ForceTagOptionCommand
|
257
|
-
include
|
262
|
+
include MuchMixin
|
258
263
|
|
259
|
-
|
264
|
+
mixin_included do
|
260
265
|
include ValidCommand
|
261
266
|
end
|
262
267
|
|
263
|
-
|
268
|
+
mixin_instance_methods do
|
264
269
|
def initialize
|
265
270
|
super do
|
266
271
|
option "force-tag", "force tagging even with uncommitted files", {
|
267
|
-
:
|
272
|
+
abbrev: "f",
|
268
273
|
}
|
269
274
|
end
|
270
275
|
end
|
@@ -282,9 +287,9 @@ class GGem::CLI
|
|
282
287
|
begin
|
283
288
|
cmd{ @repo.run_validate_clean_cmd }
|
284
289
|
cmd{ @repo.run_validate_committed_cmd }
|
285
|
-
rescue GGem::GitRepo::CmdError
|
290
|
+
rescue GGem::GitRepo::CmdError
|
286
291
|
@stderr.puts "There are files that need to be committed first."
|
287
|
-
if
|
292
|
+
if clirb.opts["force-tag"]
|
288
293
|
@stderr.puts "Forcing tag anyway..."
|
289
294
|
else
|
290
295
|
raise CommandExitError
|
@@ -303,8 +308,8 @@ class GGem::CLI
|
|
303
308
|
end
|
304
309
|
|
305
310
|
@stdout.puts "Pushed git commits and tags."
|
306
|
-
rescue GGem::GitRepo::CmdError =>
|
307
|
-
@stderr.puts
|
311
|
+
rescue GGem::GitRepo::CmdError => ex
|
312
|
+
@stderr.puts ex.message
|
308
313
|
raise CommandExitError
|
309
314
|
end
|
310
315
|
|
@@ -316,7 +321,7 @@ class GGem::CLI
|
|
316
321
|
"Usage: ggem tag [options]\n\n" \
|
317
322
|
"Options: #{@clirb}\n" \
|
318
323
|
"Description:\n" \
|
319
|
-
" #{
|
324
|
+
" #{summary}"
|
320
325
|
end
|
321
326
|
end
|
322
327
|
|
@@ -332,7 +337,7 @@ class GGem::CLI
|
|
332
337
|
|
333
338
|
def run(argv, *args)
|
334
339
|
super
|
335
|
-
@tag_command.run(
|
340
|
+
@tag_command.run(clirb.opts["force-tag"] ? ["--force-tag"] : [])
|
336
341
|
@push_command.run([])
|
337
342
|
end
|
338
343
|
|
@@ -345,14 +350,14 @@ class GGem::CLI
|
|
345
350
|
"Usage: ggem release [options]\n\n" \
|
346
351
|
"Options: #{@clirb}\n" \
|
347
352
|
"Description:\n" \
|
348
|
-
" #{
|
353
|
+
" #{summary}\n" \
|
349
354
|
" (macro for running `ggem tag && ggem push`)"
|
350
355
|
end
|
351
356
|
end
|
352
357
|
|
353
358
|
class CommandSet
|
354
359
|
def initialize(&unknown_cmd_block)
|
355
|
-
@lookup = Hash.new{ |
|
360
|
+
@lookup = Hash.new{ |_h, k| unknown_cmd_block.call(k) }
|
356
361
|
@names = []
|
357
362
|
@aliases = {}
|
358
363
|
@summaries = {}
|
@@ -361,7 +366,7 @@ class GGem::CLI
|
|
361
366
|
def add(klass, name, *aliases)
|
362
367
|
begin
|
363
368
|
cmd = klass.new
|
364
|
-
rescue
|
369
|
+
rescue
|
365
370
|
# don't add any commands you can't init
|
366
371
|
else
|
367
372
|
([name] + aliases).each{ |n| @lookup[n] = cmd }
|
@@ -388,12 +393,13 @@ class GGem::CLI
|
|
388
393
|
end
|
389
394
|
|
390
395
|
def to_s
|
391
|
-
max_name_size = @names.map
|
392
|
-
max_alias_size = @aliases.values.map
|
396
|
+
max_name_size = @names.map(&:size).max || 0
|
397
|
+
max_alias_size = @aliases.values.map(&:size).max || 0
|
393
398
|
|
394
|
-
@to_s ||= @names.map
|
395
|
-
"#{n.ljust(max_name_size)} #{@aliases[n].ljust(max_alias_size)}
|
396
|
-
|
399
|
+
@to_s ||= @names.map{ |n|
|
400
|
+
"#{n.ljust(max_name_size)} #{@aliases[n].ljust(max_alias_size)} "\
|
401
|
+
"#{@summaries[n]}"
|
402
|
+
}.join("\n")
|
397
403
|
end
|
398
404
|
end
|
399
405
|
end
|
data/lib/ggem/gem.rb
CHANGED
@@ -4,6 +4,7 @@ require "fileutils"
|
|
4
4
|
require "ggem/template"
|
5
5
|
|
6
6
|
module GGem; end
|
7
|
+
|
7
8
|
class GGem::Gem
|
8
9
|
NoNameError = Class.new(ArgumentError)
|
9
10
|
|
@@ -30,13 +31,13 @@ class GGem::Gem
|
|
30
31
|
def module_name
|
31
32
|
transforms = {
|
32
33
|
"_" => "",
|
33
|
-
"-" => ""
|
34
|
+
"-" => "",
|
34
35
|
}
|
35
|
-
@module_name ||= transform_name(transforms
|
36
|
+
@module_name ||= transform_name(transforms, &:capitalize)
|
36
37
|
end
|
37
38
|
|
38
39
|
def ruby_name
|
39
|
-
@ruby_name ||= transform_name
|
40
|
+
@ruby_name ||= transform_name(&:downcase)
|
40
41
|
end
|
41
42
|
|
42
43
|
private
|
@@ -44,15 +45,15 @@ class GGem::Gem
|
|
44
45
|
def normalize_name(name)
|
45
46
|
und_camelcs = [/([A-Z])([a-z])/, '_\1\2']
|
46
47
|
rm_dup_und = [/_+/, "_"]
|
47
|
-
rm_lead_und = [/^_/, ""
|
48
|
+
rm_lead_und = [/^_/, ""]
|
48
49
|
name.gsub(*und_camelcs).gsub(*rm_dup_und).sub(*rm_lead_und).downcase
|
49
50
|
end
|
50
51
|
|
51
52
|
def transform_name(conditions = {}, &block)
|
52
|
-
n = (block ? block.call(
|
53
|
+
n = (block ? block.call(name) : name)
|
53
54
|
conditions.each do |on, glue|
|
54
55
|
if (a = n.split(on)).size > 1
|
55
|
-
n = a.map{ |part| block
|
56
|
+
n = a.map{ |part| block&.call(part) }.join(glue)
|
56
57
|
end
|
57
58
|
end
|
58
59
|
n
|
data/lib/ggem/gemspec.rb
CHANGED
@@ -4,10 +4,11 @@ require "pathname"
|
|
4
4
|
require "scmd"
|
5
5
|
|
6
6
|
module GGem; end
|
7
|
+
|
7
8
|
class GGem::Gemspec
|
8
9
|
PUSH_HOST_META_KEY = "allowed_push_host"
|
9
|
-
DEFAULT_PUSH_HOST = "https://rubygems.org"
|
10
|
-
BUILD_TO_DIRNAME = "pkg"
|
10
|
+
DEFAULT_PUSH_HOST = "https://rubygems.org"
|
11
|
+
BUILD_TO_DIRNAME = "pkg"
|
11
12
|
|
12
13
|
NotFoundError = Class.new(ArgumentError)
|
13
14
|
LoadError = Class.new(ArgumentError)
|
@@ -55,25 +56,34 @@ class GGem::Gemspec
|
|
55
56
|
def run_cmd(cmd_string)
|
56
57
|
cmd = Scmd.new(cmd_string)
|
57
58
|
cmd.run
|
58
|
-
|
59
|
-
raise
|
60
|
-
|
59
|
+
unless cmd.success?
|
60
|
+
raise(
|
61
|
+
CmdError,
|
62
|
+
"#{cmd_string}\n#{cmd.stderr.empty? ? cmd.stdout : cmd.stderr}",
|
63
|
+
)
|
61
64
|
end
|
62
65
|
[cmd_string, cmd.exitstatus, cmd.stdout]
|
63
66
|
end
|
64
67
|
|
65
68
|
def load_gemspec(path)
|
66
|
-
eval(
|
67
|
-
|
68
|
-
|
69
|
-
|
69
|
+
eval( # rubocop:disable Security/Eval
|
70
|
+
path.read,
|
71
|
+
TOPLEVEL_BINDING,
|
72
|
+
path.expand_path.to_s,
|
73
|
+
)
|
74
|
+
rescue ScriptError, StandardError => ex
|
75
|
+
original_line = ex.backtrace.find{ |line| line.include?(path.to_s) }
|
76
|
+
msg =
|
77
|
+
"There was a #{ex.class} while loading #{path.basename}: \n#{ex.message}"
|
70
78
|
msg << " from\n #{original_line}" if original_line
|
71
79
|
msg << "\n"
|
72
80
|
raise LoadError, msg
|
73
81
|
end
|
74
82
|
|
75
83
|
def get_push_host(spec)
|
76
|
-
ENV["GGEM_PUSH_HOST"] ||
|
84
|
+
ENV["GGEM_PUSH_HOST"] ||
|
85
|
+
get_meta(spec)[PUSH_HOST_META_KEY] ||
|
86
|
+
DEFAULT_PUSH_HOST
|
77
87
|
end
|
78
88
|
|
79
89
|
def get_meta(spec)
|
data/lib/ggem/git_repo.rb
CHANGED
@@ -4,6 +4,7 @@ require "pathname"
|
|
4
4
|
require "scmd"
|
5
5
|
|
6
6
|
module GGem; end
|
7
|
+
|
7
8
|
class GGem::GitRepo
|
8
9
|
NotFoundError = Class.new(ArgumentError)
|
9
10
|
CmdError = Class.new(RuntimeError)
|
@@ -48,7 +49,7 @@ class GGem::GitRepo
|
|
48
49
|
cmd_string = "cd #{@path} && #{cmd_string}"
|
49
50
|
cmd = Scmd.new(cmd_string)
|
50
51
|
cmd.run
|
51
|
-
|
52
|
+
unless cmd.success?
|
52
53
|
raise CmdError, "#{cmd_string}\n" \
|
53
54
|
"#{cmd.stderr.empty? ? cmd.stdout : cmd.stderr}"
|
54
55
|
end
|
data/lib/ggem/template.rb
CHANGED
@@ -4,6 +4,7 @@ require "erb"
|
|
4
4
|
require "fileutils"
|
5
5
|
|
6
6
|
module GGem; end
|
7
|
+
|
7
8
|
class GGem::Template
|
8
9
|
def initialize(ggem)
|
9
10
|
@ggem = ggem
|
@@ -18,12 +19,15 @@ class GGem::Template
|
|
18
19
|
save_folder "log"
|
19
20
|
save_folder "tmp"
|
20
21
|
|
22
|
+
save_file("l.yml.erb", ".l.yml")
|
23
|
+
save_file("t.yml.erb", ".t.yml")
|
24
|
+
save_file("rubocop.yml.erb", ".rubocop.yml")
|
21
25
|
save_file("ruby-version.erb", ".ruby-version")
|
22
|
-
save_file("gitignore.erb",
|
23
|
-
save_file("Gemfile.erb",
|
24
|
-
save_file("gemspec.erb",
|
25
|
-
save_file("README.md.erb",
|
26
|
-
save_file("LICENSE.erb",
|
26
|
+
save_file("gitignore.erb", ".gitignore")
|
27
|
+
save_file("Gemfile.erb", "Gemfile")
|
28
|
+
save_file("gemspec.erb", "#{@ggem.name}.gemspec")
|
29
|
+
save_file("README.md.erb", "README.md")
|
30
|
+
save_file("LICENSE.erb", "LICENSE")
|
27
31
|
|
28
32
|
save_file("lib.rb.erb", "lib/#{@ggem.ruby_name}.rb")
|
29
33
|
save_file("lib_version.rb.erb", "lib/#{@ggem.ruby_name}/version.rb")
|
@@ -39,7 +43,7 @@ class GGem::Template
|
|
39
43
|
|
40
44
|
private
|
41
45
|
|
42
|
-
def save_folder(relative_path=nil)
|
46
|
+
def save_folder(relative_path = nil)
|
43
47
|
path = File.join([@ggem.path, relative_path].compact)
|
44
48
|
FileUtils.mkdir_p(path)
|
45
49
|
end
|
@@ -53,10 +57,10 @@ class GGem::Template
|
|
53
57
|
source_file = File.join(File.dirname(__FILE__), "template_file", source)
|
54
58
|
output_file = File.join(@ggem.root_path, @ggem.name, output)
|
55
59
|
|
56
|
-
if File.
|
60
|
+
if File.exist?(source_file)
|
57
61
|
FileUtils.mkdir_p(File.dirname(output_file))
|
58
62
|
erb = ERB.new(File.read(source_file))
|
59
|
-
File.open(output_file, "w")
|
63
|
+
File.open(output_file, "w"){ |f| f << erb.result(binding) }
|
60
64
|
else
|
61
65
|
raise ArgumentError, "the source file `#{source_file}` does not exist"
|
62
66
|
end
|
@@ -1,6 +1,6 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
|
-
# -*- encoding: utf-8 -*-
|
4
4
|
lib = File.expand_path("../lib", __FILE__)
|
5
5
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
6
6
|
require "<%= @ggem.ruby_name %>/version"
|
@@ -15,14 +15,16 @@ Gem::Specification.new do |gem|
|
|
15
15
|
gem.homepage = "TODO: homepage"
|
16
16
|
gem.license = "MIT"
|
17
17
|
|
18
|
-
gem.files
|
18
|
+
gem.files = `git ls-files | grep "^[^.]"`.split($INPUT_RECORD_SEPARATOR)
|
19
|
+
|
19
20
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
20
21
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
21
22
|
gem.require_paths = ["lib"]
|
22
23
|
|
23
24
|
gem.required_ruby_version = "~> 2.5"
|
24
25
|
|
25
|
-
gem.add_development_dependency("
|
26
|
+
gem.add_development_dependency("much-style-guide", ["~> 0.6.0"])
|
27
|
+
gem.add_development_dependency("assert", ["~> 2.19.5"])
|
26
28
|
|
27
29
|
# TODO: gem.add_dependency("gem-name", ["~> 0.0.0"])
|
28
30
|
end
|
@@ -1 +1 @@
|
|
1
|
-
2.5.
|
1
|
+
2.5.8
|
data/lib/ggem/version.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require "much-
|
3
|
+
require "much-mixin"
|
4
4
|
require "scmd"
|
5
5
|
|
6
6
|
module GGem; end
|
7
|
+
|
7
8
|
module GGem::CmdTestsHelpers
|
8
|
-
include
|
9
|
+
include MuchMixin
|
9
10
|
|
10
|
-
|
11
|
+
mixin_included do
|
11
12
|
setup do
|
12
13
|
ENV["SCMD_TEST_MODE"] = "1"
|
13
14
|
|
@@ -39,12 +40,11 @@ module GGem::CmdTestsHelpers
|
|
39
40
|
cmd.stderr = Factory.string
|
40
41
|
@cmd_spy = cmd
|
41
42
|
end
|
42
|
-
err = nil
|
43
|
-
begin; run_cmd_block.call; rescue StandardError => err; end
|
44
43
|
|
45
|
-
|
44
|
+
ex =
|
45
|
+
assert_that{ run_cmd_block.call }.raises(cmd_error_class)
|
46
46
|
exp = "#{@cmd_spy.cmd_str}\n#{@cmd_spy.stderr}"
|
47
|
-
assert_equal exp,
|
47
|
+
assert_equal exp, ex.message
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
@@ -1,18 +1,17 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
|
-
# -*- encoding: utf-8 -*-
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.name = "gem1"
|
6
6
|
gem.version = "0.1.0"
|
7
7
|
gem.authors = []
|
8
8
|
gem.email = []
|
9
|
-
gem.summary =
|
10
|
-
gem.description =
|
9
|
+
gem.summary = "Gem 1 summary"
|
10
|
+
gem.description = "Gem 1 description"
|
11
11
|
gem.license = "MIT"
|
12
12
|
|
13
13
|
gem.files = []
|
14
14
|
gem.executables = []
|
15
15
|
gem.test_files = []
|
16
16
|
gem.require_paths = []
|
17
|
-
|
18
17
|
end
|
@@ -1,13 +1,13 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
|
-
# -*- encoding: utf-8 -*-
|
4
4
|
Gem::Specification.new do |gem|
|
5
5
|
gem.name = "gem2"
|
6
6
|
gem.version = "0.2.0"
|
7
7
|
gem.authors = []
|
8
8
|
gem.email = []
|
9
|
-
gem.summary =
|
10
|
-
gem.description =
|
9
|
+
gem.summary = "Gem 2 summary"
|
10
|
+
gem.description = "Gem 2 description"
|
11
11
|
gem.license = "MIT"
|
12
12
|
|
13
13
|
gem.metadata["allowed_push_host"] = "http://gems.example.com"
|
@@ -16,5 +16,4 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.executables = []
|
17
17
|
gem.test_files = []
|
18
18
|
gem.require_paths = []
|
19
|
-
|
20
19
|
end
|
data/test/support/name_set.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module GGem; end
|
4
|
+
|
4
5
|
module GGem::NameSet
|
5
6
|
class Base
|
6
7
|
attr_reader :variations, :name, :module_name, :ruby_name
|
7
8
|
|
8
9
|
def expected_folders
|
9
|
-
[
|
10
|
+
[
|
11
|
+
"",
|
10
12
|
"lib",
|
11
13
|
"lib/#{@ruby_name}",
|
12
14
|
"test",
|
@@ -14,12 +16,13 @@ module GGem::NameSet
|
|
14
16
|
"test/system",
|
15
17
|
"test/unit",
|
16
18
|
"log",
|
17
|
-
"tmp"
|
19
|
+
"tmp",
|
18
20
|
]
|
19
21
|
end
|
20
22
|
|
21
23
|
def expected_files
|
22
|
-
[
|
24
|
+
[
|
25
|
+
".ruby-version",
|
23
26
|
".gitignore",
|
24
27
|
"Gemfile",
|
25
28
|
"#{@name}.gemspec",
|
data/test/system/ggem_tests.rb
CHANGED
@@ -7,7 +7,6 @@ require "test/support/name_set"
|
|
7
7
|
|
8
8
|
module GGem
|
9
9
|
class SystemTests < Assert::Context
|
10
|
-
|
11
10
|
NS_SIMPLE = GGem::NameSet::Simple
|
12
11
|
NS_UNDER = GGem::NameSet::Underscored
|
13
12
|
NS_HYPHEN = GGem::NameSet::HyphenatedOther
|
@@ -18,7 +17,8 @@ module GGem
|
|
18
17
|
class GemTests < SystemTests
|
19
18
|
desc "Gem"
|
20
19
|
|
21
|
-
should "know its name attrs for various name styles
|
20
|
+
should "know its name attrs for various name styles "\
|
21
|
+
"(simple/underscored/hyphenated)" do
|
22
22
|
[NS_SIMPLE, NS_UNDER, NS_HYPHEN].each do |ns|
|
23
23
|
assert_gem_name_set(ns.new)
|
24
24
|
end
|
@@ -45,7 +45,8 @@ module GGem
|
|
45
45
|
FileUtils.rm_rf(TMP_PATH)
|
46
46
|
end
|
47
47
|
|
48
|
-
should "save gems with various name styles
|
48
|
+
should "save gems with various name styles "\
|
49
|
+
"(simple/underscored/hyphenated)" do
|
49
50
|
[NS_SIMPLE, NS_UNDER, NS_HYPHEN].each do |ns|
|
50
51
|
init_gem = GGem::Gem.new(TMP_PATH, ns.new.variations.first)
|
51
52
|
gem_from_save = init_gem.save!
|
@@ -60,10 +61,12 @@ module GGem
|
|
60
61
|
def assert_gem_created(name_set)
|
61
62
|
folders = name_set.expected_folders
|
62
63
|
files = name_set.expected_files
|
63
|
-
paths = (folders + files).collect
|
64
|
+
paths = (folders + files).collect do |p|
|
65
|
+
File.join(TMP_PATH, name_set.name, p)
|
66
|
+
end
|
64
67
|
|
65
68
|
paths.flatten.each do |path|
|
66
|
-
assert File.
|
69
|
+
assert File.exist?(path), "`#{path}` does not exist"
|
67
70
|
end
|
68
71
|
end
|
69
72
|
end
|
data/test/unit/cli_tests.rb
CHANGED
@@ -8,7 +8,7 @@ require "ggem/cli/commands"
|
|
8
8
|
require "ggem/gem"
|
9
9
|
require "ggem/gemspec"
|
10
10
|
require "ggem/git_repo"
|
11
|
-
require "much-
|
11
|
+
require "much-mixin"
|
12
12
|
|
13
13
|
class GGem::CLI
|
14
14
|
class UnitTests < Assert::Context
|
@@ -147,7 +147,7 @@ class GGem::CLI
|
|
147
147
|
class RunWithHelpTests < RunSetupTests
|
148
148
|
desc "and run with the help switch"
|
149
149
|
setup do
|
150
|
-
@cli.run([
|
150
|
+
@cli.run(["--help"])
|
151
151
|
end
|
152
152
|
|
153
153
|
should "output the invalid command's help" do
|
@@ -163,7 +163,7 @@ class GGem::CLI
|
|
163
163
|
class RunWithVersionTests < RunSetupTests
|
164
164
|
desc "and run with the version switch"
|
165
165
|
setup do
|
166
|
-
@cli.run([
|
166
|
+
@cli.run(["--version"])
|
167
167
|
end
|
168
168
|
|
169
169
|
should "have output its version" do
|
@@ -217,8 +217,8 @@ class GGem::CLI
|
|
217
217
|
end
|
218
218
|
|
219
219
|
should "parse its argv on run" do
|
220
|
-
assert_raises(CLIRB::HelpExit){ subject.new.run([
|
221
|
-
assert_raises(CLIRB::VersionExit){ subject.new.run([
|
220
|
+
assert_raises(CLIRB::HelpExit){ subject.new.run(["--help"]) }
|
221
|
+
assert_raises(CLIRB::VersionExit){ subject.new.run(["--version"]) }
|
222
222
|
end
|
223
223
|
|
224
224
|
should "raise a help exit if its name is empty" do
|
@@ -269,7 +269,7 @@ class GGem::CLI
|
|
269
269
|
|
270
270
|
should "take custom CLIRB build procs" do
|
271
271
|
cmd = @command_class.new do
|
272
|
-
option "test", "testing", :
|
272
|
+
option "test", "testing", abbrev: "t"
|
273
273
|
end
|
274
274
|
cmd.run(["-t"], @stdout, @stderr)
|
275
275
|
assert_true cmd.clirb.opts["test"]
|
@@ -284,7 +284,7 @@ class GGem::CLI
|
|
284
284
|
desc "GitRepoCommand"
|
285
285
|
setup do
|
286
286
|
@gem1_root_path = TEST_SUPPORT_PATH.join("gem1")
|
287
|
-
Assert.stub(Dir, :pwd){ @gem1_root_path}
|
287
|
+
Assert.stub(Dir, :pwd){ @gem1_root_path }
|
288
288
|
|
289
289
|
@command_class = Class.new{ include GitRepoCommand }
|
290
290
|
@cmd = @command_class.new
|
@@ -305,9 +305,9 @@ class GGem::CLI
|
|
305
305
|
end
|
306
306
|
|
307
307
|
module RootPathTests
|
308
|
-
include
|
308
|
+
include MuchMixin
|
309
309
|
|
310
|
-
|
310
|
+
mixin_included do
|
311
311
|
setup do
|
312
312
|
@root_path = Factory.path
|
313
313
|
Assert.stub(Dir, :pwd){ @root_path }
|
@@ -316,14 +316,16 @@ class GGem::CLI
|
|
316
316
|
end
|
317
317
|
|
318
318
|
module GitRepoSpyTests
|
319
|
-
include
|
319
|
+
include MuchMixin
|
320
320
|
|
321
|
-
|
321
|
+
mixin_included do
|
322
322
|
include RootPathTests
|
323
323
|
|
324
324
|
setup do
|
325
325
|
@repo_spy = nil
|
326
|
-
Assert.stub(GGem::GitRepo, :new)
|
326
|
+
Assert.stub(GGem::GitRepo, :new) do |*args|
|
327
|
+
@repo_spy = GitRepoSpy.new(*args)
|
328
|
+
end
|
327
329
|
end
|
328
330
|
end
|
329
331
|
end
|
@@ -383,17 +385,15 @@ class GGem::CLI
|
|
383
385
|
|
384
386
|
should "re-raise a specific argument error on gem 'no name' errors" do
|
385
387
|
Assert.stub(@gem_class, :new){ raise GGem::Gem::NoNameError }
|
386
|
-
err = nil
|
387
|
-
begin
|
388
|
-
cmd = @command_class.new
|
389
|
-
cmd.run([])
|
390
|
-
rescue ArgumentError => err
|
391
|
-
end
|
392
388
|
|
393
|
-
|
389
|
+
ex =
|
390
|
+
assert_that{
|
391
|
+
cmd = @command_class.new
|
392
|
+
cmd.run([])
|
393
|
+
}.raises(ArgumentError)
|
394
394
|
exp = "GEM-NAME must be provided"
|
395
|
-
assert_equal exp,
|
396
|
-
assert_not_empty
|
395
|
+
assert_equal exp, ex.message
|
396
|
+
assert_not_empty ex.backtrace
|
397
397
|
end
|
398
398
|
end
|
399
399
|
|
@@ -401,7 +401,7 @@ class GGem::CLI
|
|
401
401
|
desc "GemspecCommand"
|
402
402
|
setup do
|
403
403
|
@gem1_root_path = TEST_SUPPORT_PATH.join("gem1")
|
404
|
-
Assert.stub(Dir, :pwd){ @gem1_root_path}
|
404
|
+
Assert.stub(Dir, :pwd){ @gem1_root_path }
|
405
405
|
|
406
406
|
@command_class = Class.new{ include GemspecCommand }
|
407
407
|
@cmd = @command_class.new
|
@@ -424,25 +424,23 @@ class GGem::CLI
|
|
424
424
|
root = Factory.path
|
425
425
|
Assert.stub(Dir, :pwd){ root }
|
426
426
|
|
427
|
-
|
428
|
-
cmd = @command_class.new
|
429
|
-
rescue ArgumentError => err
|
430
|
-
end
|
431
|
-
assert_not_nil err
|
427
|
+
ex = assert_that{ @command_class.new }.raises(ArgumentError)
|
432
428
|
exp = "There are no gemspecs at #{Dir.pwd}"
|
433
|
-
assert_equal exp,
|
429
|
+
assert_equal exp, ex.message
|
434
430
|
end
|
435
431
|
end
|
436
432
|
|
437
433
|
module GemspecSpyTests
|
438
|
-
include
|
434
|
+
include MuchMixin
|
439
435
|
|
440
|
-
|
436
|
+
mixin_included do
|
441
437
|
include RootPathTests
|
442
438
|
|
443
439
|
setup do
|
444
440
|
@spec_spy = nil
|
445
|
-
Assert.stub(GGem::Gemspec, :new)
|
441
|
+
Assert.stub(GGem::Gemspec, :new) do |*args|
|
442
|
+
@spec_spy = GemspecSpy.new(*args)
|
443
|
+
end
|
446
444
|
end
|
447
445
|
end
|
448
446
|
end
|
@@ -481,7 +479,9 @@ class GGem::CLI
|
|
481
479
|
assert_true @spec_spy.run_build_cmd_called
|
482
480
|
|
483
481
|
exp = ENV["DEBUG"] == "1" ? "build\nbuild cmd was run\n" : ""
|
484
|
-
exp +=
|
482
|
+
exp +=
|
483
|
+
"#{@spec_spy.name} #{@spec_spy.version} built to "\
|
484
|
+
"#{@spec_spy.gem_file}\n"
|
485
485
|
assert_equal exp, @stdout.read
|
486
486
|
|
487
487
|
ENV["DEBUG"] = nil
|
@@ -489,7 +489,9 @@ class GGem::CLI
|
|
489
489
|
|
490
490
|
should "handle cmd errors when run" do
|
491
491
|
err_msg = Factory.string
|
492
|
-
Assert.stub(@spec_spy, :run_build_cmd)
|
492
|
+
Assert.stub(@spec_spy, :run_build_cmd) do
|
493
|
+
raise GGem::Gemspec::CmdError, err_msg
|
494
|
+
end
|
493
495
|
|
494
496
|
assert_raises(CommandExitError){ subject.run([], @stdout, @stderr) }
|
495
497
|
assert_equal "#{err_msg}\n", @stderr.read
|
@@ -502,7 +504,9 @@ class GGem::CLI
|
|
502
504
|
desc "InstallCommand"
|
503
505
|
setup do
|
504
506
|
@build_spy = nil
|
505
|
-
Assert.stub(BuildCommand, :new)
|
507
|
+
Assert.stub(BuildCommand, :new) do |*args|
|
508
|
+
@build_spy = CommandSpy.new(*args)
|
509
|
+
end
|
506
510
|
|
507
511
|
@command_class = InstallCommand
|
508
512
|
@cmd = @command_class.new
|
@@ -529,7 +533,8 @@ class GGem::CLI
|
|
529
533
|
assert @build_spy
|
530
534
|
end
|
531
535
|
|
532
|
-
should "run the build command and call the spec's run install cmds when
|
536
|
+
should "run the build command and call the spec's run install cmds when "\
|
537
|
+
"run" do
|
533
538
|
ENV["DEBUG"] = [nil, "1"].sample
|
534
539
|
subject.run(@argv, @stdout, @stderr)
|
535
540
|
|
@@ -546,7 +551,9 @@ class GGem::CLI
|
|
546
551
|
|
547
552
|
should "handle cmd errors when run" do
|
548
553
|
err_msg = Factory.string
|
549
|
-
Assert.stub(@spec_spy, :run_install_cmd)
|
554
|
+
Assert.stub(@spec_spy, :run_install_cmd) do
|
555
|
+
raise GGem::Gemspec::CmdError, err_msg
|
556
|
+
end
|
550
557
|
|
551
558
|
assert_raises(CommandExitError){ subject.run(@argv, @stdout, @stderr) }
|
552
559
|
assert_equal "#{err_msg}\n", @stderr.read
|
@@ -559,7 +566,9 @@ class GGem::CLI
|
|
559
566
|
desc "PushCommand"
|
560
567
|
setup do
|
561
568
|
@build_spy = nil
|
562
|
-
Assert.stub(BuildCommand, :new)
|
569
|
+
Assert.stub(BuildCommand, :new) do |*args|
|
570
|
+
@build_spy = CommandSpy.new(*args)
|
571
|
+
end
|
563
572
|
|
564
573
|
@command_class = PushCommand
|
565
574
|
@cmd = @command_class.new
|
@@ -604,7 +613,9 @@ class GGem::CLI
|
|
604
613
|
|
605
614
|
should "handle cmd errors when run" do
|
606
615
|
err_msg = Factory.string
|
607
|
-
Assert.stub(@spec_spy, :run_push_cmd)
|
616
|
+
Assert.stub(@spec_spy, :run_push_cmd) do
|
617
|
+
raise GGem::Gemspec::CmdError, err_msg
|
618
|
+
end
|
608
619
|
|
609
620
|
assert_raises(CommandExitError){ subject.run(@argv, @stdout, @stderr) }
|
610
621
|
assert_equal "#{err_msg}\n", @stderr.read
|
@@ -717,7 +728,9 @@ class GGem::CLI
|
|
717
728
|
|
718
729
|
should "remove the version tag on push errors" do
|
719
730
|
err_msg = Factory.string
|
720
|
-
Assert.stub(@repo_spy, :run_push_cmd)
|
731
|
+
Assert.stub(@repo_spy, :run_push_cmd) do
|
732
|
+
raise GGem::GitRepo::CmdError, err_msg
|
733
|
+
end
|
721
734
|
|
722
735
|
assert_raises(CommandExitError){ subject.run([], @stdout, @stderr) }
|
723
736
|
assert_equal "#{err_msg}\n", @stderr.read
|
@@ -727,9 +740,13 @@ class GGem::CLI
|
|
727
740
|
end
|
728
741
|
|
729
742
|
should "handle tag removal cmd errors when run" do
|
730
|
-
Assert.stub(@repo_spy, :run_push_cmd)
|
743
|
+
Assert.stub(@repo_spy, :run_push_cmd) do
|
744
|
+
raise GGem::GitRepo::CmdError, Factory.string
|
745
|
+
end
|
731
746
|
err_msg = Factory.string
|
732
|
-
Assert.stub(@repo_spy, :run_rm_tag_cmd)
|
747
|
+
Assert.stub(@repo_spy, :run_rm_tag_cmd) do
|
748
|
+
raise GGem::GitRepo::CmdError, err_msg
|
749
|
+
end
|
733
750
|
|
734
751
|
assert_raises(CommandExitError){ subject.run([], @stdout, @stderr) }
|
735
752
|
assert_equal "#{err_msg}\n", @stderr.read
|
@@ -745,7 +762,9 @@ class GGem::CLI
|
|
745
762
|
Assert.stub(TagCommand, :new){ |*args| @tag_spy = CommandSpy.new(*args) }
|
746
763
|
|
747
764
|
@push_spy = nil
|
748
|
-
Assert.stub(PushCommand, :new)
|
765
|
+
Assert.stub(PushCommand, :new) do |*args|
|
766
|
+
@push_spy = CommandSpy.new(*args)
|
767
|
+
end
|
749
768
|
|
750
769
|
@command_class = ReleaseCommand
|
751
770
|
@cmd = @command_class.new
|
@@ -757,8 +776,9 @@ class GGem::CLI
|
|
757
776
|
end
|
758
777
|
|
759
778
|
should "know its summary" do
|
760
|
-
exp =
|
761
|
-
|
779
|
+
exp =
|
780
|
+
"Tag #{@spec_spy.version_tag} and push built "\
|
781
|
+
"#{@spec_spy.gem_file_name} to #{@spec_spy.push_host}"
|
762
782
|
assert_equal exp, subject.summary
|
763
783
|
end
|
764
784
|
|
@@ -937,7 +957,8 @@ class GGem::CLI
|
|
937
957
|
|
938
958
|
class GemspecSpy
|
939
959
|
attr_reader :name, :version, :version_tag, :push_host
|
940
|
-
attr_reader :run_build_cmd_called, :run_install_cmd_called
|
960
|
+
attr_reader :run_build_cmd_called, :run_install_cmd_called
|
961
|
+
attr_reader :run_push_cmd_called
|
941
962
|
|
942
963
|
def initialize(root_path)
|
943
964
|
@root = Pathname.new(File.expand_path(root_path))
|
@@ -952,15 +973,15 @@ class GGem::CLI
|
|
952
973
|
end
|
953
974
|
|
954
975
|
def path
|
955
|
-
@root.join("#{
|
976
|
+
@root.join("#{name}.gemspec")
|
956
977
|
end
|
957
978
|
|
958
979
|
def gem_file_name
|
959
|
-
"#{
|
980
|
+
"#{name}-#{version}.gem"
|
960
981
|
end
|
961
982
|
|
962
983
|
def gem_file
|
963
|
-
File.join(GGem::Gemspec::BUILD_TO_DIRNAME,
|
984
|
+
File.join(GGem::Gemspec::BUILD_TO_DIRNAME, gem_file_name)
|
964
985
|
end
|
965
986
|
|
966
987
|
def run_build_cmd
|
@@ -982,8 +1003,10 @@ class GGem::CLI
|
|
982
1003
|
class GitRepoSpy
|
983
1004
|
attr_reader :path
|
984
1005
|
attr_reader :run_init_cmd_called
|
985
|
-
attr_reader :run_validate_clean_cmd_called
|
986
|
-
attr_reader :
|
1006
|
+
attr_reader :run_validate_clean_cmd_called
|
1007
|
+
attr_reader :run_validate_committed_cmd_called
|
1008
|
+
attr_reader :run_add_version_tag_cmd_called_with
|
1009
|
+
attr_reader :run_rm_tag_cmd_called_with
|
987
1010
|
attr_reader :run_push_cmd_called
|
988
1011
|
|
989
1012
|
def initialize(path)
|
data/test/unit/gemspec_tests.rb
CHANGED
@@ -94,18 +94,23 @@ class GGem::Gemspec
|
|
94
94
|
|
95
95
|
setup do
|
96
96
|
@exp_build_path = @gem1_root_path.join(subject.gem_file_name)
|
97
|
-
@exp_pkg_path =
|
97
|
+
@exp_pkg_path =
|
98
|
+
@gem1_root_path.join(
|
99
|
+
@gemspec_class::BUILD_TO_DIRNAME,
|
100
|
+
subject.gem_file_name,
|
101
|
+
)
|
98
102
|
end
|
99
103
|
end
|
100
104
|
|
101
105
|
class RunBuildCmdTests < CmdTests
|
102
106
|
desc "`run_build_cmd`"
|
103
107
|
setup do
|
104
|
-
@exp_cmds_run =
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
108
|
+
@exp_cmds_run =
|
109
|
+
[
|
110
|
+
"gem build --verbose #{subject.path}",
|
111
|
+
"mkdir -p #{@exp_pkg_path.dirname}",
|
112
|
+
"mv #{@exp_build_path} #{@exp_pkg_path}",
|
113
|
+
]
|
109
114
|
end
|
110
115
|
|
111
116
|
should "run system cmds to build the gem" do
|
data/test/unit/git_repo_tests.rb
CHANGED
@@ -47,7 +47,7 @@ class GGem::GitRepo
|
|
47
47
|
setup do
|
48
48
|
@exp_cmds_run = [
|
49
49
|
"cd #{@repo_path} && git init",
|
50
|
-
"cd #{@repo_path} && git add --all && git add -f *.keep"
|
50
|
+
"cd #{@repo_path} && git add --all && git add -f *.keep",
|
51
51
|
]
|
52
52
|
end
|
53
53
|
|
@@ -64,7 +64,7 @@ class GGem::GitRepo
|
|
64
64
|
desc "`run_validate_clean_cmd`"
|
65
65
|
setup do
|
66
66
|
@exp_cmds_run = [
|
67
|
-
"cd #{@repo_path} && git diff --exit-code"
|
67
|
+
"cd #{@repo_path} && git diff --exit-code",
|
68
68
|
]
|
69
69
|
end
|
70
70
|
|
@@ -81,7 +81,7 @@ class GGem::GitRepo
|
|
81
81
|
desc "`run_validate_committed_cmd`"
|
82
82
|
setup do
|
83
83
|
@exp_cmds_run = [
|
84
|
-
"cd #{@repo_path} && git diff-index --quiet --cached HEAD"
|
84
|
+
"cd #{@repo_path} && git diff-index --quiet --cached HEAD",
|
85
85
|
]
|
86
86
|
end
|
87
87
|
|
@@ -99,7 +99,7 @@ class GGem::GitRepo
|
|
99
99
|
setup do
|
100
100
|
@exp_cmds_run = [
|
101
101
|
"cd #{@repo_path} && git push",
|
102
|
-
"cd #{@repo_path} && git push --tags"
|
102
|
+
"cd #{@repo_path} && git push --tags",
|
103
103
|
]
|
104
104
|
end
|
105
105
|
|
@@ -119,7 +119,7 @@ class GGem::GitRepo
|
|
119
119
|
@tag = Factory.string
|
120
120
|
|
121
121
|
@exp_cmds_run = [
|
122
|
-
"cd #{@repo_path} && git tag -a -m \"Version #{@version}\" #{@tag}"
|
122
|
+
"cd #{@repo_path} && git tag -a -m \"Version #{@version}\" #{@tag}",
|
123
123
|
]
|
124
124
|
end
|
125
125
|
|
@@ -128,7 +128,9 @@ class GGem::GitRepo
|
|
128
128
|
end
|
129
129
|
|
130
130
|
should "complain if any system cmds are not successful" do
|
131
|
-
assert_exp_cmds_error(CmdError)
|
131
|
+
assert_exp_cmds_error(CmdError) do
|
132
|
+
subject.run_add_version_tag_cmd(@version, @tag)
|
133
|
+
end
|
132
134
|
end
|
133
135
|
end
|
134
136
|
|
@@ -138,7 +140,7 @@ class GGem::GitRepo
|
|
138
140
|
@tag = Factory.string
|
139
141
|
|
140
142
|
@exp_cmds_run = [
|
141
|
-
"cd #{@repo_path} && git tag -d #{@tag}"
|
143
|
+
"cd #{@repo_path} && git tag -d #{@tag}",
|
142
144
|
]
|
143
145
|
end
|
144
146
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ggem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.10.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kelly Redding
|
@@ -9,50 +9,64 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-01-
|
12
|
+
date: 2021-01-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: much-style-guide
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 0.6.0
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 0.6.0
|
14
28
|
- !ruby/object:Gem::Dependency
|
15
29
|
name: assert
|
16
30
|
requirement: !ruby/object:Gem::Requirement
|
17
31
|
requirements:
|
18
32
|
- - "~>"
|
19
33
|
- !ruby/object:Gem::Version
|
20
|
-
version: 2.19.
|
34
|
+
version: 2.19.5
|
21
35
|
type: :development
|
22
36
|
prerelease: false
|
23
37
|
version_requirements: !ruby/object:Gem::Requirement
|
24
38
|
requirements:
|
25
39
|
- - "~>"
|
26
40
|
- !ruby/object:Gem::Version
|
27
|
-
version: 2.19.
|
41
|
+
version: 2.19.5
|
28
42
|
- !ruby/object:Gem::Dependency
|
29
|
-
name: much-
|
43
|
+
name: much-mixin
|
30
44
|
requirement: !ruby/object:Gem::Requirement
|
31
45
|
requirements:
|
32
46
|
- - "~>"
|
33
47
|
- !ruby/object:Gem::Version
|
34
|
-
version: 0.2.
|
48
|
+
version: 0.2.4
|
35
49
|
type: :runtime
|
36
50
|
prerelease: false
|
37
51
|
version_requirements: !ruby/object:Gem::Requirement
|
38
52
|
requirements:
|
39
53
|
- - "~>"
|
40
54
|
- !ruby/object:Gem::Version
|
41
|
-
version: 0.2.
|
55
|
+
version: 0.2.4
|
42
56
|
- !ruby/object:Gem::Dependency
|
43
57
|
name: scmd
|
44
58
|
requirement: !ruby/object:Gem::Requirement
|
45
59
|
requirements:
|
46
60
|
- - "~>"
|
47
61
|
- !ruby/object:Gem::Version
|
48
|
-
version: 3.0.
|
62
|
+
version: 3.0.4
|
49
63
|
type: :runtime
|
50
64
|
prerelease: false
|
51
65
|
version_requirements: !ruby/object:Gem::Requirement
|
52
66
|
requirements:
|
53
67
|
- - "~>"
|
54
68
|
- !ruby/object:Gem::Version
|
55
|
-
version: 3.0.
|
69
|
+
version: 3.0.4
|
56
70
|
description: '"Juh Gem", baby! (a gem utility CLI)'
|
57
71
|
email:
|
58
72
|
- kelly@kellyredding.com
|
@@ -80,9 +94,12 @@ files:
|
|
80
94
|
- lib/ggem/template_file/README.md.erb
|
81
95
|
- lib/ggem/template_file/gemspec.erb
|
82
96
|
- lib/ggem/template_file/gitignore.erb
|
97
|
+
- lib/ggem/template_file/l.yml.erb
|
83
98
|
- lib/ggem/template_file/lib.rb.erb
|
84
99
|
- lib/ggem/template_file/lib_version.rb.erb
|
100
|
+
- lib/ggem/template_file/rubocop.yml.erb
|
85
101
|
- lib/ggem/template_file/ruby-version.erb
|
102
|
+
- lib/ggem/template_file/t.yml.erb
|
86
103
|
- lib/ggem/template_file/test_helper.rb.erb
|
87
104
|
- lib/ggem/template_file/test_support_factory.rb.erb
|
88
105
|
- lib/ggem/version.rb
|
@@ -117,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
134
|
- !ruby/object:Gem::Version
|
118
135
|
version: '0'
|
119
136
|
requirements: []
|
120
|
-
rubygems_version: 3.
|
137
|
+
rubygems_version: 3.2.4
|
121
138
|
signing_key:
|
122
139
|
specification_version: 4
|
123
140
|
summary: '"Juh Gem", baby! (a gem utility CLI)'
|