ggem 1.9.5 → 1.10.4

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: 58d90e351c533deb56deb2c166b2f1bf1952476bf26b152e2f03d9dab41dfadb
4
- data.tar.gz: 385e2623bc98636318662f09b8868e450208278e3142fce4e681b55488bf4f34
3
+ metadata.gz: 45eb4dacea143c3b186a3ae2ec76ec01990fdf602f3d0a7d64c1f83d29ce0771
4
+ data.tar.gz: e9bedb479b361a24597449322250da74a12313875ad0ddc7a53a3b9870bd4aaf
5
5
  SHA512:
6
- metadata.gz: c70525edbbd47ba4e679d136a49ed5d9fd5a21c637f7350b94675d6541dc2759ff9ff72c3ff1fb1c32341138fc96325bde64fb259c2b136feb7651bfe81b9ba3
7
- data.tar.gz: 134e0f59d5c2d27ad5363bda4705f68f8cb0a427967c49541a8bb4b8b00049897265e46798991b151c1649f515e511a1bc75e1ed3e1853e279ad633a88fa3fbc
6
+ metadata.gz: '0680e6ccd2bf26a2b8521364e206ea049f712e0de44f814fcc9fa9621d42c69a826c192ef4a1f9f30c450618d830c183c39bf38ffdc26ef1572156175bd1f73f'
7
+ data.tar.gz: 48c14bda11865bde52b80cf1967ef3cfaf9727a33439680ecbaf9fd8a9f6ad0b622a794654b1c99cc75b737d2c506a8571fb1ebbb9b082ae133cea798a49a7f0
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 = %q{"Juh Gem", baby! (a gem utility CLI)}
14
- gem.description = %q{"Juh Gem", baby! (a gem utility CLI)}
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 = `git ls-files | grep "^[^.]"`.split($/)
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("assert", ["~> 2.19.2"])
26
+ gem.add_development_dependency("much-style-guide", ["~> 0.6.4"])
27
+ gem.add_development_dependency("assert", ["~> 2.19.6"])
26
28
 
27
- gem.add_dependency("much-plugin", ["~> 0.2.3"])
28
- gem.add_dependency("scmd", ["~> 3.0.3"])
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,18 +5,20 @@ require "ggem/cli/clirb"
5
5
  require "ggem/cli/commands"
6
6
 
7
7
  module GGem; end
8
+
8
9
  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
10
+ COMMANDS =
11
+ CommandSet.new{ |unknown| InvalidCommand.new(unknown) }.tap do |c|
12
+ c.add(GenerateCommand, "generate", "g")
13
+ c.add(BuildCommand, "build", "b")
14
+ c.add(InstallCommand, "install", "i")
15
+ c.add(PushCommand, "push", "p")
16
+ c.add(TagCommand, "tag", "t")
17
+ c.add(ReleaseCommand, "release", "r")
18
+ end
17
19
 
18
20
  def self.run(args)
19
- self.new.run(args)
21
+ new.run(args)
20
22
  end
21
23
 
22
24
  def initialize(kernel = nil, stdout = nil, stderr = nil)
@@ -34,16 +36,16 @@ class GGem::CLI
34
36
  @stdout.puts cmd.help
35
37
  rescue CLIRB::VersionExit
36
38
  @stdout.puts GGem::VERSION
37
- rescue CLIRB::Error, ArgumentError, InvalidCommandError => exception
38
- display_debug(exception)
39
- @stderr.puts "#{exception.message}\n\n"
39
+ rescue CLIRB::Error, ArgumentError, InvalidCommandError => ex
40
+ display_debug(ex)
41
+ @stderr.puts "#{ex.message}\n\n"
40
42
  @stdout.puts cmd.help
41
43
  @kernel.exit 1
42
44
  rescue CommandExitError
43
45
  @kernel.exit 1
44
- rescue StandardError => exception
45
- @stderr.puts "#{exception.class}: #{exception.message}"
46
- @stderr.puts exception.backtrace.join("\n")
46
+ rescue => ex
47
+ @stderr.puts "#{ex.class}: #{ex.message}"
48
+ @stderr.puts ex.backtrace.join("\n")
47
49
  @kernel.exit 1
48
50
  end
49
51
  @kernel.exit 0
@@ -1,9 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "ggem/cli/clirb"
4
- require "much-plugin"
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; self; end
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, "`#{self.name}` is not a command."
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 MuchPlugin
39
+ include MuchMixin
37
40
 
38
- plugin_instance_methods do
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; @clirb; end
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 MuchPlugin
63
+ include MuchMixin
59
64
 
60
- plugin_instance_methods do
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, status, output = cmd_block.call
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 MuchPlugin
84
+ include MuchMixin
80
85
 
81
- plugin_included do
86
+ mixin_included do
82
87
  include ValidCommand
83
88
  include NotifyCmdCommand
84
89
  end
85
90
 
86
- plugin_instance_methods do
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 => exception
100
- @stderr.puts exception.message
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 => exception
122
+ rescue GGem::Gem::NoNameError => ex
118
123
  error = ArgumentError.new("GEM-NAME must be provided")
119
- error.set_backtrace(exception.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
- " #{self.summary}"
140
+ " #{summary}"
136
141
  end
137
142
  end
138
143
 
139
144
  module GemspecCommand
140
- include MuchPlugin
145
+ include MuchMixin
141
146
 
142
- plugin_included do
147
+ mixin_included do
143
148
  include ValidCommand
144
149
  include NotifyCmdCommand
145
150
  end
146
151
 
147
- plugin_instance_methods do
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 => exception
159
+ rescue GGem::Gemspec::NotFoundError => ex
155
160
  error = ArgumentError.new("There are no gemspecs at #{Dir.pwd}")
156
- error.set_backtrace(exception.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 => exception
167
- @stderr.puts exception.message
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
- " #{self.summary}"
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
- " #{self.summary}"
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
- " #{self.summary}"
257
+ " #{summary}"
253
258
  end
254
259
  end
255
260
 
256
261
  module ForceTagOptionCommand
257
- include MuchPlugin
262
+ include MuchMixin
258
263
 
259
- plugin_included do
264
+ mixin_included do
260
265
  include ValidCommand
261
266
  end
262
267
 
263
- plugin_instance_methods do
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
- :abbrev => "f"
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 => err
290
+ rescue GGem::GitRepo::CmdError
286
291
  @stderr.puts "There are files that need to be committed first."
287
- if self.clirb.opts["force-tag"]
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 => err
307
- @stderr.puts err.message
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
- " #{self.summary}"
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(self.clirb.opts["force-tag"] ? ["--force-tag"] : [])
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
- " #{self.summary}\n" \
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{ |h,k| unknown_cmd_block.call(k) }
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 StandardError => err
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{ |n| n.size }.max || 0
392
- max_alias_size = @aliases.values.map{ |v| v.size }.max || 0
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 do |n|
395
- "#{n.ljust(max_name_size)} #{@aliases[n].ljust(max_alias_size)} #{@summaries[n]}"
396
- end.join("\n")
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){ |part| part.capitalize }
36
+ @module_name ||= transform_name(transforms, &:capitalize)
36
37
  end
37
38
 
38
39
  def ruby_name
39
- @ruby_name ||= transform_name{ |part| part.downcase }
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(self.name) : self.name)
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.call(part) if block }.join(glue)
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".freeze
10
- BUILD_TO_DIRNAME = "pkg".freeze
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
- if !cmd.success?
59
- raise CmdError, "#{cmd_string}\n" \
60
- "#{cmd.stderr.empty? ? cmd.stdout : cmd.stderr}"
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(path.read, TOPLEVEL_BINDING, path.expand_path.to_s)
67
- rescue ScriptError, StandardError => e
68
- original_line = e.backtrace.find{ |line| line.include?(path.to_s) }
69
- msg = "There was a #{e.class} while loading #{path.basename}: \n#{e.message}"
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"] || get_meta(spec)[PUSH_HOST_META_KEY] || DEFAULT_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)