gem_publisher 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -16,9 +16,10 @@ module GemPublisher
16
16
 
17
17
  def publish_if_updated(method)
18
18
  return unless version_bumped?
19
- gem = @builder.build(@gemspec)
20
- @git_remote.add_tag "v#@version"
21
- @pusher.push gem, method
19
+ @builder.build(@gemspec).tap { |gem|
20
+ @pusher.push gem, method
21
+ @git_remote.add_tag "v#@version"
22
+ }
22
23
  end
23
24
 
24
25
  private
@@ -1,3 +1,3 @@
1
1
  module GemPublisher
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/gem_publisher.rb CHANGED
@@ -2,6 +2,23 @@ require "gem_publisher/publisher"
2
2
  require "gem_publisher/version"
3
3
 
4
4
  module GemPublisher
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.
9
+ #
10
+ # If a remote tag matching the version already exists, nothing is done.
11
+ # Otherwise, the gem is built, pushed, and tagged.
12
+ #
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
+ #
16
+ # Method should be one of :rubygems or :gemfury, and the requisite
17
+ # credentials for the corresponding push command line tools must exist.
18
+ #
19
+ # Returns the gem file name if a gem was published; nil otherwise. A
20
+ # CliFacade::Error will be raised if a command fails.
21
+ #
5
22
  def self.publish_if_updated(gemspec, version, method=:rubygems)
6
23
  Publisher.new(gemspec, version).publish_if_updated(method)
7
24
  end
@@ -3,7 +3,7 @@ require "gem_publisher/publisher"
3
3
 
4
4
  module GemPublisher
5
5
  class PublisherTest < MiniTest::Unit::TestCase
6
- def test_should_not_do_anything_if_version_has_not_changed
6
+ def test_should_not_do_anything_and_return_nil_if_version_has_not_changed
7
7
  p = Publisher.new("foo.gemspec", "0.0.2")
8
8
  p.builder = mock
9
9
  p.builder.expects(:build).never
@@ -12,10 +12,10 @@ module GemPublisher
12
12
  p.git_remote = mock
13
13
  p.git_remote.stubs(:tags).returns(%w[v0.0.1 v0.0.2])
14
14
  p.git_remote.expects(:add_tag).never
15
- p.publish_if_updated(:bogus)
15
+ assert_nil p.publish_if_updated(:bogus)
16
16
  end
17
17
 
18
- def test_should_build_and_tag_and_publish_if_version_has_changed
18
+ def test_should_build_and_tag_and_publish_and_return_gem_name_if_version_has_changed
19
19
  p = Publisher.new("foo.gemspec", "0.0.3")
20
20
  p.builder = mock
21
21
  p.builder.expects(:build).
@@ -26,10 +26,10 @@ module GemPublisher
26
26
  p.git_remote = mock
27
27
  p.git_remote.stubs(:tags).returns(%w[v0.0.1 v0.0.2])
28
28
  p.git_remote.expects(:add_tag).with("v0.0.3")
29
- p.publish_if_updated(:method)
29
+ assert_equal "foo-0.0.3.gem", p.publish_if_updated(:method)
30
30
  end
31
31
 
32
- def test_should_build_and_tag_and_publish_if_there_is_no_released_version
32
+ def test_should_build_and_tag_and_publish_and_return_gem_name_if_there_is_no_released_version
33
33
  p = Publisher.new("foo.gemspec", "0.0.3")
34
34
  p.builder = mock
35
35
  p.builder.expects(:build).returns("foo-0.0.3.gem")
@@ -38,7 +38,7 @@ module GemPublisher
38
38
  p.git_remote = mock
39
39
  p.git_remote.stubs(:tags).returns([])
40
40
  p.git_remote.expects(:add_tag).with("v0.0.3")
41
- p.publish_if_updated(:method)
41
+ assert_equal "foo-0.0.3.gem", p.publish_if_updated(:method)
42
42
  end
43
43
  end
