ggem 1.8.4 → 1.9.4

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
- ---
2
- SHA1:
3
- data.tar.gz: e70497f9bf7cfa2b860ba621446d5fd64157b388
4
- metadata.gz: 99171d84a31b835e65a86d540e7a789616c2370e
5
- SHA512:
6
- data.tar.gz: 20fc8d088d476ecb8864fbcf8feaf34c23449ec482e23b51345429794378400eba1a93d2d660d18138c74ae9ce4b780aff8c5cd099c631fd2d5a492060805a72
7
- metadata.gz: 848dd46e4e63ab74784a0c83fd79bae2a109aa37ad5713047fd06a8fecf6c00ca0846e1986fc633f004fd4baf861235c28730290b9dc10db5bb759a1dfad3328
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 74c9970fb3622c15d7220ec27b520875b00ac22db274db925ce593f1ec9752ee
4
+ data.tar.gz: aacc07eef218717d208a677bf0dd9482f172c25a506a88e9d45d2195ea87c7ab
5
+ SHA512:
6
+ metadata.gz: b3179d50b1f2e51b90ed597250bbd58748af74fd4cd49aab434d90d3f38c47220d3470b772390473130cbec7757b0fff2aa8204b5d2aef700045a22ead025664
7
+ data.tar.gz: 573bf565353725baeb62aedd6d6e18cfcc9f58e86fe388cf970f293de06906b82199b5d124800c158d53d5cadfe6a7444522ce855dd591b5eaaaa8c693ee3ef1
data/Gemfile CHANGED
@@ -1,5 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source "https://rubygems.org"
2
4
 
5
+ ruby "~> 2.5"
6
+
3
7
  gemspec
4
8
 
5
- gem 'pry', "~> 0.9.0"
9
+ gem "pry"
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
@@ -2,6 +2,7 @@
2
2
  #
3
3
  # Copyright (c) 2008-Present Kelly Redding
4
4
  #
5
+ # frozen_string_literal: true
5
6
 
6
- require 'ggem/cli'
7
+ require "ggem/cli"
7
8
  GGem::CLI.run ARGV
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # -*- encoding: utf-8 -*-
2
- lib = File.expand_path('../lib', __FILE__)
4
+ lib = File.expand_path("../lib", __FILE__)
3
5
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
6
  require "ggem/version"
5
7
 
@@ -11,16 +13,17 @@ Gem::Specification.new do |gem|
11
13
  gem.summary = %q{"Juh Gem", baby! (a gem utility CLI)}
12
14
  gem.description = %q{"Juh Gem", baby! (a gem utility CLI)}
13
15
  gem.homepage = "http://github.com/redding/ggem"
14
- gem.license = 'MIT'
16
+ gem.license = "MIT"
15
17
 
16
- gem.files = `git ls-files`.split($/)
18
+ gem.files = `git ls-files | grep "^[^.]"`.split($/)
17
19
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
18
20
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
21
  gem.require_paths = ["lib"]
20
22
 
21
- gem.add_development_dependency("assert", ["~> 2.16.3"])
23
+ gem.required_ruby_version = "~> 2.5"
22
24
 
23
- gem.add_dependency("much-plugin", ["~> 0.2.0"])
24
- gem.add_dependency("scmd", ["~> 3.0.3"])
25
+ gem.add_development_dependency("assert", ["~> 2.19.1"])
25
26
 
27
+ gem.add_dependency("much-plugin", ["~> 0.2.3"])
28
+ gem.add_dependency("scmd", ["~> 3.0.3"])
26
29
  end
@@ -1,2 +1,4 @@
1
- require 'ggem/version'
2
- require 'ggem/gem'
1
+ # frozen_string_literal: true
2
+
3
+ require "ggem/version"
4
+ require "ggem/gem"
@@ -1,63 +1,60 @@
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
+ # frozen_string_literal: true
2
+
3
+ require "ggem/version"
4
+ require "ggem/cli/clirb"
5
+ require "ggem/cli/commands"
6
+
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
- require 'ggem/cli/clirb'
2
- require 'much-plugin'
1
+ # frozen_string_literal: true
2
+
3
+ require "ggem/cli/clirb"
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)
@@ -21,7 +21,7 @@ class GGem::CLI
21
21
  def run(argv)
