ggem 1.9.1 → 1.9.2

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: c2b2454ea3387abee594818c98c363e60a4583504ff889a682295100498f1a81
4
- data.tar.gz: 582a50960b9bd9d696d9817521274cd2d360575246413423d28f83eb7a1df795
3
+ metadata.gz: fe73b45d444a8f7ff488f19259fc7a0668c681db033d19f2eb1b221d004edac5
4
+ data.tar.gz: 5ea32d246eafec3af4fd01f17e6ed94c05c95b4a53a667d8966114cff59d387c
5
5
  SHA512:
6
- metadata.gz: 6900afe18a1a61ca1056aab174faa57bebfdb7eb943d2e3185e5e6c7913fc238a5070cb924e4b7823b81d09830c1535b3f4d473602e193a418bc73d1690b3c15
7
- data.tar.gz: 1dafa08bf81466d5469038cdea1b2dbf95115a38f79944623acbb4d2e5c9dc96e00defd6888a1fcbce3dd67b57db1bb0316d3a843aea293f42c6ccb89751154f
6
+ metadata.gz: acf33a27c2b503dc4d6233a3d6afb05dd34b86d326d19f9202b37aeb82b44cef1e70a901e140eff2a34528699e619f761c84caeabdc5029cb62f40227a026ac0
7
+ data.tar.gz: 00c64f8c24b4de4f2858994d59ff6b52b62474103e2865709a89bc62e48ae8a0d69b700bd967e669c04dd4b8ce24cda86c2f2c61707411370a97fd17776ba051
data/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- ruby '> 1.8'
3
+ ruby "~> 2.5"
4
4
 
5
5
  gemspec
6
6
 
7
- gem "pry", "~> 0.11.3"
7
+ gem "pry", "~> 0.12.2"
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
 
@@ -18,11 +18,11 @@ Gem::Specification.new do |gem|
18
18
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
19
  gem.require_paths = ["lib"]
20
20
 
21
- gem.required_ruby_version = '> 1.8'
21
+ gem.required_ruby_version = "~> 2.5"
22
22
 
23
- gem.add_development_dependency("assert", ["~> 2.17.0"])
23
+ gem.add_development_dependency("assert", ["~> 2.18.2"])
24
24
 
25
- gem.add_dependency("much-plugin", ["~> 0.2.0"])
25
+ gem.add_dependency("much-plugin", ["~> 0.2.2"])
26
26
  gem.add_dependency("scmd", ["~> 3.0.3"])
27
27
 
28
28
  end
@@ -2,62 +2,57 @@ require "ggem/version"
2
2
  require "ggem/cli/clirb"
3
3
  require "ggem/cli/commands"
4
4
 
5
- module GGem
6
-
7
- class CLI
8
-
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
5
+ module GGem; end
6
+ class GGem::CLI
7
+ COMMANDS = CommandSet.new{ |unknown| InvalidCommand.new(unknown) }.tap do |c|
8
+ c.add(GenerateCommand, "generate", "g")
9
+ c.add(BuildCommand, "build", "b")
10
+ c.add(InstallCommand, "install", "i")
11
+ c.add(PushCommand, "push", "p")
12
+ c.add(TagCommand, "tag", "t")
13
+ c.add(ReleaseCommand, "release", "r")
14
+ end
17
15
 
18
- def self.run(args)
19
- self.new.run(args)
20
- end
16
+ def self.run(args)
17
+ self.new.run(args)
18
+ end
21
19
 
22
- def initialize(kernel = nil, stdout = nil, stderr = nil)
23
- @kernel = kernel || Kernel
24
- @stdout = stdout || $stdout
25
- @stderr = stderr || $stderr
26
- end
20
+ def initialize(kernel = nil, stdout = nil, stderr = nil)
21
+ @kernel = kernel || Kernel
22
+ @stdout = stdout || $stdout
23
+ @stderr = stderr || $stderr
24
+ end
27
25
 
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
48
- end
49
- @kernel.exit 0
26
+ def run(args)
27
+ begin
28
+ cmd_name = args.shift
29
+ cmd = COMMANDS[cmd_name]
30
+ cmd.run(args)
31
+ rescue CLIRB::HelpExit
32
+ @stdout.puts cmd.help
33
+ rescue CLIRB::VersionExit
34
+ @stdout.puts GGem::VERSION
35
+ rescue CLIRB::Error, ArgumentError, InvalidCommandError => exception
36
+ display_debug(exception)
37
+ @stderr.puts "#{exception.message}\n\n"
38
+ @stdout.puts cmd.help
39
+ @kernel.exit 1
40
+ rescue CommandExitError
41
+ @kernel.exit 1
42
+ rescue StandardError => exception
43
+ @stderr.puts "#{exception.class}: #{exception.message}"
44
+ @stderr.puts exception.backtrace.join("\n")
45
+ @kernel.exit 1
50
46
  end
