porter 0.1.9 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in porter.gemspec
4
+ gemspec
data/Rakefile CHANGED
@@ -1,54 +1,2 @@
1
- require 'rubygems'
2
- require 'rake'
3
-
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "porter"
8
- gem.summary = "Capistrano and Rake tasks for cloning production database and assets to development."
9
- gem.description = "Capistrano and Rake tasks for cloning production database and assets to development."
10
- gem.email = "info@appcreations.com"
11
- gem.homepage = "http://github.com/kjohnston/porter"
12
- gem.authors = ["Kenny Johnston"]
13
- gem.add_development_dependency "capistrano", ">= 0"
14
- gem.add_development_dependency "rake", ">= 0"
15
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
16
- end
17
- Jeweler::GemcutterTasks.new
18
- rescue LoadError
19
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
20
- end
21
-
22
- require 'rake/testtask'
23
- Rake::TestTask.new(:test) do |test|
24
- test.libs << 'lib' << 'test'
25
- test.pattern = 'test/**/test_*.rb'
26
- test.verbose = true
27
- end
28
-
29
- begin
30
- require 'rcov/rcovtask'
31
- Rcov::RcovTask.new do |test|
32
- test.libs << 'test'
33
- test.pattern = 'test/**/test_*.rb'
34
- test.verbose = true
35
- end
36
- rescue LoadError
37
- task :rcov do
38
- abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
39
- end
40
- end
41
-
42
- task :test => :check_dependencies
43
-
44
- task :default => :test
45
-
46
- require 'rake/rdoctask'
47
- Rake::RDocTask.new do |rdoc|
48
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
49
-
50
- rdoc.rdoc_dir = 'rdoc'
51
- rdoc.title = "porter #{version}"
52
- rdoc.rdoc_files.include('README*')
53
- rdoc.rdoc_files.include('lib/**/*.rb')
54
- end
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
data/Readme.textile ADDED
@@ -0,0 +1,58 @@
1
+ h1. Porter Gem
2
+
3
+ The Porter gem is comprised of Capistrano and Rake tasks that make cloning your production and/or staging server data down to your development environment a cinch.
4
+
5
+ h2. Overview
6
+
7
+ * A mysqldump command is remotely issued (via Capistrano) to the remote server (production or staging environment), saving the result as a compressed (gz) file
8
+ * The database backup file from the server is retrieved (via scp) and decompressed
9
+ * The development database is dropped, recreated, and restored from the backup
10
+ * Assets stored in shared/public are rysnc'd down to your local public directory (exclusions are accepted!)
11
+ * Separate rake tasks are included for restoring the db and re-syncing the assets without re-dumping the remote db
12
+
13
+ h2. Dependencies
14
+
15
+ * Capistrano (and a config/deploy.rb file)
16
+ * Rake
17
+ * A Rails App
18
+ * rsync (locally and remotely)
19
+
20
+ h2. Installation
21
+
22
+ * Add config.gem 'porter' to your Gemfile
23
+ * Run: bundle install
24
+ * Run: rails g porter
25
+ * Add require 'porter' to your config/deploy.rb
26
+ * See the generated config/porter_config.yml - it's pretty straight-forward
27
+
28
+ h2. Usage
29
+
30
+ * cap porter:[stage] (creates the remote db backup file then calls the two rake tasks below)
31
+ * rake porter:[stage]:db (if you've already got a db backup on the remote server and want to restore from it again)
32
+ * rake porter:[stage]:assets (rsync the assets down from the remote server again)
33
+
34
+ Note: [stage] is most likely going to be 'production' unless your app has a staging or demo environment and you want to pull from there instead.
35
+
36
+ h2. License
37
+
38
+ The MIT License
39
+
40
+ Copyright (c) 2010-2011 Kenny Johnston
41
+
42
+ Permission is hereby granted, free of charge, to any person obtaining a copy
43
+ of this software and associated documentation files (the "Software"), to deal
44
+ in the Software without restriction, including without limitation the rights
45
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
46
+ copies of the Software, and to permit persons to whom the Software is
47
+ furnished to do so, subject to the following conditions:
48
+
49
+ The above copyright notice and this permission notice shall be included in
50
+ all copies or substantial portions of the Software.
51
+
52
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
53
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
54
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
55
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
56
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
57
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
58
+ THE SOFTWARE.
@@ -0,0 +1,19 @@
1
+ require 'rails/generators'
2
+
3
+ class PorterGenerator < Rails::Generators::Base
4
+
5
+ attr_accessor :app, :domain
6
+
7
+ def self.source_root
8
+ @source_root ||= File.join(File.dirname(__FILE__), 'templates')
9
+ end
10
+
11
+ def create_config_file
12
+ @app = Dir.glob(Rails.root).to_s.split('/').last
13
+ @domain = @app + (@app.include?('.') ? '' : '.com')
14
+
15
+ template 'porter_config.yml', 'config/porter_config.yml'
16
+ readme 'INSTALL'
17
+ end
18
+
19
+ end
@@ -0,0 +1,7 @@
1
+ *******************************************************
2
+
3
+ Add the following to the top of your config/deploy.rb:
4
+
5
+ require 'porter'
6
+
7
+ *******************************************************
@@ -0,0 +1,16 @@
1
+ # Config file for porter gem
2
+
3
+ production:
4
+ user: deploy
5
+ domain: <%= domain %>
6
+ app_dir: /opt/apps/<%= app %>
7
+ asset_dirs: system
8
+ rsync_options: --verbose --progress --stats --recursive --times --compress --delete
9
+
10
+ # staging:
11
+ # user: deploy
12
+ # domain: <%= domain %>
13
+ # dir: /opt/apps/<%= app %>
14
+ # asset_dirs: system
15
+ # rsync_options: --verbose --progress --stats --recursive --times --compress --delete
16
+
data/lib/porter.rb CHANGED
@@ -1 +1,5 @@
1
1
  require "#{File.dirname(__FILE__)}/porter/recipes/porter"
2
+
3
+ module Porter
4
+ require 'porter/railtie'
5
+ end
@@ -0,0 +1,11 @@
1
+ require 'porter'
2
+ require 'rails'
3
+ module Porter
4
+ class Railtie < Rails::Railtie
5
+ railtie_name :porter
6
+
7
+ rake_tasks do
8
+ load "tasks/porter.rake"
9
+ end
10
+ end
11
+ end
@@ -1,4 +1,4 @@
1
- if defined?(Capistrano::Configuration)
1
+ if defined?(Capistrano)
2
2
  Capistrano::Configuration.instance.load do
3
3
  namespace :porter do
4
4
  CONFIG = YAML::load_file('config/porter_config.yml')
@@ -12,10 +12,10 @@ if defined?(Capistrano::Configuration)
12
12
  db = src_db['database']
13
13
  user = src_db['username']
14
14
  pass = src_db['password']
15
-
16
- domain = CONFIG[stage].nil? ? CONFIG['server']['domain'] : CONFIG[stage]['domain']
15
+
16
+ domain = CONFIG[stage]['domain']
17
17
  server domain, :porter
18
-
18
+
19
19
  run "mysqldump --user=#{user} --password=#{pass} #{db} | gzip > ~/#{db}.sql.gz", :roles => :porter
20
20
  system "rake porter:#{stage}:db"
21
21
  system "rake porter:#{stage}:assets"
@@ -23,4 +23,4 @@ if defined?(Capistrano::Configuration)
23
23
  end
24
24
  end
25
25
  end
26
- end
26
+ end
@@ -0,0 +1,3 @@
1
+ module Porter
2
+ VERSION = "1.0.0"
3
+ end
@@ -1,28 +1,25 @@
1
- CONFIG = YAML::load_file(File.join(RAILS_ROOT, 'config', 'porter_config.yml'))
2
- DATABASES = YAML::load_file(File.join(RAILS_ROOT, 'config', 'database.yml'))
1
+ CONFIG = YAML::load_file(Rails.root.join('config', 'porter_config.yml'))
2
+ DATABASES = YAML::load_file(Rails.root.join('config', 'database.yml'))
3
3
  STAGES = DATABASES.keys - %w(development test) # you don't need data out of these
4
4
 
5
5
  namespace :porter do
6
6
  STAGES.each do |stage|
7
7
  namespace stage do
8
8
  task :db => :environment do
9
- # Optional: You can setup specific username and host
10
- # combos for each stage in porter_config.yml or use
11
- # the default 'server' key to apply to all stages
12
9
  if CONFIG[stage]
13
10
  src_user = CONFIG[stage]['user']
14
11
  src_domain = CONFIG[stage]['domain']
15
12
  else
16
- src_user = CONFIG['server']['user']
17
- src_domain = CONFIG['server']['domain']
13
+ puts "Please tell config/porter_config.yml about the '#{stage}' server."
14
+ return
18
15
  end
19
16
 
20
17
  src_db = ActiveRecord::Base.configurations[stage]
21
- dest_db = ActiveRecord::Base.configurations[RAILS_ENV]
22
- dest_root = RAILS_ROOT
18
+ dest_db = ActiveRecord::Base.configurations[Rails.env]
19
+ dest_root = Rails.root
23
20
 
24
21
  app = src_db['database'].split('_').first
25
- root = RAILS_ROOT
22
+ root = Rails.root
26
23
 
27
24
  puts "Retrieving latest compressed database backup from #{stage} server..."
28
25
  system "scp #{src_user}@#{src_domain}:~/#{src_db['database']}.sql.gz #{root}"
@@ -55,41 +52,23 @@ namespace :porter do
55
52
  puts "Removing database backup file..."
56
53
  system "rm #{root}/#{src_db['database']}.sql"
57
54
 
58
- puts "Production data reload complete"
55
+ puts "Database reload complete"
59
56
  end
60
57
 
61
58
  task :assets => :environment do
62
- root = RAILS_ROOT
63
- user = CONFIG[stage].nil? ? CONFIG['server']['user'] : CONFIG[stage]['user']
64
- domain = CONFIG[stage].nil? ? CONFIG['server']['domain'] : CONFIG[stage]['domain']
65
- dir = CONFIG[stage].nil? ? CONFIG['server']['dir'] : CONFIG[stage]['dir']
66
- entire_dirs = CONFIG['assets']['entire_dirs'].blank? ? '' : CONFIG['assets']['entire_dirs'].gsub(/,/,'').split(' ').map { |i| i.strip }
67
- excludable_dir = CONFIG['assets']['excludable_dir']
68
- model = CONFIG['assets']['excludable_model'].constantize unless CONFIG['assets']['excludable_model'].blank?
69
- column = CONFIG['assets']['excludable_column']
70
- exclusions = CONFIG['assets']['excludable_matches'].blank? ? '' : CONFIG['assets']['excludable_matches'].gsub(/,/,'').split(' ').map { |i| i.strip }
71
- rsync_options = CONFIG['assets']['rsync_options']
59
+ root = Rails.root
60
+ user = CONFIG[stage]['user']
61
+ domain = CONFIG[stage]['domain']
62
+ app_dir = CONFIG[stage]['app_dir']
63
+ asset_dirs = CONFIG[stage]['asset_dirs'].blank? ? '' : CONFIG[stage]['asset_dirs'].gsub(/,/,'').split(' ').map { |i| i.strip }
64
+ rsync_options = CONFIG[stage]['rsync_options']
72
65
 
73
- if exclusions.blank?
74
- entire_dirs << excludable_dir unless excludable_dir.blank?
75
- else
76
- puts "Building a list of excludable assets (excluding: #{exclusions.join(', ')}) to rsync down..."
77
- rsync_file_list = File.new('rsync_file_list.txt', "w")
78
- attachments = model.find(:all, :conditions => ["#{column} NOT IN (?)", exclusions])
79
- attachments.each do |a|
80
- rsync_file_list.send((a == attachments.last ? :print : :puts), a.partitioned_path.join('/'))
81
- end
82
- rsync_file_list.close
83
- system "rsync --files-from=#{root}/rsync_file_list.txt #{rsync_options} #{user}@#{domain}:#{dir}/shared/#{excludable_dir}/ #{excludable_dir}"
84
- system "rm #{root}/rsync_file_list.txt" if File.exists?("#{root}/rsync_file_list.txt")
85
- end
86
-
87
- entire_dirs.each do |d|
66
+ asset_dirs.each do |d|
88
67
  puts "Synchronizing assets in #{d}..."
89
- system "rsync #{rsync_options} #{user}@#{domain}:#{dir}/shared/#{d}/ #{d}"
68
+ system "rsync #{rsync_options} #{user}@#{domain}:#{app_dir}/shared/#{d}/ #{d}"
90
69
  end
91
70
 
92
- puts "Production asset synchronization complete"
71
+ puts "Asset synchronization complete"
93
72
  end
94
73
  end
95
74
  end
data/porter.gemspec CHANGED
@@ -1,59 +1,21 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
1
  # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "porter/version"
5
4
 
6
5
  Gem::Specification.new do |s|
7
- s.name = %q{porter}
8
- s.version = "0.1.9"
6
+ s.name = "porter"
7
+ s.version = Porter::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Kenny Johnston", "Robert Bousquet"]
10
+ s.email = ["kjohnston.ca@gmail.com"]
11
+ s.homepage = "http://github.com/kjohnston/porter"
12
+ s.summary = %q{Capistrano and Rake tasks for cloning production and/or staging databases and assets to development.}
13
+ s.description = %q{Capistrano and Rake tasks for cloning production and/or staging databases and assets to development.}
9
14
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Kenny Johnston", "Robert Bousquet"]
12
- s.date = %q{2010-08-25}
13
- s.description = %q{Capistrano and Rake tasks for cloning production database and assets to development.}
14
- s.email = %q{info@appcreations.com}
15
- s.extra_rdoc_files = [
16
- "LICENSE",
17
- "README.rdoc"
18
- ]
19
- s.files = [
20
- ".gitignore",
21
- "LICENSE",
22
- "README.rdoc",
23
- "Rakefile",
24
- "generators/porter/lib/insert_commands.rb",
25
- "generators/porter/porter_generator.rb",
26
- "generators/porter/templates/porter.rb",
27
- "generators/porter/templates/porter_config.yml",
28
- "lib/porter.rb",
29
- "lib/porter/recipes/porter.rb",
30
- "lib/tasks/porter.rake",
31
- "porter.gemspec",
32
- "test/helper.rb"
33
- ]
34
- s.homepage = %q{http://github.com/kjohnston/porter}
35
- s.rdoc_options = ["--charset=UTF-8"]
36
- s.require_paths = ["lib"]
37
- s.rubygems_version = %q{1.3.7}
38
- s.summary = %q{Capistrano and Rake tasks for cloning production database and assets to development.}
39
- s.test_files = [
40
- "test/helper.rb"
41
- ]
42
-
43
- if s.respond_to? :specification_version then
44
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
45
- s.specification_version = 3
15
+ s.rubyforge_project = "porter"
46
16
 
47
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
48
- s.add_development_dependency(%q<capistrano>, [">= 0"])
49
- s.add_development_dependency(%q<rake>, [">= 0"])
50
- else
51
- s.add_dependency(%q<capistrano>, [">= 0"])
52
- s.add_dependency(%q<rake>, [">= 0"])
53
- end
54
- else
55
- s.add_dependency(%q<capistrano>, [">= 0"])
56
- s.add_dependency(%q<rake>, [">= 0"])
57
- end
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
58
21
  end
59
-
metadata CHANGED
@@ -1,95 +1,81 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: porter
3
- version: !ruby/object:Gem::Version
4
- version: 0.1.9
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
5
  prerelease:
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 0
10
+ version: 1.0.0
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Kenny Johnston
9
14
  - Robert Bousquet
10
15
  autorequire:
11
16
  bindir: bin
12
17
  cert_chain: []
13
- date: 2010-08-25 00:00:00.000000000 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: capistrano
17
- requirement: !ruby/object:Gem::Requirement
18
- none: false
19
- requirements:
20
- - - ! '>='
21
- - !ruby/object:Gem::Version
22
- version: '0'
23
- type: :development
24
- prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
- requirements:
28
- - - ! '>='
29
- - !ruby/object:Gem::Version
30
- version: '0'
31
- - !ruby/object:Gem::Dependency
32
- name: rake
33
- requirement: !ruby/object:Gem::Requirement
34
- none: false
35
- requirements:
36
- - - ! '>='
37
- - !ruby/object:Gem::Version
38
- version: '0'
39
- type: :development
40
- prerelease: false
41
- version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
- requirements:
44
- - - ! '>='
45
- - !ruby/object:Gem::Version
46
- version: '0'
47
- description: Capistrano and Rake tasks for cloning production database and assets
48
- to development.
49
- email: info@appcreations.com
18
+
19
+ date: 2011-03-10 00:00:00 -08:00
20
+ default_executable:
21
+ dependencies: []
22
+
23
+ description: Capistrano and Rake tasks for cloning production and/or staging databases and assets to development.
24
+ email:
25
+ - kjohnston.ca@gmail.com
50
26
  executables: []
27
+
51
28
  extensions: []
52
- extra_rdoc_files:
53
- - LICENSE
54
- - README.rdoc
55
- files:
29
+
30
+ extra_rdoc_files: []
31
+
32
+ files:
56
33
  - .gitignore
57
- - LICENSE
58
- - README.rdoc
34
+ - Gemfile
59
35
  - Rakefile
60
- - generators/porter/lib/insert_commands.rb
61
- - generators/porter/porter_generator.rb
62
- - generators/porter/templates/porter.rb
63
- - generators/porter/templates/porter_config.yml
36
+ - Readme.textile
37
+ - lib/generators/porter/porter_generator.rb
38
+ - lib/generators/porter/templates/INSTALL
39
+ - lib/generators/porter/templates/porter_config.yml
64
40
  - lib/porter.rb
41
+ - lib/porter/railtie.rb
65
42
  - lib/porter/recipes/porter.rb
43
+ - lib/porter/version.rb
66
44
  - lib/tasks/porter.rake
67
45
  - porter.gemspec
68
- - test/helper.rb
46
+ has_rdoc: true
69
47
  homepage: http://github.com/kjohnston/porter
70
48
  licenses: []
49
+
71
50
  post_install_message:
72
- rdoc_options:
73
- - --charset=UTF-8
74
- require_paths:
51
+ rdoc_options: []
52
+
53
+ require_paths:
75
54
  - lib
76
- required_ruby_version: !ruby/object:Gem::Requirement
55
+ required_ruby_version: !ruby/object:Gem::Requirement
77
56
  none: false
78
- requirements:
79
- - - ! '>='
80
- - !ruby/object:Gem::Version
81
- version: '0'
82
- required_rubygems_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ hash: 3
61
+ segments:
62
+ - 0
63
+ version: "0"
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
65
  none: false
84
- requirements:
85
- - - ! '>='
86
- - !ruby/object:Gem::Version
87
- version: '0'
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ hash: 3
70
+ segments:
71
+ - 0
72
+ version: "0"
88
73
  requirements: []
89
- rubyforge_project:
90
- rubygems_version: 1.8.24
74
+
75
+ rubyforge_project: porter
76
+ rubygems_version: 1.5.3
91
77
  signing_key:
92
78
  specification_version: 3
93
- summary: Capistrano and Rake tasks for cloning production database and assets to development.
94
- test_files:
95
- - test/helper.rb
79
+ summary: Capistrano and Rake tasks for cloning production and/or staging databases and assets to development.
80
+ test_files: []
81
+
data/LICENSE DELETED
@@ -1,20 +0,0 @@
1
- Copyright (c) 2009 Kenny Johnston
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc DELETED
@@ -1,37 +0,0 @@
1
- = Porter Gem
2
-
3
- The Porter gem is comprised of Capistrano and Rake tasks that make cloning your production server data down to your development environment a cinch.
4
-
5
- == Overview
6
-
7
- * A mysqldump command is remotely issued (via Capistrano) to the remote server (production or staging environment), saving the result as a compressed (gz) file
8
- * The database backup file from the server is retrieved (via scp) and decompressed
9
- * The development database is dropped, recreated, and restored from the backup
10
- * Assets stored in shared/public are rysnc'd down to your local public directory (exclusions are accepted!)
11
- * Separate rake tasks are included for restoring the db and re-syncing the assets without re-dumping the remote db
12
-
13
- == Dependencies
14
-
15
- * Capistrano (and a config/deploy.rb file)
16
- * Rake
17
- * A Rails App
18
- * rsync (locally and remotely)
19
-
20
- == Installation
21
-
22
- * sudo gem install porter
23
- * config.gem 'porter'
24
- * script/generate porter
25
- * See the generated config/porter_config.yml - it's pretty straight-forward
26
-
27
- == Usage
28
-
29
- * cap porter:[stage] (creates the remote db backup file then calls the two rake tasks below)
30
- * rake porter:[stage]:db (if you've already got a db backup on the remote server and want to restore from it again)
31
- * rake porter:[stage]:assets (rsync the assets down from the remote server again)
32
-
33
- Note: [stage] is most likely going to be 'production' unless your app has a staging or demo environment and you want to pull from there instead.
34
-
35
- == Copyright
36
-
37
- Copyright (c) 2010 Kenny Johnston. See LICENSE for details.
@@ -1,34 +0,0 @@
1
- # Mostly pinched from http://github.com/ryanb/nifty-generators/tree/master
2
-
3
- Rails::Generator::Commands::Base.class_eval do
4
- def file_contains?(relative_destination, line)
5
- File.read(destination_path(relative_destination)).include?(line)
6
- end
7
- end
8
-
9
- Rails::Generator::Commands::Create.class_eval do
10
- def append_to(file, line)
11
- logger.insert "#{line} appended to #{file}"
12
- unless options[:pretend] || file_contains?(file, line)
13
- File.open(file, "a") do |file|
14
- file.puts
15
- file.puts line
16
- end
17
- end
18
- end
19
- end
20
-
21
- Rails::Generator::Commands::Destroy.class_eval do
22
- def append_to(file, line)
23
- logger.remove "#{line} removed from #{file}"
24
- unless options[:pretend]
25
- gsub_file file, "\n#{line}", ''
26
- end
27
- end
28
- end
29
-
30
- Rails::Generator::Commands::List.class_eval do
31
- def append_to(file, line)
32
- logger.insert "#{line} appended to #{file}"
33
- end
34
- end
@@ -1,19 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + "/lib/insert_commands.rb")
2
-
3
- class PorterGenerator < Rails::Generator::Base
4
-
5
- attr_accessor :app, :domain
6
-
7
- def manifest
8
- @app = Dir.glob(RAILS_ROOT).to_s.split('/').last
9
- @domain = @app + (@app.include?('.') ? '' : '.com')
10
-
11
- record do |m|
12
- m.template 'porter_config.yml', File.join('config', 'porter_config.yml')
13
- m.template 'porter.rb', File.join('lib', 'tasks', 'porter.rb')
14
- m.append_to 'config/deploy.rb', "require 'porter'"
15
- m.append_to 'Rakefile', "require 'tasks/porter'"
16
- end
17
- end
18
-
19
- end
@@ -1,4 +0,0 @@
1
- $VERBOSE = nil
2
- if porter = Gem.searcher.find('porter')
3
- Dir["#{porter.full_gem_path}/lib/tasks/*.rake"].each { |ext| load ext }
4
- end
@@ -1,38 +0,0 @@
1
- # Config file for porter gem
2
-
3
- server:
4
- user: deploy
5
- domain: <%= domain %>
6
- dir: /opt/apps/<%= app %>
7
-
8
- # If you want to be able to pull from different environments, and the domains,
9
- # usernames or directories differ, you can delete the catch-all server option
10
- # above and enable a config for each environment's details like this:
11
- #
12
- # production:
13
- # user: deploy
14
- # domain: <%= domain %>
15
- # dir: /opt/apps/<%= app %>
16
- #
17
- # staging:
18
- # user: deploy
19
- # domain: <%= domain %>
20
- # dir: /opt/apps/<%= app %>
21
-
22
- assets:
23
- entire_dirs: public/attachments
24
- excludable_dir:
25
- excludable_model:
26
- excludable_column:
27
- excludable_matches:
28
- rsync_options: --verbose --progress --stats --recursive --times --compress
29
-
30
- # Example:
31
- #
32
- # assets:
33
- # entire_dirs: public/campaign public/user
34
- # excludable_dir: public/attachments
35
- # excludable_model: Attachment
36
- # excludable_column: attachable_type
37
- # excludable_matches: Document Product
38
- # rsync_options: --verbose --progress --stats --recursive --times --compress
data/test/helper.rb DELETED
@@ -1,10 +0,0 @@
1
- require 'rubygems'
2
- require 'test/unit'
3
- require 'shoulda'
4
-
5
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
- $LOAD_PATH.unshift(File.dirname(__FILE__))
7
- require 'porter'
8
-
9
- class Test::Unit::TestCase
10
- end