dpl 1.4.1 → 1.4.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 478f6fafe432230c66b9452ba5072588ea0f9dc1
4
- data.tar.gz: 45db3d5e7a930300a7a8779e084976c29548929d
3
+ metadata.gz: af89a10a5a1d66462990934a93215af341bbbfcf
4
+ data.tar.gz: 5400021aba1ffcea9549d910773ad0c90afd2ad7
5
5
  SHA512:
6
- metadata.gz: bc6991fc24f3249decd6ceb3bd5fb584e14f5dce4304411b188222153702310c5fc0edfd162887ffd8fdf02630c9a50fc4a78fc48c502b2bede6da03ba9f4a6b
7
- data.tar.gz: 7b3045f1eaabb9bf25f5706cc46d2aa2df5b63b3fd498868e226d4f45ddc1d2bc9344ec5f4534101c52f4bc2bb5e3b2489df75550f63d983f246ed709c0c8354
6
+ metadata.gz: dfa28b8549431d85202aa2b5148bd8afdb1e1243c0454682484bf9e7df19ac701c1ddb98170bf964fbe5341d11ab1a3765b301ff0fb36ef7e2f632cc60501cc3
7
+ data.tar.gz: b109321326bec28b89d239a387f74008593161e887b96738bc1228ad03147d0b904cb2b910b16a9de109eef56c90a98c0350caa1911f0cde0f2f38d8fc5e17e5
data/Gemfile CHANGED
@@ -10,3 +10,7 @@ end
10
10
  group :openshift do
11
11
  gem 'rhc'
12
12
  end
13
+
14
+ group :rubygems do
15
+ gem 'gems'
16
+ end
data/README.md CHANGED
@@ -11,3 +11,4 @@ Supported providers:
11
11
  * Openshift
12
12
  * Engine Yard (experimental)
13
13
  * dotCloud (experimental)
14
+ * RubyGems (experimental)
@@ -10,6 +10,7 @@ module DPL
10
10
  autoload :DotCloud, 'dpl/provider/dot_cloud'
11
11
  autoload :Nodejitsu, 'dpl/provider/nodejitsu'
12
12
  autoload :Openshift, 'dpl/provider/openshift'
13
+ autoload :RubyGems, 'dpl/provider/rubygems'
13
14
 
14
15
  def self.new(context, options)
15
16
  return super if self < Provider
@@ -64,47 +65,37 @@ module DPL
64
65
  end
65
66
  end
66
67
 
67
- def should_deploy?
68
- (not options[:tags_only] or has_tag?)
69
- end
70
-
71
- def has_tag?
72
- context.shell('git describe --exact-match')
73
- $?.success?
74
- end
75
-
76
68
  def deploy
77
69
  rm_rf ".dpl"
78
70
  mkdir_p ".dpl"
79
- if should_deploy?
80
- context.fold("Preparing deploy") do
81
- check_auth
82
- check_app
83
-
84
- if needs_key?
85
- create_key(".dpl/id_rsa")
86
- setup_key(".dpl/id_rsa.pub")
87
- setup_git_ssh(".dpl/git-ssh", ".dpl/id_rsa")
88
- end
89
-
90
- cleanup
91
- end
92
71
 
93
- context.fold("Deploying application") { push_app }
72
+ context.fold("Preparing deploy") do
73
+ check_auth
74
+ check_app
94
75
 
95
- Array(options[:run]).each do |command|
96
- if command == 'restart'
97
- context.fold("Restarting application") { restart }
98
- else
99
- context.fold("Running %p" % command) { run(command) }
100
- end
76
+ if needs_key?
77
+ create_key(".dpl/id_rsa")
78
+ setup_key(".dpl/id_rsa.pub")
79
+ setup_git_ssh(".dpl/git-ssh", ".dpl/id_rsa")
101
80
  end
81
+
82
+ cleanup
102
83
  end
