capobvious 0.3.pre3 → 0.3.pre4

Sign up to get free protection for your applications and to get access to all the features.
data/bin/capobvious CHANGED
@@ -38,6 +38,8 @@ end
38
38
 
39
39
  repository=`git remote -v`.split("\n").first.split("\t").last.split(/\s+/).first rescue nil
40
40
 
41
+ deploy_to = 'set :deploy_to, "/home/#{user}/www/#{application}"'
42
+
41
43
  files = {
42
44
  "Capfile" => <<FILE,
43
45
  load 'deploy'
@@ -48,23 +50,20 @@ FILE
48
50
 
49
51
  "config/deploy.rb" => <<FILE,
50
52
  # -*- encoding : utf-8 -*-
51
- set :rvm_ruby_string, '1.9.3'
52
- set :application, "appname"
53
+ set :ruby_version, '#{RUBY_VERSION}'
54
+ set :application, "#{File.basename(Dir.getwd)}"
53
55
  set :user, "USER_NAME_HERE"
54
56
  set :serv, "IP_ADDRESS_HERE"
55
57
 
56
58
  set :repository, "#{repository||'REPOSITORY_HERE'}"
57
59
  set :branch, "master"
58
- set :server_name, "example.com"
59
- set :server_redirect, "www.example.com"
60
+ set :server_name, "EXAMPLE.com"
61
+ set :server_redirect, "WWW.EXAMPLE.COM"
60
62
 
61
- set :assets, true
62
63
  set :backup_db, false
63
64
  set :backup_sys, false
64
- set :auto_migrate, true
65
65
 
66
- #set :deploy_folder, "/home/user/www/application"
67
- set :deploy_via, :remote_cache
66
+ #{deploy_to}
68
67
 
69
68
  set :keep_releases, 5
70
69
  set :use_sudo, false
@@ -1,7 +1,16 @@
1
1
  Capistrano::Configuration.instance(:must_exist).load do
2
+ def database_yml(env = rails_env)
3
+ yml = File.read(fetch(:database_yml_path))
4
+ config = YAML::load(yml)[env.to_s]
5
+ config.keys.each do |key|
6
+ config[(key.to_sym rescue key) || key] = config.delete(key)
7
+ end
8
+ config
9
+ end
2
10
  namespace :backup do
3
11
  desc "Backup a database"
4
12
  task :db do
13
+ yml = database_yml
5
14
  file_name = fetch(:db_file_name)
6
15
  archive_ext = fetch(:db_archive_ext)
7
16
  dump_file_path = "#{shared_path}/backup/#{file_name}"
@@ -9,15 +18,15 @@ Capistrano::Configuration.instance(:must_exist).load do
9
18
  output_file_path = "#{dump_file_path}.#{archive_ext}"
10
19
  require 'yaml'
11
20
  run "mkdir -p #{shared_path}/backup"
12
- if adapter == "postgresql"
13
- logger.important("Backup database #{database}", "Backup:db")
14
- run "export PGPASSWORD=\"#{db_password}\" && pg_dump -U #{db_username} #{database} > #{dump_file_path}"
21
+ if yml[:adapter] == "postgresql"
22
+ logger.important("Backup database #{yml[:database]}", "Backup:db")
23
+ run "export PGPASSWORD=\"#{yml[:password]}\" && pg_dump -U #{yml[:username]} #{yml[:database]} > #{dump_file_path}"
15
24
  run "cd #{shared_path}/backup && #{arch_create} #{output_file} #{file_name} && rm #{dump_file_path}"
16
25
  else
17
- puts "Cannot backup, adapter #{adapter} is not implemented for backup yet"
26
+ puts "Cannot backup, adapter #{yml[:adapter]} is not implemented for backup yet"
18
27
  end
19
- system "mkdir -p #{local_folder_path}"
20
- download_path = "#{local_folder_path}/#{file_name}.#{archive_ext}"
28
+ system "mkdir -p #{backup_folder_path}"
29
+ download_path = "#{backup_folder_path}/#{file_name}.#{archive_ext}"
21
30
  logger.important("Downloading database to #{download_path}", "Backup:db")
22
31
  download(output_file_path, download_path)
23
32
  run "rm -v #{output_file_path}" if fetch(:del_backup)
@@ -27,7 +36,7 @@ Capistrano::Configuration.instance(:must_exist).load do
27
36
  file_path = "#{shared_path}/backup/#{sys_file_name}"
28
37
  logger.important("Backup shared/system folder", "Backup:sys")
29
38
  run "#{arch_create} #{file_path} -C #{shared_path} system"
30
- download_path = "#{local_folder_path}/#{sys_file_name}"
39
+ download_path = "#{backup_folder_path}/#{sys_file_name}"
31
40
  logger.important("Downloading system to #{download_path}", "Backup:db")
32
41
  download(file_path, download_path)
33
42
  run "rm -v #{file_path}" if fetch(:del_backup)
@@ -54,14 +54,16 @@ Capistrano::Configuration.instance(:must_exist).load do
54
54
  end
55
55
 
56
56
  task :import do
57
+ yml = database_yml(:development)
58
+ yml[:username] = `whoami`.chop unless yml[:username]
59
+
57
60
  file_name = "#{db_file_name}.#{db_archive_ext}"
58
61
  file_path = "#{backup_folder_path}/#{file_name}"
59
62
  system "cd #{backup_folder_path} && #{arch_extract} #{file_name}"
60
- system "echo \"drop database IF EXISTS #{local_database}\" | #{psql_postgres}"
61
- system "echo \"create database #{local_database} owner #{local_db_username};\" | #{psql_postgres}"
62
- # system "#{psql_postgre} #{local_database} < #{backup_folder_path}/#{db_file_name}"
63
- puts "ENTER your development password: #{local_db_password}"
64
- system "#{psql} -U#{local_db_username} #{local_database} < #{backup_folder_path}/#{db_file_name}"
63
+ system "echo \"drop database IF EXISTS #{yml[:database]}\" | #{psql_postgres}"
64
+ system "echo \"create database #{yml[:database]} owner #{yml[:username]};\" | #{psql_postgres}"
65
+ puts "ENTER your development password: #{yml[:password]}"
66
+ system "#{psql} -U#{yml[:username]} #{yml[:database]} < #{backup_folder_path}/#{db_file_name}"
65
67
  system "rm #{backup_folder_path}/#{db_file_name}"
66
68
  end
67
69
  task :pg_import do
@@ -10,6 +10,7 @@ Capistrano::Configuration.instance(:must_exist).load do
10
10
  _cset :del_backup, true
11
11
  _cset :backup_folder_path, "tmp/backup"
12
12
  _cset :database_yml_path, 'config/database.yml'
13
+ _cset :auto_migrate, true
13
14
 
14
15
  set :rvmrc_string ,"rvm use #{fetch(:ruby_version)}"
15
16
  after "deploy:update_code", "create:rvmrc"
@@ -1,3 +1,3 @@
1
1
  module Capobvious
2
- VERSION = "0.3.pre3"
2
+ VERSION = "0.3.pre4"
3
3
  end
metadata CHANGED
@@ -1,48 +1,48 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capobvious
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.pre3
5
4
  prerelease: 4
5
+ version: 0.3.pre4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Dmitry Gruzd
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-01 00:00:00.000000000 Z
12
+ date: 2012-12-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: capistrano
16
- prerelease: false
15
+ type: :runtime
17
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
18
  requirements:
19
19
  - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
21
  version: '0'
22
- none: false
23
- type: :runtime
22
+ prerelease: false
24
23
  version_requirements: !ruby/object:Gem::Requirement
24
+ none: false
25
25
  requirements:
26
26
  - - ! '>='
27
27
  - !ruby/object:Gem::Version
28
28
  version: '0'
29
- none: false
29
+ name: capistrano
30
30
  - !ruby/object:Gem::Dependency
31
- name: rvm-capistrano
32
- prerelease: false
31
+ type: :runtime
33
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
34
  requirements:
35
35
  - - ! '>='
36
36
  - !ruby/object:Gem::Version
37
37
  version: '0'
38
- none: false
39
- type: :runtime
38
+ prerelease: false
40
39
  version_requirements: !ruby/object:Gem::Requirement
40
+ none: false
41
41
  requirements:
42
42
  - - ! '>='
43
43
  - !ruby/object:Gem::Version
44
44
  version: '0'
45
- none: false
45
+ name: rvm-capistrano
46
46
  description: Capfile that we use every day
47
47
  email:
48
48
  - donotsendhere@gmail.com
@@ -80,17 +80,17 @@ rdoc_options: []
80
80
  require_paths:
81
81
  - lib
82
82
  required_ruby_version: !ruby/object:Gem::Requirement
83
+ none: false
83
84
  requirements:
84
85
  - - ! '>='
85
86
  - !ruby/object:Gem::Version
86
87
  version: '0'
87
- none: false
88
88
  required_rubygems_version: !ruby/object:Gem::Requirement
89
+ none: false
89
90
  requirements:
90
91
  - - ! '>'
91
92
  - !ruby/object:Gem::Version
92
93
  version: 1.3.1
93
- none: false
94
94
  requirements: []
95
95
  rubyforge_project: capobvious
96
96
  rubygems_version: 1.8.24