yad 0.0.4

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.
@@ -0,0 +1,79 @@
1
+ require 'spec'
2
+
3
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
4
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
5
+ require 'yad'
6
+
7
+ module GlobalHelpers
8
+ def set_example_hosts
9
+ Rake::RemoteTask.host "app.example.com", :app
10
+ Rake::RemoteTask.host "db.example.com", :db
11
+ end
12
+ end
13
+
14
+ Spec::Runner.configure do |config|
15
+ config.include(GlobalHelpers)
16
+
17
+ config.before(:each) do
18
+ Rake::RemoteTask.reset
19
+ Rake.application.clear
20
+ @task_count = Rake.application.tasks.size
21
+ Rake::RemoteTask.set :domain, "example.com"
22
+ end
23
+ end
24
+
25
+
26
+ class StringIO
27
+ def readpartial(size) read end
28
+ end
29
+
30
+ module Process
31
+ def self.expected status
32
+ @@expected ||= []
33
+ @@expected << status
34
+ end
35
+
36
+ class << self
37
+ alias :waitpid2_old :waitpid2
38
+
39
+ def waitpid2(pid)
40
+ [ @@expected.shift ]
41
+ end
42
+ end
43
+ end
44
+
45
+
46
+ class Rake::RemoteTask
47
+ attr_accessor :commands, :action, :input, :output, :error
48
+
49
+ Status = Struct.new :exitstatus
50
+
51
+ class Status
52
+ def success?() exitstatus == 0 end
53
+ end
54
+
55
+ def system(*command)
56
+ @commands << command
57
+ self.action ? self.action[command.join(' ')] : true
58
+ end
59
+
60
+ def popen4(*command)
61
+ @commands << command
62
+
63
+ @input = StringIO.new
64
+ out = StringIO.new @output.shift.to_s
65
+ err = StringIO.new @error.shift.to_s
66
+
67
+ raise if block_given?
68
+
69
+ status = self.action ? self.action[command.join(' ')] : 0
70
+ Process.expected Status.new(status)
71
+
72
+ return 42, @input, out, err
73
+ end
74
+
75
+ def select(reads, writes, errs, timeout)
76
+ [reads, writes, errs]
77
+ end
78
+
79
+ end
@@ -0,0 +1,10 @@
1
+ require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
2
+
3
+ describe Yad::App::Passenger do
4
+
5
+ it "should build the start command" do
6
+ cmd = Yad::App::Passenger.build_start_command('path/to/release')
7
+ cmd.should eql("touch path/to/release/tmp/restart.txt")
8
+ end
9
+
10
+ end
@@ -0,0 +1,69 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'spec_helper')
2
+
3
+ describe Yad::Core do
4
+
5
+ it "should build the setup command" do
6
+ cmd = Yad::Core.build_setup_command('myapp', :umask => '02', :shared_subdirectories => %w(processing_files))
7
+ cmd.should eql("umask 02 && mkdir -p myapp/releases myapp/scm myapp/shared myapp/shared/config myapp/shared/processing_files")
8
+ end
9
+
10
+ it "should build the update source code command" do
11
+ cmd = Yad::Core.build_update_source_code_command('my checkout command', 'my export command', 'path/to/new/release')
12
+ cmd.should eql("my checkout command && my export command && chmod -R g+w path/to/new/release")
13
+ end
14
+
15
+ it "should build the update symlink command" do
16
+ cmd = Yad::Core.build_update_symlink_command('path/to/current/release', 'path/to/new/release')
17
+ cmd.should eql("rm -f path/to/current/release && ln -s path/to/new/release path/to/current/release")
18
+ end
19
+
20
+ it "should build the remove directory command" do
21
+ cmd = Yad::Core.build_remove_directory_command('path/to/directory')
22
+ cmd.should eql("rm -rf path/to/directory")
23
+ end
24
+
25
+ it "should build the revision log command" do
26
+ cmd = Yad::Core.build_revision_log_command('timestamp', 'inline_revision_identifier_command', 'path/to/new/release', 'path/to/deployment')
27
+ cmd.should eql("echo timestamp $USER inline_revision_identifier_command #{File.basename('path/to/new/release')} >> path/to/deployment/revisions.log")
28
+ end
29
+
30
+ it "should not build the rollback command if there are less than 2 releases" do
31
+ cmd = Yad::Core.build_rollback_command('path/to/current/release', nil, 'path/to/latest/release')
32
+ cmd.should eql("echo no previous release for rollback")
33
+ end
34
+
35
+ it "should build the rollback command if there are at lease 2 releases" do
36
+ cmd = Yad::Core.build_rollback_command('path/to/current/release', 'path/to/previous/release', 'path/to/latest/release')
37
+ cmd.should eql("rm -f path/to/current/release; ln -s path/to/previous/release path/to/current/release && rm -rf path/to/latest/release")
38
+ end
39
+
40
+ it "should not build the cleanup command when there are less than or equal to the max number of releases to keep" do
41
+ cmd = Yad::Core.build_cleanup_command(5, 'path/to/releases', %w(release1 release2 release3 release4))
42
+ cmd.should eql("echo keeping all releases")
43
+ cmd = Yad::Core.build_cleanup_command(5, 'path/to/releases', %w(release1 release2 release3 release4 release5))
44
+ cmd.should eql("echo keeping all releases")
45
+ end
46
+
47
+ it "should build the cleanup command when there are more than the max number of releases to keep" do
48
+ cmd = Yad::Core.build_cleanup_command(5, 'path/to/releases', %w(release1 release2 release3 release4 release5 release6 release7))
49
+ cmd.should eql("rm -rf path/to/releases/release1 path/to/releases/release2")
50
+ end
51
+
52
+ it "should build an empty files array for no files" do
53
+ cmd = Yad::Core.build_files_array('')
54
+ cmd.should eql([])
55
+ cmd = Yad::Core.build_files_array(nil)
56
+ cmd.should eql([])
57
+ end
58
+
59
+ it "should build the files array for a single file" do
60
+ cmd = Yad::Core.build_files_array('file1')
61
+ cmd.should eql(%w(file1))
62
+ end
63
+
64
+ it "should build the files array for multiple files" do
65
+ cmd = Yad::Core.build_files_array('file1, file2,file3')
66
+ cmd.should eql(%w(file1 file2 file3))
67
+ end
68
+
69
+ end
@@ -0,0 +1,15 @@
1
+ require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
2
+
3
+ describe Yad::Db::Rails do
4
+
5
+ it "should build the create db command" do
6
+ cmd = Yad::Db::Rails.build_create_db_command('path/to/release', :app_env => 'production', :rake_cmd => 'rake')
7
+ cmd.should eql("cd path/to/release; rake RAILS_ENV=production db:create")
8
+ end
9
+
10
+ it "should build the migrate db command" do
11
+ cmd = Yad::Db::Rails.build_migrate_db_command('path/to/release', :app_env => 'production', :rake_cmd => 'rake', :migrate_args => 'MIGRATE=ARGS')
12
+ cmd.should eql("cd path/to/release; rake RAILS_ENV=production db:migrate MIGRATE=ARGS")
13
+ end
14
+
15
+ end
@@ -0,0 +1,25 @@
1
+ require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
2
+
3
+ describe Yad::Framework::Rails do
4
+
5
+ it "should build the setup command" do
6
+ cmd = Yad::Framework::Rails.build_setup_command('path/to/shared/directory', :umask => '02')
7
+ cmd.should eql("umask 02 && mkdir -p path/to/shared/directory/log path/to/shared/directory/pids path/to/shared/directory/system")
8
+ end
9
+
10
+ it "should build the update command" do
11
+ cmd = Yad::Framework::Rails.build_update_command('path/to/new/release', 'path/to/shared/directory', :app_env => 'production', :framework_update_db_config_via => 'none')
12
+ cmd.should eql("rm -rf path/to/new/release/log path/to/new/release/public/system path/to/new/release/tmp/pids && mkdir -p path/to/new/release/tmp && ln -s path/to/shared/directory/log path/to/new/release/log && ln -s path/to/shared/directory/pids path/to/new/release/tmp/pids && ln -s path/to/shared/directory/system path/to/new/release/public/system")
13
+ end
14
+
15
+ it "should build the update command with db config setup via copy" do
16
+ cmd = Yad::Framework::Rails.build_update_command('path/to/new/release', 'path/to/shared/directory', :app_env => 'production', :framework_update_db_config_via => 'copy')
17
+ cmd.should eql("rm -rf path/to/new/release/log path/to/new/release/public/system path/to/new/release/tmp/pids && mkdir -p path/to/new/release/tmp && ln -s path/to/shared/directory/log path/to/new/release/log && ln -s path/to/shared/directory/pids path/to/new/release/tmp/pids && ln -s path/to/shared/directory/system path/to/new/release/public/system && cp -f path/to/new/release/config/database_production.yml path/to/new/release/config/database.yml")
18
+ end
19
+
20
+ it "should build the update command with db config setup via symlink" do
21
+ cmd = Yad::Framework::Rails.build_update_command('path/to/new/release', 'path/to/shared/directory', :app_env => 'production', :framework_update_db_config_via => 'symlink')
22
+ cmd.should eql("rm -rf path/to/new/release/log path/to/new/release/public/system path/to/new/release/tmp/pids && mkdir -p path/to/new/release/tmp && ln -s path/to/shared/directory/log path/to/new/release/log && ln -s path/to/shared/directory/pids path/to/new/release/tmp/pids && ln -s path/to/shared/directory/system path/to/new/release/public/system && ln -nfs path/to/shared/directory/config/database.yml path/to/new/release/config/database.yml")
23
+ end
24
+
25
+ end
@@ -0,0 +1,15 @@
1
+ require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
2
+
3
+ describe Yad::Maintenance::SharedSystem do
4
+
5
+ it "should build the turn on command" do
6
+ cmd = Yad::Maintenance::SharedSystem.build_turn_on_command('path/to/shared/directory')
7
+ cmd.should eql("cp -f path/to/shared/directory/config/maintenance.html path/to/shared/directory/system/")
8
+ end
9
+
10
+ it "should build the turn off command" do
11
+ cmd = Yad::Maintenance::SharedSystem.build_turn_off_command('path/to/shared/directory')
12
+ cmd.should eql("rm -f path/to/shared/directory/system/maintenance.html")
13
+ end
14
+
15
+ end
@@ -0,0 +1,30 @@
1
+ require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
2
+
3
+ describe Yad::Scm::Git do
4
+
5
+ it "should build the default checkout command" do
6
+ cmd = Yad::Scm::Git.build_checkout_command('ssh://some.domain.com/path/to/myapp.git', 'path/to/scm')
7
+ cmd.should eql("([ -d path/to/scm/cached-copy/.git ] && echo 'Existing repository found' || git clone ssh://some.domain.com/path/to/myapp.git path/to/scm/cached-copy) && cd path/to/scm/cached-copy && git fetch && git reset --hard origin/master && git submodule -q init && git submodule -q update")
8
+ end
9
+
10
+ it "should build the checkout command with revision" do
11
+ cmd = Yad::Scm::Git.build_checkout_command('ssh://some.domain.com/path/to/myapp.git', 'path/to/scm', :revision => 'origin/staging')
12
+ cmd.should eql("([ -d path/to/scm/cached-copy/.git ] && echo 'Existing repository found' || git clone ssh://some.domain.com/path/to/myapp.git path/to/scm/cached-copy) && cd path/to/scm/cached-copy && git fetch && git reset --hard origin/staging && git submodule -q init && git submodule -q update")
13
+ end
14
+
15
+ it "should build the checkout command without submodules" do
16
+ cmd = Yad::Scm::Git.build_checkout_command('ssh://some.domain.com/path/to/myapp.git', 'path/to/scm', :enable_submodules => false)
17
+ cmd.should eql("([ -d path/to/scm/cached-copy/.git ] && echo 'Existing repository found' || git clone ssh://some.domain.com/path/to/myapp.git path/to/scm/cached-copy) && cd path/to/scm/cached-copy && git fetch && git reset --hard origin/master")
18
+ end
19
+
20
+ it "should build the export command" do
21
+ cmd = Yad::Scm::Git.build_export_command('path/to/source', 'path/to/destination')
22
+ cmd.should eql("mkdir -p path/to/destination && rsync -a -f '- .git' path/to/source/cached-copy/ path/to/destination")
23
+ end
24
+
25
+ it "should build the inline revision identifier command" do
26
+ cmd = Yad::Scm::Git.build_inline_revision_identifier_command('path/to/scm')
27
+ cmd.should eql("`cd path/to/scm/cached-copy && git rev-parse origin/master`")
28
+ end
29
+
30
+ end
@@ -0,0 +1,25 @@
1
+ require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
2
+
3
+ describe Yad::Web::Apache do
4
+
5
+ it "should build the start command with an alternate apache command" do
6
+ cmd = Yad::Web::Apache.build_start_command(:apache_command => 'apache2ctl')
7
+ cmd.should eql("apache2ctl start")
8
+ end
9
+
10
+ it "should build the start command" do
11
+ cmd = Yad::Web::Apache.build_start_command
12
+ cmd.should eql("apachectl start")
13
+ end
14
+
15
+ it "should build the restart command" do
16
+ cmd = Yad::Web::Apache.build_restart_command
17
+ cmd.should eql("apachectl restart")
18
+ end
19
+
20
+ it "should build the stop command" do
21
+ cmd = Yad::Web::Apache.build_stop_command
22
+ cmd.should eql("apachectl stop")
23
+ end
24
+
25
+ end
@@ -0,0 +1,87 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{yad}
5
+ s.version = "0.0.4"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Don Barlow"]
9
+ s.date = %q{2009-07-24}
10
+ s.description = %q{Yad: Yet Another Deployer}
11
+ s.email = %q{ottobar@perryburghacker.com}
12
+ s.extra_rdoc_files = [
13
+ "LICENSE",
14
+ "README.rdoc"
15
+ ]
16
+ s.files = [
17
+ ".gitignore",
18
+ "LICENSE",
19
+ "README.rdoc",
20
+ "Rakefile",
21
+ "VERSION.yml",
22
+ "doc/faq.rdoc",
23
+ "features/step_definitions/yad_steps.rb",
24
+ "features/support/env.rb",
25
+ "features/yad.feature",
26
+ "lib/ext/rake.rb",
27
+ "lib/ext/rake/remote_task.rb",
28
+ "lib/ext/string.rb",
29
+ "lib/yad.rb",
30
+ "lib/yad/app/passenger.rb",
31
+ "lib/yad/core.rb",
32
+ "lib/yad/db/rails.rb",
33
+ "lib/yad/framework/rails.rb",
34
+ "lib/yad/maintenance/shared_system.rb",
35
+ "lib/yad/scm/git.rb",
36
+ "lib/yad/web/apache.rb",
37
+ "spec/ext/rake/remote_task_spec.rb",
38
+ "spec/spec_helper.rb",
39
+ "spec/yad/app/passenger_spec.rb",
40
+ "spec/yad/core_spec.rb",
41
+ "spec/yad/db/rails_spec.rb",
42
+ "spec/yad/framework/rails_spec.rb",
43
+ "spec/yad/maintenance/shared_system_spec.rb",
44
+ "spec/yad/scm/git_spec.rb",
45
+ "spec/yad/web/apache_spec.rb",
46
+ "yad.gemspec"
47
+ ]
48
+ s.homepage = %q{http://yad.rubyforge.org}
49
+ s.rdoc_options = ["--charset=UTF-8"]
50
+ s.require_paths = ["lib"]
51
+ s.rubyforge_project = %q{yad}
52
+ s.rubygems_version = %q{1.3.4}
53
+ s.summary = %q{Yet another deployer, pretty much stolen from Vlad}
54
+ s.test_files = [
55
+ "spec/ext/rake/remote_task_spec.rb",
56
+ "spec/spec_helper.rb",
57
+ "spec/yad/app/passenger_spec.rb",
58
+ "spec/yad/core_spec.rb",
59
+ "spec/yad/db/rails_spec.rb",
60
+ "spec/yad/framework/rails_spec.rb",
61
+ "spec/yad/maintenance/shared_system_spec.rb",
62
+ "spec/yad/scm/git_spec.rb",
63
+ "spec/yad/web/apache_spec.rb"
64
+ ]
65
+
66
+ if s.respond_to? :specification_version then
67
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
68
+ s.specification_version = 3
69
+
70
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
71
+ s.add_runtime_dependency(%q<rake>, ["~> 0.8.7"])
72
+ s.add_runtime_dependency(%q<open4>, ["~> 0.9.6"])
73
+ s.add_development_dependency(%q<voloko-sdoc>, ["~> 0.2.12.1"])
74
+ s.add_development_dependency(%q<technicalpickles-jeweler>, ["~> 1.0.1"])
75
+ else
76
+ s.add_dependency(%q<rake>, ["~> 0.8.7"])
77
+ s.add_dependency(%q<open4>, ["~> 0.9.6"])
78
+ s.add_dependency(%q<voloko-sdoc>, ["~> 0.2.12.1"])
79
+ s.add_dependency(%q<technicalpickles-jeweler>, ["~> 1.0.1"])
80
+ end
81
+ else
82
+ s.add_dependency(%q<rake>, ["~> 0.8.7"])
83
+ s.add_dependency(%q<open4>, ["~> 0.9.6"])
84
+ s.add_dependency(%q<voloko-sdoc>, ["~> 0.2.12.1"])
85
+ s.add_dependency(%q<technicalpickles-jeweler>, ["~> 1.0.1"])
86
+ end
87
+ end
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: yad
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
+ platform: ruby
6
+ authors:
7
+ - Don Barlow
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-07-24 00:00:00 -04:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rake
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ~>
22
+ - !ruby/object:Gem::Version
23
+ version: 0.8.7
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: open4
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 0.9.6
34
+ version:
35
+ - !ruby/object:Gem::Dependency
36
+ name: voloko-sdoc
37
+ type: :development
38
+ version_requirement:
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 0.2.12.1
44
+ version:
45
+ - !ruby/object:Gem::Dependency
46
+ name: technicalpickles-jeweler
47
+ type: :development
48
+ version_requirement:
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 1.0.1
54
+ version:
55
+ description: "Yad: Yet Another Deployer"
56
+ email: ottobar@perryburghacker.com
57
+ executables: []
58
+
59
+ extensions: []
60
+
61
+ extra_rdoc_files:
62
+ - LICENSE
63
+ - README.rdoc
64
+ files:
65
+ - .gitignore
66
+ - LICENSE
67
+ - README.rdoc
68
+ - Rakefile
69
+ - VERSION.yml
70
+ - doc/faq.rdoc
71
+ - features/step_definitions/yad_steps.rb
72
+ - features/support/env.rb
73
+ - features/yad.feature
74
+ - lib/ext/rake.rb
75
+ - lib/ext/rake/remote_task.rb
76
+ - lib/ext/string.rb
77
+ - lib/yad.rb
78
+ - lib/yad/app/passenger.rb
79
+ - lib/yad/core.rb
80
+ - lib/yad/db/rails.rb
81
+ - lib/yad/framework/rails.rb
82
+ - lib/yad/maintenance/shared_system.rb
83
+ - lib/yad/scm/git.rb
84
+ - lib/yad/web/apache.rb
85
+ - spec/ext/rake/remote_task_spec.rb
86
+ - spec/spec_helper.rb
87
+ - spec/yad/app/passenger_spec.rb
88
+ - spec/yad/core_spec.rb
89
+ - spec/yad/db/rails_spec.rb
90
+ - spec/yad/framework/rails_spec.rb
91
+ - spec/yad/maintenance/shared_system_spec.rb
92
+ - spec/yad/scm/git_spec.rb
93
+ - spec/yad/web/apache_spec.rb
94
+ - yad.gemspec
95
+ has_rdoc: true
96
+ homepage: http://yad.rubyforge.org
97
+ licenses: []
98
+
99
+ post_install_message:
100
+ rdoc_options:
101
+ - --charset=UTF-8
102
+ require_paths:
103
+ - lib
104
+ required_ruby_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: "0"
109
+ version:
110
+ required_rubygems_version: !ruby/object:Gem::Requirement
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ version: "0"
115
+ version:
116
+ requirements: []
117
+
118
+ rubyforge_project: yad
119
+ rubygems_version: 1.3.4
120
+ signing_key:
121
+ specification_version: 3
122
+ summary: Yet another deployer, pretty much stolen from Vlad
123
+ test_files:
124
+ - spec/ext/rake/remote_task_spec.rb
125
+ - spec/spec_helper.rb
126
+ - spec/yad/app/passenger_spec.rb
127
+ - spec/yad/core_spec.rb
128
+ - spec/yad/db/rails_spec.rb
129
+ - spec/yad/framework/rails_spec.rb
130
+ - spec/yad/maintenance/shared_system_spec.rb
131
+ - spec/yad/scm/git_spec.rb
132
+ - spec/yad/web/apache_spec.rb