gem_publisher 1.3.2 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,8 +12,8 @@ module GemPublisher
12
12
  # If a remote tag matching the version already exists, nothing is done.
13
13
  # Otherwise, the gem is built, pushed, and tagged.
14
14
  #
15
- # Tags are expected to be of the form "v1.2.3", and generated tags follow
16
- # this pattern.
15
+ # Tags are of the form "v1.2.3" by default, and generated tags follow
16
+ # this pattern; you can override this by passing in the :tag_prefix option.
17
17
  #
18
18
  # Method should be one of :rubygems or :gemfury, and the requisite
19
19
  # credentials for the corresponding push command line tools must exist.
@@ -22,6 +22,7 @@ module GemPublisher
22
22
  # CliFacade::Error will be raised if a command fails.
23
23
  #
24
24
  def self.publish_if_updated(gemspec, method=:rubygems, options={})
25
- Publisher.new(gemspec).publish_if_updated(method, options)
25
+ publisher = Publisher.new(gemspec, tag_prefix: options.delete(:tag_prefix))
26
+ publisher.publish_if_updated(method, options)
26
27
  end
27
28
  end
@@ -8,8 +8,11 @@ module GemPublisher
8
8
  attr_accessor :git_remote, :builder, :pusher
9
9
  attr_reader :version
10
10
 
11
- def initialize(gemspec)
11
+ # Supported options:
12
+ # :tag_prefix - use a custom prefix for Git tags (defaults to 'v')
13
+ def initialize(gemspec, options = {})
12
14
  @gemspec = gemspec
15
+ @tag_prefix = options[:tag_prefix] || 'v'
13
16
 
14
17
  @version = eval(File.read(gemspec), TOPLEVEL_BINDING).version.to_s
15
18
 
@@ -18,17 +21,22 @@ module GemPublisher
18
21
  @pusher = Pusher.new
19
22
  end
20
23
 
24
+ # Publish the gem if its version has changed since the last release.
25
+ #
26
+ # Supported options:
27
+ # :as - specify a shared account to publish the gem (Gemfury only)
21
28
  def publish_if_updated(method, options = {})
22
29
  return if version_released?
23
30
  @builder.build(@gemspec).tap { |gem|
31
+ tag_prefix = options[:tag_prefix] || 'v'
24
32
  @pusher.push gem, method, options
25
- @git_remote.add_tag "v#@version"
33
+ @git_remote.add_tag "#{@tag_prefix}#{@version}"
26
34
  }
27
35
  end
28
36
 
29
37
  def version_released?
30
38
  releases = @git_remote.tags.
31
- select { |t| t =~ /^v\d+(\.\d+)+/ }.
39
+ select { |t| t =~ /^#{@tag_prefix}\d+(\.\d+)+/ }.
32
40
  map { |t| t.scan(/\d+/).map(&:to_i) }
33
41
  this_release = @version.split(/\./).map(&:to_i)
34
42
  releases.include?(this_release)
@@ -11,6 +11,10 @@ module GemPublisher
11
11
  "gemfury" => %w[fury push]
12
12
  }
13
13
 
14
+ # Publish the gem.
15
+ #
16
+ # Supported options:
17
+ # :as - specify a shared account to publish the gem (Gemfury only)
14
18
  def push(gem, method, options = {})
15
19
  push_command = PUSH_METHODS[method.to_s] or raise "Unknown Gem push method #{method.inspect}."
16
20
  push_command += [gem]
@@ -1,3 +1,3 @@
1
1
  module GemPublisher
2
- VERSION = "1.3.2"
2
+ VERSION = "1.4.0"
3
3
  end
@@ -79,6 +79,18 @@ module GemPublisher
79
79
  assert_equal "foo-0.0.3.gem", p.publish_if_updated(:method)
80
80
  end
81
81
 
82
+ def test_should_publish_with_custom_git_tag_prefix_if_given
83
+ p = Publisher.new(data_file_path("example.gemspec"), :tag_prefix => "prefix")
84
+ p.builder = mock
85
+ p.builder.expects(:build).returns("foo-0.0.3.gem")
86
+ p.pusher = mock
87
+ p.pusher.expects(:push).with("foo-0.0.3.gem", :method, {})
88
+ p.git_remote = mock
89
+ p.git_remote.stubs(:tags).returns(%w[prefix0.0.1 prefix0.0.2 prefix0.1.0])
90
+ p.git_remote.expects(:add_tag).with("prefix0.0.3")
91
+ assert_equal "foo-0.0.3.gem", p.publish_if_updated(:method)
92
+ end
93
+
82
94
  ::VERSION = "0.2.3"
83
95
  def test_should_eval_gemspec_in_root_context
84
96
  # Previously this would pick up GemPublisher::VERSION incorrectly
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gem_publisher
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,27 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-06-24 00:00:00.000000000 Z
12
+ date: 2014-08-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mocha
16
- requirement: !ruby/object:Gem::Requirement
16
+ requirement: &9717880 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - '='
19
+ - - =
20
20
  - !ruby/object:Gem::Version
21
21
  version: 0.14.0
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - '='
28
- - !ruby/object:Gem::Version
29
- version: 0.14.0
24
+ version_requirements: *9717880
30
25
  - !ruby/object:Gem::Dependency
31
26
  name: rake
32
- requirement: !ruby/object:Gem::Requirement
27
+ requirement: &9717460 !ruby/object:Gem::Requirement
33
28
  none: false
34
29
  requirements:
35
30
  - - ! '>='
@@ -37,12 +32,7 @@ dependencies:
37
32
  version: '0'
38
33
  type: :development
39
34
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
35
+ version_requirements: *9717460
46
36
  description: Automatically build, tag, and push a gem when its version has been updated.
47
37
  email: pbattley@gmail.com
48
38
  executables: []
@@ -68,7 +58,8 @@ files:
68
58
  - test/integration_test.rb
69
59
  - test/git_remote_test.rb
70
60
  homepage: http://github.com/alphagov/gem_publisher
71
- licenses: []
61
+ licenses:
62
+ - MIT
72
63
  post_install_message:
73
64
  rdoc_options: []
74
65
  require_paths:
@@ -81,7 +72,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
81
72
  version: '0'
82
73
  segments:
83
74
  - 0
84
- hash: -113103099571362151
75
+ hash: -4102411382457102235
85
76
  required_rubygems_version: !ruby/object:Gem::Requirement
86
77
  none: false
87
78
  requirements:
@@ -90,10 +81,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
81
  version: '0'
91
82
  segments:
92
83
  - 0
93
- hash: -113103099571362151
84
+ hash: -4102411382457102235
94
85
  requirements: []
95
86
  rubyforge_project:
96
- rubygems_version: 1.8.23
87
+ rubygems_version: 1.8.11
97
88
  signing_key:
98
89
  specification_version: 3
99
90
  summary: Automatically build, tag, and push gems