103
- ensure
104
- if needs_key?
105
- remove_key rescue nil
84
+
85
+ context.fold("Deploying application") { push_app }
86
+
87
+ Array(options[:run]).each do |command|
88
+ if command == 'restart'
89
+ context.fold("Restarting application") { restart }
90
+ else
91
+ context.fold("Running %p" % command) { run(command) }
106
92
  end
107
93
  end
94
+ ensure
95
+ if needs_key?
96
+ remove_key rescue nil
97
+ end
98
+ end
108
99
 
109
100
  def sha
110
101
  @sha ||= ENV['TRAVIS_COMMIT'] || `git rev-parse HEAD`.strip
@@ -0,0 +1,48 @@
1
+ module DPL
2
+ class Provider
3
+ class RubyGems < Provider
4
+ experimental "RubyGems"
5
+
6
+ requires 'gems'
7
+
8
+ def setup_auth
9
+ ::Gems.key = option(:api_key) if options[:api_key]
10
+ ::Gems.username = option(:user) unless options[:api_key]
11
+ ::Gems.password = option(:password) unless options[:api_key]
12
+ end
13
+
14
+ def needs_key?
15
+ false
16
+ end
17
+
18
+ def setup_gem
19
+ options[:gem] ||= options[:app]
20
+ end
21
+
22
+ def gemspec
23
+ options[:gemspec].gsub('.gemspec', '') if options[:gemspec]
24
+ end
25
+
26
+ def check_app
27
+ setup_auth
28
+ setup_gem
29
+ info = ::Gems.info(options[:gem])
30
+ log "Found gem #{info['name']}"
31
+ end
32
+
33
+ def check_auth
34
+ setup_auth
35
+ log "Authenticated with username #{::Gems.username}" if ::Gems.username
36
+ end
37
+
38
+ def push_app
39
+ setup_auth
40
+ setup_gem
41
+ context.shell "gem build #{gemspec || option(:gem)}.gemspec"
42
+ Dir.glob("#{gemspec || option(:gem)}-*.gem") do |f|
43
+ log ::Gems.push File.new f
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -1,3 +1,3 @@
1
1
  module DPL
2
- VERSION = '1.4.1'
2
+ VERSION = '1.4.2'
3
3
  end
