ggem 1.9.0 → 1.9.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +4 -2
- data/README.md +0 -3
- data/bin/ggem +1 -0
- data/ggem.gemspec +5 -4
- data/lib/ggem.rb +2 -0
- data/lib/ggem/cli.rb +47 -50
- data/lib/ggem/cli/clirb.rb +46 -48
- data/lib/ggem/cli/commands.rb +8 -40
- data/lib/ggem/gem.rb +43 -41
- data/lib/ggem/gemspec.rb +61 -64
- data/lib/ggem/git_repo.rb +39 -42
- data/lib/ggem/template.rb +52 -57
- data/lib/ggem/template_file/Gemfile.erb +5 -1
- data/lib/ggem/template_file/README.md.erb +3 -3
- data/lib/ggem/template_file/gemspec.erb +10 -6
- data/lib/ggem/template_file/lib.rb.erb +4 -2
- data/lib/ggem/template_file/lib_version.rb.erb +3 -1
- data/lib/ggem/template_file/ruby-version.erb +1 -0
- data/lib/ggem/template_file/test_helper.rb.erb +6 -4
- data/lib/ggem/template_file/test_support_factory.rb.erb +2 -1
- data/lib/ggem/version.rb +3 -1
- data/log/{.gitkeep → .keep} +0 -0
- data/test/helper.rb +6 -4
- data/test/support/cmd_tests_helpers.rb +35 -38
- data/test/support/factory.rb +2 -1
- data/test/support/gem1/gem1.gemspec +2 -0
- data/test/support/gem2/gem2.gemspec +2 -0
- data/test/support/name_set.rb +54 -57
- data/test/system/ggem_tests.rb +2 -5
- data/test/unit/cli_tests.rb +2 -31
- data/test/unit/gem_tests.rb +3 -5
- data/test/unit/gemspec_tests.rb +3 -8
- data/test/unit/git_repo_tests.rb +3 -12
- metadata +11 -12
- data/lib/ggem/template_file/circleci_config.yml.erb +0 -82
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58d90e351c533deb56deb2c166b2f1bf1952476bf26b152e2f03d9dab41dfadb
|
4
|
+
data.tar.gz: 385e2623bc98636318662f09b8868e450208278e3142fce4e681b55488bf4f34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c70525edbbd47ba4e679d136a49ed5d9fd5a21c637f7350b94675d6541dc2759ff9ff72c3ff1fb1c32341138fc96325bde64fb259c2b136feb7651bfe81b9ba3
|
7
|
+
data.tar.gz: 134e0f59d5c2d27ad5363bda4705f68f8cb0a427967c49541a8bb4b8b00049897265e46798991b151c1649f515e511a1bc75e1ed3e1853e279ad633a88fa3fbc
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -58,9 +58,6 @@ The `generate` command creates a folder and files for developing, testing, and r
|
|
58
58
|
* adds `TODO` entries in files where user input is needed
|
59
59
|
* source control using [Git](https://git-scm.com/)
|
60
60
|
* test using [Assert](https://github.com/redding/assert)
|
61
|
-
* CI with CircleCI
|
62
|
-
* see `.circleci/config.yml`
|
63
|
-
* need to replace `/todo_org_name` with the gem's org name (ie `/redding`)
|
64
61
|
|
65
62
|
You can also call this command using the `g` alias: `ggem g -h`.
|
66
63
|
|
data/bin/ggem
CHANGED
data/ggem.gemspec
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# -*- encoding: utf-8 -*-
|
2
4
|
lib = File.expand_path("../lib", __FILE__)
|
3
5
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
@@ -18,11 +20,10 @@ Gem::Specification.new do |gem|
|
|
18
20
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
21
|
gem.require_paths = ["lib"]
|
20
22
|
|
21
|
-
gem.required_ruby_version =
|
23
|
+
gem.required_ruby_version = "~> 2.5"
|
22
24
|
|
23
|
-
gem.add_development_dependency("assert", ["~> 2.
|
25
|
+
gem.add_development_dependency("assert", ["~> 2.19.2"])
|
24
26
|
|
25
|
-
gem.add_dependency("much-plugin", ["~> 0.2.
|
27
|
+
gem.add_dependency("much-plugin", ["~> 0.2.3"])
|
26
28
|
gem.add_dependency("scmd", ["~> 3.0.3"])
|
27
|
-
|
28
29
|
end
|
data/lib/ggem.rb
CHANGED
data/lib/ggem/cli.rb
CHANGED
@@ -1,63 +1,60 @@
|
|
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
|
-
module GGem
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
c.add(ReleaseCommand, "release", "r")
|
16
|
-
end
|
7
|
+
module GGem; end
|
8
|
+
class GGem::CLI
|
9
|
+
COMMANDS = CommandSet.new{ |unknown| InvalidCommand.new(unknown) }.tap do |c|
|
10
|
+
c.add(GenerateCommand, "generate", "g")
|
11
|
+
c.add(BuildCommand, "build", "b")
|
12
|
+
c.add(InstallCommand, "install", "i")
|
13
|
+
c.add(PushCommand, "push", "p")
|
14
|
+
c.add(TagCommand, "tag", "t")
|
15
|
+
c.add(ReleaseCommand, "release", "r")
|
16
|
+
end
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
def self.run(args)
|
19
|
+
self.new.run(args)
|
20
|
+
end
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
def initialize(kernel = nil, stdout = nil, stderr = nil)
|
23
|
+
@kernel = kernel || Kernel
|
24
|
+
@stdout = stdout || $stdout
|
25
|
+
@stderr = stderr || $stderr
|
26
|
+
end
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
end
|
49
|
-
@kernel.exit 0
|
28
|
+
def run(args)
|
29
|
+
begin
|
30
|
+
cmd_name = args.shift
|
31
|
+
cmd = COMMANDS[cmd_name]
|
32
|
+
cmd.run(args)
|
33
|
+
rescue CLIRB::HelpExit
|
34
|
+
@stdout.puts cmd.help
|
35
|
+
rescue CLIRB::VersionExit
|
36
|
+
@stdout.puts GGem::VERSION
|
37
|
+
rescue CLIRB::Error, ArgumentError, InvalidCommandError => exception
|
38
|
+
display_debug(exception)
|
39
|
+
@stderr.puts "#{exception.message}\n\n"
|
40
|
+
@stdout.puts cmd.help
|
41
|
+
@kernel.exit 1
|
42
|
+
rescue CommandExitError
|
43
|
+
@kernel.exit 1
|
44
|
+
rescue StandardError => exception
|
45
|
+
@stderr.puts "#{exception.class}: #{exception.message}"
|
46
|
+
@stderr.puts exception.backtrace.join("\n")
|
47
|
+
@kernel.exit 1
|
50
48
|
end
|
49
|
+
@kernel.exit 0
|
50
|
+
end
|
51
51
|
|
52
|
-
|
52
|
+
private
|
53
53
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
end
|
54
|
+
def display_debug(exception)
|
55
|
+
if ENV["DEBUG"]
|
56
|
+
@stderr.puts "#{exception.class}: #{exception.message}"
|
57
|
+
@stderr.puts exception.backtrace.join("\n")
|
59
58
|
end
|
60
|
-
|
61
59
|
end
|
62
|
-
|
63
60
|
end
|
data/lib/ggem/cli/clirb.rb
CHANGED
@@ -1,59 +1,57 @@
|
|
1
|
-
|
2
|
-
class GGem::CLI
|
3
|
-
|
4
|
-
class CLIRB # Version 1.0.0, https://github.com/redding/cli.rb
|
5
|
-
Error = Class.new(RuntimeError);
|
6
|
-
HelpExit = Class.new(RuntimeError); VersionExit = Class.new(RuntimeError)
|
7
|
-
attr_reader :argv, :args, :opts, :data
|
1
|
+
# frozen_string_literal: true
|
8
2
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
3
|
+
module GGem; end
|
4
|
+
class GGem::CLI; end
|
5
|
+
class GGem::CLI::CLIRB # Version 1.1.0, https://github.com/redding/cli.rb
|
6
|
+
Error = Class.new(RuntimeError);
|
7
|
+
HelpExit = Class.new(RuntimeError); VersionExit = Class.new(RuntimeError)
|
8
|
+
attr_reader :argv, :args, :opts, :data
|
9
|
+
|
10
|
+
def initialize(&block)
|
11
|
+
@options = []; instance_eval(&block) if block
|
12
|
+
require "optparse"
|
13
|
+
@data, @args, @opts = [], [], {}; @parser = OptionParser.new do |p|
|
14
|
+
p.banner = ""; @options.each do |o|
|
15
|
+
@opts[o.name] = o.value; p.on(*o.parser_args){ |v| @opts[o.name] = v }
|
18
16
|
end
|
17
|
+
p.on_tail("--version", ""){ |v| raise VersionExit, v.to_s }
|
18
|
+
p.on_tail("--help", ""){ |v| raise HelpExit, v.to_s }
|
19
19
|
end
|
20
|
+
end
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
class Option
|
34
|
-
attr_reader :name, :opt_name, :desc, :abbrev, :value, :klass, :parser_args
|
22
|
+
def option(*args); @options << Option.new(*args); end
|
23
|
+
def parse!(argv)
|
24
|
+
@args = (argv || []).dup.tap do |args_list|
|
25
|
+
begin; @parser.parse!(args_list)
|
26
|
+
rescue OptionParser::ParseError => err; raise Error, err.message; end
|
27
|
+
end; @data = @args + [@opts]
|
28
|
+
end
|
29
|
+
def to_s; @parser.to_s; end
|
30
|
+
def inspect
|
31
|
+
"#<#{self.class}:#{"0x0%x" % (object_id << 1)} @data=#{@data.inspect}>"
|
32
|
+
end
|
35
33
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
34
|
+
class Option
|
35
|
+
attr_reader :name, :opt_name, :desc, :abbrev, :value, :klass, :parser_args
|
36
|
+
|
37
|
+
def initialize(name, desc = nil, abbrev: nil, value: nil)
|
38
|
+
@name, @desc = name, desc || ""
|
39
|
+
@opt_name, @abbrev = parse_name_values(name, abbrev)
|
40
|
+
@value, @klass = gvalinfo(value)
|
41
|
+
@parser_args = if [TrueClass, FalseClass, NilClass].include?(@klass)
|
42
|
+
["-#{@abbrev}", "--[no-]#{@opt_name}", @desc]
|
43
|
+
else
|
44
|
+
["-#{@abbrev}", "--#{@opt_name} VALUE", @klass, @desc]
|
45
45
|
end
|
46
|
+
end
|
46
47
|
|
47
|
-
|
48
|
+
private
|
48
49
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
end
|
54
|
-
def gvalinfo(v); v.kind_of?(Class) ? [nil,gklass(v)] : [v,gklass(v.class)]; end
|
55
|
-
def gklass(k); k == Fixnum ? Integer : k; end
|
50
|
+
def parse_name_values(name, custom_abbrev)
|
51
|
+
[ (processed_name = name.to_s.strip.downcase).gsub("_", "-"),
|
52
|
+
custom_abbrev || processed_name.gsub(/[^a-z]/, "").chars.first || "a"
|
53
|
+
]
|
56
54
|
end
|
55
|
+
def gvalinfo(v); v.kind_of?(Class) ? [nil,v] : [v,v.class]; end
|
57
56
|
end
|
58
|
-
|
59
57
|
end
|
data/lib/ggem/cli/commands.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "ggem/cli/clirb"
|
2
4
|
require "much-plugin"
|
3
5
|
|
4
6
|
module GGem; end
|
5
7
|
class GGem::CLI
|
6
|
-
|
7
8
|
InvalidCommandError = Class.new(ArgumentError)
|
8
9
|
CommandExitError = Class.new(RuntimeError)
|
9
10
|
|
10
11
|
class InvalidCommand
|
11
|
-
|
12
12
|
attr_reader :name, :clirb
|
13
13
|
|
14
14
|
def initialize(name)
|
@@ -30,18 +30,12 @@ class GGem::CLI
|
|
30
30
|
"Commands:\n" \
|
31
31
|
"#{COMMANDS.to_s.split("\n").map{ |l| " #{l}" }.join("\n")}\n"
|
32
32
|
end
|
33
|
-
|
34
33
|
end
|
35
34
|
|
36
35
|
module ValidCommand
|
37
36
|
include MuchPlugin
|
38
37
|
|
39
|
-
|
40
|
-
include InstanceMethods
|
41
|
-
end
|
42
|
-
|
43
|
-
module InstanceMethods
|
44
|
-
|
38
|
+
plugin_instance_methods do
|
45
39
|
def initialize(&clirb_build)
|
46
40
|
@clirb = CLIRB.new(&clirb_build)
|
47
41
|
end
|
@@ -57,20 +51,13 @@ class GGem::CLI
|
|
57
51
|
def summary
|
58
52
|
""
|
59
53
|
end
|
60
|
-
|
61
54
|
end
|
62
|
-
|
63
55
|
end
|
64
56
|
|
65
57
|
module NotifyCmdCommand
|
66
58
|
include MuchPlugin
|
67
59
|
|
68
|
-
|
69
|
-
include InstanceMethods
|
70
|
-
end
|
71
|
-
|
72
|
-
module InstanceMethods
|
73
|
-
|
60
|
+
plugin_instance_methods do
|
74
61
|
private
|
75
62
|
|
76
63
|
def notify(success_msg, &cmd_block)
|
@@ -85,9 +72,7 @@ class GGem::CLI
|
|
85
72
|
@stdout.puts output
|
86
73
|
end
|
87
74
|
end
|
88
|
-
|
89
75
|
end
|
90
|
-
|
91
76
|
end
|
92
77
|
|
93
78
|
module GitRepoCommand
|
@@ -96,10 +81,9 @@ class GGem::CLI
|
|
96
81
|
plugin_included do
|
97
82
|
include ValidCommand
|
98
83
|
include NotifyCmdCommand
|
99
|
-
include InstanceMethods
|
100
84
|
end
|
101
85
|
|
102
|
-
|
86
|
+
plugin_instance_methods do
|
103
87
|
def initialize(*args)
|
104
88
|
super
|
105
89
|
|
@@ -117,7 +101,6 @@ class GGem::CLI
|
|
117
101
|
raise CommandExitError
|
118
102
|
end
|
119
103
|
end
|
120
|
-
|
121
104
|
end
|
122
105
|
end
|
123
106
|
|
@@ -151,7 +134,6 @@ class GGem::CLI
|
|
151
134
|
"Description:\n" \
|
152
135
|
" #{self.summary}"
|
153
136
|
end
|
154
|
-
|
155
137
|
end
|
156
138
|
|
157
139
|
module GemspecCommand
|
@@ -160,10 +142,9 @@ class GGem::CLI
|
|
160
142
|
plugin_included do
|
161
143
|
include ValidCommand
|
162
144
|
include NotifyCmdCommand
|
163
|
-
include InstanceMethods
|
164
145
|
end
|
165
146
|
|
166
|
-
|
147
|
+
plugin_instance_methods do
|
167
148
|
def initialize(*args)
|
168
149
|
super
|
169
150
|
|
@@ -187,7 +168,6 @@ class GGem::CLI
|
|
187
168
|
raise CommandExitError
|
188
169
|
end
|
189
170
|
end
|
190
|
-
|
191
171
|
end
|
192
172
|
end
|
193
173
|
|
@@ -212,7 +192,6 @@ class GGem::CLI
|
|
212
192
|
"Description:\n" \
|
213
193
|
" #{self.summary}"
|
214
194
|
end
|
215
|
-
|
216
195
|
end
|
217
196
|
|
218
197
|
class InstallCommand
|
@@ -242,7 +221,6 @@ class GGem::CLI
|
|
242
221
|
"Description:\n" \
|
243
222
|
" #{self.summary}"
|
244
223
|
end
|
245
|
-
|
246
224
|
end
|
247
225
|
|
248
226
|
class PushCommand
|
@@ -273,7 +251,6 @@ class GGem::CLI
|
|
273
251
|
"Description:\n" \
|
274
252
|
" #{self.summary}"
|
275
253
|
end
|
276
|
-
|
277
254
|
end
|
278
255
|
|
279
256
|
module ForceTagOptionCommand
|
@@ -281,11 +258,9 @@ class GGem::CLI
|
|
281
258
|
|
282
259
|
plugin_included do
|
283
260
|
include ValidCommand
|
284
|
-
include InstanceMethods
|
285
261
|
end
|
286
262
|
|
287
|
-
|
288
|
-
|
263
|
+
plugin_instance_methods do
|
289
264
|
def initialize
|
290
265
|
super do
|
291
266
|
option "force-tag", "force tagging even with uncommitted files", {
|
@@ -293,9 +268,7 @@ class GGem::CLI
|
|
293
268
|
}
|
294
269
|
end
|
295
270
|
end
|
296
|
-
|
297
271
|
end
|
298
|
-
|
299
272
|
end
|
300
273
|
|
301
274
|
class TagCommand
|
@@ -345,7 +318,6 @@ class GGem::CLI
|
|
345
318
|
"Description:\n" \
|
346
319
|
" #{self.summary}"
|
347
320
|
end
|
348
|
-
|
349
321
|
end
|
350
322
|
|
351
323
|
class ReleaseCommand
|
@@ -376,11 +348,9 @@ class GGem::CLI
|
|
376
348
|
" #{self.summary}\n" \
|
377
349
|
" (macro for running `ggem tag && ggem push`)"
|
378
350
|
end
|
379
|
-
|
380
351
|
end
|
381
352
|
|
382
353
|
class CommandSet
|
383
|
-
|
384
354
|
def initialize(&unknown_cmd_block)
|
385
355
|
@lookup = Hash.new{ |h,k| unknown_cmd_block.call(k) }
|
386
356
|
@names = []
|
@@ -392,7 +362,7 @@ class GGem::CLI
|
|
392
362
|
begin
|
393
363
|
cmd = klass.new
|
394
364
|
rescue StandardError => err
|
395
|
-
# don
|
365
|
+
# don't add any commands you can't init
|
396
366
|
else
|
397
367
|
([name] + aliases).each{ |n| @lookup[n] = cmd }
|
398
368
|
@to_s = nil
|
@@ -425,7 +395,5 @@ class GGem::CLI
|
|
425
395
|
"#{n.ljust(max_name_size)} #{@aliases[n].ljust(max_alias_size)} #{@summaries[n]}"
|
426
396
|
end.join("\n")
|
427
397
|
end
|
428
|
-
|
429
398
|
end
|
430
|
-
|
431
399
|
end
|