whiskey_disk 0.0.0 → 0.0.1

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.
data/Rakefile CHANGED
@@ -20,7 +20,7 @@ begin
20
20
  gemspec.email = "rick@rickbradley.com"
21
21
  gemspec.homepage = "http://github.com/flogic/whiskey_disk"
22
22
  gemspec.authors = ["Rick Bradley"]
23
- gemspec.add_dependency('vlad', '>= 1.3.2')
23
+ gemspec.add_dependency('rake')
24
24
  end
25
25
  Jeweler::GemcutterTasks.new
26
26
  rescue LoadError
data/TODO.txt CHANGED
@@ -1,3 +1,2 @@
1
1
  - update the README
2
- - push gem to gemcutter
3
2
  - install hooks (look at maybe git-deploy for good examples)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.0
1
+ 0.0.1
data/lib/tasks/deploy.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), '..', 'whiskey_disk'))
2
2
  require 'rake'
3
- require 'vlad'
4
3
 
5
4
  namespace :deploy do
6
5
  desc "Perform initial setup for deployment"
data/lib/whiskey_disk.rb CHANGED
@@ -36,10 +36,6 @@ class WhiskeyDisk
36
36
  File.split(path).last
37
37
  end
38
38
 
39
- def register_configuration
40
- configuration.each_pair {|k,v| set k, v }
41
- end
42
-
43
39
  def needs(*keys)
44
40
  keys.each do |key|
45
41
  raise "No value for '#{key}' declared in configuration files [#{WhiskeyDisk::Config.filenames.join(", ")}]" unless self[key]
@@ -48,16 +44,16 @@ class WhiskeyDisk
48
44
 
49
45
  def bundle
50
46
  return '' if buffer.empty?
51
- buffer.collect {|c| "(#{c})" }.join(' && ')
47
+ buffer.collect {|c| "{ #{c} ; }"}.join(' && ')
48
+ end
49
+
50
+ def run(cmd)
51
+ needs(:domain)
52
+ system('ssh', '-v', self[:domain], "set -x; " + cmd)
52
53
  end
53
54
 
54
55
  def flush
55
- if remote?
56
- register_configuration
57
- run(bundle)
58
- else
59
- system(bundle)
60
- end
56
+ remote? ? run(bundle) : system(bundle)
61
57
  end
62
58
 
63
59
  def ensure_main_parent_path_is_present
@@ -73,7 +69,7 @@ class WhiskeyDisk
73
69
  def checkout_main_repository
74
70
  needs(:deploy_to, :repository)
75
71
  enqueue "cd #{parent_path(self[:deploy_to])}"
76
- enqueue "git clone #{self[:repository]} #{tail_path(self[:deploy_to])} || true"
72
+ enqueue "git clone #{self[:repository]} #{tail_path(self[:deploy_to])} ; true"
77
73
  end
78
74
 
79
75
  def install_hooks
@@ -84,7 +80,7 @@ class WhiskeyDisk
84
80
  def checkout_configuration_repository
85
81
  needs(:deploy_config_to, :config_repository)
86
82
  enqueue "cd #{parent_path(self[:deploy_config_to])}"
87
- enqueue "git clone #{self[:config_repository]} #{tail_path(self[:deploy_config_to])} || true"
83
+ enqueue "git clone #{self[:config_repository]} #{tail_path(self[:deploy_config_to])} ; true"
88
84
  end
89
85
 
90
86
  def update_main_repository_checkout
@@ -110,13 +106,13 @@ class WhiskeyDisk
110
106
  def run_post_setup_hooks
111
107
  needs(:deploy_to)
112
108
  enqueue "cd #{self[:deploy_to]}"
113
- enqueue "rake deploy:post_setup"
109
+ enqueue "rake --trace deploy:post_setup"
114
110
  end
115
111
 
116
112
  def run_post_deploy_hooks
117
113
  needs(:deploy_to)
118
114
  enqueue "cd #{self[:deploy_to]}"
119
- enqueue "rake deploy:post_deploy"
115
+ enqueue "rake --trace deploy:post_deploy"
120
116
  end
121
117
  end
122
118
  end
@@ -94,7 +94,7 @@ describe 'WhiskeyDisk' do
94
94
 
95
95
  it 'should ignore errors from failing to clone an existing repository' do
96
96
  WhiskeyDisk.checkout_main_repository
97
- WhiskeyDisk.buffer.join(' ').should.match(%r{\|\| true})
97
+ WhiskeyDisk.buffer.join(' ').should.match(%r{; true})
98
98
  end
99
99
  end
100
100
 
@@ -146,7 +146,7 @@ describe 'WhiskeyDisk' do
146
146
 
147
147
  it 'should ignore errors from failing to clone an existing repository' do
148
148
  WhiskeyDisk.checkout_configuration_repository
