forkcms_new_deploy 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "shoulda", ">= 0"
10
+ gem "bundler", "~> 1.0.0"
11
+ gem "jeweler", "~> 1.6.4"
12
+ gem "rcov", ">= 0"
13
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,20 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ git (1.2.5)
5
+ jeweler (1.6.4)
6
+ bundler (~> 1.0)
7
+ git (>= 1.2.5)
8
+ rake
9
+ rake (0.9.2)
10
+ rcov (0.9.10)
11
+ shoulda (2.11.3)
12
+
13
+ PLATFORMS
14
+ ruby
15
+
16
+ DEPENDENCIES
17
+ bundler (~> 1.0.0)
18
+ jeweler (~> 1.6.4)
19
+ rcov
20
+ shoulda
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 sam@sumocoders.be
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 ADDED
@@ -0,0 +1,19 @@
1
+ = forkcms_new_deploy
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to forkcms_new_deploy
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
9
+ * Fork the project
10
+ * Start a feature/bugfix branch
11
+ * Commit and push until you are happy with your contribution
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2011 sam@sumocoders.be. See LICENSE.txt for
18
+ further details.
19
+
data/Rakefile ADDED
@@ -0,0 +1,53 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "forkcms_new_deploy"
18
+ gem.homepage = "http://github.com/samtubbax/forkcms_new_deploy"
19
+ gem.license = "MIT"
20
+ gem.summary = 'Deploys fork CMS 3.0 and up'
21
+ gem.description = 'Deploys fork CMS 3.0 and up'
22
+ gem.email = "sam@sumocoders.be"
23
+ gem.authors = ["sam@sumocoders.be"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rake/testtask'
29
+ Rake::TestTask.new(:test) do |test|
30
+ test.libs << 'lib' << 'test'
31
+ test.pattern = 'test/**/test_*.rb'
32
+ test.verbose = true
33
+ end
34
+
35
+ require 'rcov/rcovtask'
36
+ Rcov::RcovTask.new do |test|
37
+ test.libs << 'test'
38
+ test.pattern = 'test/**/test_*.rb'
39
+ test.verbose = true
40
+ test.rcov_opts << '--exclude "gems/*"'
41
+ end
42
+
43
+ task :default => :test
44
+
45
+ require 'rake/rdoctask'
46
+ Rake::RDocTask.new do |rdoc|
47
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
48
+
49
+ rdoc.rdoc_dir = 'rdoc'
50
+ rdoc.title = "forkcms_new_deploy #{version}"
51
+ rdoc.rdoc_files.include('README*')
52
+ rdoc.rdoc_files.include('lib/**/*.rb')
53
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,2 @@
1
+ require 'forkcms_new_deploy/forkcms'
2
+ require 'forkcms_new_deploy/overwrites'
@@ -0,0 +1,22 @@
1
+ configuration = Capistrano::Configuration.respond_to?(:instance) ? Capistrano::Configuration.instance(:must_exist) : Capistrano.configuration(:must_exist)
2
+
3
+ configuration.load do
4
+ # don't use sudo, on most shared setups we won't have sudo-access
5
+ set :use_sudo, false
6
+
7
+ # we're on a share setup so group_writable isn't allowed
8
+ set :group_writable, false
9
+
10
+ # 3 releases should be enough.
11
+ set :keep_releases, 3
12
+
13
+ # remote caching will keep a local git repo on the server you're deploying to and simply run a fetch from that
14
+ # rather than an entire clone. This is probably the best option and will only fetch the differences each deploy
15
+ set :deploy_via, :remote_cache
16
+
17
+ # set the value for pseudo terminals in Capistrano
18
+ default_run_options[:pty] = true
19
+
20
+ # your computer must be running ssh-agent for the git checkout to work from the server to the git server
21
+ set :ssh_options, { :forward_agent => true }
22
+ end
@@ -0,0 +1,104 @@
1
+ configuration = Capistrano::Configuration.respond_to?(:instance) ? Capistrano::Configuration.instance(:must_exist) : Capistrano.configuration(:must_exist)
2
+
3
+ configuration.load do
4
+ # define some extra folder to create
5
+ set :shared_children, %w(files config/frontend config/backend config/library)
6
+
7
+ # custom events configuration
8
+ after 'deploy:setup' do
9
+ forkcms.link_document_root
10
+ end
11
+
12
+ after 'deploy:update_code' do
13
+ forkcms.link_configs
14
+ forkcms.link_files
15
+ end
16
+
17
+ # Fork CMS specific tasks
18
+ namespace :forkcms do
19
+ desc 'Clear the frontend and backend cache-folders'
20
+ task :clear_cached do
21
+ # remove frontend cached data
22
+ run %{
23
+ rm -rf #{current_path}/frontend/cache/cached_templates/* &&
24
+ rm -rf #{current_path}/frontend/cache/locale/* &&
25
+ rm -rf #{current_path}/frontend/cache/minified_css/* &&
26
+ rm -rf #{current_path}/frontend/cache/minified_js/* &&
27
+ rm -rf #{current_path}/frontend/cache/navigation/* &&
28
+ rm -rf #{current_path}/frontend/cache/statistics/* &&
29
+ rm -rf #{current_path}/frontend/cache/templates/*
30
+ }
31
+
32
+ # remove backend cached data
33
+ run %{
34
+ rm -rf #{current_path}/backend/cache/analytics/* &&
35
+ rm -rf #{current_path}/backend/cache/cronjobs/* &&
36
+ rm -rf #{current_path}/backend/cache/locale/* &&
37
+ rm -rf #{current_path}/backend/cache/mailmotor/* &&
38
+ rm -rf #{current_path}/backend/cache/templates/*
39
+ }
40
+ end
41
+
42
+ desc 'Link the config files'
43
+ task :link_configs do
44
+ # create config files
45
+ path_library = <<-CONFIG
46
+ <?php
47
+ // custom constant used by the init classes
48
+ define('INIT_PATH_LIBRARY', '#{current_path}/library');
49
+ ?>
50
+ CONFIG
51
+
52
+ # upload the files
53
+ put path_library, "#{shared_path}/config/frontend/config.php"
54
+ put path_library, "#{shared_path}/config/backend/config.php"
55
+
56
+ # change the path to current_path
57
+ run "if [ -f #{shared_path}/config/library/globals.php ]; then sed -i 's/#{version_dir}\\/[0-9]*/#{current_dir}/' #{shared_path}/config/library/globals.php; fi"
58
+
59
+ # create dirs
60
+ run %{
61
+ mkdir -p #{release_path}/frontend/cache/config &&
62
+ mkdir -p #{release_path}/backend/cache/config
63
+ }
64
+
65
+ # symlink the globals
66
+ run %{
67
+ ln -sf #{shared_path}/config/library/globals_backend.php #{release_path}/library/globals_backend.php &&
68
+ ln -sf #{shared_path}/config/library/globals_frontend.php #{release_path}/library/globals_frontend.php &&
69
+ ln -sf #{shared_path}/config/library/globals.php #{release_path}/library/globals.php &&
70
+ ln -sf #{shared_path}/config/frontend/config.php #{release_path}/frontend/cache/config/config.php &&
71
+ ln -sf #{shared_path}/config/backend/config.php #{release_path}/backend/cache/config/config.php
72
+ }
73
+ end
74
+
75
+ desc 'link the document root to the current/default_www-folder'
76
+ task :link_document_root do
77
+ # create symlink for document_root if it doesn't exists
78
+ documentRootExists = capture("if [ ! -e #{document_root} ]; then ln -sf #{current_path} #{document_root}; echo 'no'; fi").chomp
79
+
80
+ unless documentRootExists == 'no'
81
+ warn "Warning: Document root (#{document_root}) already exists"
82
+ warn "to link it to the Fork deploy issue the following command:"
83
+ warn " ln -sf #{current_path} #{document_root}"
84
+ end
85
+ end
86
+
87
+ desc 'Create needed symlinks'
88
+ task :link_files do
89
+ # get the list of folders in /frontend/files
90
+ folders = capture("ls -1 #{release_path}/frontend/files").split(/\r?\n/)
91
+
92
+ # loop the folders
93
+ folders.each do |folder|
94
+ # copy them to the shared path, remove them from the release and symlink them
95
+ run %{
96
+ mkdir -p #{shared_path}/files/#{folder} &&
97
+ cp -r #{release_path}/frontend/files/#{folder} #{shared_path}/files/ &&
98
+ rm -rf #{release_path}/frontend/files/#{folder} &&
99
+ ln -s #{shared_path}/files/#{folder} #{release_path}/frontend/files/#{folder}
100
+ }
101
+ end
102
+ end
103
+ end
104
+ end
@@ -0,0 +1,31 @@
1
+ configuration = Capistrano::Configuration.respond_to?(:instance) ? Capistrano::Configuration.instance(:must_exist) : Capistrano.configuration(:must_exist)
2
+
3
+ configuration.load do
4
+ # Deployment process
5
+ namespace :deploy do
6
+ desc 'Prepares the servers for deployment.'
7
+ task :setup, :except => { :no_release => true } do
8
+ # this method is overwritten because Fork CMS isn't a Rails-application
9
+
10
+ # define folders to create
11
+ dirs = [deploy_to, releases_path, shared_path]
12
+
13
+ # add folder that aren't standard
14
+ dirs += shared_children.map { |d| File.join(shared_path, d) }
15
+
16
+ # create the dirs
17
+ run %{
18
+ #{try_sudo} mkdir -p #{dirs.join(' ')} &&
19
+ #{try_sudo} chmod g+w #{dirs.join(' ')}
20
+ }
21
+ end
22
+
23
+ task :finalize_update, :except => { :no_release => true } do
24
+ # Fork CMS isn't a Rails-application so don't do Rails specific stuff
25
+ run 'chmod -R g+w #{latest_release}' if fetch(:group_writable, true)
26
+ end
27
+
28
+ # overrule restart
29
+ task :restart do; end
30
+ end
31
+ end
data/test/helper.rb ADDED
@@ -0,0 +1,18 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'test/unit'
11
+ require 'shoulda'
12
+
13
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
15
+ require 'forkcms_new_deploy'
16
+
17
+ class Test::Unit::TestCase
18
+ end
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestForkcmsNewDeploy < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,137 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: forkcms_new_deploy
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - sam@sumocoders.be
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-10-26 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ version_requirements: &id001 !ruby/object:Gem::Requirement
22
+ none: false
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ hash: 3
27
+ segments:
28
+ - 0
29
+ version: "0"
30
+ name: shoulda
31
+ prerelease: false
32
+ type: :development
33
+ requirement: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ version_requirements: &id002 !ruby/object:Gem::Requirement
36
+ none: false
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ hash: 23
41
+ segments:
42
+ - 1
43
+ - 0
44
+ - 0
45
+ version: 1.0.0
46
+ name: bundler
47
+ prerelease: false
48
+ type: :development
49
+ requirement: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ version_requirements: &id003 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ~>
55
+ - !ruby/object:Gem::Version
56
+ hash: 7
57
+ segments:
58
+ - 1
59
+ - 6
60
+ - 4
61
+ version: 1.6.4
62
+ name: jeweler
63
+ prerelease: false
64
+ type: :development
65
+ requirement: *id003
66
+ - !ruby/object:Gem::Dependency
67
+ version_requirements: &id004 !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ hash: 3
73
+ segments:
74
+ - 0
75
+ version: "0"
76
+ name: rcov
77
+ prerelease: false
78
+ type: :development
79
+ requirement: *id004
80
+ description: Deploys fork CMS 3.0 and up
81
+ email: sam@sumocoders.be
82
+ executables: []
83
+
84
+ extensions: []
85
+
86
+ extra_rdoc_files:
87
+ - LICENSE.txt
88
+ - README.rdoc
89
+ files:
90
+ - .document
91
+ - Gemfile
92
+ - Gemfile.lock
93
+ - LICENSE.txt
94
+ - README.rdoc
95
+ - Rakefile
96
+ - VERSION
97
+ - lib/forkcms_new_deploy.rb
98
+ - lib/forkcms_new_deploy/defaults.rb
99
+ - lib/forkcms_new_deploy/forkcms.rb
100
+ - lib/forkcms_new_deploy/overwrites.rb
101
+ - test/helper.rb
102
+ - test/test_forkcms_new_deploy.rb
103
+ homepage: http://github.com/samtubbax/forkcms_new_deploy
104
+ licenses:
105
+ - MIT
106
+ post_install_message:
107
+ rdoc_options: []
108
+
109
+ require_paths:
110
+ - lib
111
+ required_ruby_version: !ruby/object:Gem::Requirement
112
+ none: false
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ hash: 3
117
+ segments:
118
+ - 0
119
+ version: "0"
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ hash: 3
126
+ segments:
127
+ - 0
128
+ version: "0"
129
+ requirements: []
130
+
131
+ rubyforge_project:
132
+ rubygems_version: 1.8.10
133
+ signing_key:
134
+ specification_version: 3
135
+ summary: Deploys fork CMS 3.0 and up
136
+ test_files: []
137
+