dpl 1.9.1.travis.2639.5 → 1.9.1.travis.2660.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dpl/provider.rb +9 -10
- data/lib/dpl/version.rb +1 -1
- data/spec/provider_spec.rb +18 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7494a96a838bdb9db9a0b0042cb001e9fd1a0ac1fbdb2c7ae97fcbb19986155e
|
4
|
+
data.tar.gz: a5ab9c1124ea55f1d4af111b983896904591041bd2bb01653dfa8ce380fe2565
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1eac4ca1809c551e8a576cba99f7fffd25097bdafa187fc81be660cd15a369848b0fe714f53dfb4c55479a6e956d24c9fadedf19f9009122103d9aec85ca69d
|
7
|
+
data.tar.gz: 8e23bda53945418170fd2132c2b6d23ebf944d528d6244d4dd2cabb1938f8e8865ef339546052d73126c7c5996d7736e52228d8670015bffb83dae31150b5830
|
data/lib/dpl/provider.rb
CHANGED
@@ -67,21 +67,20 @@ module DPL
|
|
67
67
|
begin
|
68
68
|
opt_lower = super.option(:provider).to_s.downcase
|
69
69
|
opt = opt_lower.gsub(/[^a-z0-9]/, '')
|
70
|
-
|
71
|
-
raise Error, "could not find provider %p" % opt unless
|
72
|
-
|
73
|
-
|
74
|
-
provider = const_get(name).new(context, options)
|
70
|
+
class_name = PROVIDERS.keys.detect { |p| p.to_s.downcase == opt }
|
71
|
+
raise Error, "could not find provider %p" % opt unless class_name
|
72
|
+
require "dpl/provider/#{PROVIDERS[class_name]}"
|
73
|
+
provider = const_get(class_name).new(context, options)
|
75
74
|
rescue NameError, LoadError => e
|
76
|
-
if /uninitialized constant DPL::Provider::(?<provider_wanted>\S+)/ =~ e.message
|
75
|
+
if /uninitialized constant DPL::Provider::(?<provider_wanted>\S+)/ =~ e.message
|
77
76
|
provider_gem_name = PROVIDERS[provider_wanted]
|
78
77
|
elsif %r(cannot load such file -- dpl/provider/(?<provider_file_name>\S+)) =~ e.message
|
79
|
-
provider_gem_name =
|
78
|
+
provider_gem_name = PROVIDERS[class_name]
|
80
79
|
else
|
81
80
|
# don't know what to do with this error
|
82
81
|
raise e
|
83
82
|
end
|
84
|
-
install_cmd = "gem install dpl-#{
|
83
|
+
install_cmd = "gem install dpl-#{provider_gem_name || opt} -v #{ENV['DPL_VERSION'] || DPL::VERSION}"
|
85
84
|
|
86
85
|
if File.exist?(local_gem = File.join(Dir.pwd, "dpl-#{PROVIDERS[provider_gem_name] || opt_lower}-#{ENV['DPL_VERSION'] || DPL::VERSION}.gem"))
|
87
86
|
install_cmd = "gem install #{local_gem}"
|
@@ -90,8 +89,8 @@ module DPL
|
|
90
89
|
context.shell(install_cmd)
|
91
90
|
Gem.clear_paths
|
92
91
|
|
93
|
-
require "dpl/provider/#{PROVIDERS[
|
94
|
-
provider = const_get(
|
92
|
+
require "dpl/provider/#{PROVIDERS[class_name]}"
|
93
|
+
provider = const_get(class_name).new(context, options)
|
95
94
|
rescue DPL::Error
|
96
95
|
if opt_lower
|
97
96
|
provider = const_get(opt.capitalize).new(context, options)
|
data/lib/dpl/version.rb
CHANGED
data/spec/provider_spec.rb
CHANGED
@@ -3,22 +3,32 @@ require 'dpl/provider'
|
|
3
3
|
|
4
4
|
describe DPL::Provider do
|
5
5
|
let(:example_provider) { Class.new(described_class)}
|
6
|
-
|
6
|
+
let(:context) { DummyContext.new }
|
7
|
+
subject(:provider) { example_provider.new(context, :app => 'example', :key_name => 'foo', :run => ["foo", "bar"]) }
|
7
8
|
|
8
9
|
before { stub_const "DPL::Provider::Example", example_provider }
|
9
10
|
|
10
11
|
describe "#new" do
|
11
|
-
example { expect(described_class.new(
|
12
|
-
example { expect(described_class.new(
|
13
|
-
example { expect(described_class.new(
|
14
|
-
example { expect(described_class.new(
|
15
|
-
example { expect(described_class.new(
|
16
|
-
example { expect(described_class.new(
|
12
|
+
example { expect(described_class.new(context, :provider => "example")) .to be_an(example_provider) }
|
13
|
+
example { expect(described_class.new(context, :provider => "Example")) .to be_an(example_provider) }
|
14
|
+
example { expect(described_class.new(context, :provider => "exa_mple")).to be_an(example_provider) }
|
15
|
+
example { expect(described_class.new(context, :provider => "exa-mple")).to be_an(example_provider) }
|
16
|
+
example { expect(described_class.new(context, :provider => "scri_pt")).to be_an(DPL::Provider::Script) }
|
17
|
+
example { expect(described_class.new(context, :provider => "scri _pt")).to be_an(DPL::Provider::Script) }
|
18
|
+
example { expect(described_class.new(context, :provider => "cloudfoundry")).to be_an(DPL::Provider::CloudFoundry) }
|
17
19
|
example "install deployment dependencies" do
|
18
20
|
expect_any_instance_of(described_class).to receive(:respond_to?).with(:install_deploy_dependencies).and_return(true)
|
19
21
|
expect_any_instance_of(described_class).to receive(:install_deploy_dependencies)
|
20
|
-
described_class.new(
|
22
|
+
described_class.new(context, :provider => "example")
|
21
23
|
end
|
24
|
+
|
25
|
+
it "installs correct gem when provider name does not match" do
|
26
|
+
expect(context).to receive(:shell).with("gem install dpl-cloud_foundry -v #{ENV['DPL_VERSION'] || DPL::VERSION}")
|
27
|
+
expect(described_class).to receive(:require).with("dpl/provider/cloud_foundry").and_raise LoadError.new("cannot load such file -- dpl/provider/cloud_foundry")
|
28
|
+
expect(described_class).to receive(:require).with("dpl/provider/cloud_foundry").and_call_original
|
29
|
+
described_class.new(context, :provider => 'cloudfoundry')
|
30
|
+
end
|
31
|
+
|
22
32
|
end
|
23
33
|
|
24
34
|
describe "#pip" do
|
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.9.1.travis.
|
4
|
+
version: 1.9.1.travis.2660.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Konstantin Haase
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|