ggem 1.8.3 → 1.9.3

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
- metadata.gz: 47b788c7af22b10dae04d58149767be30d8ff7fb
4
- data.tar.gz: 60b3328e31c1ec8f17622281805a6ca824b0c8e8
5
- SHA512:
6
- metadata.gz: e18f2ed64b8a280b01106864e3f098e0828f95ac39994d204214a6e161009ce35d875205bb551ef46dcfefc15e6cbdce9bf1b1c92c3821540e68d42fa4deb3b6
7
- data.tar.gz: d55e6b25e1bb96baa96eaa08e6d132661f2469804d973af8b9978cfc6998038d2665df5903935e00d865270da3677c76043e498ed68ab1e1ebf91c3cae6458e4
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 48965215e38e1840ec8b4b3bf1480cbceb0d86eab560b36f81dbebb258d17330
4
+ data.tar.gz: b25db4250efee3239408378bc44cb7ae0663995f30dccbe90ab5a770f50e728c
5
+ SHA512:
6
+ metadata.gz: a8447f11f20b90554e8804f06c3de1e3d0522dafc6808b93a2e926e74dccdc1a09c60bad6f51c4461f28d37268aa77d63380338fbd3db7fc1cfd1e60d6363f13
7
+ data.tar.gz: 0bba44fe414eef3d9d5c5da9e1f512f75a68c8d67af4d638079aad7eedc66489018dc32c25073041cb5f952d38c3f43a9436a65afcd4266a9ea4ec678f37ab4c
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.19.0"])
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
@@ -242,7 +219,6 @@ class GGem::CLI
242
219
  "Description:\n" \
243
220
  " #{self.summary}"
244
221
  end
245
-
246
222
  end
247
223
 
248
224
  class PushCommand
@@ -273,7 +249,6 @@ class GGem::CLI
273
249
  "Description:\n" \
274
250
  " #{self.summary}"
275
251
  end
276
-
277
252
  end
278
253
 
279
254
  module ForceTagOptionCommand
@@ -281,21 +256,17 @@ class GGem::CLI
281
256
 
282
257
  plugin_included do
283
258
  include ValidCommand
284
- include InstanceMethods
285
259
  end
286
260
 
287
- module InstanceMethods
288
-
261
+ plugin_instance_methods do
289
262
  def initialize
290
263
  super do
291
- option 'force-tag', 'force tagging even with uncommitted files', {
292
- :abbrev => 'f'
264
+ option "force-tag", "force tagging even with uncommitted files", {
265
+ :abbrev => "f"
293
266
  }
294
267
  end
295
268
  end
296
-
297
269
  end
298
-
299
270
  end
300
271
 
301
272
  class TagCommand
@@ -311,7 +282,7 @@ class GGem::CLI
311
282
  cmd{ @repo.run_validate_committed_cmd }
312
283
  rescue GGem::GitRepo::CmdError => err
313
284
  @stderr.puts "There are files that need to be committed first."
314
- if self.clirb.opts['force-tag']
285
+ if self.clirb.opts["force-tag"]
315
286
  @stderr.puts "Forcing tag anyway..."
316
287
  else
317
288
  raise CommandExitError
@@ -345,7 +316,6 @@ class GGem::CLI
345
316
  "Description:\n" \
346
317
  " #{self.summary}"
347
318
  end
348
-
349
319
  end
350
320
 
351
321
  class ReleaseCommand
@@ -360,7 +330,7 @@ class GGem::CLI
360
330
 
361
331
  def run(argv, *args)
362
332
  super
363
- @tag_command.run(self.clirb.opts['force-tag'] ? ['--force-tag'] : [])
333
+ @tag_command.run(self.clirb.opts["force-tag"] ? ["--force-tag"] : [])
364
334
  @push_command.run([])
365
335
  end
366
336
 
@@ -376,11 +346,9 @@ class GGem::CLI
376
346
  " #{self.summary}\n" \
377
347
  " (macro for running `ggem tag && ggem push`)"
378
348
  end
379
-
380
349
  end
381
350
 
382
351
  class CommandSet
383
-
384
352
  def initialize(&unknown_cmd_block)
385
353
  @lookup = Hash.new{ |h,k| unknown_cmd_block.call(k) }
386
354
  @names = []
@@ -397,8 +365,8 @@ class GGem::CLI
397
365
  ([name] + aliases).each{ |n| @lookup[n] = cmd }
398
366
  @to_s = nil
399
367
  @names << name
400
- @aliases[name] = aliases.empty? ? '' : "(#{aliases.join(', ')})"
401
- @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}"
402
370
  end
403
371
  end
404
372
 
@@ -425,7 +393,5 @@ class GGem::CLI
425
393
  "#{n.ljust(max_name_size)} #{@aliases[n].ljust(max_alias_size)} #{@summaries[n]}"
426
394
  end.join("\n")
427
395
  end
428
-
429
396
  end
430
-
431
397
  end