gem_publisher 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -21,7 +21,7 @@ module GemPublisher
21
21
  # Returns the gem file name if a gem was published; nil otherwise. A
22
22
  # CliFacade::Error will be raised if a command fails.
23
23
  #
24
- def self.publish_if_updated(gemspec, method=:rubygems)
25
- Publisher.new(gemspec).publish_if_updated(method)
24
+ def self.publish_if_updated(gemspec, method=:rubygems, options={})
25
+ Publisher.new(gemspec).publish_if_updated(method, options)
26
26
  end
27
27
  end
@@ -17,10 +17,10 @@ module GemPublisher
17
17
  @pusher = Pusher.new
18
18
  end
19
19
 
20
- def publish_if_updated(method)
20
+ def publish_if_updated(method, options = {})
21
21
  return if version_released?
22
22
  @builder.build(@gemspec).tap { |gem|
23
- @pusher.push gem, method
23
+ @pusher.push gem, method, options
24
24
  @git_remote.add_tag "v#@version"
25
25
  }
26
26
  end
@@ -11,9 +11,11 @@ module GemPublisher
11
11
  "gemfury" => %w[fury push]
12
12
  }
13
13
 
14
- def push(gem, method)
14
+ def push(gem, method, options = {})
15
15
  push_command = PUSH_METHODS[method.to_s] or raise "Unknown Gem push method #{method.inspect}."
16
- @cli_facade.execute *push_command + [gem]
16
+ push_command += [gem]
17
+ push_command += ["--as", options[:as]] if options[:as]
18
+ @cli_facade.execute *push_command
17
19
  end
18
20
  end
19
21
  end
@@ -1,3 +1,3 @@
1
1
  module GemPublisher
2
- VERSION = "1.1.1"
2
+ VERSION = "1.2.0"
3
3
  end
@@ -23,5 +23,27 @@ module GemPublisher
23
23
  expect_cli "git push origin tag v0.0.3"
24
24
  GemPublisher.publish_if_updated gemspec
25
25
  end
26
+
27
+ def test_should_build_and_tag_and_publish_to_gemfury
28
+ gemspec = data_file_path("example.gemspec")
29
+ expect_cli "git ls-remote --tags origin", data_file("tags")
30
+ expect_cli "gem build #{gemspec}", data_file("gem_build")
31
+ expect_cli "fury push example-0.0.3.gem"
32
+ expect_cli "git rev-parse HEAD", "1234abcd"
33
+ expect_cli "git update-ref refs/tags/v0.0.3 1234abcd"
34
+ expect_cli "git push origin tag v0.0.3"
35
+ GemPublisher.publish_if_updated gemspec, :gemfury
36
+ end
37
+
38
+ def test_should_build_and_tag_and_publish_to_gemfury_as_given_user
39
+ gemspec = data_file_path("example.gemspec")
40
+ expect_cli "git ls-remote --tags origin", data_file("tags")
41
+ expect_cli "gem build #{gemspec}", data_file("gem_build")
42
+ expect_cli "fury push example-0.0.3.gem --as foo"
43
+ expect_cli "git rev-parse HEAD", "1234abcd"
44
+ expect_cli "git update-ref refs/tags/v0.0.3 1234abcd"
45
+ expect_cli "git push origin tag v0.0.3"
46
+ GemPublisher.publish_if_updated gemspec, :gemfury, :as => "foo"
47
+ end
26
48
  end
27
49
  end
@@ -35,13 +35,26 @@ module GemPublisher
35
35
  with(gemspec).
36
36
  returns("foo-0.0.3.gem")
37
37
  p.pusher = mock
38
- p.pusher.expects(:push).with("foo-0.0.3.gem", :method)
38
+ p.pusher.expects(:push).with("foo-0.0.3.gem", :method, {})
39
39
  p.git_remote = mock
40
40
  p.git_remote.stubs(:tags).returns(%w[v0.0.1 v0.0.2])
41
41
  p.git_remote.expects(:add_tag).with("v0.0.3")
42
42
  assert_equal "foo-0.0.3.gem", p.publish_if_updated(:method)
43
43
  end
44
44
 
45
+ def test_should_publish_with_options_if_given
46
+ gemspec = data_file_path("example.gemspec")
47
+ p = Publisher.new(gemspec)
48
+ p.builder = mock
49
+ p.builder.stubs(:build).returns("foo-0.0.3.gem")
50
+ p.pusher = mock
51
+ p.pusher.expects(:push).with("foo-0.0.3.gem", :method, :foo => "bar")
52
+ p.git_remote = mock
53
+ p.git_remote.stubs(:tags).returns(%w[v0.0.1 v0.0.2])
54
+ p.git_remote.stubs(:add_tag)
55
+ assert_equal "foo-0.0.3.gem", p.publish_if_updated(:method, :foo => "bar")
56
+ end
57
+
45
58
  def test_should_build_and_tag_and_publish_and_return_gem_name_if_there_is_no_released_version
46
59
  p = Publisher.new(data_file_path("example.gemspec"))
47
60
  p.builder = mock
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.1
5
+ version: 1.2.0
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-07-18 00:00:00 Z
13
+ date: 2013-02-22 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: mocha
@@ -43,23 +43,23 @@ extensions: []
43
43
  extra_rdoc_files: []
44
44
 
45
45
  files:
46
- - lib/gem_publisher/builder.rb
47
- - lib/gem_publisher/pusher.rb
46
+ - lib/gem_publisher.rb
47
+ - lib/gem_publisher/version.rb
48
48
  - lib/gem_publisher/cli_facade.rb
49
49
  - lib/gem_publisher/publisher.rb
50
+ - lib/gem_publisher/pusher.rb
51
+ - lib/gem_publisher/builder.rb
50
52
  - lib/gem_publisher/git_remote.rb
51
- - lib/gem_publisher/version.rb
52
- - lib/gem_publisher.rb
53
53
  - lib/rubygems_plugin.rb
54
- - test/common.rb
55
- - test/publisher_test.rb
54
+ - test/builder_test.rb
56
55
  - test/git_remote_test.rb
57
56
  - test/cli_facade_test.rb
58
- - test/builder_test.rb
59
- - test/data/tags
57
+ - test/common.rb
58
+ - test/integration_test.rb
59
+ - test/publisher_test.rb
60
60
  - test/data/gem_build
61
+ - test/data/tags
61
62
  - test/data/example.gemspec
62
- - test/integration_test.rb
63
63
  homepage: http://github.com/alphagov/gem_publisher
64
64
  licenses: []
65
65
 
@@ -73,7 +73,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - ">="
75
75
  - !ruby/object:Gem::Version
76
- hash: 4214267775999231123
76
+ hash: 1697636813584148113
77
77
  segments:
78
78
  - 0
79
79
  version: "0"
@@ -82,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
82
82
  requirements:
83
83
  - - ">="
84
84
  - !ruby/object:Gem::Version
85
- hash: 4214267775999231123
85
+ hash: 1697636813584148113
86
86
  segments:
87
87
  - 0
88
88
  version: "0"