ggem 1.9.3 → 1.10.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -1
- data/bin/ggem +1 -0
- data/ggem.gemspec +10 -7
- data/lib/ggem.rb +2 -0
- data/lib/ggem/cli.rb +10 -7
- data/lib/ggem/cli/clirb.rb +2 -0
- data/lib/ggem/cli/commands.rb +53 -45
- data/lib/ggem/gem.rb +9 -6
- data/lib/ggem/gemspec.rb +22 -10
- data/lib/ggem/git_repo.rb +4 -1
- data/lib/ggem/template.rb +14 -8
- data/lib/ggem/template_file/Gemfile.erb +3 -1
- data/lib/ggem/template_file/gemspec.erb +6 -2
- data/lib/ggem/template_file/gitignore.erb +1 -0
- data/lib/ggem/template_file/l.yml.erb +8 -0
- data/lib/ggem/template_file/lib.rb.erb +2 -0
- data/lib/ggem/template_file/lib_version.rb.erb +2 -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/template_file/test_helper.rb.erb +6 -4
- data/lib/ggem/template_file/test_support_factory.rb.erb +2 -0
- data/lib/ggem/version.rb +3 -1
- data/test/helper.rb +6 -4
- data/test/support/cmd_tests_helpers.rb +9 -7
- data/test/support/factory.rb +2 -0
- data/test/support/gem1/gem1.gemspec +4 -3
- data/test/support/gem2/gem2.gemspec +4 -3
- data/test/support/name_set.rb +8 -3
- data/test/system/ggem_tests.rb +10 -5
- data/test/unit/cli_tests.rb +75 -50
- data/test/unit/gem_tests.rb +2 -0
- data/test/unit/gemspec_tests.rb +13 -6
- data/test/unit/git_repo_tests.rb +11 -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: def73e1c484bc3f53187ff0794b383268a5757b66b63412cde998df88157ba72
|
4
|
+
data.tar.gz: dc06c2753531740179a2c5863851cef0de7c5663a264f6f249d1c53425fbe0c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 00dcde4ad715b9ff52a7455080e077cfdc2b1b64584db75cf5c7e5dbc85f5d3b241ca94cf188423a098aac942e365a002f7d021941a15780587ba5228d6413c6
|
7
|
+
data.tar.gz: 89e1324ad76a38e5fe606fb91d655db0d2564c9903142814fda6a7fdd22ed502853d5fb72171d20804c9cfaf5c46307cf8fd51cad453821ecbe43052ff87fcc0
|
data/Gemfile
CHANGED
data/bin/ggem
CHANGED
data/ggem.gemspec
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
2
4
|
lib = File.expand_path("../lib", __FILE__)
|
3
5
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
6
|
require "ggem/version"
|
@@ -8,21 +10,22 @@ Gem::Specification.new do |gem|
|
|
8
10
|
gem.version = GGem::VERSION
|
9
11
|
gem.authors = ["Kelly Redding", "Collin Redding"]
|
10
12
|
gem.email = ["kelly@kellyredding.com", "collin.redding@me.com"]
|
11
|
-
gem.summary =
|
12
|
-
gem.description =
|
13
|
+
gem.summary = '"Juh Gem", baby! (a gem utility CLI)'
|
14
|
+
gem.description = '"Juh Gem", baby! (a gem utility CLI)'
|
13
15
|
gem.homepage = "http://github.com/redding/ggem"
|
14
16
|
gem.license = "MIT"
|
15
17
|
|
16
|
-
gem.files
|
18
|
+
gem.files = `git ls-files | grep "^[^.]"`.split($INPUT_RECORD_SEPARATOR)
|
19
|
+
|
17
20
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
18
21
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
22
|
gem.require_paths = ["lib"]
|
20
23
|
|
21
24
|
gem.required_ruby_version = "~> 2.5"
|
22
25
|
|
23
|
-
gem.add_development_dependency("
|
24
|
-
|
25
|
-
gem.add_dependency("much-plugin", ["~> 0.2.2"])
|
26
|
-
gem.add_dependency("scmd", ["~> 3.0.3"])
|
26
|
+
gem.add_development_dependency("much-style-guide", ["~> 0.6.0"])
|
27
|
+
gem.add_development_dependency("assert", ["~> 2.19.4"])
|
27
28
|
|
29
|
+
gem.add_dependency("much-mixin", ["~> 0.2.4"])
|
30
|
+
gem.add_dependency("scmd", ["~> 3.0.4"])
|
28
31
|
end
|
data/lib/ggem.rb
CHANGED
data/lib/ggem/cli.rb
CHANGED
@@ -1,8 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "ggem/version"
|
2
4
|
require "ggem/cli/clirb"
|
3
5
|
require "ggem/cli/commands"
|
4
6
|
|
5
7
|
module GGem; end
|
8
|
+
|
6
9
|
class GGem::CLI
|
7
10
|
COMMANDS = CommandSet.new{ |unknown| InvalidCommand.new(unknown) }.tap do |c|
|
8
11
|
c.add(GenerateCommand, "generate", "g")
|
@@ -14,7 +17,7 @@ class GGem::CLI
|
|
14
17
|
end
|
15
18
|
|
16
19
|
def self.run(args)
|
17
|
-
|
20
|
+
new.run(args)
|
18
21
|
end
|
19
22
|
|
20
23
|
def initialize(kernel = nil, stdout = nil, stderr = nil)
|
@@ -32,16 +35,16 @@ class GGem::CLI
|
|
32
35
|
@stdout.puts cmd.help
|
33
36
|
rescue CLIRB::VersionExit
|
34
37
|
@stdout.puts GGem::VERSION
|
35
|
-
rescue CLIRB::Error, ArgumentError, InvalidCommandError =>
|
36
|
-
display_debug(
|
37
|
-
@stderr.puts "#{
|
38
|
+
rescue CLIRB::Error, ArgumentError, InvalidCommandError => ex
|
39
|
+
display_debug(ex)
|
40
|
+
@stderr.puts "#{ex.message}\n\n"
|
38
41
|
@stdout.puts cmd.help
|
39
42
|
@kernel.exit 1
|
40
43
|
rescue CommandExitError
|
41
44
|
@kernel.exit 1
|
42
|
-
rescue
|
43
|
-
@stderr.puts "#{
|
44
|
-
@stderr.puts
|
45
|
+
rescue => ex
|
46
|
+
@stderr.puts "#{ex.class}: #{ex.message}"
|
47
|
+
@stderr.puts ex.backtrace.join("\n")
|
45
48
|
@kernel.exit 1
|
46
49
|
end
|
47
50
|
@kernel.exit 0
|
data/lib/ggem/cli/clirb.rb
CHANGED
data/lib/ggem/cli/commands.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "ggem/cli/clirb"
|
2
|
-
require "much-
|
4
|
+
require "much-mixin"
|
3
5
|
|
4
6
|
module GGem; end
|
7
|
+
|
5
8
|
class GGem::CLI
|
6
9
|
InvalidCommandError = Class.new(ArgumentError)
|
7
10
|
CommandExitError = Class.new(RuntimeError)
|
@@ -14,12 +17,14 @@ class GGem::CLI
|
|
14
17
|
@clirb = CLIRB.new
|
15
18
|
end
|
16
19
|
|
17
|
-
def new
|
20
|
+
def new
|
21
|
+
self
|
22
|
+
end
|
18
23
|
|
19
24
|
def run(argv)
|
20
25
|
@clirb.parse!([@name, argv].flatten.compact)
|
21
26
|
raise CLIRB::HelpExit if @name.to_s.empty?
|
22
|
-
raise InvalidCommandError, "`#{
|
27
|
+
raise InvalidCommandError, "`#{name}` is not a command."
|
23
28
|
end
|
24
29
|
|
25
30
|
def help
|
@@ -31,14 +36,16 @@ class GGem::CLI
|
|
31
36
|
end
|
32
37
|
|
33
38
|
module ValidCommand
|
34
|
-
include
|
39
|
+
include MuchMixin
|
35
40
|
|
36
|
-
|
41
|
+
mixin_instance_methods do
|
37
42
|
def initialize(&clirb_build)
|
38
43
|
@clirb = CLIRB.new(&clirb_build)
|
39
44
|
end
|
40
45
|
|
41
|
-
def clirb
|
46
|
+
def clirb
|
47
|
+
@clirb
|
48
|
+
end
|
42
49
|
|
43
50
|
def run(argv, stdout = nil, stderr = nil)
|
44
51
|
@clirb.parse!(argv)
|
@@ -53,9 +60,9 @@ class GGem::CLI
|
|
53
60
|
end
|
54
61
|
|
55
62
|
module NotifyCmdCommand
|
56
|
-
include
|
63
|
+
include MuchMixin
|
57
64
|
|
58
|
-
|
65
|
+
mixin_instance_methods do
|
59
66
|
private
|
60
67
|
|
61
68
|
def notify(success_msg, &cmd_block)
|
@@ -64,7 +71,7 @@ class GGem::CLI
|
|
64
71
|
end
|
65
72
|
|
66
73
|
def cmd(&cmd_block)
|
67
|
-
cmd,
|
74
|
+
cmd, _status, output = cmd_block.call
|
68
75
|
if ENV["DEBUG"]
|
69
76
|
@stdout.puts cmd
|
70
77
|
@stdout.puts output
|
@@ -74,14 +81,14 @@ class GGem::CLI
|
|
74
81
|
end
|
75
82
|
|
76
83
|
module GitRepoCommand
|
77
|
-
include
|
84
|
+
include MuchMixin
|
78
85
|
|
79
|
-
|
86
|
+
mixin_included do
|
80
87
|
include ValidCommand
|
81
88
|
include NotifyCmdCommand
|
82
89
|
end
|
83
90
|
|
84
|
-
|
91
|
+
mixin_instance_methods do
|
85
92
|
def initialize(*args)
|
86
93
|
super
|
87
94
|
|
@@ -94,8 +101,8 @@ class GGem::CLI
|
|
94
101
|
def notify(*args, &block)
|
95
102
|
begin
|
96
103
|
super
|
97
|
-
rescue GGem::GitRepo::CmdError =>
|
98
|
-
@stderr.puts
|
104
|
+
rescue GGem::GitRepo::CmdError => ex
|
105
|
+
@stderr.puts ex.message
|
99
106
|
raise CommandExitError
|
100
107
|
end
|
101
108
|
end
|
@@ -112,9 +119,9 @@ class GGem::CLI
|
|
112
119
|
require "ggem/gem"
|
113
120
|
path = GGem::Gem.new(Dir.pwd, @clirb.args.first).save!.path
|
114
121
|
@stdout.puts "created gem in #{path}"
|
115
|
-
rescue GGem::Gem::NoNameError =>
|
122
|
+
rescue GGem::Gem::NoNameError => ex
|
116
123
|
error = ArgumentError.new("GEM-NAME must be provided")
|
117
|
-
error.set_backtrace(
|
124
|
+
error.set_backtrace(ex.backtrace)
|
118
125
|
raise error
|
119
126
|
end
|
120
127
|
|
@@ -130,28 +137,28 @@ class GGem::CLI
|
|
130
137
|
"Usage: ggem generate [options] GEM-NAME\n\n" \
|
131
138
|
"Options: #{@clirb}\n" \
|
132
139
|
"Description:\n" \
|
133
|
-
" #{
|
140
|
+
" #{summary}"
|
134
141
|
end
|
135
142
|
end
|
136
143
|
|
137
144
|
module GemspecCommand
|
138
|
-
include
|
145
|
+
include MuchMixin
|
139
146
|
|
140
|
-
|
147
|
+
mixin_included do
|
141
148
|
include ValidCommand
|
142
149
|
include NotifyCmdCommand
|
143
150
|
end
|
144
151
|
|
145
|
-
|
152
|
+
mixin_instance_methods do
|
146
153
|
def initialize(*args)
|
147
154
|
super
|
148
155
|
|
149
156
|
require "ggem/gemspec"
|
150
157
|
begin
|
151
158
|
@spec = GGem::Gemspec.new(Dir.pwd)
|
152
|
-
rescue GGem::Gemspec::NotFoundError =>
|
159
|
+
rescue GGem::Gemspec::NotFoundError => ex
|
153
160
|
error = ArgumentError.new("There are no gemspecs at #{Dir.pwd}")
|
154
|
-
error.set_backtrace(
|
161
|
+
error.set_backtrace(ex.backtrace)
|
155
162
|
raise error
|
156
163
|
end
|
157
164
|
end
|
@@ -161,8 +168,8 @@ class GGem::CLI
|
|
161
168
|
def notify(*args, &block)
|
162
169
|
begin
|
163
170
|
super
|
164
|
-
rescue GGem::Gemspec::CmdError =>
|
165
|
-
@stderr.puts
|
171
|
+
rescue GGem::Gemspec::CmdError => ex
|
172
|
+
@stderr.puts ex.message
|
166
173
|
raise CommandExitError
|
167
174
|
end
|
168
175
|
end
|
@@ -188,7 +195,7 @@ class GGem::CLI
|
|
188
195
|
"Usage: ggem build [options]\n\n" \
|
189
196
|
"Options: #{@clirb}\n" \
|
190
197
|
"Description:\n" \
|
191
|
-
" #{
|
198
|
+
" #{summary}"
|
192
199
|
end
|
193
200
|
end
|
194
201
|
|
@@ -217,7 +224,7 @@ class GGem::CLI
|
|
217
224
|
"Usage: ggem install [options]\n\n" \
|
218
225
|
"Options: #{@clirb}\n" \
|
219
226
|
"Description:\n" \
|
220
|
-
" #{
|
227
|
+
" #{summary}"
|
221
228
|
end
|
222
229
|
end
|
223
230
|
|
@@ -247,22 +254,22 @@ class GGem::CLI
|
|
247
254
|
"Usage: ggem push [options]\n\n" \
|
248
255
|
"Options: #{@clirb}\n" \
|
249
256
|
"Description:\n" \
|
250
|
-
" #{
|
257
|
+
" #{summary}"
|
251
258
|
end
|
252
259
|
end
|
253
260
|
|
254
261
|
module ForceTagOptionCommand
|
255
|
-
include
|
262
|
+
include MuchMixin
|
256
263
|
|
257
|
-
|
264
|
+
mixin_included do
|
258
265
|
include ValidCommand
|
259
266
|
end
|
260
267
|
|
261
|
-
|
268
|
+
mixin_instance_methods do
|
262
269
|
def initialize
|
263
270
|
super do
|
264
271
|
option "force-tag", "force tagging even with uncommitted files", {
|
265
|
-
:
|
272
|
+
abbrev: "f",
|
266
273
|
}
|
267
274
|
end
|
268
275
|
end
|
@@ -280,9 +287,9 @@ class GGem::CLI
|
|
280
287
|
begin
|
281
288
|
cmd{ @repo.run_validate_clean_cmd }
|
282
289
|
cmd{ @repo.run_validate_committed_cmd }
|
283
|
-
rescue GGem::GitRepo::CmdError
|
290
|
+
rescue GGem::GitRepo::CmdError
|
284
291
|
@stderr.puts "There are files that need to be committed first."
|
285
|
-
if
|
292
|
+
if clirb.opts["force-tag"]
|
286
293
|
@stderr.puts "Forcing tag anyway..."
|
287
294
|
else
|
288
295
|
raise CommandExitError
|
@@ -301,8 +308,8 @@ class GGem::CLI
|
|
301
308
|
end
|
302
309
|
|
303
310
|
@stdout.puts "Pushed git commits and tags."
|
304
|
-
rescue GGem::GitRepo::CmdError =>
|
305
|
-
@stderr.puts
|
311
|
+
rescue GGem::GitRepo::CmdError => ex
|
312
|
+
@stderr.puts ex.message
|
306
313
|
raise CommandExitError
|
307
314
|
end
|
308
315
|
|
@@ -314,7 +321,7 @@ class GGem::CLI
|
|
314
321
|
"Usage: ggem tag [options]\n\n" \
|
315
322
|
"Options: #{@clirb}\n" \
|
316
323
|
"Description:\n" \
|
317
|
-
" #{
|
324
|
+
" #{summary}"
|
318
325
|
end
|
319
326
|
end
|
320
327
|
|
@@ -330,7 +337,7 @@ class GGem::CLI
|
|
330
337
|
|
331
338
|
def run(argv, *args)
|
332
339
|
super
|
333
|
-
@tag_command.run(
|
340
|
+
@tag_command.run(clirb.opts["force-tag"] ? ["--force-tag"] : [])
|
334
341
|
@push_command.run([])
|
335
342
|
end
|
336
343
|
|
@@ -343,14 +350,14 @@ class GGem::CLI
|
|
343
350
|
"Usage: ggem release [options]\n\n" \
|
344
351
|
"Options: #{@clirb}\n" \
|
345
352
|
"Description:\n" \
|
346
|
-
" #{
|
353
|
+
" #{summary}\n" \
|
347
354
|
" (macro for running `ggem tag && ggem push`)"
|
348
355
|
end
|
349
356
|
end
|
350
357
|
|
351
358
|
class CommandSet
|
352
359
|
def initialize(&unknown_cmd_block)
|
353
|
-
@lookup = Hash.new{ |
|
360
|
+
@lookup = Hash.new{ |_h, k| unknown_cmd_block.call(k) }
|
354
361
|
@names = []
|
355
362
|
@aliases = {}
|
356
363
|
@summaries = {}
|
@@ -359,7 +366,7 @@ class GGem::CLI
|
|
359
366
|
def add(klass, name, *aliases)
|
360
367
|
begin
|
361
368
|
cmd = klass.new
|
362
|
-
rescue
|
369
|
+
rescue
|
363
370
|
# don't add any commands you can't init
|
364
371
|
else
|
365
372
|
([name] + aliases).each{ |n| @lookup[n] = cmd }
|
@@ -386,12 +393,13 @@ class GGem::CLI
|
|
386
393
|
end
|
387
394
|
|
388
395
|
def to_s
|
389
|
-
max_name_size = @names.map
|
390
|
-
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
|
391
398
|
|
392
|
-
@to_s ||= @names.map
|
393
|
-
"#{n.ljust(max_name_size)} #{@aliases[n].ljust(max_alias_size)}
|
394
|
-
|
399
|
+
@to_s ||= @names.map{ |n|
|
400
|
+
"#{n.ljust(max_name_size)} #{@aliases[n].ljust(max_alias_size)} "\
|
401
|
+
"#{@summaries[n]}"
|
402
|
+
}.join("\n")
|
395
403
|
end
|
396
404
|
end
|
397
405
|
end
|
data/lib/ggem/gem.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "fileutils"
|
2
4
|
require "ggem/template"
|
3
5
|
|
4
6
|
module GGem; end
|
7
|
+
|
5
8
|
class GGem::Gem
|
6
9
|
NoNameError = Class.new(ArgumentError)
|
7
10
|
|
@@ -28,13 +31,13 @@ class GGem::Gem
|
|
28
31
|
def module_name
|
29
32
|
transforms = {
|
30
33
|
"_" => "",
|
31
|
-
"-" => ""
|
34
|
+
"-" => "",
|
32
35
|
}
|
33
|
-
@module_name ||= transform_name(transforms
|
36
|
+
@module_name ||= transform_name(transforms, &:capitalize)
|
34
37
|
end
|
35
38
|
|
36
39
|
def ruby_name
|
37
|
-
@ruby_name ||= transform_name
|
40
|
+
@ruby_name ||= transform_name(&:downcase)
|
38
41
|
end
|
39
42
|
|
40
43
|
private
|
@@ -42,15 +45,15 @@ class GGem::Gem
|
|
42
45
|
def normalize_name(name)
|
43
46
|
und_camelcs = [/([A-Z])([a-z])/, '_\1\2']
|
44
47
|
rm_dup_und = [/_+/, "_"]
|
45
|
-
rm_lead_und = [/^_/, ""
|
48
|
+
rm_lead_und = [/^_/, ""]
|
46
49
|
name.gsub(*und_camelcs).gsub(*rm_dup_und).sub(*rm_lead_und).downcase
|
47
50
|
end
|
48
51
|
|
49
52
|
def transform_name(conditions = {}, &block)
|
50
|
-
n = (block ? block.call(
|
53
|
+
n = (block ? block.call(name) : name)
|
51
54
|
conditions.each do |on, glue|
|
52
55
|
if (a = n.split(on)).size > 1
|
53
|
-
n = a.map{ |part| block
|
56
|
+
n = a.map{ |part| block&.call(part) }.join(glue)
|
54
57
|
end
|
55
58
|
end
|
56
59
|
n
|