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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bb8dc845b435566b7087e4965db63b2f7748a2dad1c71fc23d4a3723716d1a4d
4
- data.tar.gz: b6ec3468d1fa99ce0186ce9d2dbe80d22083c10f59ef323c264ef99f8e5c687a
3
+ metadata.gz: 58d90e351c533deb56deb2c166b2f1bf1952476bf26b152e2f03d9dab41dfadb
4
+ data.tar.gz: 385e2623bc98636318662f09b8868e450208278e3142fce4e681b55488bf4f34
5
5
  SHA512:
6
- metadata.gz: c2a6d656edc4b1fa4cd9522c15640653946acb3c4c8430e1c343c80ddc0794e41adad78d7f6270c399685917b1e9e151b9e7c1848c38cb8fd9b96a26b205457c
7
- data.tar.gz: 19b1b2c5ca9b4b886d68235309756dcff13cf8e2c026aa10e764a62b7a865f8480ffc812d34febf89707432a6638a3c71b4ea8841b570fcaa0834eb620dc3453
6
+ metadata.gz: c70525edbbd47ba4e679d136a49ed5d9fd5a21c637f7350b94675d6541dc2759ff9ff72c3ff1fb1c32341138fc96325bde64fb259c2b136feb7651bfe81b9ba3
7
+ data.tar.gz: 134e0f59d5c2d27ad5363bda4705f68f8cb0a427967c49541a8bb4b8b00049897265e46798991b151c1649f515e511a1bc75e1ed3e1853e279ad633a88fa3fbc
data/Gemfile CHANGED
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source "https://rubygems.org"
2
4
 
3
- ruby '> 1.8'
5
+ ruby "~> 2.5"
4
6
 
5
7
  gemspec
6
8
 
7
- gem "pry", "~> 0.11.3"
9
+ gem "pry"
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
@@ -2,6 +2,7 @@
2
2
  #
3
3
  # Copyright (c) 2008-Present Kelly Redding
4
4
  #
5
+ # frozen_string_literal: true
5
6
 
6
7
  require "ggem/cli"
7
8
  GGem::CLI.run ARGV
@@ -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 = '> 1.8'
23
+ gem.required_ruby_version = "~> 2.5"
22
24
 
23
- gem.add_development_dependency("assert", ["~> 2.17.0"])
25
+ gem.add_development_dependency("assert", ["~> 2.19.2"])
24
26
 
25
- gem.add_dependency("much-plugin", ["~> 0.2.0"])
27
+ gem.add_dependency("much-plugin", ["~> 0.2.3"])
26
28
  gem.add_dependency("scmd", ["~> 3.0.3"])
27
-
28
29
  end
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "ggem/version"
2
4
  require "ggem/gem"
@@ -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
- 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
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
- def self.run(args)
19
- self.new.run(args)
20
- end
18
+ def self.run(args)
19
+ self.new.run(args)
20
+ end
21
21
 
22
- def initialize(kernel = nil, stdout = nil, stderr = nil)
23
- @kernel = kernel || Kernel
24
- @stdout = stdout || $stdout
25
- @stderr = stderr || $stderr
26
- end
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
- 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
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
- private
52
+ private
53
53
 
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
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
@@ -1,59 +1,57 @@
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
1
+ # frozen_string_literal: true
8
2
 
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 }
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
- 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
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
- 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
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
- private
48
+ private
48
49
 
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
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
@@ -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
- plugin_included do
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
- plugin_included do
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
- module InstanceMethods
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
- module InstanceMethods
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
- module InstanceMethods
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"t add any commands you can't init
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