@@ -0,0 +1,96 @@
1
+ require 'spec_helper'
2
+ require 'rubygems'
3
+ require 'gems'
4
+ require 'dpl/provider/rubygems'
5
+
6
+ describe DPL::Provider::RubyGems do
7
+ subject :provider do
8
+ described_class.new(DummyContext.new, :app => 'example', :api_key => 'foo')
9
+ end
10
+
11
+ describe :api do
12
+ example "with an api key" do
13
+ ::Gems.should_receive(:key=).with('foo')
14
+ provider.setup_auth
15
+ end
16
+
17
+ example "with a username and password" do
18
+ provider.options.update(:user => 'test', :password => 'blah')
19
+ provider.options.delete(:api_key)
20
+ ::Gems.should_receive(:username=).with('test')
21
+ ::Gems.should_receive(:password=).with('blah')
22
+ provider.setup_auth
23
+ end
24
+ end
25
+
26
+ describe :check_auth do
27
+ example do
28
+ provider.options.update(:user => 'test', :password => 'blah')
29
+ provider.options.delete(:api_key)
30
+ provider.should_receive(:log).with("Authenticated with username test")
31
+ provider.check_auth
32
+ end
33
+ end
34
+
35
+ describe :check_app do
36
+ example do
37
+ ::Gems.should_receive(:info).with('example').and_return({'name' => 'example'})
38
+ provider.should_receive(:log).with("Found gem example")
39
+ provider.check_app
40
+ end
41
+ end
42
+
43
+ describe :push_app do
44
+ after(:each) do
45
+ File.should_receive(:new).with('File').and_return('Test file')
46
+ ::Gems.should_receive(:push).with('Test file').and_return('Yes!')
47
+ provider.should_receive(:log).with('Yes!')
48
+ provider.push_app
49
+ end
50
+
51
+ example "with options[:app]" do
52
+ provider.options.update(:app => 'example')
53
+ provider.context.should_receive(:shell).with("gem build example.gemspec")
54
+ Dir.should_receive(:glob).with('example-*.gem').and_yield('File')
55
+ end
56
+
57
+ example "with options[:gem]" do
58
+ provider.options.update(:gem => 'example-gem')
59
+ provider.context.should_receive(:shell).with("gem build example-gem.gemspec")
60
+ Dir.should_receive(:glob).with('example-gem-*.gem').and_yield('File')
61
+ end
62
+
63
+ example "with options[:gemspec]" do
64
+ provider.options.update(:gemspec => 'blah.gemspec')
65
+ provider.context.should_receive(:shell).with("gem build blah.gemspec")
66
+ Dir.should_receive(:glob).with('blah-*.gem').and_yield('File')
67
+ end
68
+ end
69
+
70
+ describe :setup_gem do
71
+ example "with options[:gem] and options[:app] set" do
72
+ provider.options.update(:gem => 'test', :app => 'blah')
73
+ provider.setup_gem
74
+ provider.options[:gem].should be == 'test'
75
+ end
76
+
77
+ example "with options[:app] set" do
78
+ provider.options.update(:app => 'foo')
79
+ provider.setup_gem
80
+ provider.options[:gem].should be == 'foo'
81
+ end
82
+
83
+ example "with options[:gem] set" do
84
+ provider.options.update(:gem => 'bar')
85
+ provider.setup_gem
86
+ provider.options[:gem].should be == 'bar'
87
+ end
88
+ end
89
+
90
+ describe :gemspec do
91
+ example do
92
+ provider.options.update(:gemspec => 'test.gemspec')
93
+ provider.gemspec.should be == 'test'
94
+ end
95
+ end
96
+ end
@@ -132,19 +132,4 @@ describe DPL::Provider do
132
132
  expect { provider.error("Foo") }.to raise_error("Foo")
133
133
  end
134
134
  end
135
-
136
- describe :has_tag? do
137
- example do
138
- provider.context.should_receive(:shell).with('git describe --exact-match')
139
- provider.has_tag?
140
- end
141
- end
142
-
143
- describe :should_deploy? do
144
- example "tags_only with tag" do
145
- provider.options[:tags_only] = true
146
- provider.should_receive(:has_tag?).and_return(true)
147
- provider.should_deploy?.should be == true
148
- end
149
- end
150
135
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dpl
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Konstantin Haase
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-30 00:00:00.000000000 Z
11
+ date: 2013-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -92,6 +92,7 @@ files:
92
92
  - lib/dpl/provider/heroku/git.rb
93
93
  - lib/dpl/provider/nodejitsu.rb
94
94
  - lib/dpl/provider/openshift.rb
95
+ - lib/dpl/provider/rubygems.rb
95
96
  - lib/dpl/version.rb
96
97
  - notes/dotcloud.md
97
98
  - notes/engine_yard.md
@@ -101,6 +102,7 @@ files:
101
102
  - spec/provider/heroku_anvil_spec.rb
102
103
  - spec/provider/heroku_git_spec.rb
103
104
  - spec/provider/openshift_spec.rb
105
+ - spec/provider/rubygems_spec.rb
104
106
  - spec/provider_spec.rb
105
107
  - spec/spec_helper.rb
106
108
  homepage: https://github.com/rkh/dpl
@@ -133,6 +135,7 @@ test_files:
133
135
  - spec/provider/heroku_anvil_spec.rb
134
136
  - spec/provider/heroku_git_spec.rb
135
137
  - spec/provider/openshift_spec.rb
138
+ - spec/provider/rubygems_spec.rb
136
139
  - spec/provider_spec.rb
137
140
  - spec/spec_helper.rb
138
141
  has_rdoc: