ee_recipes 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 jayronc
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.
@@ -0,0 +1,17 @@
1
+ = ee_recipes
2
+
3
+ Description goes here.
4
+
5
+ == Note on Patches/Pull Requests
6
+
7
+ * Fork the project.
8
+ * Make your feature addition or bug fix.
9
+ * Add tests for it. This is important so I don't break it in a
10
+ future version unintentionally.
11
+ * Commit, do not mess with rakefile, version, or history.
12
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
13
+ * Send me a pull request. Bonus points for topic branches.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2009 jayronc. See LICENSE for details.
@@ -0,0 +1,52 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "ee_recipes"
8
+ gem.summary = %Q{EE Recipes fro deploy}
9
+ gem.description = %Q{Recipes to deploy and manage expression engine with capistrano}
10
+ gem.email = "jerrodblavos@mac.com"
11
+ gem.homepage = "http://github.com/jerrod/ee_recipes"
12
+ gem.authors = ["jayronc"]
13
+ gem.add_development_dependency "yard", ">= 0"
14
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
+ end
16
+ Jeweler::GemcutterTasks.new
17
+ rescue LoadError
18
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
19
+ end
20
+
21
+ require 'rake/testtask'
22
+ Rake::TestTask.new(:test) do |test|
23
+ test.libs << 'lib' << 'test'
24
+ test.pattern = 'test/**/test_*.rb'
25
+ test.verbose = true
26
+ end
27
+
28
+ begin
29
+ require 'rcov/rcovtask'
30
+ Rcov::RcovTask.new do |test|
31
+ test.libs << 'test'
32
+ test.pattern = 'test/**/test_*.rb'
33
+ test.verbose = true
34
+ end
35
+ rescue LoadError
36
+ task :rcov do
37
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
38
+ end
39
+ end
40
+
41
+ task :test => :check_dependencies
42
+
43
+ task :default => :test
44
+
45
+ begin
46
+ require 'yard'
47
+ YARD::Rake::YardocTask.new
48
+ rescue LoadError
49
+ task :yardoc do
50
+ abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
51
+ end
52
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,133 @@
1
+ Capistrano::Configuration.instance(:must_exist).load do
2
+ namespace :ee do
3
+ desc "runs git pull origin master in httpdocs on the server"
4
+ task :deploy do
5
+ cmd = [
6
+ "cd #{path_to_src_dir}",
7
+ "git pull origin master"
8
+ ].join(" && ")
9
+ run cmd
10
+ end
11
+
12
+ desc "checks code into git"
13
+ task :git_push do
14
+ system "git push origin master"
15
+ end
16
+
17
+ desc "runs the rake production:deploy command"
18
+ task :prepare_deploy do
19
+ system "rake production:deploy"
20
+ end
21
+
22
+ task :backup_name do
23
+ now = Time.now
24
+ run "mkdir -p db_backups"
25
+ backup_time = [now.year, now.month, now.day, now.hour, now.min, now.sec].join('-')
26
+ set :backup_file, "db_backups/#{dbname}-snapshot-#{backup_time}.sql"
27
+ end
28
+
29
+ task :local_backup_name do
30
+ now = Time.now
31
+ run "mkdir -p db_backups_from_local"
32
+ backup_time = [now.year, now.month, now.day, now.hour, now.min, now.sec].join('-')
33
+ set :local_backup_file, "db_backups_from_local/#{dbname}-snapshot-#{backup_time}.sql"
34
+ end
35
+
36
+ desc "dumps a database to /db_backups"
37
+ task :dump do
38
+ backup_name
39
+ run "mysqldump --add-drop-table -u #{dbuser} -p #{dbname} | bzip2 -c > #{backup_file}.bz2" do |ch, stream, out|
40
+ ch.send_data "#{dbpass}\n" if out=~ /^Enter password:/
41
+ end
42
+ end
43
+
44
+ task :local_dump do
45
+ system "mysqldump --add-drop-table -u root #{dbname} | bzip2 -c > /tmp/#{dbname}-snapshot.sql.bz2"
46
+ end
47
+
48
+ task :clone_to_local do
49
+ backup_name
50
+ dump
51
+ get "#{backup_file}.bz2", "/tmp/#{application}.sql.gz"
52
+ system "bzcat /tmp/#{application}.sql.gz | mysql -u root #{dbname}"
53
+ end
54
+
55
+ desc "Pushes the database on to staging"
56
+ task :deploy_database do
57
+ #first backup the database
58
+ backup_name
59
+ dump
60
+
61
+ #dump a local copy of the database
62
+ local_dump
63
+
64
+ #create the local backup directory on the server if it doesn't exist
65
+ local_backup_name
66
+
67
+ #upload the file
68
+ put(File.read("/tmp/#{dbname}-snapshot.sql.bz2"), "#{local_backup_file}.bz2", :mode => 0666)
69
+
70
+ #import the database
71
+ run("bzcat #{local_backup_file}.bz2 | mysql -u #{dbuser} --password=\"#{dbpass}\" #{dbname}", { :shell => false})
72
+ end
73
+
74
+ desc "Updates the file paths on production / staging"
75
+ task :update_file_upload_paths do
76
+
77
+ #set the file name
78
+ now = Time.now
79
+ creation_time = [now.year, now.month, now.day, now.hour, now.min, now.sec].join('-')
80
+
81
+ set :upload_file_name, "/tmp/#{dbname}_upload_locations-#{creation_time}.txt"
82
+
83
+ #dump a list of file upload paths
84
+ run "mysql -u #{dbuser} --password=\"#{dbpass}\" --database=#{dbname} --execute=\"SELECT id, url from exp_upload_prefs INTO OUTFILE '#{upload_file_name}'\""
85
+
86
+ #get the file upload paths locally
87
+ get("#{upload_file_name}", "#{upload_file_name}")
88
+
89
+ urls = []
90
+
91
+ #open tthe file
92
+ file = File.open("#{upload_file_name}")
93
+ file.readlines.each do |line|
94
+
95
+ db_row = line.split("\t")
96
+ row_id = db_row[0]
97
+ upload_path = db_row[1]
98
+
99
+ server_path = "#{path_to_src_dir}/public#{upload_path}"
100
+
101
+ #update the permissions while we're here
102
+ run "chmod 777 #{server_path}"
103
+
104
+ #for each entry update the database
105
+ run "mysql -u #{dbuser} --password=\"#{dbpass}\" --database=#{dbname} --execute=\"UPDATE exp_upload_prefs SET server_path='#{server_path}' WHERE id = #{row_id}\""
106
+ end
107
+ end
108
+
109
+ desc "Copies any uploads from the server to the same folder locally"
110
+ task :clone_uploads_to_local do
111
+ cmd = [
112
+ "cd #{path_to_src_dir}",
113
+ "tar -cjf uploads.tar #{path_to_uploads_dir}"
114
+ ].join(" && ")
115
+
116
+ run cmd
117
+
118
+ get("#{path_to_src_dir}/uploads.tar", "/tmp/uploads.tar")
119
+
120
+ run "rm -Rf #{path_to_src_dir}/uploads.tar"
121
+
122
+ cmd = [
123
+ "tar -xvf /tmp/uploads.tar",
124
+ "rm -Rf /tmp/uploads.tar"
125
+ ].join(" && ")
126
+
127
+ system cmd
128
+ end
129
+
130
+ after "ee:deploy_database", "ee:update_file_upload_paths"
131
+ before "ee:deploy", "ee:git_push"
132
+ end
133
+ end
@@ -0,0 +1,9 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+
4
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ require 'ee_recipes'
7
+
8
+ class Test::Unit::TestCase
9
+ end
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestEeRecipes < Test::Unit::TestCase
4
+ def test_something_for_real
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ee_recipes
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - jayronc
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-12-30 00:00:00 -05:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: yard
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ description: Recipes to deploy and manage expression engine with capistrano
26
+ email: jerrodblavos@mac.com
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - LICENSE
33
+ - README.rdoc
34
+ files:
35
+ - .document
36
+ - .gitignore
37
+ - LICENSE
38
+ - README.rdoc
39
+ - Rakefile
40
+ - VERSION
41
+ - lib/ee_recipes.rb
42
+ - test/helper.rb
43
+ - test/test_ee_recipes.rb
44
+ has_rdoc: true
45
+ homepage: http://github.com/jerrod/ee_recipes
46
+ licenses: []
47
+
48
+ post_install_message:
49
+ rdoc_options:
50
+ - --charset=UTF-8
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: "0"
58
+ version:
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: "0"
64
+ version:
65
+ requirements: []
66
+
67
+ rubyforge_project:
68
+ rubygems_version: 1.3.5
69
+ signing_key:
70
+ specification_version: 3
71
+ summary: EE Recipes fro deploy
72
+ test_files:
73
+ - test/helper.rb
74
+ - test/test_ee_recipes.rb