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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 48965215e38e1840ec8b4b3bf1480cbceb0d86eab560b36f81dbebb258d17330
4
- data.tar.gz: b25db4250efee3239408378bc44cb7ae0663995f30dccbe90ab5a770f50e728c
3
+ metadata.gz: def73e1c484bc3f53187ff0794b383268a5757b66b63412cde998df88157ba72
4
+ data.tar.gz: dc06c2753531740179a2c5863851cef0de7c5663a264f6f249d1c53425fbe0c3
5
5
  SHA512:
6
- metadata.gz: a8447f11f20b90554e8804f06c3de1e3d0522dafc6808b93a2e926e74dccdc1a09c60bad6f51c4461f28d37268aa77d63380338fbd3db7fc1cfd1e60d6363f13
7
- data.tar.gz: 0bba44fe414eef3d9d5c5da9e1f512f75a68c8d67af4d638079aad7eedc66489018dc32c25073041cb5f952d38c3f43a9436a65afcd4266a9ea4ec678f37ab4c
6
+ metadata.gz: 00dcde4ad715b9ff52a7455080e077cfdc2b1b64584db75cf5c7e5dbc85f5d3b241ca94cf188423a098aac942e365a002f7d021941a15780587ba5228d6413c6
7
+ data.tar.gz: 89e1324ad76a38e5fe606fb91d655db0d2564c9903142814fda6a7fdd22ed502853d5fb72171d20804c9cfaf5c46307cf8fd51cad453821ecbe43052ff87fcc0
data/Gemfile CHANGED
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source "https://rubygems.org"
2
4
 
3
5
  ruby "~> 2.5"
4
6
 
5
7
  gemspec
6
8
 
7
- gem "pry", "~> 0.12.2"
9
+ gem "pry"
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,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 = %q{"Juh Gem", baby! (a gem utility CLI)}
12
- 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)'
13
15
  gem.homepage = "http://github.com/redding/ggem"
14
16
  gem.license = "MIT"
15
17
 
16
- gem.files = `git ls-files | grep "^[^.]"`.split($/)
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("assert", ["~> 2.19.0"])
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
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "ggem/version"
2
4
  require "ggem/gem"
@@ -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
- self.new.run(args)
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 => exception
36
- display_debug(exception)
37
- @stderr.puts "#{exception.message}\n\n"
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 StandardError => exception
43
- @stderr.puts "#{exception.class}: #{exception.message}"
44
- @stderr.puts exception.backtrace.join("\n")
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
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module GGem; end
2
4
  class GGem::CLI; end
3
5
  class GGem::CLI::CLIRB # Version 1.1.0, https://github.com/redding/cli.rb
@@ -1,7 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "ggem/cli/clirb"
2
- require "much-plugin"
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; self; end
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, "`#{self.name}` is not a command."
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 MuchPlugin
39
+ include MuchMixin
35
40
 
36
- plugin_instance_methods do
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; @clirb; end
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 MuchPlugin
63
+ include MuchMixin
57
64
 
58
- plugin_instance_methods do
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, status, output = cmd_block.call
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 MuchPlugin
84
+ include MuchMixin
78
85
 
79
- plugin_included do
86
+ mixin_included do
80
87
  include ValidCommand
81
88
  include NotifyCmdCommand
82
89
  end
83
90
 
84
- plugin_instance_methods do
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 => exception
98
- @stderr.puts exception.message
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 => exception
122
+ rescue GGem::Gem::NoNameError => ex
116
123
  error = ArgumentError.new("GEM-NAME must be provided")
117
- error.set_backtrace(exception.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
- " #{self.summary}"
140
+ " #{summary}"
134
141
  end
135
142
  end
136
143
 
137
144
  module GemspecCommand
138
- include MuchPlugin
145
+ include MuchMixin
139
146
 
140
- plugin_included do
147
+ mixin_included do
141
148
  include ValidCommand
142
149
  include NotifyCmdCommand
143
150
  end
144
151
 
145
- plugin_instance_methods do
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 => exception
159
+ rescue GGem::Gemspec::NotFoundError => ex
153
160
  error = ArgumentError.new("There are no gemspecs at #{Dir.pwd}")
154
- error.set_backtrace(exception.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 => exception
165
- @stderr.puts exception.message
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
- " #{self.summary}"
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
- " #{self.summary}"
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
- " #{self.summary}"
257
+ " #{summary}"
251
258
  end
252
259
  end
253
260
 
254
261
  module ForceTagOptionCommand
255
- include MuchPlugin
262
+ include MuchMixin
256
263
 
257
- plugin_included do
264
+ mixin_included do
258
265
  include ValidCommand
259
266
  end
260
267
 
261
- plugin_instance_methods do
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
- :abbrev => "f"
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 => err
290
+ rescue GGem::GitRepo::CmdError
284
291
  @stderr.puts "There are files that need to be committed first."
285
- if self.clirb.opts["force-tag"]
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 => err
305
- @stderr.puts err.message
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
- " #{self.summary}"
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(self.clirb.opts["force-tag"] ? ["--force-tag"] : [])
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
- " #{self.summary}\n" \
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{ |h,k| unknown_cmd_block.call(k) }
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 StandardError => err
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{ |n| n.size }.max || 0
390
- 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
391
398
 
392
- @to_s ||= @names.map do |n|
393
- "#{n.ljust(max_name_size)} #{@aliases[n].ljust(max_alias_size)} #{@summaries[n]}"
394
- 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")
395
403
  end
396
404
  end
397
405
  end
@@ -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){ |part| part.capitalize }
36
+ @module_name ||= transform_name(transforms, &:capitalize)
34
37
  end
35
38
 
36
39
  def ruby_name
37
- @ruby_name ||= transform_name{ |part| part.downcase }
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(self.name) : self.name)
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.call(part) if block }.join(glue)
56
+ n = a.map{ |part| block&.call(part) }.join(glue)
54
57
  end
55
58
  end
56
59
  n