capistrano-fast_remote_cache 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,18 @@
1
+ .DS_Store
2
+ *.gem
3
+ *.rbc
4
+ .bundle
5
+ .config
6
+ .yardoc
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
@@ -0,0 +1 @@
1
+ 1.9.3@capistrano-fast_remote_cache
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fast_remote_cache.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,24 @@
1
+ Original plugin Copyright (c) 2008 by 37signals, LLC
2
+
3
+ Copyright 2012 New Leaders
4
+
5
+ MIT License
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining
8
+ a copy of this software and associated documentation files (the
9
+ "Software"), to deal in the Software without restriction, including
10
+ without limitation the rights to use, copy, modify, merge, publish,
11
+ distribute, sublicense, and/or sell copies of the Software, and to
12
+ permit persons to whom the Software is furnished to do so, subject to
13
+ the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be
16
+ included in all copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,72 @@
1
+ # Capistrano Fast Remote Cache
2
+
3
+ A gem built from the original 37 Signals fast_remote_cache rails plugin. Think of this gem as one less deprecation message for your stubborn Rails apps.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem "capistrano-fast_remote_cache"
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install capistrano-fast_remote_cache
18
+
19
+ ## Usage
20
+
21
+ In your deploy.rb or Capfile:
22
+
23
+ require "capistrano/fast_remote_cache"
24
+
25
+ Set the Capistrano deployment strategy in the same file with:
26
+
27
+ set :deploy_via, :fast_remote_cache
28
+
29
+ _Note the stragey name!_
30
+
31
+ To exclude certain directories or files from being deployed, set the copy_exclude variable (can also include glob patterns):
32
+
33
+ set :copy_exclude, %w(test .git doc config/database.yml)
34
+
35
+ ## Contributing
36
+
37
+ 1. Fork it
38
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
39
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
40
+ 4. Push to the branch (`git push origin my-new-feature`)
41
+ 5. Create new Pull Request
42
+
43
+ ## From the Original Plugin README
44
+
45
+ The FastRemoteCache is a custom deployment strategy that specializes the standard RemoteCache strategy. It works just like the RemoteCache, but instead of actually copying the cache to the final release directory, it uses a custom "copy.rb" script to hard link the files. This allows the copy stage to be very fast.
46
+
47
+ For small applications, and especially for those that aren't bundling vendor/rails, this won't make much of a difference. But for large applications the speed-up will be significant.
48
+
49
+ ### Dependencies
50
+
51
+ * Capistrano 2 or later (http://www.capify.org)
52
+
53
+ ### Assumptions
54
+
55
+ The FastRemoteCache, as the RemoteCache, assumes that your source repository is accessible from both your local (deploying) host, as well as the remote (target) hosts. If either of these is not true, you will not be able to use the FastRemoteCache strategy.
56
+
57
+ Furthermore, it assumes that you have Ruby (1.8.6, preferably) installed on the target machines. If it is not installed in a standard location, you can set the :ruby variable to the location of the ruby executable.
58
+
59
+ ### Tips
60
+
61
+ For the fastest possible deploys:
62
+
63
+ * Always deploy as the same user. If you're part of a team where everyone can (and does) deploy, create a new user (e.g., "deploy") and set it up so that your team can all log in as this user. Make sure this user also has read access to your source code repository.
64
+ * Avoid sudo if at all possible. set(:use_sudo, false), and then make sure that the deploy user has sufficient permissions to start and stop the mongrels, write to the necessary directories, etc.
65
+ * Disable the "group_writable" setting: set(:group_writable, false). This is only necessary when you have multiple users deploying.
66
+ * Don't include Rails (or other large libraries) in your application. Yes, it is convenient to include them, but they bloat your app and make checkouts and copies much slower. You have to balance convenience in development versus speed of deployment. Find a compromise that works for you.
67
+
68
+ ### License
69
+
70
+ This code is released under the MIT license, and is copyright (c) 2008 by 37signals, LLC. Please see the accompanying LICENSE file for the full text of the license.
71
+
72
+ Modified for Gem release by New Leaders 2012.
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/capistrano/fast_remote_cache/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Don Morrison"]
6
+ gem.email = ["dmorrison@newleaders.com"]
7
+ gem.description = %q{Gem version of the 37 Signals Capistrano Fast Remote Cache (fast_remote_cache) Rails plugin}
8
+ gem.summary = %q{Gem version of the 37 Signals Capistrano Fast Remote Cache (fast_remote_cache) Rails plugin}
9
+ gem.homepage = ""
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "capistrano-fast_remote_cache"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Capistrano::FastRemoteCache::VERSION
17
+
18
+ gem.add_dependency "capistrano", ">=2.0.0"
19
+ end
@@ -0,0 +1 @@
1
+ require "capistrano/fast_remote_cache/version"
@@ -0,0 +1,57 @@
1
+ # ---------------------------------------------------------------------------
2
+ # This is a recipe definition file for Capistrano. The tasks are documented
3
+ # below.
4
+ # ---------------------------------------------------------------------------
5
+ # This file is distributed under the terms of the MIT license by 37signals,
6
+ # LLC, and is copyright (c) 2008 by the same. See the LICENSE file distributed
7
+ # with this file for the complete text of the license.
8
+ # ---------------------------------------------------------------------------
9
+ # Modified by New Leaders for capistrano-fast_remote_cache gem
10
+ #
11
+
12
+ # Add the top-level directory to the load path because the ridiculous
13
+ # capistrano/recipes/deploy/strategy path is hardcoded in
14
+ # capistrano/lib/capistrano/recipes/deploy/strategy.rb
15
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "fast_remote_cache"))
16
+
17
+ module Capistrano
18
+ # We only want to hook onto Capistrano when the Configuration module is
19
+ # present. Hat tip to the rvm-capistrano gem.
20
+ if const_defined? :Configuration
21
+ Configuration.instance(true).load do
22
+ namespace :fast_remote_cache do
23
+
24
+ desc <<-DESC
25
+ Perform any setup required by fast_remote_cache. This is called
26
+ automatically after deploy:setup, but may be invoked manually to configure
27
+ a new machine. It is also necessary to invoke when you are switching to the
28
+ fast_remote_cache strategy for the first time.
29
+ DESC
30
+ task :setup, :except => { :no_release => true } do
31
+ if deploy_via == :fast_remote_cache
32
+ strategy.setup!
33
+ else
34
+ logger.important "you're including the fast_remote_cache strategy, but not using it!"
35
+ end
36
+ end
37
+
38
+ desc <<-DESC
39
+ Updates the remote cache. This is handy for either priming a new box so
40
+ the cache is all set for the first deploy, or for preparing for a large
41
+ deploy by making sure the cache is updated before the deploy goes through.
42
+ Either way, this will happen automatically as part of a deploy; this task
43
+ is purely convenience for giving admins more control over the deployment.
44
+ DESC
45
+ task :prepare, :except => { :no_release => true } do
46
+ if deploy_via == :fast_remote_cache
47
+ strategy.prepare!
48
+ else
49
+ logger.important "#{current_task.fully_qualified_name} only works with the fast_remote_cache strategy"
50
+ end
51
+ end
52
+ end
53
+
54
+ after "deploy:setup", "fast_remote_cache:setup"
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,48 @@
1
+ # ---------------------------------------------------------------------------
2
+ # This implements a specialization of the standard Capistrano RemoteCache
3
+ # deployment strategy. The most significant difference between this strategy
4
+ # and the RemoteCache is the way the cache is copied to the final release
5
+ # directory: it uses the bundled "copy.rb" script to use hard links to the
6
+ # files instead of actually copying, so the copy stage is much, much faster.
7
+ # ---------------------------------------------------------------------------
8
+ # This file is distributed under the terms of the MIT license by 37signals,
9
+ # LLC, and is copyright (c) 2008 by the same. See the LICENSE file distributed
10
+ # with this file for the complete text of the license.
11
+ # ---------------------------------------------------------------------------
12
+ # Modified by New Leaders for capistrano-fast_remote_cache gem
13
+ #
14
+
15
+ # Magic path added to the load path by capistrano
16
+ require 'capistrano/recipes/deploy/strategy/remote_cache'
17
+
18
+ class Capistrano::Deploy::Strategy::FastRemoteCache < Capistrano::Deploy::Strategy::RemoteCache
19
+ def check!
20
+ super.check do |d|
21
+ d.remote.command(configuration.fetch(:ruby, "ruby"))
22
+ d.remote.directory(bin_path)
23
+ d.remote.file(File.join(bin_path, "copy.rb"))
24
+ end
25
+ end
26
+
27
+ def setup!
28
+ run "mkdir -p #{bin_path}"
29
+ upload(File.join(File.dirname(__FILE__), "utilities", "copy.rb"), File.join(bin_path, "copy.rb"))
30
+ end
31
+
32
+ def prepare!
33
+ update_repository_cache
34
+ end
35
+
36
+ private
37
+
38
+ def bin_path
39
+ @bin_path ||= File.join(configuration[:shared_path], "bin")
40
+ end
41
+
42
+ def copy_repository_cache
43
+ logger.trace "copying the cached version to #{configuration[:release_path]}"
44
+ ruby = configuration.fetch(:ruby, "ruby")
45
+ excludes = Array(configuration[:copy_exclude]).join(" ")
46
+ run "#{ruby} #{File.join(bin_path, 'copy.rb')} #{repository_cache} #{configuration[:release_path]} #{excludes} && #{mark}"
47
+ end
48
+ end
@@ -0,0 +1,53 @@
1
+ # ---------------------------------------------------------------------------
2
+ # A simple copy script for doing hard links and symbolic links instead of
3
+ # explicit copies. Some OS's will already have a utility to do this, but
4
+ # some won't; this file suffices in either case.
5
+ #
6
+ # Usage: ruby copy.rb <source> <target> <exclude> ...
7
+ #
8
+ # The <source> directory is recursively descended, and hard links to all of
9
+ # the files are created in corresponding locations under <target>. Symbolic
10
+ # links in <source> map to symbolic links in <target> that point to the same
11
+ # destination.
12
+ #
13
+ # All arguments after <target> are taken to be exclude patterns. Any file
14
+ # or directory in <source> that matches any of those patterns will be
15
+ # skipped, and will thus not be present in <target>.
16
+ # ---------------------------------------------------------------------------
17
+ # This file is distributed under the terms of the MIT license by 37signals,
18
+ # LLC, and is copyright (c) 2008 by the same. See the LICENSE file distributed
19
+ # with this file for the complete text of the license.
20
+ # ---------------------------------------------------------------------------
21
+ require 'fileutils'
22
+
23
+ from = ARGV.shift or abort "need source directory"
24
+ to = ARGV.shift or abort "need target directory"
25
+
26
+ exclude = ARGV
27
+
28
+ from = File.expand_path(from)
29
+ to = File.expand_path(to)
30
+
31
+ Dir.chdir(from) do
32
+ FileUtils.mkdir_p(to)
33
+ queue = Dir.glob("*", File::FNM_DOTMATCH)
34
+ while queue.any?
35
+ item = queue.shift
36
+ name = File.basename(item)
37
+
38
+ next if name == "." || name == ".."
39
+ next if exclude.any? { |pattern| File.fnmatch(pattern, item) }
40
+
41
+ source = File.join(from, item)
42
+ target = File.join(to, item)
43
+
44
+ if File.symlink?(item)
45
+ FileUtils.ln_s(File.readlink(source), target)
46
+ elsif File.directory?(item)
47
+ queue += Dir.glob("#{item}/*", File::FNM_DOTMATCH)
48
+ FileUtils.mkdir_p(target, :mode => File.stat(item).mode)
49
+ else
50
+ FileUtils.ln(source, target)
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,5 @@
1
+ module Capistrano
2
+ module FastRemoteCache
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-fast_remote_cache
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Don Morrison
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-11-21 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: capistrano
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 2.0.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 2.0.0
30
+ description: Gem version of the 37 Signals Capistrano Fast Remote Cache (fast_remote_cache)
31
+ Rails plugin
32
+ email:
33
+ - dmorrison@newleaders.com
34
+ executables: []
35
+ extensions: []
36
+ extra_rdoc_files: []
37
+ files:
38
+ - .gitignore
39
+ - .ruby-version
40
+ - Gemfile
41
+ - LICENSE
42
+ - README.md
43
+ - Rakefile
44
+ - capistrano-fast_remote_cache.gemspec
45
+ - lib/capistrano-fast_remote_cache.rb
46
+ - lib/capistrano/fast_remote_cache.rb
47
+ - lib/capistrano/fast_remote_cache/capistrano/recipes/deploy/strategy/fast_remote_cache.rb
48
+ - lib/capistrano/fast_remote_cache/capistrano/recipes/deploy/strategy/utilities/copy.rb
49
+ - lib/capistrano/fast_remote_cache/version.rb
50
+ homepage: ''
51
+ licenses: []
52
+ post_install_message:
53
+ rdoc_options: []
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ! '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ requirements: []
69
+ rubyforge_project:
70
+ rubygems_version: 1.8.24
71
+ signing_key:
72
+ specification_version: 3
73
+ summary: Gem version of the 37 Signals Capistrano Fast Remote Cache (fast_remote_cache)
74
+ Rails plugin
75
+ test_files: []