capistrano-local-precompile 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +2 -0
- data/capistrano-local-precompile.gemspec +8 -4
- data/lib/capistrano-local-precompile/version.rb +1 -1
- data/lib/capistrano/local_precompile.rb +7 -3
- data/spec/configuration_spec.rb +7 -2
- data/spec/integration_spec.rb +12 -5
- metadata +15 -30
- data/.gemtest +0 -0
- data/.gitignore +0 -40
- data/.rspec +0 -3
- data/.travis.yml +0 -8
- data/Gemfile +0 -17
- data/Guardfile +0 -6
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: bb00e3f26e972e7a92b1748a756d8fa961ceee88
|
4
|
+
data.tar.gz: 68ef492a99d2ec000658da3f5a288a200c5a0a5a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 888b8745174aeceea149dc1378b2210f1985fb627e90f626e36bb2dfb5276cef6f8ed2fa03ac9c273e279427b96151828df4cd4b645930ecd330b228da10eee8
|
7
|
+
data.tar.gz: f6ed52b5d61f3835d0fc1468dd13d1b9a448e190302d60c515f880b7ffeec4cf26ec5a0f3f7496c802c67a16253b0fab6dd2b12d9bcfd5a8b5fe7ac673d78c44
|
data/README.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
If your Rails apps are anything like mine, one of the slowest parts of your deployment is waiting for asset pipeline precompilation. It's sometimes so slow, it's painful. So I went searching for some solutions. [turbo-sprockets](https://github.com/ndbroadbent/turbo-sprockets-rails3) helped, but it's not a silver bullet. This gem isn't a silver bullet either, but it can help. Capistrano Local Precompile takes a different approach. It builds your assets locally and rsync's them to your web server(s).
|
4
4
|
|
5
|
+
*Note: This gem is not yet compatible with Capistrano 3.*
|
6
|
+
|
5
7
|
## Usage
|
6
8
|
|
7
9
|
Add capistrano-local-precompile to your Gemfile:
|
@@ -13,11 +13,15 @@ Gem::Specification.new do |gem|
|
|
13
13
|
gem.description = 'Local asset-pipeline precompilation for Capstrano'
|
14
14
|
gem.summary = gem.description
|
15
15
|
|
16
|
-
gem.
|
16
|
+
gem.license = 'MIT'
|
17
17
|
|
18
|
-
gem.
|
19
|
-
|
20
|
-
gem.
|
18
|
+
gem.add_dependency 'capistrano', '~> 2'
|
19
|
+
|
20
|
+
gem.files = %w(.yardopts LICENSE.md README.md Rakefile capistrano-local-precompile.gemspec)
|
21
|
+
gem.files += Dir.glob("lib/**/*.rb")
|
22
|
+
gem.files += Dir.glob("spec/**/*")
|
23
|
+
|
24
|
+
gem.test_files = Dir.glob("spec/**/*")
|
21
25
|
|
22
26
|
gem.require_paths = ['lib']
|
23
27
|
end
|
@@ -6,8 +6,8 @@ module Capistrano
|
|
6
6
|
def self.load_into(configuration)
|
7
7
|
configuration.load do
|
8
8
|
|
9
|
-
set(:precompile_cmd) { "#{
|
10
|
-
set(:cleanexpired_cmd) { "#{
|
9
|
+
set(:precompile_cmd) { "RAILS_ENV=#{rails_env.to_s.shellescape} #{asset_env} #{rake} assets:precompile" }
|
10
|
+
set(:cleanexpired_cmd) { "RAILS_ENV=#{rails_env.to_s.shellescape} #{asset_env} #{rake} assets:clean_expired" }
|
11
11
|
set(:assets_dir) { "public/assets" }
|
12
12
|
|
13
13
|
set(:turbosprockets_enabled) { false }
|
@@ -39,12 +39,16 @@ module Capistrano
|
|
39
39
|
|
40
40
|
desc "Precompile assets locally and then rsync to app servers"
|
41
41
|
task :precompile, :only => { :primary => true }, :on_no_matching_servers => :continue do
|
42
|
+
|
43
|
+
local_manifest_path = run_locally "ls #{assets_dir}/manifest*"
|
44
|
+
local_manifest_path.strip!
|
45
|
+
|
42
46
|
servers = find_servers :roles => assets_role, :except => { :no_release => true }
|
43
47
|
servers.each do |srvr|
|
44
48
|
run_locally "#{fetch(:rsync_cmd)} ./#{fetch(:assets_dir)}/ #{user}@#{srvr}:#{release_path}/#{fetch(:assets_dir)}/"
|
49
|
+
run_locally "#{fetch(:rsync_cmd)} ./#{local_manifest_path} #{user}@#{srvr}:#{release_path}/assets_manifest#{File.extname(local_manifest_path)}"
|
45
50
|
end
|
46
51
|
end
|
47
|
-
|
48
52
|
end
|
49
53
|
end
|
50
54
|
end
|
data/spec/configuration_spec.rb
CHANGED
@@ -3,16 +3,21 @@ require 'spec_helper'
|
|
3
3
|
describe Capistrano::LocalPrecompile, "configuration" do
|
4
4
|
before do
|
5
5
|
@configuration = Capistrano::Configuration.new
|
6
|
+
@configuration.load do
|
7
|
+
def rails_env; 'production'; end
|
8
|
+
def rake; 'rake'; end
|
9
|
+
def asset_env; "RAILS_GROUPS=assets"; end
|
10
|
+
end
|
6
11
|
Capistrano::LocalPrecompile.load_into(@configuration)
|
7
12
|
end
|
8
13
|
|
9
14
|
it "defines precompile_cmd" do
|
10
|
-
cmd = '
|
15
|
+
cmd = 'RAILS_ENV=production RAILS_GROUPS=assets rake assets:precompile'
|
11
16
|
expect(@configuration.fetch(:precompile_cmd)).to eq(cmd)
|
12
17
|
end
|
13
18
|
|
14
19
|
it "defines cleanexpired_cmd" do
|
15
|
-
cmd = '
|
20
|
+
cmd = 'RAILS_ENV=production RAILS_GROUPS=assets rake assets:clean_expired'
|
16
21
|
expect(@configuration.fetch(:cleanexpired_cmd)).to eq(cmd)
|
17
22
|
end
|
18
23
|
|
data/spec/integration_spec.rb
CHANGED
@@ -3,6 +3,11 @@ require 'spec_helper'
|
|
3
3
|
describe Capistrano::LocalPrecompile, "integration" do
|
4
4
|
before do
|
5
5
|
@configuration = Capistrano::Configuration.new
|
6
|
+
@configuration.load do
|
7
|
+
def rails_env; 'production'; end
|
8
|
+
def rake; 'rake'; end
|
9
|
+
def asset_env; "RAILS_GROUPS=assets"; end
|
10
|
+
end
|
6
11
|
Capistrano::LocalPrecompile.load_into(@configuration)
|
7
12
|
end
|
8
13
|
|
@@ -18,7 +23,7 @@ describe Capistrano::LocalPrecompile, "integration" do
|
|
18
23
|
describe 'prepare task' do
|
19
24
|
it 'invokes the precompile command' do
|
20
25
|
expect(@configuration).to receive(:run_locally).
|
21
|
-
with('
|
26
|
+
with('RAILS_ENV=production RAILS_GROUPS=assets rake assets:precompile').once
|
22
27
|
|
23
28
|
@configuration.find_and_execute_task('deploy:assets:prepare')
|
24
29
|
end
|
@@ -29,7 +34,9 @@ describe Capistrano::LocalPrecompile, "integration" do
|
|
29
34
|
|
30
35
|
before do
|
31
36
|
allow(@configuration).to receive(:run_locally).
|
32
|
-
with(
|
37
|
+
with("ls public/assets/manifest*").and_return("public/assets/manifest.yml").once
|
38
|
+
allow(@configuration).to receive(:run_locally).
|
39
|
+
with('RAILS_ENV=production RAILS_GROUPS=assets rake assets:precompile').once
|
33
40
|
allow(@configuration).to receive(:run_locally).
|
34
41
|
with('rm -rf public/assets').once
|
35
42
|
|
@@ -41,7 +48,7 @@ describe Capistrano::LocalPrecompile, "integration" do
|
|
41
48
|
end
|
42
49
|
|
43
50
|
it 'rsyncs the local asset files to the server' do
|
44
|
-
expect(@configuration).to receive(:run_locally).with(/rsync -av/).
|
51
|
+
expect(@configuration).to receive(:run_locally).with(/rsync -av/).exactly(4).times
|
45
52
|
|
46
53
|
@configuration.find_and_execute_task('deploy:assets:precompile')
|
47
54
|
end
|
@@ -68,9 +75,9 @@ describe Capistrano::LocalPrecompile, "integration" do
|
|
68
75
|
expect(@configuration).to receive(:run_locally).
|
69
76
|
with('mv public/.assets public/assets').once
|
70
77
|
expect(@configuration).to receive(:run_locally).
|
71
|
-
with('
|
78
|
+
with('RAILS_ENV=production RAILS_GROUPS=assets rake assets:clean_expired').once
|
72
79
|
expect(@configuration).to receive(:run_locally).
|
73
|
-
with('
|
80
|
+
with('RAILS_ENV=production RAILS_GROUPS=assets rake assets:precompile').once
|
74
81
|
|
75
82
|
@configuration.find_and_execute_task('deploy:assets:prepare')
|
76
83
|
end
|
metadata
CHANGED
@@ -1,84 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-local-precompile
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.3
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Steve Agalloco
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-03-07 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: capistrano
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
19
|
+
version: '2'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
26
|
+
version: '2'
|
30
27
|
description: Local asset-pipeline precompilation for Capstrano
|
31
28
|
email: steve.agalloco@gmail.com
|
32
29
|
executables: []
|
33
30
|
extensions: []
|
34
31
|
extra_rdoc_files: []
|
35
32
|
files:
|
36
|
-
- .gemtest
|
37
|
-
- .gitignore
|
38
|
-
- .rspec
|
39
|
-
- .travis.yml
|
40
33
|
- .yardopts
|
41
|
-
- Gemfile
|
42
|
-
- Guardfile
|
43
34
|
- LICENSE.md
|
44
35
|
- README.md
|
45
36
|
- Rakefile
|
46
37
|
- capistrano-local-precompile.gemspec
|
47
|
-
- lib/capistrano-local-precompile.rb
|
48
|
-
- lib/capistrano-local-precompile/version.rb
|
49
38
|
- lib/capistrano/local_precompile.rb
|
39
|
+
- lib/capistrano-local-precompile/version.rb
|
40
|
+
- lib/capistrano-local-precompile.rb
|
50
41
|
- spec/configuration_spec.rb
|
51
42
|
- spec/integration_spec.rb
|
52
43
|
- spec/spec_helper.rb
|
53
44
|
homepage: https://github.com/spagalloco/capistrano-local-precompile
|
54
|
-
licenses:
|
45
|
+
licenses:
|
46
|
+
- MIT
|
47
|
+
metadata: {}
|
55
48
|
post_install_message:
|
56
49
|
rdoc_options: []
|
57
50
|
require_paths:
|
58
51
|
- lib
|
59
52
|
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
-
none: false
|
61
53
|
requirements:
|
62
|
-
- -
|
54
|
+
- - '>='
|
63
55
|
- !ruby/object:Gem::Version
|
64
56
|
version: '0'
|
65
|
-
segments:
|
66
|
-
- 0
|
67
|
-
hash: -4036955457369989334
|
68
57
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
-
none: false
|
70
58
|
requirements:
|
71
|
-
- -
|
59
|
+
- - '>='
|
72
60
|
- !ruby/object:Gem::Version
|
73
61
|
version: '0'
|
74
|
-
segments:
|
75
|
-
- 0
|
76
|
-
hash: -4036955457369989334
|
77
62
|
requirements: []
|
78
63
|
rubyforge_project:
|
79
|
-
rubygems_version:
|
64
|
+
rubygems_version: 2.0.14
|
80
65
|
signing_key:
|
81
|
-
specification_version:
|
66
|
+
specification_version: 4
|
82
67
|
summary: Local asset-pipeline precompilation for Capstrano
|
83
68
|
test_files:
|
84
69
|
- spec/configuration_spec.rb
|
data/.gemtest
DELETED
File without changes
|
data/.gitignore
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
*.gem
|
2
|
-
*.rbc
|
3
|
-
*.sw[a-p]
|
4
|
-
*.tmproj
|
5
|
-
*.tmproject
|
6
|
-
*.un~
|
7
|
-
*~
|
8
|
-
.DS_Store
|
9
|
-
.Spotlight-V100
|
10
|
-
.Trashes
|
11
|
-
._*
|
12
|
-
.bundle
|
13
|
-
.config
|
14
|
-
.directory
|
15
|
-
.elc
|
16
|
-
.emacs.desktop
|
17
|
-
.emacs.desktop.lock
|
18
|
-
.redcar
|
19
|
-
.yardoc
|
20
|
-
Desktop.ini
|
21
|
-
Gemfile.lock
|
22
|
-
Icon?
|
23
|
-
InstalledFiles
|
24
|
-
Session.vim
|
25
|
-
Thumbs.db
|
26
|
-
\#*\#
|
27
|
-
_yardoc
|
28
|
-
auto-save-list
|
29
|
-
coverage
|
30
|
-
doc
|
31
|
-
lib/bundler/man
|
32
|
-
pkg
|
33
|
-
pkg/*
|
34
|
-
rdoc
|
35
|
-
spec/reports
|
36
|
-
test/tmp
|
37
|
-
test/version_tmp
|
38
|
-
tmp
|
39
|
-
tmtags
|
40
|
-
tramp
|
data/.rspec
DELETED
data/.travis.yml
DELETED
data/Gemfile
DELETED