bard 0.7.8 → 0.7.9

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.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/bard.gemspec +1 -1
  3. data/lib/bard/capistrano.rb +85 -83
  4. metadata +1 -1
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.8
1
+ 0.7.9
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{bard}
8
- s.version = "0.7.8"
8
+ s.version = "0.7.9"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Micah Geisel", "Nick Hogle"]
@@ -1,105 +1,107 @@
1
- role :staging, "staging@staging.botandrose.com"
1
+ Capistrano::Configuration.instance(:must_exist).load do
2
+ role :staging, "staging@staging.botandrose.com"
2
3
 
3
- namespace "data" do
4
- namespace "pull" do
5
- desc "pull data from production"
6
- task :default, :roles => :production do
7
- data_pull :production
8
- end
9
- task :staging, :roles => :staging do
10
- data_pull :staging
11
- end
4
+ namespace "data" do
5
+ namespace "pull" do
6
+ desc "pull data from production"
7
+ task :default, :roles => :production do
8
+ data_pull :production
9
+ end
10
+ task :staging, :roles => :staging do
11
+ data_pull :staging
12
+ end
12
13
 
13
- desc "pull data from production"
14
- task :yml, :roles => :production do
15
- run "cd #{application} && rake db:data:dump && gzip -9f db/data.yml"
16
- transfer :down, "#{application}/db/data.yml.gz", "db/data.yml.gz"
17
- system "gunzip -f db/data.yml.gz"
18
- system "rake db:data:load"
14
+ desc "pull data from production"
15
+ task :yml, :roles => :production do
16
+ run "cd #{application} && rake db:data:dump && gzip -9f db/data.yml"
17
+ transfer :down, "#{application}/db/data.yml.gz", "db/data.yml.gz"
18
+ system "gunzip -f db/data.yml.gz"
19
+ system "rake db:data:load"
20
+ end
19
21
  end
20
22
  end
21
- end
22
23
 
23
- def data_pull(env)
24
- config = YAML::load(File.open("config/database.yml"))
25
- source = config[env.to_s]
26
- target = config["development"]
27
- run "cd #{application} && mysqldump -u#{source["username"]} #{"-p#{source["password"]}" if source["password"]} '#{source["database"]}' > db/data.sql && gzip -9f db/data.sql"
28
- transfer :down, "#{application}/db/data.sql.gz", "db/data.sql.gz"
29
- run "cd #{application} && rm db/data.sql.gz"
30
- system "gunzip -f db/data.sql.gz"
31
- system "echo 'DROP DATABASE `#{target["database"]}`; CREATE DATABASE `#{target["database"]}`;' | mysql -u#{target["username"]}"
32
- system "mysql -u#{target["username"]} '#{target["database"]}' < db/data.sql"
33
- # system "rm db/data.sql"
34
- end
24
+ def data_pull(env)
25
+ config = YAML::load(File.open("config/database.yml"))
26
+ source = config[env.to_s]
27
+ target = config["development"]
28
+ run "cd #{application} && mysqldump -u#{source["username"]} #{"-p#{source["password"]}" if source["password"]} '#{source["database"]}' > db/data.sql && gzip -9f db/data.sql"
29
+ transfer :down, "#{application}/db/data.sql.gz", "db/data.sql.gz"
30
+ run "cd #{application} && rm db/data.sql.gz"
31
+ system "gunzip -f db/data.sql.gz"
32
+ system "echo 'DROP DATABASE `#{target["database"]}`; CREATE DATABASE `#{target["database"]}`;' | mysql -u#{target["username"]}"
33
+ system "mysql -u#{target["username"]} '#{target["database"]}' < db/data.sql"
34
+ # system "rm db/data.sql"
35
+ end
35
36
 
36
- namespace "deploy" do
37
- desc "push app from staging to production"
38
- task :default, :roles => :production do
39
- begin
37
+ namespace "deploy" do
38
+ desc "push app from staging to production"
39
+ task :default, :roles => :production do
40
+ begin
40
41
 
41
- if `curl -s -I http://integrity.botandrose.com/#{application}` !~ /\b404\b/
42
- puts "Integrity: verifying build..."
43
- system "curl -sX POST http://integrity.botandrose.com/#{application}/builds"
44
- while true
45
- response = `curl -s http://integrity.botandrose.com/#{application}`
46
- break unless response =~ /div class='(building|pending)' id='last_build'/
47
- sleep(1)
42
+ if `curl -s -I http://integrity.botandrose.com/#{application}` !~ /\b404\b/
43
+ puts "Integrity: verifying build..."
44
+ system "curl -sX POST http://integrity.botandrose.com/#{application}/builds"
45
+ while true
46
+ response = `curl -s http://integrity.botandrose.com/#{application}`
47
+ break unless response =~ /div class='(building|pending)' id='last_build'/
48
+ sleep(1)
49
+ end
50
+ case response
51
+ when /div class='failed' id='last_build'/ then raise TestsFailedError
52
+ when /div class='success' id='last_build'/ then success "Integrity: success! deploying to production"
53
+ else raise "Unknown response from CI server:\n#{response}"
54
+ end
48
55
  end
49
- case response
50
- when /div class='failed' id='last_build'/ then raise TestsFailedError
51
- when /div class='success' id='last_build'/ then success "Integrity: success! deploying to production"
52
- else raise "Unknown response from CI server:\n#{response}"
53
- end
54
- end
55
56
 
56
- system "git push" if `git remote show origin` =~ /github\.com/
57
- run "cd #{application} && git pull"
58
- run "cd #{application} && rake gems:install" if File.exist?("Rakefile")
59
- run "cd #{application} && script/runner 'Sass::Plugin.options[:always_update] = true; Sass::Plugin.update_stylesheets'" if File.exist?("public/stylesheets/sass") or File.exist?("app/sass")
60
- run "cd #{application} && rake asset:packager:build_all" if File.exist?("vendor/plugins/asset_packager")
61
- run "cd #{application} && git submodule init && git submodule update" if File.exist?(".gitmodules")
62
- run "cd #{application} && rake db:migrate && rake restart" if File.exist?("Rakefile")
63
- success "Deploy Succeeded"
57
+ system "git push" if `git remote show origin` =~ /github\.com/
58
+ run "cd #{application} && git pull"
59
+ run "cd #{application} && rake gems:install" if File.exist?("Rakefile")
60
+ run "cd #{application} && script/runner 'Sass::Plugin.options[:always_update] = true; Sass::Plugin.update_stylesheets'" if File.exist?("public/stylesheets/sass") or File.exist?("app/sass")
61
+ run "cd #{application} && rake asset:packager:build_all" if File.exist?("vendor/plugins/asset_packager")
62
+ run "cd #{application} && git submodule init && git submodule update" if File.exist?(".gitmodules")
63
+ run "cd #{application} && rake db:migrate && rake restart" if File.exist?("Rakefile")
64
+ success "Deploy Succeeded"
64
65
 
65
- rescue BardError => e
66
- handle_error e
66
+ rescue BardError => e
67
+ handle_error e
68
+ end
67
69
  end
68
- end
69
70
 
70
- def readline(prompt)
71
- STDOUT.print(prompt)
72
- STDOUT.flush
73
- STDIN.gets
71
+ def readline(prompt)
72
+ STDOUT.print(prompt)
73
+ STDOUT.flush
74
+ STDIN.gets
75
+ end
76
+
77
+ def handle_error(error)
78
+ name = error.message.split('::').last.gsub(/([A-Z])/, " \\1").gsub(/^ /,'').gsub(/ Error/, '')
79
+ failure "!!! Deploy Error: #{name}"
80
+ end
74
81
  end
75
-
82
+
83
+ ## ERROR HANDLING
84
+
76
85
  def handle_error(error)
77
86
  name = error.message.split('::').last.gsub(/([A-Z])/, " \\1").gsub(/^ /,'').gsub(/ Error/, '')
78
87
  failure "!!! Deploy Error: #{name}"
79
88
  end
80
- end
81
89
 
82
- ## ERROR HANDLING
90
+ class BardError < Capistrano::Error; end
91
+ class TestsFailedError < BardError; end
92
+ class WorkingDirectoryDirtyError < BardError; end
93
+ class StagingWorkingDirectoryDirtyError < BardError; end
94
+ class NonFastForwardError < BardError; end
83
95
 
84
- def handle_error(error)
85
- name = error.message.split('::').last.gsub(/([A-Z])/, " \\1").gsub(/^ /,'').gsub(/ Error/, '')
86
- failure "!!! Deploy Error: #{name}"
87
- end
88
-
89
- class BardError < Capistrano::Error; end
90
- class TestsFailedError < BardError; end
91
- class WorkingDirectoryDirtyError < BardError; end
92
- class StagingWorkingDirectoryDirtyError < BardError; end
93
- class NonFastForwardError < BardError; end
96
+ def success(msg)
97
+ puts "#{GREEN}#{msg}#{DEFAULT}"
98
+ end
94
99
 
95
- def success(msg)
96
- puts "#{GREEN}#{msg}#{DEFAULT}"
97
- end
100
+ def failure(msg)
101
+ abort "#{RED}#{msg}#{DEFAULT}"
102
+ end
98
103
 
99
- def failure(msg)
100
- abort "#{RED}#{msg}#{DEFAULT}"
104
+ GREEN = "\033[1;32m"
105
+ RED = "\033[1;31m"
106
+ DEFAULT = "\033[0m"
101
107
  end
102
-
103
- GREEN = "\033[1;32m"
104
- RED = "\033[1;31m"
105
- DEFAULT = "\033[0m"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.8
4
+ version: 0.7.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Micah Geisel