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.
@@ -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 and version via
7
- # method, iff this version has not already been released and tagged
8
- # in the origin Git repository.
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
- # Version should be a string of the form "1.2.3". Tags are expected to
14
- # be of the form "v1.2.3", and generated tags follow this pattern.
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, version, method=:rubygems)
23
- Publisher.new(gemspec, version).publish_if_updated(method)
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, version)
10
+ def initialize(gemspec)
10
11
  @gemspec = gemspec
11
- @version = version
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
@@ -1,3 +1,3 @@
1
1
  module GemPublisher
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -10,7 +10,7 @@ module GemPublisher
10
10
  returns(data_file("gem_build"))
11
11
 
12
12
  builder = Builder.new(cli_facade)
13
- assert_equal "test_gem-0.0.2.gem", builder.build("foo.gemspec")
13
+ assert_equal "example-0.0.3.gem", builder.build("foo.gemspec")
14
14
  end
15
15
  end
16
16
  end
@@ -6,6 +6,10 @@ require "mocha"
6
6
 
7
7
  class MiniTest::Unit::TestCase
8
8
  def data_file(name)
9
- File.read(File.expand_path("../data/#{name}", __FILE__))
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
@@ -1,4 +1,4 @@
1
1
  Successfully built RubyGem
2
- Name: test_gem
3
- Version: 0.0.2
4
- File: test_gem-0.0.2.gem
2
+ Name: example
3
+ Version: 0.0.3
4
+ File: example-0.0.3.gem
@@ -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 example.gemspec", data_file("gem_build")
19
- expect_cli "gem push test_gem-0.0.2.gem"
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/v1.0.0 1234abcd"
22
- expect_cli "git push origin tag v1.0.0"
23
- GemPublisher.publish_if_updated "example.gemspec", "1.0.0"
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("foo.gemspec", "0.0.2")
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
- p = Publisher.new("foo.gemspec", "0.0.3")
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("foo.gemspec").
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("foo.gemspec", "0.0.3")
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.3
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: -2618561868502119280
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: -2618561868502119280
84
+ hash: -2881051043129598916
84
85
  segments:
85
86
  - 0
86
87
  version: "0"