gem_publisher 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -18,7 +18,7 @@ module GemPublisher
18
18
  end
19
19
 
20
20
  def publish_if_updated(method)
21
- return unless version_bumped?
21
+ return if version_released?
22
22
  @builder.build(@gemspec).tap { |gem|
23
23
  @pusher.push gem, method
24
24
  @git_remote.add_tag "v#@version"
@@ -26,13 +26,12 @@ module GemPublisher
26
26
  end
27
27
 
28
28
  private
29
- def version_bumped?
30
- last_release = @git_remote.tags.
29
+ def version_released?
30
+ releases = @git_remote.tags.
31
31
  select { |t| t =~ /^v\d+(\.\d+)+/ }.
32
- map { |t| t.scan(/\d+/).map(&:to_i) }.
33
- sort.last
32
+ map { |t| t.scan(/\d+/).map(&:to_i) }
34
33
  this_release = @version.split(/\./).map(&:to_i)
35
- this_release != last_release
34
+ releases.include?(this_release)
36
35
  end
37
36
 
38
37
  def tag_remote
@@ -1,3 +1,3 @@
1
1
  module GemPublisher
2
- VERSION = "1.1.0"
2
+ VERSION = "1.1.1"
3
3
  end
@@ -15,6 +15,18 @@ module GemPublisher
15
15
  assert_nil p.publish_if_updated(:bogus)
16
16
  end
17
17
 
18
+ def test_should_not_do_anything_and_return_nil_if_version_has_already_been_tagged_even_with_a_later_tag
19
+ p = Publisher.new(data_file_path("example.gemspec"))
20
+ p.builder = mock
21
+ p.builder.expects(:build).never
22
+ p.pusher = mock
23
+ p.pusher.expects(:push).never
24
+ p.git_remote = mock
25
+ p.git_remote.stubs(:tags).returns(%w[v0.0.1 v0.0.2 v0.0.3 v0.1.0])
26
+ p.git_remote.expects(:add_tag).never
27
+ assert_nil p.publish_if_updated(:bogus)
28
+ end
29
+
18
30
  def test_should_build_and_tag_and_publish_and_return_gem_name_if_version_has_changed
19
31
  gemspec = data_file_path("example.gemspec")
20
32
  p = Publisher.new(gemspec)
@@ -41,5 +53,17 @@ module GemPublisher
41
53
  p.git_remote.expects(:add_tag).with("v0.0.3")
42
54
  assert_equal "foo-0.0.3.gem", p.publish_if_updated(:method)
43
55
  end
56
+
57
+ def test_should_build_and_tag_and_publish_and_return_gem_name_if_the_current_version_has_not_been_released
58
+ p = Publisher.new(data_file_path("example.gemspec"))
59
+ p.builder = mock
60
+ p.builder.expects(:build).returns("foo-0.0.3.gem")
61
+ p.pusher = mock
62
+ p.pusher.expects(:push)
63
+ p.git_remote = mock
64
+ p.git_remote.stubs(:tags).returns(%w[v0.0.1 v0.0.2 v0.1.0])
65
+ p.git_remote.expects(:add_tag).with("v0.0.3")
66
+ assert_equal "foo-0.0.3.gem", p.publish_if_updated(:method)
67
+ end
44
68
  end
45
69
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: gem_publisher
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.1.0
5
+ version: 1.1.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Paul Battley
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2012-06-07 00:00:00 Z
13
+ date: 2012-07-18 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: mocha
@@ -73,7 +73,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - ">="
75
75
  - !ruby/object:Gem::Version
76
- hash: -660420523550429852
76
+ hash: 4214267775999231123
77
77
  segments:
78
78
  - 0
79
79
  version: "0"
@@ -82,14 +82,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
82
  requirements:
83
83
  - - ">="
84
84
  - !ruby/object:Gem::Version
85
- hash: -660420523550429852
85
+ hash: 4214267775999231123
86
86
  segments:
87
87
  - 0
88
88
  version: "0"
89
89
  requirements: []
90
90
 
91
91
  rubyforge_project:
92
- rubygems_version: 1.8.12
92
+ rubygems_version: 1.8.24
93
93
  signing_key:
94
94
  specification_version: 3
95
95
  summary: Automatically build, tag, and push gems