47
+ @kernel.exit 0
48
+ end
51
49
 
52
- private
50
+ private
53
51
 
54
- def display_debug(exception)
55
- if ENV["DEBUG"]
56
- @stderr.puts "#{exception.class}: #{exception.message}"
57
- @stderr.puts exception.backtrace.join("\n")
58
- end
52
+ def display_debug(exception)
53
+ if ENV["DEBUG"]
54
+ @stderr.puts "#{exception.class}: #{exception.message}"
55
+ @stderr.puts exception.backtrace.join("\n")
59
56
  end
60
-
61
57
  end
62
-
63
58
  end
@@ -1,59 +1,55 @@
1
1
  module GGem; end
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
8
-
9
- def initialize(&block)
10
- @options = []; instance_eval(&block) if block
11
- require "optparse"
12
- @data, @args, @opts = [], [], {}; @parser = OptionParser.new do |p|
13
- p.banner = ""; @options.each do |o|
14
- @opts[o.name] = o.value; p.on(*o.parser_args){ |v| @opts[o.name] = v }
15
- end
16
- p.on_tail("--version", ""){ |v| raise VersionExit, v.to_s }
17
- p.on_tail("--help", ""){ |v| raise HelpExit, v.to_s }
2
+ class GGem::CLI; end
3
+ class GGem::CLI::CLIRB # Version 1.1.0, https://github.com/redding/cli.rb
4
+ Error = Class.new(RuntimeError);
5
+ HelpExit = Class.new(RuntimeError); VersionExit = Class.new(RuntimeError)
6
+ attr_reader :argv, :args, :opts, :data
7
+
8
+ def initialize(&block)
9
+ @options = []; instance_eval(&block) if block
10
+ require "optparse"
11
+ @data, @args, @opts = [], [], {}; @parser = OptionParser.new do |p|
12
+ p.banner = ""; @options.each do |o|
13
+ @opts[o.name] = o.value; p.on(*o.parser_args){ |v| @opts[o.name] = v }
18
14
  end
15
+ p.on_tail("--version", ""){ |v| raise VersionExit, v.to_s }
16
+ p.on_tail("--help", ""){ |v| raise HelpExit, v.to_s }
19
17
  end
18
+ end
20
19
 
21
- def option(*args); @options << Option.new(*args); end
22
- def parse!(argv)
23
- @args = (argv || []).dup.tap do |args_list|
24
- begin; @parser.parse!(args_list)
25
- rescue OptionParser::ParseError => err; raise Error, err.message; end
26
- end; @data = @args + [@opts]
27
- end
28
- def to_s; @parser.to_s; end
29
- def inspect
30
- "#<#{self.class}:#{"0x0%x" % (object_id << 1)} @data=#{@data.inspect}>"
31
- end
32
-
33
- class Option
34
- attr_reader :name, :opt_name, :desc, :abbrev, :value, :klass, :parser_args
20
+ def option(*args); @options << Option.new(*args); end
21
+ def parse!(argv)
22
+ @args = (argv || []).dup.tap do |args_list|
23
+ begin; @parser.parse!(args_list)
24
+ rescue OptionParser::ParseError => err; raise Error, err.message; end
25
+ end; @data = @args + [@opts]
26
+ end
27
+ def to_s; @parser.to_s; end
28
+ def inspect
29
+ "#<#{self.class}:#{"0x0%x" % (object_id << 1)} @data=#{@data.inspect}>"
30
+ end
35
31
 
36
- def initialize(name, *args)
37
- settings, @desc = args.last.kind_of?(::Hash) ? args.pop : {}, args.pop || ""
38
- @name, @opt_name, @abbrev = parse_name_values(name, settings[:abbrev])
39
- @value, @klass = gvalinfo(settings[:value])
40
- @parser_args = if [TrueClass, FalseClass, NilClass].include?(@klass)
41
- ["-#{@abbrev}", "--[no-]#{@opt_name}", @desc]
42
- else
43
- ["-#{@abbrev}", "--#{@opt_name} #{@opt_name.upcase}", @klass, @desc]
44
- end
32
+ class Option
33
+ attr_reader :name, :opt_name, :desc, :abbrev, :value, :klass, :parser_args
34
+
35
+ def initialize(name, desc = nil, abbrev: nil, value: nil)
36
+ @name, @desc = name, desc || ""
37
+ @opt_name, @abbrev = parse_name_values(name, abbrev)
38
+ @value, @klass = gvalinfo(value)
39
+ @parser_args = if [TrueClass, FalseClass, NilClass].include?(@klass)
40
+ ["-#{@abbrev}", "--[no-]#{@opt_name}", @desc]
41
+ else
42
+ ["-#{@abbrev}", "--#{@opt_name} VALUE", @klass, @desc]
45
43
  end
