ggem 1.8.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
- ---
2
- SHA1:
3
- metadata.gz: 78af14258ae315c8ee616b840770779d1084d591
4
- data.tar.gz: 227aff8e65f1aca57f6a9b18e30fd67da6c967f2
5
- SHA512:
6
- metadata.gz: 9652f4d234a556ce6259f83aad0208b1b6ab175ef07b1a426408873ec01d669c55463daf7e91e8d50d840ad0fcc552eafe5934489a2db1320e3af518975d6ff9
7
- data.tar.gz: adbb62ae9184ec3ddf508b7a80a6633154de627c41ed60b212567ab026d28642ed6a8827a9ecff82995466e6fc32fb6077711b7a0fec070df65ac168d1fd2d24
1
+ ---
2
+ SHA256:
3
+ metadata.gz: fe73b45d444a8f7ff488f19259fc7a0668c681db033d19f2eb1b221d004edac5
4
+ data.tar.gz: 5ea32d246eafec3af4fd01f17e6ed94c05c95b4a53a667d8966114cff59d387c
5
+ SHA512:
6
+ metadata.gz: acf33a27c2b503dc4d6233a3d6afb05dd34b86d326d19f9202b37aeb82b44cef1e70a901e140eff2a34528699e619f761c84caeabdc5029cb62f40227a026ac0
7
+ data.tar.gz: 00c64f8c24b4de4f2858994d59ff6b52b62474103e2865709a89bc62e48ae8a0d69b700bd967e669c04dd4b8ce24cda86c2f2c61707411370a97fd17776ba051
data/Gemfile CHANGED
@@ -1,5 +1,7 @@
1
1
  source "https://rubygems.org"
2
2
 
3
+ ruby "~> 2.5"
4
+
3
5
  gemspec
4
6
 
5
- gem 'pry', "~> 0.9.0"
7
+ gem "pry", "~> 0.12.2"
data/README.md CHANGED
@@ -114,7 +114,7 @@ To override the default `https://rubygems.org` push host, add a metadata entry t
114
114
 
115
115
  ```ruby
116
116
  # ...
117
- gem.metadata['allowed_push_host'] = "https://gems.example.com"
117
+ gem.metadata["allowed_push_host"] = "https://gems.example.com"
118
118
  # ...
119
119
  ```
120
120
 
@@ -175,6 +175,6 @@ $ gem install ggem
175
175
 
176
176
  1. Fork it
177
177
  2. Create your feature branch (`git checkout -b my-new-feature`)
178
- 3. Commit your changes (`git commit -am 'Added some feature'`)
178
+ 3. Commit your changes (`git commit -am "Added some feature"`)
179
179
  4. Push to the branch (`git push origin my-new-feature`)
180
180
  5. Create new Pull Request
data/bin/ggem CHANGED
@@ -3,5 +3,5 @@
3
3
  # Copyright (c) 2008-Present Kelly Redding
4
4
  #
5
5
 
6
- require 'ggem/cli'
6
+ require "ggem/cli"
7
7
  GGem::CLI.run ARGV
@@ -1,5 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
- lib = File.expand_path('../lib', __FILE__)
2
+ lib = File.expand_path("../lib", __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require "ggem/version"
5
5
 
@@ -11,16 +11,18 @@ Gem::Specification.new do |gem|
11
11
  gem.summary = %q{"Juh Gem", baby! (a gem utility CLI)}
12
12
  gem.description = %q{"Juh Gem", baby! (a gem utility CLI)}
13
13
  gem.homepage = "http://github.com/redding/ggem"
14
- gem.license = 'MIT'
14
+ gem.license = "MIT"
15
15
 
16
- gem.files = `git ls-files`.split($/)
16
+ gem.files = `git ls-files | grep "^[^.]"`.split($/)
17
17
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
18
18
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
19
  gem.require_paths = ["lib"]
20
20
 
21
- gem.add_development_dependency("assert", ["~> 2.16.1"])
21
+ gem.required_ruby_version = "~> 2.5"
22
22
 
23
- gem.add_dependency("much-plugin", ["~> 0.1.0"])
24
- gem.add_dependency("scmd", ["~> 3.0.1"])
23
+ gem.add_development_dependency("assert", ["~> 2.18.2"])
24
+
25
+ gem.add_dependency("much-plugin", ["~> 0.2.2"])
26
+ gem.add_dependency("scmd", ["~> 3.0.3"])
25
27
 
26
28
  end
@@ -1,2 +1,2 @@
1
- require 'ggem/version'
2
- require 'ggem/gem'
1
+ require "ggem/version"
2
+ require "ggem/gem"
@@ -1,63 +1,58 @@
1
- require 'ggem/version'
2
- require 'ggem/cli/clirb'
3
- require 'ggem/cli/commands'
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
1
+ require "ggem/version"
2
+ require "ggem/cli/clirb"
3
+ require "ggem/cli/commands"
4
+
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
@@ -1,14 +1,12 @@
1
- require 'ggem/cli/clirb'
2
- require 'much-plugin'
1
+ require "ggem/cli/clirb"
2
+ 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)
@@ -21,7 +19,7 @@ class GGem::CLI
21
19
  def run(argv)
22
20
  @clirb.parse!([@name, argv].flatten.compact)
23
21
  raise CLIRB::HelpExit if @name.to_s.empty?
24
- raise InvalidCommandError, "'#{self.name}' is not a command."
22
+ raise InvalidCommandError, "`#{self.name}` is not a command."
25
23
  end
26
24
 
27
25
  def help
@@ -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
@@ -55,22 +47,15 @@ class GGem::CLI
55
47
  end
