gem_publisher 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/gem_publisher.rb +9 -7
- data/lib/gem_publisher/publisher.rb +5 -2
- data/lib/gem_publisher/version.rb +1 -1
- data/test/builder_test.rb +1 -1
- data/test/common.rb +5 -1
- data/test/data/example.gemspec +12 -0
- data/test/data/gem_build +3 -3
- data/test/integration_test.rb +6 -5
- data/test/{gem_publisher_test.rb → publisher_test.rb} +6 -5
- metadata +5 -4
data/lib/gem_publisher.rb
CHANGED
@@ -3,15 +3,17 @@ require "gem_publisher/version"
|
|
3
3
|
|
4
4
|
module GemPublisher
|
5
5
|
|
6
|
-
# Publish a gem based on the supplied gemspec
|
7
|
-
#
|
8
|
-
#
|
6
|
+
# Publish a gem based on the supplied gemspec via supplied method, iff this
|
7
|
+
# version has not already been released and tagged in the origin Git
|
8
|
+
# repository.
|
9
|
+
#
|
10
|
+
# Version is derived from the gemspec.
|
9
11
|
#
|
10
12
|
# If a remote tag matching the version already exists, nothing is done.
|
11
13
|
# Otherwise, the gem is built, pushed, and tagged.
|
12
14
|
#
|
13
|
-
#
|
14
|
-
#
|
15
|
+
# Tags are expected to be of the form "v1.2.3", and generated tags follow
|
16
|
+
# this pattern.
|
15
17
|
#
|
16
18
|
# Method should be one of :rubygems or :gemfury, and the requisite
|
17
19
|
# credentials for the corresponding push command line tools must exist.
|
@@ -19,7 +21,7 @@ module GemPublisher
|
|
19
21
|
# Returns the gem file name if a gem was published; nil otherwise. A
|
20
22
|
# CliFacade::Error will be raised if a command fails.
|
21
23
|
#
|
22
|
-
def self.publish_if_updated(gemspec,
|
23
|
-
Publisher.new(gemspec
|
24
|
+
def self.publish_if_updated(gemspec, method=:rubygems)
|
25
|
+
Publisher.new(gemspec).publish_if_updated(method)
|
24
26
|
end
|
25
27
|
end
|
@@ -1,14 +1,17 @@
|
|
1
1
|
require "gem_publisher/git_remote"
|
2
2
|
require "gem_publisher/builder"
|
3
3
|
require "gem_publisher/pusher"
|
4
|
+
require "rubygems/specification"
|
4
5
|
|
5
6
|
module GemPublisher
|
6
7
|
class Publisher
|
7
8
|
attr_accessor :git_remote, :builder, :pusher
|
8
9
|
|
9
|
-
def initialize(gemspec
|
10
|
+
def initialize(gemspec)
|
10
11
|
@gemspec = gemspec
|
11
|
-
|
12
|
+
|
13
|
+
@version = eval(File.read(gemspec)).version.to_s
|
14
|
+
|
12
15
|
@git_remote = GitRemote.new
|
13
16
|
@builder = Builder.new
|
14
17
|
@pusher = Pusher.new
|
data/test/builder_test.rb
CHANGED
data/test/common.rb
CHANGED
@@ -6,6 +6,10 @@ require "mocha"
|
|
6
6
|
|
7
7
|
class MiniTest::Unit::TestCase
|
8
8
|
def data_file(name)
|
9
|
-
File.read(
|
9
|
+
File.read(data_file_path(name))
|
10
|
+
end
|
11
|
+
|
12
|
+
def data_file_path(name)
|
13
|
+
File.expand_path("../data/#{name}", __FILE__)
|
10
14
|
end
|
11
15
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
gemspec = Gem::Specification.new do |s|
|
2
|
+
s.name = 'example'
|
3
|
+
s.version = '0.0.3'
|
4
|
+
s.summary = 'summary'
|
5
|
+
s.description = 'description'
|
6
|
+
s.files = Dir.glob("{lib,test}/**/*")
|
7
|
+
s.require_path = 'lib'
|
8
|
+
s.has_rdoc = true
|
9
|
+
s.homepage = 'http://example.com'
|
10
|
+
s.authors = ['Luther Blisset']
|
11
|
+
s.email = 'user@example.com'
|
12
|
+
end
|
data/test/data/gem_build
CHANGED
@@ -1,4 +1,4 @@
|
|
1
1
|
Successfully built RubyGem
|
2
|
-
Name:
|
3
|
-
Version: 0.0.
|
4
|
-
File:
|
2
|
+
Name: example
|
3
|
+
Version: 0.0.3
|
4
|
+
File: example-0.0.3.gem
|
data/test/integration_test.rb
CHANGED
@@ -14,13 +14,14 @@ module GemPublisher
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def test_should_build_and_tag_and_publish
|
17
|
+
gemspec = data_file_path("example.gemspec")
|
17
18
|
expect_cli "git ls-remote --tags origin", data_file("tags")
|
18
|
-
expect_cli "gem build
|
19
|
-
expect_cli "gem push
|
19
|
+
expect_cli "gem build #{gemspec}", data_file("gem_build")
|
20
|
+
expect_cli "gem push example-0.0.3.gem"
|
20
21
|
expect_cli "git rev-parse HEAD", "1234abcd"
|
21
|
-
expect_cli "git update-ref refs/tags/
|
22
|
-
expect_cli "git push origin tag
|
23
|
-
GemPublisher.publish_if_updated
|
22
|
+
expect_cli "git update-ref refs/tags/v0.0.3 1234abcd"
|
23
|
+
expect_cli "git push origin tag v0.0.3"
|
24
|
+
GemPublisher.publish_if_updated gemspec
|
24
25
|
end
|
25
26
|
end
|
26
27
|
end
|
@@ -4,22 +4,23 @@ require "gem_publisher/publisher"
|
|
4
4
|
module GemPublisher
|
5
5
|
class PublisherTest < MiniTest::Unit::TestCase
|
6
6
|
def test_should_not_do_anything_and_return_nil_if_version_has_not_changed
|
7
|
-
p = Publisher.new("
|
7
|
+
p = Publisher.new(data_file_path("example.gemspec"))
|
8
8
|
p.builder = mock
|
9
9
|
p.builder.expects(:build).never
|
10
10
|
p.pusher = mock
|
11
11
|
p.pusher.expects(:push).never
|
12
12
|
p.git_remote = mock
|
13
|
-
p.git_remote.stubs(:tags).returns(%w[v0.0.1 v0.0.2])
|
13
|
+
p.git_remote.stubs(:tags).returns(%w[v0.0.1 v0.0.2 v0.0.3])
|
14
14
|
p.git_remote.expects(:add_tag).never
|
15
15
|
assert_nil p.publish_if_updated(:bogus)
|
16
16
|
end
|
17
17
|
|
18
18
|
def test_should_build_and_tag_and_publish_and_return_gem_name_if_version_has_changed
|
19
|
-
|
19
|
+
gemspec = data_file_path("example.gemspec")
|
20
|
+
p = Publisher.new(gemspec)
|
20
21
|
p.builder = mock
|
21
22
|
p.builder.expects(:build).
|
22
|
-
with(
|
23
|
+
with(gemspec).
|
23
24
|
returns("foo-0.0.3.gem")
|
24
25
|
p.pusher = mock
|
25
26
|
p.pusher.expects(:push).with("foo-0.0.3.gem", :method)
|
@@ -30,7 +31,7 @@ module GemPublisher
|
|
30
31
|
end
|
31
32
|
|
32
33
|
def test_should_build_and_tag_and_publish_and_return_gem_name_if_there_is_no_released_version
|
33
|
-
p = Publisher.new("
|
34
|
+
p = Publisher.new(data_file_path("example.gemspec"))
|
34
35
|
p.builder = mock
|
35
36
|
p.builder.expects(:build).returns("foo-0.0.3.gem")
|
36
37
|
p.pusher = mock
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: gem_publisher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.4
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Paul Battley
|
@@ -51,12 +51,13 @@ files:
|
|
51
51
|
- lib/gem_publisher/version.rb
|
52
52
|
- lib/gem_publisher.rb
|
53
53
|
- test/common.rb
|
54
|
+
- test/publisher_test.rb
|
54
55
|
- test/git_remote_test.rb
|
55
|
-
- test/gem_publisher_test.rb
|
56
56
|
- test/cli_facade_test.rb
|
57
57
|
- test/builder_test.rb
|
58
58
|
- test/data/tags
|
59
59
|
- test/data/gem_build
|
60
|
+
- test/data/example.gemspec
|
60
61
|
- test/integration_test.rb
|
61
62
|
homepage: http://github.com/alphagov/gem_publisher
|
62
63
|
licenses: []
|
@@ -71,7 +72,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
71
72
|
requirements:
|
72
73
|
- - ">="
|
73
74
|
- !ruby/object:Gem::Version
|
74
|
-
hash: -
|
75
|
+
hash: -2881051043129598916
|
75
76
|
segments:
|
76
77
|
- 0
|
77
78
|
version: "0"
|
@@ -80,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
80
81
|
requirements:
|
81
82
|
- - ">="
|
82
83
|
- !ruby/object:Gem::Version
|
83
|
-
hash: -
|
84
|
+
hash: -2881051043129598916
|
84
85
|
segments:
|
85
86
|
- 0
|
86
87
|
version: "0"
|