44
+ end
46
45
 
47
- private
46
+ private
48
47
 
49
- def parse_name_values(name, custom_abbrev)
50
- [ (processed_name = name.to_s.strip.downcase), processed_name.gsub("_", "-"),
51
- custom_abbrev || processed_name.gsub(/[^a-z]/, "").chars.first || "a"
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
48
+ def parse_name_values(name, custom_abbrev)
49
+ [ (processed_name = name.to_s.strip.downcase).gsub("_", "-"),
50
+ custom_abbrev || processed_name.gsub(/[^a-z]/, "").chars.first || "a"
51
+ ]
56
52
  end
53
+ def gvalinfo(v); v.kind_of?(Class) ? [nil,v] : [v,v.class]; end
57
54
  end
58
-
59
55
  end
@@ -3,12 +3,10 @@ require "much-plugin"
3
3
 
4
4
  module GGem; end
5
5
  class GGem::CLI
6
-
7
6
  InvalidCommandError = Class.new(ArgumentError)
8
7
  CommandExitError = Class.new(RuntimeError)
9
8
 
10
9
  class InvalidCommand
11
-
12
10
  attr_reader :name, :clirb
13
11
 
14
12
  def initialize(name)
@@ -30,18 +28,12 @@ class GGem::CLI
30
28
  "Commands:\n" \
31
29
  "#{COMMANDS.to_s.split("\n").map{ |l| " #{l}" }.join("\n")}\n"
32
30
  end
33
-
34
31
  end
35
32
 
36
33
  module ValidCommand
37
34
  include MuchPlugin
38
35
 
39
- plugin_included do
40
- include InstanceMethods
41
- end
42
-
43
- module InstanceMethods
44
-
36
+ plugin_instance_methods do
45
37
  def initialize(&clirb_build)
46
38
  @clirb = CLIRB.new(&clirb_build)
47
39
  end
@@ -57,20 +49,13 @@ class GGem::CLI
57
49
  def summary
58
50
  ""
59
51
  end
60
-
61
52
  end
62
-
63
53
  end
64
54
 
65
55
  module NotifyCmdCommand
66
56
  include MuchPlugin
67
57
 
68
- plugin_included do
69
- include InstanceMethods
70
- end
71
-
72
- module InstanceMethods
73
-
58
+ plugin_instance_methods do
74
59
  private
75
60
 
76
61
  def notify(success_msg, &cmd_block)
@@ -85,9 +70,7 @@ class GGem::CLI
85
70
  @stdout.puts output
86
71
  end
87
72
  end
88
-
89
73
  end
90
-
91
74
  end
92
75
 
93
76
  module GitRepoCommand
@@ -96,10 +79,9 @@ class GGem::CLI
96
79
  plugin_included do
97
80
  include ValidCommand
98
81
  include NotifyCmdCommand
99
- include InstanceMethods
100
82
  end
101
83
 
102
- module InstanceMethods
84
+ plugin_instance_methods do
103
85
  def initialize(*args)
104
86
  super
105
87
 
@@ -117,7 +99,6 @@ class GGem::CLI
117
99
  raise CommandExitError
118
100
  end
119
101
  end
120
-
121
102
  end
122
103
  end
123
104
 
@@ -151,7 +132,6 @@ class GGem::CLI
151
132
  "Description:\n" \
152
133
  " #{self.summary}"
153
134
  end
154
-
155
135
  end
156
136
 
157
137
  module GemspecCommand
@@ -160,10 +140,9 @@ class GGem::CLI
160
140
  plugin_included do
161
141
  include ValidCommand
162
142
  include NotifyCmdCommand
163
- include InstanceMethods
164
143
  end
165
144
 
166
- module InstanceMethods
145
+ plugin_instance_methods do
167
146
  def initialize(*args)
168
147
  super
169
148
 
@@ -187,7 +166,6 @@ class GGem::CLI
187
166
  raise CommandExitError
188
167
  end
189
168
  end
190
-
191
169
  end
192
170
  end
193
171
 
@@ -212,7 +190,6 @@ class GGem::CLI
212
190
  "Description:\n" \
213
191
  " #{self.summary}"
214
192
  end
215
-
216
193
  end
217
194
 
218
195
  class InstallCommand
@@ -242,7 +219,6 @@ class GGem::CLI
242
219
  "Description:\n" \
243
220
  " #{self.summary}"
244
221
  end
245
-
246
222
  end
247
223
 
248
224
  class PushCommand
@@ -273,7 +249,6 @@ class GGem::CLI
273
249
  "Description:\n" \
274
250
  " #{self.summary}"
275
251
  end
276
-
277
252
  end
278
253
 
279
254
  module ForceTagOptionCommand
@@ -281,11 +256,9 @@ class GGem::CLI
281
256
 
282
257
  plugin_included do
283
258
  include ValidCommand
284
- include InstanceMethods
285
259
  end
286
260
 
287
- module InstanceMethods
288
-
261
+ plugin_instance_methods do
289
262
  def initialize
290
263
  super do
291
264
  option "force-tag", "force tagging even with uncommitted files", {
@@ -293,9 +266,7 @@ class GGem::CLI
293
266
  }
294
267
  end
295
268
  end
296
-
297
269
  end
298
-
299
270
  end
300
271
 
301
272
  class TagCommand
@@ -345,7 +316,6 @@ class GGem::CLI
345
316
  "Description:\n" \
346
317
  " #{self.summary}"
347
318
  end
348
-
349
319
  end
350
320
 
351
321
  class ReleaseCommand
@@ -376,11 +346,9 @@ class GGem::CLI
376
346
  " #{self.summary}\n" \
377
347
  " (macro for running `ggem tag && ggem push`)"
378
348
  end
379
-
380
349
  end
381
350
 
382
351
  class CommandSet
383
-
384
352
  def initialize(&unknown_cmd_block)
385
353
  @lookup = Hash.new{ |h,k| unknown_cmd_block.call(k) }
386
354
  @names = []
@@ -425,7 +393,5 @@ class GGem::CLI
425
393
  "#{n.ljust(max_name_size)} #{@aliases[n].ljust(max_alias_size)} #{@summaries[n]}"
426
394
  end.join("\n")
427
395
  end
428
-
429
396
  end
430
-
431
397
  end
@@ -1,58 +1,58 @@
1
1
  require "fileutils"
2
2
  require "ggem/template"
3
3
 
4
- module GGem
4
+ module GGem; end
5
+ class GGem::Gem
6
+ NoNameError = Class.new(ArgumentError)
5
7
 
6
- class Gem
8
+ attr_reader :root_path, :name
7
9
 
8
- attr_reader :root_path, :name
10
+ def initialize(path, name)
11
+ raise NoNameError if name.to_s.empty?
12
+ @root_path, self.name = path, name
13
+ end
9
14
 
10
- def initialize(path, name)
11
- raise NoNameError if name.to_s.empty?
12
- @root_path, self.name = path, name
13
- end
15
+ def save!
16
+ GGem::Template.new(self).save
17
+ self
18
+ end
14
19
 
15
- def save!
16
- Template.new(self).save
17
- self
18
- end
20
+ def path
21
+ File.join(@root_path, @name)
22
+ end
19
23
 
20
- def path; File.join(@root_path, @name); end
21
- def name=(name); @name = normalize_name(name); end
24
+ def name=(name)
25
+ @name = normalize_name(name)
26
+ end
22
27
 
23
- def module_name
24
- transforms = {
25
- "_" => "",
26
- "-" => ""
27
- }
28
- @module_name ||= transform_name(transforms){ |part| part.capitalize }
29
- end
28
+ def module_name
29
+ transforms = {
30
+ "_" => "",
31
+ "-" => ""
32
+ }
33
+ @module_name ||= transform_name(transforms){ |part| part.capitalize }
34
+ end
30
35
 
31
- def ruby_name
32
- @ruby_name ||= transform_name{ |part| part.downcase }
33
- end
36
+ def ruby_name
37
+ @ruby_name ||= transform_name{ |part| part.downcase }
38
+ end
34
39
 
35
- private
40
+ private
36
41
 
37
- def normalize_name(name)
38
- und_camelcs = [ /([A-Z])([a-z])/, '_\1\2' ]
39
- rm_dup_und = [ /_+/, "_" ]
40
- rm_lead_und = [ /^_/, "" ]
41
- name.gsub(*und_camelcs).gsub(*rm_dup_und).sub(*rm_lead_und).downcase
42
- end
42
+ def normalize_name(name)
43
+ und_camelcs = [/([A-Z])([a-z])/, '_\1\2']
44
+ rm_dup_und = [/_+/, "_"]
45
+ rm_lead_und = [/^_/, "" ]
46
+ name.gsub(*und_camelcs).gsub(*rm_dup_und).sub(*rm_lead_und).downcase
47
+ end
43
48
 
44
- def transform_name(conditions = {}, &block)
45
- n = (block ? block.call(self.name) : self.name)
46
- conditions.each do |on, glue|
47
- if (a = n.split(on)).size > 1
48
- n = a.map{ |part| block.call(part) if block }.join(glue)
49
- end
49
+ def transform_name(conditions = {}, &block)
50
+ n = (block ? block.call(self.name) : self.name)
51
+ conditions.each do |on, glue|
52
+ if (a = n.split(on)).size > 1
53
+ n = a.map{ |part| block.call(part) if block }.join(glue)
50
54
  end
51
- n
52
55
  end
53
-
54
- NoNameError = Class.new(ArgumentError)
55
-
56
+ n
56
57
  end
57
-
58
58
  end