ggem 1.7.0 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +153 -9
- data/bin/ggem +1 -1
- data/ggem.gemspec +6 -3
- data/lib/ggem/cli.rb +40 -83
- data/lib/ggem/cli/clirb.rb +59 -0
- data/lib/ggem/cli/commands.rb +402 -0
- data/lib/ggem/gem.rb +9 -3
- data/lib/ggem/gemspec.rb +85 -0
- data/lib/ggem/git_repo.rb +60 -0
- data/lib/ggem/template.rb +2 -8
- data/lib/ggem/template_file/Gemfile.erb +1 -2
- data/lib/ggem/template_file/gemspec.erb +5 -5
- data/lib/ggem/version.rb +1 -1
- data/test/helper.rb +5 -44
- data/test/support/cmd_tests_helpers.rb +53 -0
- data/test/support/gem1/gem1.gemspec +16 -0
- data/test/support/gem2/gem2.gemspec +18 -0
- data/test/support/name_set.rb +0 -1
- data/test/system/ggem_tests.rb +45 -17
- data/test/unit/cli_tests.rb +1012 -0
- data/test/unit/gem_tests.rb +21 -4
- data/test/unit/gemspec_tests.rb +154 -0
- data/test/unit/git_repo_tests.rb +162 -0
- metadata +50 -33
- data/lib/ggem/template_file/Rakefile.erb +0 -1
data/test/unit/gem_tests.rb
CHANGED
@@ -3,21 +3,38 @@ require "ggem/gem"
|
|
3
3
|
|
4
4
|
class GGem::Gem
|
5
5
|
|
6
|
-
class
|
6
|
+
class UnitTests < Assert::Context
|
7
7
|
desc "GGem::Gem"
|
8
8
|
setup do
|
9
|
-
@
|
9
|
+
@gem_class = GGem::Gem
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
|
+
end
|
13
|
+
|
14
|
+
class InitTests < UnitTests
|
15
|
+
desc "when init"
|
16
|
+
setup do
|
17
|
+
@gem_name = Factory.string
|
18
|
+
@gem = @gem_class.new(TMP_PATH, @gem_name)
|
19
|
+
end
|
20
|
+
subject{ @gem }
|
12
21
|
|
13
22
|
should have_readers :root_path, :name
|
14
23
|
should have_imeths :save!, :path, :name=, :module_name, :ruby_name
|
15
24
|
|
16
25
|
should "know its root path and path" do
|
17
26
|
assert_equal TMP_PATH, subject.root_path
|
18
|
-
assert_equal File.join(TMP_PATH,
|
27
|
+
assert_equal File.join(TMP_PATH, @gem_name), subject.path
|
28
|
+
end
|
29
|
+
|
30
|
+
should "complain if no name is provided" do
|
31
|
+
assert_raises(NoNameError) do
|
32
|
+
@gem_class.new(TMP_PATH, [nil, ''].choice)
|
33
|
+
end
|
19
34
|
end
|
20
35
|
|
36
|
+
# most of the gem's behavior is covered in the system tests
|
37
|
+
|
21
38
|
end
|
22
39
|
|
23
40
|
end
|
@@ -0,0 +1,154 @@
|
|
1
|
+
require "assert"
|
2
|
+
require "ggem/gemspec"
|
3
|
+
|
4
|
+
require 'ggem/version'
|
5
|
+
require 'test/support/cmd_tests_helpers'
|
6
|
+
|
7
|
+
class GGem::Gemspec
|
8
|
+
|
9
|
+
class UnitTests < Assert::Context
|
10
|
+
desc "GGem::Gemspec"
|
11
|
+
setup do
|
12
|
+
@gemspec_class = GGem::Gemspec
|
13
|
+
end
|
14
|
+
subject{ @gemspec_class }
|
15
|
+
|
16
|
+
should "know the push host meta key" do
|
17
|
+
assert_equal 'allowed_push_host', subject::PUSH_HOST_META_KEY
|
18
|
+
end
|
19
|
+
|
20
|
+
should "use Rubygems as its default push host" do
|
21
|
+
assert_equal 'https://rubygems.org', subject::DEFAULT_PUSH_HOST
|
22
|
+
end
|
23
|
+
|
24
|
+
should "know which dir to build gems to" do
|
25
|
+
assert_equal 'pkg', subject::BUILD_TO_DIRNAME
|
26
|
+
end
|
27
|
+
|
28
|
+
should "know its exceptions" do
|
29
|
+
assert subject::NotFoundError < ArgumentError
|
30
|
+
assert subject::LoadError < ArgumentError
|
31
|
+
assert subject::CmdError < RuntimeError
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
class InitTests < UnitTests
|
37
|
+
desc "when init"
|
38
|
+
setup do
|
39
|
+
@gem1_root_path = TEST_SUPPORT_PATH.join('gem1')
|
40
|
+
@spec = @gemspec_class.new(@gem1_root_path)
|
41
|
+
end
|
42
|
+
subject{ @spec }
|
43
|
+
|
44
|
+
should have_readers :path, :name, :version, :version_tag
|
45
|
+
should have_readers :gem_file_name, :gem_file, :push_host
|
46
|
+
should have_imeths :run_build_cmd, :run_install_cmd, :run_push_cmd
|
47
|
+
|
48
|
+
should "know its attrs" do
|
49
|
+
exp = @gem1_root_path.join('gem1.gemspec')
|
50
|
+
assert_equal exp, subject.path
|
51
|
+
|
52
|
+
assert_equal 'gem1', subject.name
|
53
|
+
assert_equal '0.1.0', subject.version.to_s
|
54
|
+
assert_equal 'v0.1.0', subject.version_tag
|
55
|
+
|
56
|
+
exp = "#{subject.name}-#{subject.version}.gem"
|
57
|
+
assert_equal exp, subject.gem_file_name
|
58
|
+
|
59
|
+
exp = File.join(@gemspec_class::BUILD_TO_DIRNAME, subject.gem_file_name)
|
60
|
+
assert_equal exp, subject.gem_file
|
61
|
+
end
|
62
|
+
|
63
|
+
should "know its push host" do
|
64
|
+
# gem1 has no meta host specified, so the default push host is used
|
65
|
+
assert_equal @gemspec_class::DEFAULT_PUSH_HOST, subject.push_host
|
66
|
+
|
67
|
+
# gem2 has a meta host specified, so that is used over the default
|
68
|
+
gem2_spec = @gemspec_class.new(TEST_SUPPORT_PATH.join('gem2'))
|
69
|
+
assert_equal 'http://gems.example.com', gem2_spec.push_host
|
70
|
+
|
71
|
+
# prefer the env push hosts over configured and default hosts
|
72
|
+
prev_env_push_host = ENV['GGEM_PUSH_HOST']
|
73
|
+
ENV['GGEM_PUSH_HOST'] = Factory.string
|
74
|
+
spec = @gemspec_class.new(TEST_SUPPORT_PATH.join(['gem1', 'gem2'].choice))
|
75
|
+
assert_equal ENV['GGEM_PUSH_HOST'], spec.push_host
|
76
|
+
ENV['GGEM_PUSH_HOST'] = prev_env_push_host
|
77
|
+
end
|
78
|
+
|
79
|
+
should "complain if the given gemspec root doesn't exist" do
|
80
|
+
assert_raises(NotFoundError) do
|
81
|
+
@gemspec_class.new('path/that-is/not-found')
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
should "complain if the given gemspec root contains no gemspec file" do
|
86
|
+
assert_raises(NotFoundError) do
|
87
|
+
@gemspec_class.new(TEST_SUPPORT_PATH)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
class CmdTests < InitTests
|
94
|
+
include GGem::CmdTestsHelpers
|
95
|
+
setup do
|
96
|
+
@exp_build_path = @gem1_root_path.join(subject.gem_file_name)
|
97
|
+
@exp_pkg_path = @gem1_root_path.join(@gemspec_class::BUILD_TO_DIRNAME, subject.gem_file_name)
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
|
102
|
+
class RunBuildCmdTests < CmdTests
|
103
|
+
desc "`run_build_cmd`"
|
104
|
+
setup do
|
105
|
+
@exp_cmds_run = [
|
106
|
+
"gem build --verbose #{subject.path}",
|
107
|
+
"mkdir -p #{@exp_pkg_path.dirname}",
|
108
|
+
"mv #{@exp_build_path} #{@exp_pkg_path}"
|
109
|
+
]
|
110
|
+
end
|
111
|
+
|
112
|
+
should "run system cmds to build the gem" do
|
113
|
+
assert_exp_cmds_run{ subject.run_build_cmd }
|
114
|
+
end
|
115
|
+
|
116
|
+
should "complain if any system cmds are not successful" do
|
117
|
+
assert_exp_cmds_error(CmdError){ subject.run_build_cmd }
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
121
|
+
|
122
|
+
class RunInstallCmdTests < CmdTests
|
123
|
+
desc "`run_install_cmd`"
|
124
|
+
setup do
|
125
|
+
@exp_cmds_run = ["gem install #{@exp_pkg_path}"]
|
126
|
+
end
|
127
|
+
|
128
|
+
should "run a system cmd to install the gem" do
|
129
|
+
assert_exp_cmds_run{ subject.run_install_cmd }
|
130
|
+
end
|
131
|
+
|
132
|
+
should "complain if the system cmd is not successful" do
|
133
|
+
assert_exp_cmds_error(CmdError){ subject.run_install_cmd }
|
134
|
+
end
|
135
|
+
|
136
|
+
end
|
137
|
+
|
138
|
+
class RunPushCmdTests < CmdTests
|
139
|
+
desc "`run_push_cmd`"
|
140
|
+
setup do
|
141
|
+
@exp_cmds_run = ["gem push #{@exp_pkg_path} --host #{subject.push_host}"]
|
142
|
+
end
|
143
|
+
|
144
|
+
should "run a system cmd to push the gem to the push host" do
|
145
|
+
assert_exp_cmds_run{ subject.run_push_cmd }
|
146
|
+
end
|
147
|
+
|
148
|
+
should "complain if the system cmd is not successful" do
|
149
|
+
assert_exp_cmds_error(CmdError){ subject.run_push_cmd }
|
150
|
+
end
|
151
|
+
|
152
|
+
end
|
153
|
+
|
154
|
+
end
|
@@ -0,0 +1,162 @@
|
|
1
|
+
require "assert"
|
2
|
+
require "ggem/git_repo"
|
3
|
+
|
4
|
+
require 'test/support/cmd_tests_helpers'
|
5
|
+
|
6
|
+
class GGem::GitRepo
|
7
|
+
|
8
|
+
class UnitTests < Assert::Context
|
9
|
+
desc "GGem::GitRepo"
|
10
|
+
setup do
|
11
|
+
@git_repo_class = GGem::GitRepo
|
12
|
+
end
|
13
|
+
subject{ @git_repo_class }
|
14
|
+
|
15
|
+
should "know its exceptions" do
|
16
|
+
assert subject::NotFoundError < ArgumentError
|
17
|
+
assert subject::CmdError < RuntimeError
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
class InitTests < UnitTests
|
23
|
+
desc "when init"
|
24
|
+
setup do
|
25
|
+
@repo_path = TEST_SUPPORT_PATH.join('gem1')
|
26
|
+
@repo = @git_repo_class.new(@repo_path)
|
27
|
+
end
|
28
|
+
subject{ @repo }
|
29
|
+
|
30
|
+
should have_readers :path
|
31
|
+
should have_imeths :run_init_cmd
|
32
|
+
should have_imeths :run_validate_clean_cmd, :run_validate_committed_cmd
|
33
|
+
should have_imeths :run_push_cmd
|
34
|
+
should have_imeths :run_add_version_tag_cmd, :run_rm_tag_cmd
|
35
|
+
|
36
|
+
should "know its path" do
|
37
|
+
assert_equal @repo_path, subject.path
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
class CmdTests < InitTests
|
43
|
+
include GGem::CmdTestsHelpers
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
class RunInitCmdTests < CmdTests
|
48
|
+
desc "`run_init_cmd`"
|
49
|
+
setup do
|
50
|
+
@exp_cmds_run = [
|
51
|
+
"cd #{@repo_path} && git init",
|
52
|
+
"cd #{@repo_path} && git add --all && git add -f *.gitkeep"
|
53
|
+
]
|
54
|
+
end
|
55
|
+
|
56
|
+
should "run a system cmd to init the repo and add any existing files" do
|
57
|
+
assert_exp_cmds_run{ subject.run_init_cmd }
|
58
|
+
end
|
59
|
+
|
60
|
+
should "complain if any system cmds are not successful" do
|
61
|
+
assert_exp_cmds_error(CmdError){ subject.run_init_cmd }
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
class RunValidateCleanCmdTests < CmdTests
|
67
|
+
desc "`run_validate_clean_cmd`"
|
68
|
+
setup do
|
69
|
+
@exp_cmds_run = [
|
70
|
+
"cd #{@repo_path} && git diff --exit-code"
|
71
|
+
]
|
72
|
+
end
|
73
|
+
|
74
|
+
should "run a system cmd to see if there are any diffs" do
|
75
|
+
assert_exp_cmds_run{ subject.run_validate_clean_cmd }
|
76
|
+
end
|
77
|
+
|
78
|
+
should "complain if any system cmds are not successful" do
|
79
|
+
assert_exp_cmds_error(CmdError){ subject.run_validate_clean_cmd }
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
class RunValidateCommittedCmdTests < CmdTests
|
85
|
+
desc "`run_validate_committed_cmd`"
|
86
|
+
setup do
|
87
|
+
@exp_cmds_run = [
|
88
|
+
"cd #{@repo_path} && git diff-index --quiet --cached HEAD"
|
89
|
+
]
|
90
|
+
end
|
91
|
+
|
92
|
+
should "run a system cmd to see if there is anything still uncommitted" do
|
93
|
+
assert_exp_cmds_run{ subject.run_validate_committed_cmd }
|
94
|
+
end
|
95
|
+
|
96
|
+
should "complain if any system cmds are not successful" do
|
97
|
+
assert_exp_cmds_error(CmdError){ subject.run_validate_committed_cmd }
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
|
102
|
+
class RunPushCmdTests < CmdTests
|
103
|
+
desc "`run_push_cmd`"
|
104
|
+
setup do
|
105
|
+
@exp_cmds_run = [
|
106
|
+
"cd #{@repo_path} && git push",
|
107
|
+
"cd #{@repo_path} && git push --tags"
|
108
|
+
]
|
109
|
+
end
|
110
|
+
|
111
|
+
should "run a system cmds to push commits/tags" do
|
112
|
+
assert_exp_cmds_run{ subject.run_push_cmd }
|
113
|
+
end
|
114
|
+
|
115
|
+
should "complain if any system cmds are not successful" do
|
116
|
+
assert_exp_cmds_error(CmdError){ subject.run_push_cmd }
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
120
|
+
|
121
|
+
class RunAddVersionTagCmdTests < CmdTests
|
122
|
+
desc "`run_add_version_tag_cmd`"
|
123
|
+
setup do
|
124
|
+
@version = Factory.string
|
125
|
+
@tag = Factory.string
|
126
|
+
|
127
|
+
@exp_cmds_run = [
|
128
|
+
"cd #{@repo_path} && git tag -a -m \"Version #{@version}\" #{@tag}"
|
129
|
+
]
|
130
|
+
end
|
131
|
+
|
132
|
+
should "run a system cmd to add a tag for a given version/tag string" do
|
133
|
+
assert_exp_cmds_run{ subject.run_add_version_tag_cmd(@version, @tag) }
|
134
|
+
end
|
135
|
+
|
136
|
+
should "complain if any system cmds are not successful" do
|
137
|
+
assert_exp_cmds_error(CmdError){ subject.run_add_version_tag_cmd(@version, @tag) }
|
138
|
+
end
|
139
|
+
|
140
|
+
end
|
141
|
+
|
142
|
+
class RunRmTagCmdTests < CmdTests
|
143
|
+
desc "`run_rm_tag_cmd`"
|
144
|
+
setup do
|
145
|
+
@tag = Factory.string
|
146
|
+
|
147
|
+
@exp_cmds_run = [
|
148
|
+
"cd #{@repo_path} && git tag -d #{@tag}"
|
149
|
+
]
|
150
|
+
end
|
151
|
+
|
152
|
+
should "run a system cmd to remove a tag with the given tag string" do
|
153
|
+
assert_exp_cmds_run{ subject.run_rm_tag_cmd(@tag) }
|
154
|
+
end
|
155
|
+
|
156
|
+
should "complain if any system cmds are not successful" do
|
157
|
+
assert_exp_cmds_error(CmdError){ subject.run_rm_tag_cmd(@tag) }
|
158
|
+
end
|
159
|
+
|
160
|
+
end
|
161
|
+
|
162
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ggem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 7
|
9
|
-
- 0
|
10
|
-
version: 1.7.0
|
4
|
+
version: 1.8.0
|
11
5
|
platform: ruby
|
12
6
|
authors:
|
13
7
|
- Kelly Redding
|
@@ -16,24 +10,39 @@ autorequire:
|
|
16
10
|
bindir: bin
|
17
11
|
cert_chain: []
|
18
12
|
|
19
|
-
date:
|
13
|
+
date: 2016-01-04 00:00:00 Z
|
20
14
|
dependencies:
|
21
15
|
- !ruby/object:Gem::Dependency
|
22
|
-
|
23
|
-
none: false
|
16
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
24
17
|
requirements:
|
25
18
|
- - ~>
|
26
19
|
- !ruby/object:Gem::Version
|
27
|
-
|
28
|
-
segments:
|
29
|
-
- 2
|
30
|
-
- 15
|
31
|
-
version: "2.15"
|
20
|
+
version: 2.15.0
|
32
21
|
type: :development
|
22
|
+
requirement: *id001
|
33
23
|
name: assert
|
34
|
-
version_requirements: *id001
|
35
24
|
prerelease: false
|
36
|
-
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
27
|
+
requirements:
|
28
|
+
- - ~>
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: 0.1.0
|
31
|
+
type: :runtime
|
32
|
+
requirement: *id002
|
33
|
+
name: much-plugin
|
34
|
+
prerelease: false
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 3.0.1
|
41
|
+
type: :runtime
|
42
|
+
requirement: *id003
|
43
|
+
name: scmd
|
44
|
+
prerelease: false
|
45
|
+
description: "\"Juh Gem\", baby! (a gem utility CLI)"
|
37
46
|
email:
|
38
47
|
- kelly@kellyredding.com
|
39
48
|
- collin.redding@me.com
|
@@ -53,12 +62,15 @@ files:
|
|
53
62
|
- ggem.gemspec
|
54
63
|
- lib/ggem.rb
|
55
64
|
- lib/ggem/cli.rb
|
65
|
+
- lib/ggem/cli/clirb.rb
|
66
|
+
- lib/ggem/cli/commands.rb
|
56
67
|
- lib/ggem/gem.rb
|
68
|
+
- lib/ggem/gemspec.rb
|
69
|
+
- lib/ggem/git_repo.rb
|
57
70
|
- lib/ggem/template.rb
|
58
71
|
- lib/ggem/template_file/Gemfile.erb
|
59
72
|
- lib/ggem/template_file/LICENSE.erb
|
60
73
|
- lib/ggem/template_file/README.md.erb
|
61
|
-
- lib/ggem/template_file/Rakefile.erb
|
62
74
|
- lib/ggem/template_file/gemspec.erb
|
63
75
|
- lib/ggem/template_file/gitignore.erb
|
64
76
|
- lib/ggem/template_file/lib.rb.erb
|
@@ -67,46 +79,51 @@ files:
|
|
67
79
|
- lib/ggem/template_file/test_support_factory.rb.erb
|
68
80
|
- lib/ggem/version.rb
|
69
81
|
- test/helper.rb
|
82
|
+
- test/support/cmd_tests_helpers.rb
|
70
83
|
- test/support/factory.rb
|
84
|
+
- test/support/gem1/gem1.gemspec
|
85
|
+
- test/support/gem2/gem2.gemspec
|
71
86
|
- test/support/name_set.rb
|
72
87
|
- test/system/ggem_tests.rb
|
88
|
+
- test/unit/cli_tests.rb
|
73
89
|
- test/unit/gem_tests.rb
|
90
|
+
- test/unit/gemspec_tests.rb
|
91
|
+
- test/unit/git_repo_tests.rb
|
74
92
|
homepage: http://github.com/redding/ggem
|
75
93
|
licenses:
|
76
94
|
- MIT
|
95
|
+
metadata: {}
|
96
|
+
|
77
97
|
post_install_message:
|
78
98
|
rdoc_options: []
|
79
99
|
|
80
100
|
require_paths:
|
81
101
|
- lib
|
82
102
|
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
-
none: false
|
84
103
|
requirements:
|
85
|
-
-
|
104
|
+
- &id004
|
105
|
+
- ">="
|
86
106
|
- !ruby/object:Gem::Version
|
87
|
-
hash: 3
|
88
|
-
segments:
|
89
|
-
- 0
|
90
107
|
version: "0"
|
91
108
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
|
-
none: false
|
93
109
|
requirements:
|
94
|
-
-
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
hash: 3
|
97
|
-
segments:
|
98
|
-
- 0
|
99
|
-
version: "0"
|
110
|
+
- *id004
|
100
111
|
requirements: []
|
101
112
|
|
102
113
|
rubyforge_project:
|
103
|
-
rubygems_version:
|
114
|
+
rubygems_version: 2.5.1
|
104
115
|
signing_key:
|
105
|
-
specification_version:
|
106
|
-
summary: "\"Juh Gem\", baby! (a
|
116
|
+
specification_version: 4
|
117
|
+
summary: "\"Juh Gem\", baby! (a gem utility CLI)"
|
107
118
|
test_files:
|
108
119
|
- test/helper.rb
|
120
|
+
- test/support/cmd_tests_helpers.rb
|
109
121
|
- test/support/factory.rb
|
122
|
+
- test/support/gem1/gem1.gemspec
|
123
|
+
- test/support/gem2/gem2.gemspec
|
110
124
|
- test/support/name_set.rb
|
111
125
|
- test/system/ggem_tests.rb
|
126
|
+
- test/unit/cli_tests.rb
|
112
127
|
- test/unit/gem_tests.rb
|
128
|
+
- test/unit/gemspec_tests.rb
|
129
|
+
- test/unit/git_repo_tests.rb
|