dpl 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 267de34ef36aefd6e0b78de417fb8f385a9ceb5d
4
- data.tar.gz: 3d8ce9151696e3f9285bd8bb400c40f838ab2141
3
+ metadata.gz: b60ef07c3efd10ed791e52662655bf6ae8b9f25a
4
+ data.tar.gz: a03dc4e7e633af8bb810b961f88554e6e6e11b2f
5
5
  SHA512:
6
- metadata.gz: d6ca1cfe5a1d1101f6e65b0812cf9c79eb5b66d3613181ed4ca261a8eec69b3390fe9585b20708107bf0710c3013ba560750d5c8b88d539f6d4aaa24b25e8076
7
- data.tar.gz: 44ed924d345248cab30f8500b5dc214de372c67e7eb0c01ba9682e02a4c9d26043c0fe7c91c02ae032aa49394f3ad628187f166b89350f665d1d19ec3cc593fe
6
+ metadata.gz: ca7d8f39d87084784d1217e2fbeda9cbfb56aa7c8cfb8330e88ce4ebd6502956db4228cb6374adb614c2ecf749113b211c4bdeddf47c85843030ee2da1bd5965
7
+ data.tar.gz: d9e896346cae4da0c2ce91de14f924177e49863a11b7b36cb1d1ea782cb6e88535c34a850b8b4aa09b067717c2a018bd18a4364496392f8e9e08b8ff55eaf700
@@ -50,6 +50,10 @@ module DPL
50
50
  }
51
51
  end
52
52
 
53
+ def shell(command)
54
+ system(command)
55
+ end
56
+
53
57
  def die(message)
54
58
  $stderr.puts(message)
55
59
  exit 1
@@ -29,18 +29,26 @@ module DPL
29
29
  load = options[:load] || name
30
30
  gem(name, version)
31
31
  rescue LoadError
32
- system("gem install %s -v %p" % [name, version])
32
+ context.shell("gem install %s -v %p" % [name, version])
33
33
  Gem.clear_paths
34
34
  ensure
35
35
  require load
36
36
  end
37
37
 
38
+ def self.context
39
+ self
40
+ end
41
+
42
+ def self.shell(command)
43
+ system(command)
44
+ end
45
+
38
46
  def self.pip(name, command = name)
39
- system "pip install #{name}" if `which #{command}`.chop.empty?
47
+ context.shell "pip install #{name}" if `which #{command}`.chop.empty?
40
48
  end
41
49
 
42
50
  def self.npm_g(name, command = name)
43
- system "npm install -g #{name}" if `which #{command}`.chop.empty?
51
+ context.shell "npm install -g #{name}" if `which #{command}`.chop.empty?
44
52
  end
45
53
 
46
54
  attr_reader :context, :options
@@ -68,6 +76,8 @@ module DPL
68
76
  setup_key(".dpl/id_rsa.pub")
69
77
  setup_git_ssh(".dpl/git-ssh", ".dpl/id_rsa")
70
78
  end
79
+
80
+ cleanup
71
81
  end
72
82
 
73
83
  context.fold("Deploying application") { push_app }
@@ -83,6 +93,15 @@ module DPL
83
93
  remove_key if needs_key?
84
94
  end
85
95
 
96
+ def sha
97
+ @sha ||= ENV['TRAVIS_COMMIT'] || `git rev-parse HEAD`.strip
98
+ end
99
+
100
+ def cleanup
101
+ context.shell "git reset --hard #{sha}"
102
+ context.shell "git clean -dffqx -e .dpl"
103
+ end
104
+
86
105
  def needs_key?
87
106
  true
88
107
  end
@@ -91,7 +110,7 @@ module DPL
91
110
  end
92
111
 
93
112
  def create_key(file)
94
- system "ssh-keygen -t rsa -N \"\" -C #{option(:key_name)} -f #{file}"
113
+ context.shell "ssh-keygen -t rsa -N \"\" -C #{option(:key_name)} -f #{file}"
95
114
  end
96
115
 
97
116
  def setup_git_ssh(path, key_path)
@@ -5,7 +5,7 @@ module DPL
5
5
  pip 'dotcloud'
6
6
 
7
7
  def check_auth
8
- system "echo #{option(:api_key)} | dotcloud setup --api-key"
8
+ context.shell "echo #{option(:api_key)} | dotcloud setup --api-key"
9
9
  end
10
10
 
11
11
  def check_app
@@ -33,7 +33,7 @@ module DPL
33
33
  end
34
34
 
35
35
  def push_app
36
- system "git push #{option(:git)} HEAD:master -f"
36
+ context.shell "git push #{option(:git)} HEAD:master -f"
37
37
  end
38
38
 
39
39
  def run(command)
@@ -32,7 +32,7 @@ module DPL
32
32
  end
33
33
 
34
34
  def push_app
35
- system "jitsu deploy -j #{CONFIG_FILE} --release=yes"
35
+ context.shell "jitsu deploy -j #{CONFIG_FILE} --release=yes"
36
36
  end
37
37
  end
38
38
  end
@@ -1,3 +1,3 @@
1
1
  module DPL
2
- VERSION = '1.1.1'
2
+ VERSION = '1.2.0'
3
3
  end
@@ -69,7 +69,7 @@ describe DPL::Provider::Heroku do
69
69
  describe :push_app do
70
70
  example do
71
71
  provider.options[:git] = "git://something"
72
- provider.should_receive(:system).with("git push git://something HEAD:master -f")
72
+ provider.context.should_receive(:shell).with("git push git://something HEAD:master -f")
73
73
  provider.push_app
74
74
  end
75
75
  end
@@ -27,7 +27,7 @@ describe DPL::Provider do
27
27
 
28
28
  example "missing" do
29
29
  example_provider.should_receive(:gem).with("foo", "~> 1.4").and_raise(LoadError)
30
- example_provider.should_receive(:system).with('gem install foo -v "~> 1.4"')
30
+ example_provider.context.should_receive(:shell).with('gem install foo -v "~> 1.4"')
31
31
  example_provider.requires("foo", :version => "~> 1.4")
32
32
  end
33
33
  end
@@ -41,7 +41,7 @@ describe DPL::Provider do
41
41
 
42
42
  example "missing" do
43
43
  example_provider.should_receive(:`).with("which foo").and_return("")
44
- example_provider.should_receive(:system).with("pip install foo")
44
+ example_provider.context.should_receive(:shell).with("pip install foo")
45
45
  example_provider.pip("foo")
46
46
  end
47
47
  end
@@ -71,7 +71,7 @@ describe DPL::Provider do
71
71
 
72
72
  describe :create_key do
73
73
  example do
74
- provider.should_receive(:system).with('ssh-keygen -t rsa -N "" -C foo -f thekey')
74
+ provider.context.should_receive(:shell).with('ssh-keygen -t rsa -N "" -C foo -f thekey')
75
75
  provider.create_key('thekey')
76
76
  end
77
77
  end
@@ -8,6 +8,9 @@ SimpleCov.start do
8
8
  end
9
9
 
10
10
  class DummyContext
11
+ def shell(command)
12
+ end
13
+
11
14
  def fold(message)
12
15
  yield
13
16
  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.1.1
4
+ version: 1.2.0
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-17 00:00:00.000000000 Z
11
+ date: 2013-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec