ggem 1.8.1 → 1.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -7
- data/Gemfile +3 -1
- data/README.md +2 -2
- data/bin/ggem +1 -1
- data/ggem.gemspec +8 -6
- data/lib/ggem.rb +2 -2
- data/lib/ggem/cli.rb +49 -54
- data/lib/ggem/cli/clirb.rb +44 -48
- data/lib/ggem/cli/commands.rb +23 -56
- data/lib/ggem/gem.rb +43 -43
- data/lib/ggem/gemspec.rb +68 -73
- data/lib/ggem/git_repo.rb +39 -44
- data/lib/ggem/template.rb +52 -54
- data/lib/ggem/template_file/Gemfile.erb +3 -1
- data/lib/ggem/template_file/README.md.erb +4 -4
- data/lib/ggem/template_file/gemspec.erb +10 -8
- data/lib/ggem/template_file/lib.rb.erb +2 -2
- data/lib/ggem/template_file/lib_version.rb.erb +1 -1
- data/lib/ggem/template_file/ruby-version.erb +1 -0
- data/lib/ggem/template_file/test_helper.rb.erb +2 -11
- data/lib/ggem/template_file/test_support_factory.rb.erb +1 -2
- data/lib/ggem/version.rb +1 -1
- data/log/.keep +0 -0
- data/test/helper.rb +6 -15
- data/test/support/cmd_tests_helpers.rb +35 -40
- data/test/support/factory.rb +1 -2
- data/test/support/gem1/gem1.gemspec +1 -1
- data/test/support/gem2/gem2.gemspec +2 -2
- data/test/support/name_set.rb +53 -53
- data/test/system/ggem_tests.rb +7 -12
- data/test/unit/cli_tests.rb +100 -121
- data/test/unit/gem_tests.rb +1 -5
- data/test/unit/gemspec_tests.rb +19 -26
- data/test/unit/git_repo_tests.rb +3 -14
- metadata +64 -57
- data/.gitignore +0 -19
@@ -1,4 +1,4 @@
|
|
1
|
-
# <%= @
|
1
|
+
# <%= @ggem.module_name %>
|
2
2
|
|
3
3
|
TODO: Write a gem description
|
4
4
|
|
@@ -10,7 +10,7 @@ TODO: Write code samples and usage instructions here
|
|
10
10
|
|
11
11
|
Add this line to your application's Gemfile:
|
12
12
|
|
13
|
-
gem
|
13
|
+
gem "<%= @ggem.name %>"
|
14
14
|
|
15
15
|
And then execute:
|
16
16
|
|
@@ -18,12 +18,12 @@ And then execute:
|
|
18
18
|
|
19
19
|
Or install it yourself as:
|
20
20
|
|
21
|
-
$ gem install <%= @
|
21
|
+
$ gem install <%= @ggem.name %>
|
22
22
|
|
23
23
|
## Contributing
|
24
24
|
|
25
25
|
1. Fork it
|
26
26
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
-
3. Commit your changes (`git commit -am
|
27
|
+
3. Commit your changes (`git commit -am "Added some feature"`)
|
28
28
|
4. Push to the branch (`git push origin my-new-feature`)
|
29
29
|
5. Create new Pull Request
|
@@ -1,24 +1,26 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
lib = File.expand_path(
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require "<%= @
|
4
|
+
require "<%= @ggem.ruby_name %>/version"
|
5
5
|
|
6
6
|
Gem::Specification.new do |gem|
|
7
|
-
gem.name = "<%= @
|
8
|
-
gem.version = <%= @
|
7
|
+
gem.name = "<%= @ggem.name %>"
|
8
|
+
gem.version = <%= @ggem.module_name %>::VERSION
|
9
9
|
gem.authors = ["TODO: authors"]
|
10
10
|
gem.email = ["TODO: emails"]
|
11
11
|
gem.summary = "TODO: Write a gem summary"
|
12
12
|
gem.description = "TODO: Write a gem description"
|
13
13
|
gem.homepage = "TODO: homepage"
|
14
|
-
gem.license =
|
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.
|
22
|
-
|
21
|
+
gem.required_ruby_version = "~> 2.5"
|
22
|
+
|
23
|
+
gem.add_development_dependency("assert", ["~> 2.18.2"])
|
23
24
|
|
25
|
+
# TODO: gem.add_dependency("gem-name", ["~> 0.0.0"])
|
24
26
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
2.5.5
|
@@ -5,17 +5,8 @@
|
|
5
5
|
$LOAD_PATH.unshift(File.expand_path("../..", __FILE__))
|
6
6
|
|
7
7
|
# require pry for debugging (`binding.pry`)
|
8
|
-
require
|
8
|
+
require "pry"
|
9
9
|
|
10
|
-
require
|
11
|
-
|
12
|
-
# 1.8.7 backfills
|
13
|
-
|
14
|
-
# Array#sample
|
15
|
-
if !(a = Array.new).respond_to?(:sample) && a.respond_to?(:choice)
|
16
|
-
class Array
|
17
|
-
alias_method :sample, :choice
|
18
|
-
end
|
19
|
-
end
|
10
|
+
require "test/support/factory"
|
20
11
|
|
21
12
|
# TODO: put test helpers here...
|
data/lib/ggem/version.rb
CHANGED
data/log/.keep
ADDED
File without changes
|
data/test/helper.rb
CHANGED
@@ -2,22 +2,13 @@
|
|
2
2
|
# put any test helpers here
|
3
3
|
|
4
4
|
# add the root dir to the load path
|
5
|
-
require
|
6
|
-
ROOT_PATH = Pathname.new(File.expand_path(
|
5
|
+
require "pathname"
|
6
|
+
ROOT_PATH = Pathname.new(File.expand_path("../..", __FILE__))
|
7
7
|
$LOAD_PATH.unshift(ROOT_PATH.to_s)
|
8
|
-
TMP_PATH = ROOT_PATH.join(
|
9
|
-
TEST_SUPPORT_PATH = ROOT_PATH.join(
|
8
|
+
TMP_PATH = ROOT_PATH.join("tmp")
|
9
|
+
TEST_SUPPORT_PATH = ROOT_PATH.join("test/support")
|
10
10
|
|
11
11
|
# require pry for debugging (`binding.pry`)
|
12
|
-
require
|
12
|
+
require "pry"
|
13
13
|
|
14
|
-
require
|
15
|
-
|
16
|
-
# 1.8.7 backfills
|
17
|
-
|
18
|
-
# Array#sample
|
19
|
-
if !(a = Array.new).respond_to?(:sample) && a.respond_to?(:choice)
|
20
|
-
class Array
|
21
|
-
alias_method :sample, :choice
|
22
|
-
end
|
23
|
-
end
|
14
|
+
require "test/support/factory"
|
@@ -1,53 +1,48 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "much-plugin"
|
2
|
+
require "scmd"
|
3
3
|
|
4
|
-
module GGem
|
4
|
+
module GGem; end
|
5
|
+
module GGem::CmdTestsHelpers
|
6
|
+
include MuchPlugin
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
+
plugin_included do
|
9
|
+
setup do
|
10
|
+
ENV["SCMD_TEST_MODE"] = "1"
|
8
11
|
|
9
|
-
|
10
|
-
|
11
|
-
ENV['SCMD_TEST_MODE'] = '1'
|
12
|
+
@cmd_spy = nil
|
13
|
+
Scmd.reset
|
12
14
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
Scmd.reset
|
20
|
-
ENV.delete('SCMD_TEST_MODE')
|
21
|
-
end
|
15
|
+
@exp_cmds_run = []
|
16
|
+
end
|
17
|
+
teardown do
|
18
|
+
Scmd.reset
|
19
|
+
ENV.delete("SCMD_TEST_MODE")
|
20
|
+
end
|
22
21
|
|
23
|
-
|
22
|
+
private
|
24
23
|
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
def assert_exp_cmds_run(&run_cmd_block)
|
25
|
+
cmd_str, exitstatus, stdout = run_cmd_block.call
|
26
|
+
assert_equal @exp_cmds_run, Scmd.calls.map(&:cmd_str)
|
28
27
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
28
|
+
assert_equal Scmd.calls.first.cmd_str, cmd_str
|
29
|
+
assert_equal Scmd.calls.first.cmd.exitstatus, exitstatus
|
30
|
+
assert_equal Scmd.calls.first.cmd.stdout, stdout
|
31
|
+
end
|
33
32
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
end
|
41
|
-
err = nil
|
42
|
-
begin; run_cmd_block.call; rescue StandardError => err; end
|
43
|
-
|
44
|
-
assert_kind_of cmd_error_class, err
|
45
|
-
exp = "#{@cmd_spy.cmd_str}\n#{@cmd_spy.stderr}"
|
46
|
-
assert_equal exp, err.message
|
33
|
+
def assert_exp_cmds_error(cmd_error_class, &run_cmd_block)
|
34
|
+
err_cmd_str = @exp_cmds_run.sample
|
35
|
+
Scmd.add_command(err_cmd_str) do |cmd|
|
36
|
+
cmd.exitstatus = 1
|
37
|
+
cmd.stderr = Factory.string
|
38
|
+
@cmd_spy = cmd
|
47
39
|
end
|
40
|
+
err = nil
|
41
|
+
begin; run_cmd_block.call; rescue StandardError => err; end
|
48
42
|
|
43
|
+
assert_kind_of cmd_error_class, err
|
44
|
+
exp = "#{@cmd_spy.cmd_str}\n#{@cmd_spy.stderr}"
|
45
|
+
assert_equal exp, err.message
|
49
46
|
end
|
50
|
-
|
51
47
|
end
|
52
|
-
|
53
48
|
end
|
data/test/support/factory.rb
CHANGED
@@ -6,9 +6,9 @@ Gem::Specification.new do |gem|
|
|
6
6
|
gem.email = []
|
7
7
|
gem.summary = %q{Gem 2 summary}
|
8
8
|
gem.description = %q{Gem 2 description}
|
9
|
-
gem.license =
|
9
|
+
gem.license = "MIT"
|
10
10
|
|
11
|
-
gem.metadata[
|
11
|
+
gem.metadata["allowed_push_host"] = "http://gems.example.com"
|
12
12
|
|
13
13
|
gem.files = []
|
14
14
|
gem.executables = []
|
data/test/support/name_set.rb
CHANGED
@@ -1,67 +1,67 @@
|
|
1
|
-
module GGem
|
2
|
-
|
1
|
+
module GGem; end
|
2
|
+
module GGem::NameSet
|
3
|
+
class Base
|
4
|
+
attr_reader :variations, :name, :module_name, :ruby_name
|
3
5
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
'tmp'
|
17
|
-
]
|
18
|
-
end
|
6
|
+
def expected_folders
|
7
|
+
[ "",
|
8
|
+
"lib",
|
9
|
+
"lib/#{@ruby_name}",
|
10
|
+
"test",
|
11
|
+
"test/support",
|
12
|
+
"test/system",
|
13
|
+
"test/unit",
|
14
|
+
"log",
|
15
|
+
"tmp"
|
16
|
+
]
|
17
|
+
end
|
19
18
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
19
|
+
def expected_files
|
20
|
+
[ ".ruby-version",
|
21
|
+
".gitignore",
|
22
|
+
"Gemfile",
|
23
|
+
"#{@name}.gemspec",
|
24
|
+
"README.md",
|
25
|
+
"LICENSE",
|
26
26
|
|
27
|
-
|
28
|
-
|
27
|
+
"lib/#{@ruby_name}.rb",
|
28
|
+
"lib/#{@ruby_name}/version.rb",
|
29
29
|
|
30
|
-
|
31
|
-
|
30
|
+
"test/helper.rb",
|
31
|
+
"test/support/factory.rb",
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
33
|
+
"log/.keep",
|
34
|
+
"test/system/.keep",
|
35
|
+
"test/unit/.keep",
|
36
|
+
"tmp/.keep",
|
37
|
+
]
|
37
38
|
end
|
39
|
+
end
|
38
40
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
end
|
41
|
+
class Simple < Base
|
42
|
+
def initialize
|
43
|
+
@variations = ["simple"]
|
44
|
+
@name = "simple"
|
45
|
+
@module_name = "Simple"
|
46
|
+
@ruby_name = "simple"
|
46
47
|
end
|
48
|
+
end
|
47
49
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
end
|
50
|
+
class Underscored < Base
|
51
|
+
def initialize
|
52
|
+
@variations = ["my_gem", "my__gem", "MyGem", "myGem", "My_Gem"]
|
53
|
+
@name = "my_gem"
|
54
|
+
@module_name = "MyGem"
|
55
|
+
@ruby_name = "my_gem"
|
55
56
|
end
|
57
|
+
end
|
56
58
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
end
|
59
|
+
class HyphenatedOther < Base
|
60
|
+
def initialize
|
61
|
+
@variations = ["my-gem"]
|
62
|
+
@name = "my-gem"
|
63
|
+
@module_name = "MyGem"
|
64
|
+
@ruby_name = "my-gem"
|
64
65
|
end
|
65
|
-
|
66
66
|
end
|
67
67
|
end
|
data/test/system/ggem_tests.rb
CHANGED
@@ -1,10 +1,9 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "assert"
|
2
|
+
require "ggem"
|
3
3
|
|
4
|
-
require
|
4
|
+
require "test/support/name_set"
|
5
5
|
|
6
6
|
module GGem
|
7
|
-
|
8
7
|
class SystemTests < Assert::Context
|
9
8
|
|
10
9
|
NS_SIMPLE = GGem::NameSet::Simple
|
@@ -12,7 +11,6 @@ module GGem
|
|
12
11
|
NS_HYPHEN = GGem::NameSet::HyphenatedOther
|
13
12
|
|
14
13
|
desc "GGem"
|
15
|
-
|
16
14
|
end
|
17
15
|
|
18
16
|
class GemTests < SystemTests
|
@@ -29,12 +27,11 @@ module GGem
|
|
29
27
|
def assert_gem_name_set(name_set)
|
30
28
|
name_set.variations.each do |variation|
|
31
29
|
the_gem = GGem::Gem.new(TMP_PATH, variation)
|
32
|
-
|
33
|
-
|
34
|
-
|
30
|
+
assert_equal name_set.name, the_gem.name
|
31
|
+
assert_equal name_set.module_name, the_gem.module_name
|
32
|
+
assert_equal name_set.ruby_name, the_gem.ruby_name
|
35
33
|
end
|
36
34
|
end
|
37
|
-
|
38
35
|
end
|
39
36
|
|
40
37
|
class GemSaveTests < GemTests
|
@@ -64,10 +61,8 @@ module GGem
|
|
64
61
|
paths = (folders + files).collect{ |p| File.join(TMP_PATH, name_set.name, p) }
|
65
62
|
|
66
63
|
paths.flatten.each do |path|
|
67
|
-
assert File.exists?(path), "
|
64
|
+
assert File.exists?(path), "`#{path}` does not exist"
|
68
65
|
end
|
69
66
|
end
|
70
|
-
|
71
67
|
end
|
72
|
-
|
73
68
|
end
|