capobvious 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -2,3 +2,4 @@
2
2
  .bundle
3
3
  Gemfile.lock
4
4
  pkg/*
5
+ .DS_Store
@@ -1,61 +1,63 @@
1
- Add to the end of Capfile
2
- require 'capistrano/ext/capobvious'
1
+ How to use
2
+ ======
3
+
4
+ Add to the end of Capfile
5
+ **require 'capistrano/ext/capobvious'**
3
6
 
4
7
  some task need 7z
5
8
  Ubuntu: sudo apt-get install p7zip-full
6
9
 
7
10
 
8
- backup:db
11
+ Cap recipies
12
+ ======
13
+
14
+ **backup:db**
9
15
  if you want to backup your production postgres database
10
16
  it will create 7z archive at your tmp/backup project folder & shared/backup on server (NOTE: it need p7zip installed on server)
11
17
 
12
- backup:sys
18
+ **backup:sys**
13
19
  backup your system folder on server to 7z archive at tmp/backup & shared/backup on server (NOTE: need p7zip)
14
20
 
15
- backup:clean
21
+ **backup:clean**
16
22
  delete all files in server shared/backup folder
17
23
 
18
24
 
19
- assets:precompile
25
+ **assets:precompile**
20
26
  precompiles assets on developer's machine & sends it to server
21
27
  NOTE:
22
28
  if in config/deploy.rb will be setted :assets to true, task will run automatically by deploy
23
29
 
24
30
 
25
- db:create
26
- will create a Postgresql database and user with password that stored in database.yml
31
+ **db:create**
32
+ will create a Postgresql database on server and user with password that stored in database.yml
27
33
 
28
- db:seed
34
+ **db:seed**
29
35
  run rake db:seed with right RAILS_ENV
30
36
 
31
- db:pg_import
37
+ **db:pg_import**
32
38
  import remote server postgresql database to your development postgresql database IT WILL DELETE YOUR DEV DATABASE (NOTE: need installed p7zip)
33
39
 
34
40
 
35
- rake TASK=db:seed
41
+ r**ake TASK=db:seed**
36
42
  runs custom rake task
37
43
 
38
44
 
39
45
 
40
- nginx:restart
41
- nginx:reload
42
- nginx:start
43
- nginx:stop
46
+ **nginx:restart**
47
+ **nginx:reload**
48
+ **nginx:start**
49
+ **nginx:stop**
44
50
 
45
51
 
46
52
 
47
- bundle:install
53
+ **bundle:install**
48
54
 
49
55
 
50
- log:tail
56
+ **log:tail**
51
57
  catch errors with tail -f log
52
58
 
53
59
 
54
60
 
55
- unicorn:start
56
- unicorn:stop
57
- unicorn:restart
58
-
59
-
60
-
61
-
61
+ **unicorn:start**
62
+ **unicorn:stop**
63
+ **unicorn:restart**
data/capobvious.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  $:.push File.expand_path("../lib", __FILE__)
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "capobvious"
@@ -15,15 +15,32 @@ unless exists?(:dbconf)
15
15
  set :dbconf, "database.yml"
16
16
  end
17
17
 
18
+ if `uname -a`.include?("Darwin")
19
+ run_local_psql = "psql -h localhost -U postgres"
20
+ else
21
+ run_local_psql = "#{sudo} -u postgres psql"
22
+ end
23
+
18
24
  config = YAML::load(File.open("config/#{dbconf}"))
19
25
  adapter = config[rails_env]["adapter"]
20
26
  database = config[rails_env]["database"]
21
27
  db_username = config[rails_env]["username"]
22
28
  db_password = config[rails_env]["password"]
23
29
 
30
+
31
+ local_rails_env = 'development'
32
+ config = YAML::load(File.open("config/database.yml"))
33
+ local_adapter = config[local_rails_env]["adapter"]
34
+ local_database = config[local_rails_env]["database"]
35
+ local_db_username = config[local_rails_env]["username"]
36
+ local_db_password = config[local_rails_env]["password"]
37
+
38
+
39
+
24
40
  set :local_folder_path, "tmp/backup"
25
41
  set :timestamp, Time.new.to_i.to_s
26
42
  set :db_file_name, "#{database}-#{timestamp}.sql"
43
+ set :sys_file_name, "#{application}-system-#{timestamp}.7z"
27
44
  set :db_archive_ext, "7z"
28
45
 
29
46
 
@@ -77,10 +94,10 @@ namespace :db do
77
94
  file_name = "#{db_file_name}.#{db_archive_ext}"
78
95
  file_path = "#{local_folder_path}/#{file_name}"
79
96
  system "cd #{local_folder_path} && 7z x #{file_name}"
80
- system "echo \"drop database #{database}\" | sudo -u postgres psql"
81
- system "echo \"create database #{database} owner #{db_username};\" | sudo -u postgres psql"
82
- system "sudo -u postgres psql #{database} < #{local_folder_path}/#{db_file_name}"
83
- system "rm -v #{local_folder_path}/#{db_file_name}"
97
+ system "echo \"drop database #{local_database}\" | #{run_local_psql}"
98
+ system "echo \"create database #{local_database} owner #{local_db_username};\" | #{run_local_psql}"
99
+ system "#{run_local_psql} #{local_database} < #{local_folder_path}/#{db_file_name}"
100
+ system "rm #{local_folder_path}/#{db_file_name}"
84
101
  end
85
102
  task :pg_import do
86
103
  backup.db
@@ -88,6 +105,17 @@ namespace :db do
88
105
  end
89
106
  end
90
107
 
108
+ namespace :import do
109
+ task :sys do
110
+ backup.sys
111
+ system "rm -rfv public/system/"
112
+ system "7z x #{local_folder_path}/#{sys_file_name} -opublic"
113
+ end
114
+ task :db do
115
+ db.pg_import
116
+ end
117
+ end
118
+
91
119
  # PRIKHA-TASK
92
120
  desc "Run custom task usage: cap rake TASK=patch:project_category"
93
121
  task :rake do
@@ -119,10 +147,9 @@ namespace :backup do
119
147
  end
120
148
  desc "Backup public/system folder"
121
149
  task :sys do
122
- file_name = "#{application}-system-#{timestamp}.7z"
123
- file_path = "#{shared_path}/backup/#{file_name}"
150
+ file_path = "#{shared_path}/backup/#{sys_file_name}"
124
151
  run "7z a #{file_path} #{shared_path}/system"
125
- download(file_path, "#{local_folder_path}/#{file_name}")
152
+ download(file_path, "#{local_folder_path}/#{sys_file_name}")
126
153
  end
127
154
  desc "Clean backup folder"
128
155
  task :clean do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capobvious
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-21 00:00:00.000000000 Z
12
+ date: 2012-02-22 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Capfile that we use every day
15
15
  email:
@@ -20,7 +20,7 @@ extra_rdoc_files: []
20
20
  files:
21
21
  - .gitignore
22
22
  - Gemfile
23
- - README
23
+ - README.markdown
24
24
  - Rakefile
25
25
  - capobvious.gemspec
26
26
  - lib/capistrano/ext/capobvious.rb