56
48
 
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)
@@ -80,14 +65,12 @@ class GGem::CLI
80
65
 
81
66
  def cmd(&cmd_block)
82
67
  cmd, status, output = cmd_block.call
83
- if ENV['DEBUG']
68
+ if ENV["DEBUG"]
84
69
  @stdout.puts cmd
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,14 +79,13 @@ 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
 
106
- require 'ggem/git_repo'
88
+ require "ggem/git_repo"
107
89
  @repo = GGem::GitRepo.new(Dir.pwd)
108
90
  end
109
91
 
@@ -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
 
@@ -128,7 +109,7 @@ class GGem::CLI
128
109
  super
129
110
 
130
111
  begin
131
- require 'ggem/gem'
112
+ require "ggem/gem"
132
113
  path = GGem::Gem.new(Dir.pwd, @clirb.args.first).save!.path
133
114
  @stdout.puts "created gem in #{path}"
134
115
  rescue GGem::Gem::NoNameError => exception
@@ -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,14 +140,13 @@ 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
 
170
- require 'ggem/gemspec'
149
+ require "ggem/gemspec"
171
150
  begin
172
151
  @spec = GGem::Gemspec.new(Dir.pwd)
173
152
  rescue GGem::Gemspec::NotFoundError => exception
@@ -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
@@ -225,7 +202,8 @@ class GGem::CLI
225
202
 
226
203
  def run(argv, *args)
227
204
  super
228
- @build_command.run(argv)
205
+ @build_command.run([])
206
+
229
207
  notify("#{@spec.name} #{@spec.version} installed to system gems") do
230
208
  @spec.run_install_cmd
231
209
  end
@@ -241,7 +219,6 @@ class GGem::CLI
241
219
  "Description:\n" \
242
220
  " #{self.summary}"
243
221
  end
244
-
245
222
  end
246
223
 
247
224
  class PushCommand
@@ -254,7 +231,7 @@ class GGem::CLI
254
231
 
255
232
  def run(argv, *args)
256
233
  super
257
- @build_command.run(argv)
234
+ @build_command.run([])
258
235
 
259
236
  @stdout.puts "Pushing #{@spec.gem_file_name} to #{@spec.push_host}..."
260
237
  notify("#{@spec.gem_file_name} received.") do
@@ -272,7 +249,6 @@ class GGem::CLI
272
249
  "Description:\n" \
273
250
  " #{self.summary}"
274
251
  end
275
-
276
252
  end
277
253
 
278
254
  module ForceTagOptionCommand
@@ -280,21 +256,17 @@ class GGem::CLI
280
256
 
281
257
  plugin_included do
282
258
  include ValidCommand
283
- include InstanceMethods
284
259
  end
285
260
 
286
- module InstanceMethods
287
-
261
+ plugin_instance_methods do
288
262
  def initialize
289
263
  super do
290
- option 'force-tag', 'force tagging even with uncommitted files', {
291
- :abbrev => 'f'
264
+ option "force-tag", "force tagging even with uncommitted files", {
265
+ :abbrev => "f"
292
266
  }
293
267
  end
294
268
  end
295
-
296
269
  end
297
-
298
270
  end
299
271
 
300
272
  class TagCommand
@@ -310,7 +282,7 @@ class GGem::CLI
310
282
  cmd{ @repo.run_validate_committed_cmd }
311
283
  rescue GGem::GitRepo::CmdError => err
312
284
  @stderr.puts "There are files that need to be committed first."
313
- if self.clirb.opts['force-tag']
285
+ if self.clirb.opts["force-tag"]
314
286
  @stderr.puts "Forcing tag anyway..."
315
287
  else
316
288
  raise CommandExitError
@@ -344,7 +316,6 @@ class GGem::CLI
344
316
  "Description:\n" \
345
317
  " #{self.summary}"
346
318
  end
347
-
348
319
  end
349
320
 
350
321
  class ReleaseCommand
@@ -359,8 +330,8 @@ class GGem::CLI
359
330
 
360
331
  def run(argv, *args)
361
332
  super
362
- @tag_command.run(argv)
363
- @push_command.run(argv)
333
+ @tag_command.run(self.clirb.opts["force-tag"] ? ["--force-tag"] : [])
334
+ @push_command.run([])
364
335
  end
365
336
 
366
337
  def summary
@@ -375,11 +346,9 @@ class GGem::CLI
375
346
  " #{self.summary}\n" \
376
347
  " (macro for running `ggem tag && ggem push`)"
377
348
  end
378
-
379
349
  end
380
350
 
381
351
  class CommandSet
382
-
383
352
  def initialize(&unknown_cmd_block)
384
353
  @lookup = Hash.new{ |h,k| unknown_cmd_block.call(k) }
385
354
  @names = []
@@ -396,8 +365,8 @@ class GGem::CLI
396
365
  ([name] + aliases).each{ |n| @lookup[n] = cmd }
397
366
  @to_s = nil
398
367
  @names << name
399
- @aliases[name] = aliases.empty? ? '' : "(#{aliases.join(', ')})"
400
- @summaries[name] = cmd.summary.to_s.empty? ? '' : "# #{cmd.summary}"
368
+ @aliases[name] = aliases.empty? ? "" : "(#{aliases.join(", ")})"
369
+ @summaries[name] = cmd.summary.to_s.empty? ? "" : "# #{cmd.summary}"
401
370
  end
402
371
  end
403
372
 
@@ -424,7 +393,5 @@ class GGem::CLI
424
393
  "#{n.ljust(max_name_size)} #{@aliases[n].ljust(max_alias_size)} #{@summaries[n]}"
425
394
  end.join("\n")
426
395
  end
427
-
428
396
  end
429
-
430
397
  end