44
44
  end
@@ -16,10 +16,10 @@ module GemPublisher
16
16
  def test_should_build_and_tag_and_publish
17
17
  expect_cli "git ls-remote --tags origin", data_file("tags")
18
18
  expect_cli "gem build example.gemspec", data_file("gem_build")
19
+ expect_cli "gem push test_gem-0.0.2.gem"
19
20
  expect_cli "git rev-parse HEAD", "1234abcd"
20
21
  expect_cli "git update-ref refs/tags/v1.0.0 1234abcd"
21
22
  expect_cli "git push origin tag v1.0.0"
22
- expect_cli "gem push test_gem-0.0.2.gem"
23
23
  GemPublisher.publish_if_updated "example.gemspec", "1.0.0"
24
24
  end
25
25
  end
metadata CHANGED
@@ -1,60 +1,95 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: gem_publisher
3
- version: !ruby/object:Gem::Version
4
- version: 0.0.1
3
+ version: !ruby/object:Gem::Version
5
4
  prerelease:
5
+ version: 0.0.2
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Paul Battley
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-10 00:00:00.000000000 Z
13
- dependencies: []
12
+
13
+ date: 2012-05-11 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: mocha
17
+ requirement: &id001 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: "0"
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: *id001
26
+ - !ruby/object:Gem::Dependency
27
+ name: rake
28
+ requirement: &id002 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: *id002
14
37
  description: Automatically build, tag, and push a gem when its version has been updated.
15
38
  email: pbattley@gmail.com
16
39
  executables: []
40
+
17
41
  extensions: []
42
+
18
43
  extra_rdoc_files: []
19
- files:
20
- - lib/gem_publisher/git_remote.rb
44
+
45
+ files:
21
46
  - lib/gem_publisher/builder.rb
22
- - lib/gem_publisher/cli_facade.rb
23
47
  - lib/gem_publisher/pusher.rb
48
+ - lib/gem_publisher/cli_facade.rb
24
49
  - lib/gem_publisher/publisher.rb
50
+ - lib/gem_publisher/git_remote.rb
25
51
  - lib/gem_publisher/version.rb
26
52
  - lib/gem_publisher.rb
27
- - test/builder_test.rb
53
+ - test/common.rb
28
54
  - test/git_remote_test.rb
55
+ - test/gem_publisher_test.rb
56
+ - test/cli_facade_test.rb
57
+ - test/builder_test.rb
29
58
  - test/data/tags
30
59
  - test/data/gem_build
31
- - test/cli_facade_test.rb
32
- - test/gem_publisher_test.rb
33
60
  - test/integration_test.rb
34
- - test/common.rb
35
- homepage: http://github.com/threedaymonk/gem_publisher
61
+ homepage: http://github.com/alphagov/gem_publisher
36
62
  licenses: []
63
+
37
64
  post_install_message:
38
65
  rdoc_options: []
39
- require_paths:
66
+
67
+ require_paths:
40
68
  - lib
41
- required_ruby_version: !ruby/object:Gem::Requirement
69
+ required_ruby_version: !ruby/object:Gem::Requirement
42
70
  none: false
43
- requirements:
44
- - - ! '>='
45
- - !ruby/object:Gem::Version
46
- version: '0'
47
- required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ hash: 1427601280392416500
75
+ segments:
76
+ - 0
77
+ version: "0"
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
79
  none: false
49
- requirements:
50
- - - ! '>='
51
- - !ruby/object:Gem::Version
52
- version: '0'
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ hash: 1427601280392416500
84
+ segments:
85
+ - 0
86
+ version: "0"
53
87
  requirements: []
88
+
54
89
  rubyforge_project:
55
- rubygems_version: 1.8.24
90
+ rubygems_version: 1.8.12
56
91
  signing_key:
57
92
  specification_version: 3
58
93
  summary: Automatically build, tag, and push gems
59
94
  test_files: []
60
- has_rdoc: true
95
+