149
- WhiskeyDisk.buffer.join(' ').should.match(%r{\|\| true})
149
+ WhiskeyDisk.buffer.join(' ').should.match(%r{; true})
150
150
  end
151
151
  end
152
152
 
@@ -309,11 +309,6 @@ describe 'WhiskeyDisk' do
309
309
  WhiskeyDisk.stub!(:run)
310
310
  end
311
311
 
312
- it 'should register our configuration with vlad' do
313
- WhiskeyDisk.should.receive(:register_configuration)
314
- WhiskeyDisk.flush
315
- end
316
-
317
312
  it 'should bundle the buffer of commands' do
318
313
  WhiskeyDisk.enqueue('x')
319
314
  WhiskeyDisk.enqueue('y')
@@ -336,11 +331,6 @@ describe 'WhiskeyDisk' do
336
331
  WhiskeyDisk.stub!(:system)
337
332
  end
338
333
 
339
- it 'should NOT register our configuration with vlad' do
340
- WhiskeyDisk.should.not.receive(:register_configuration)
341
- WhiskeyDisk.flush
342
- end
343
-
344
334
  it 'should bundle the buffer of commands' do
345
335
  WhiskeyDisk.enqueue('x')
346
336
  WhiskeyDisk.enqueue('y')
@@ -364,23 +354,38 @@ describe 'WhiskeyDisk' do
364
354
  WhiskeyDisk.bundle.should == ''
365
355
  end
366
356
 
367
- it 'should wrap each command as a subshell () and join with &&s' do
357
+ it 'should wrap each command with {} and join with &&s' do
368
358
  WhiskeyDisk.enqueue("cd foo/bar/baz || true")
369
359
  WhiskeyDisk.enqueue("rsync -avz --progress /yer/mom /yo/")
370
- WhiskeyDisk.bundle.should == "(cd foo/bar/baz || true) && (rsync -avz --progress /yer/mom /yo/)"
360
+ WhiskeyDisk.bundle.should == "{ cd foo/bar/baz || true ; } && { rsync -avz --progress /yer/mom /yo/ ; }"
371
361
  end
372
362
  end
373
363
 
374
- describe 'registering the configuration with vlad' do
364
+ describe 'when running a command string remotely' do
375
365
  before do
376
- @parameters = { 'deploy_to' => '/path/to/main/repo', 'foo' => 'bar', 'domain' => 'name' }
377
- WhiskeyDisk::Config.stub!(:fetch).and_return(@parameters)
366
+ @domain = 'ogc@ogtastic.com'
367
+ WhiskeyDisk::Config.stub!(:fetch).and_return({ 'domain' => @domain })
368
+ WhiskeyDisk.reset
369
+ WhiskeyDisk.stub!(:system)
370
+ end
371
+
372
+ it 'should accept a command string' do
373
+ lambda { WhiskeyDisk.run('ls') }.should.not.raise(ArgumentError)
374
+ end
375
+
376
+ it 'should require a command string' do
377
+ lambda { WhiskeyDisk.run }.should.raise(ArgumentError)
378
+ end
379
+
380
+ it 'should fail if the domain path is not specified' do
381
+ WhiskeyDisk::Config.stub!(:fetch).and_return({})
378
382
  WhiskeyDisk.reset
383
+ lambda { WhiskeyDisk.run('ls') }.should.raise
379
384
  end
380
385
 
381
- it "should call vlad's 'set' for each configuration parameters" do
382
- @parameters.each_pair {|k,v| WhiskeyDisk.should.receive(:set).with(k, v) }
383
- WhiskeyDisk.register_configuration
386
+ it 'should pass the string to ssh with verbosity enabled' do
387
+ WhiskeyDisk.should.receive(:system).with('ssh', '-v', @domain, "set -x; ls")
388
+ WhiskeyDisk.run('ls')
384
389
  end
385
390
  end
386
391
  end
data/tasks/deploy.rake ADDED
@@ -0,0 +1,2 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'tasks', 'deploy'))
2
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: whiskey_disk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rick Bradley
@@ -13,14 +13,14 @@ date: 2009-12-30 00:00:00 +05:30
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: vlad
16
+ name: rake
17
17
  type: :runtime
18
18
  version_requirement:
19
19
  version_requirements: !ruby/object:Gem::Requirement
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 1.3.2
23
+ version: "0"
24
24
  version:
25
25
  description: Opinionated gem for doing fast git-based server deployments.
26
26
  email: rick@rickbradley.com
@@ -51,6 +51,7 @@ files:
51
51
  - spec/tasks/deploy_spec.rb
52
52
  - spec/whiskey_disk/config_spec.rb
53
53
  - spec/whiskey_disk_spec.rb
54
+ - tasks/deploy.rake
54
55
  has_rdoc: true
55
56
  homepage: http://github.com/flogic/whiskey_disk
56
57
  licenses: []