22
22
  @clirb.parse!([@name, argv].flatten.compact)
23
23
  raise CLIRB::HelpExit if @name.to_s.empty?
24
- raise InvalidCommandError, "'#{self.name}' is not a command."
24
+ raise InvalidCommandError, "`#{self.name}` is not a command."
25
25
  end
26
26
 
27
27
  def help
@@ -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
@@ -55,22 +49,15 @@ class GGem::CLI
55
49
  end
56
50
 
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)
@@ -80,14 +67,12 @@ class GGem::CLI
80
67
 
81
68
  def cmd(&cmd_block)
82
69
  cmd, status, output = cmd_block.call
83
- if ENV['DEBUG']
70
+ if ENV["DEBUG"]
84
71
  @stdout.puts cmd
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,14 +81,13 @@ 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
 
106
- require 'ggem/git_repo'
90
+ require "ggem/git_repo"
107
91
  @repo = GGem::GitRepo.new(Dir.pwd)
108
92
  end
109
93
 
@@ -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
 
@@ -128,7 +111,7 @@ class GGem::CLI
128
111
  super
129
112
 
130
113
  begin
131
- require 'ggem/gem'
114
+ require "ggem/gem"
132
115
  path = GGem::Gem.new(Dir.pwd, @clirb.args.first).save!.path
133
116
  @stdout.puts "created gem in #{path}"
134
117
  rescue GGem::Gem::NoNameError => exception
@@ -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,14 +142,13 @@ 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
 
170
- require 'ggem/gemspec'
151
+ require "ggem/gemspec"
171
152
  begin
172
153
  @spec = GGem::Gemspec.new(Dir.pwd)
173
154
  rescue GGem::Gemspec::NotFoundError => exception
@@ -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,21 +258,17 @@ 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
- option 'force-tag', 'force tagging even with uncommitted files', {
292
- :abbrev => 'f'
266
+ option "force-tag", "force tagging even with uncommitted files", {
267
+ :abbrev => "f"
293
268
  }
294
269
  end
295
270
  end
296
-
297
271
  end
298
-
299
272
  end
300
273
 
301
274
  class TagCommand
@@ -311,7 +284,7 @@ class GGem::CLI
311
284
  cmd{ @repo.run_validate_committed_cmd }
312
285
  rescue GGem::GitRepo::CmdError => err
313
286
  @stderr.puts "There are files that need to be committed first."
314
- if self.clirb.opts['force-tag']
287
+ if self.clirb.opts["force-tag"]
315
288
  @stderr.puts "Forcing tag anyway..."
316
289
  else
317
290
  raise CommandExitError
@@ -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
@@ -360,7 +332,7 @@ class GGem::CLI
360
332
 
361
333
  def run(argv, *args)
362
334
  super
363
- @tag_command.run(self.clirb.opts['force-tag'] ? ['--force-tag'] : [])
335
+ @tag_command.run(self.clirb.opts["force-tag"] ? ["--force-tag"] : [])
364
336
  @push_command.run([])
365
337
  end
366
338
 
@@ -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 = []
@@ -397,8 +367,8 @@ class GGem::CLI
397
367
  ([name] + aliases).each{ |n| @lookup[n] = cmd }
398
368
  @to_s = nil
399
369
  @names << name
400
- @aliases[name] = aliases.empty? ? '' : "(#{aliases.join(', ')})"
401
- @summaries[name] = cmd.summary.to_s.empty? ? '' : "# #{cmd.summary}"
370
+ @aliases[name] = aliases.empty? ? "" : "(#{aliases.join(", ")})"
371
+ @summaries[name] = cmd.summary.to_s.empty? ? "" : "# #{cmd.summary}"
402
372
  end
403
373
  end
404
374
 
@@ -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