capistrano-stretcher-rails 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ab908e9d7df8a2498c4d4b3128d7f461e6081ab5
4
- data.tar.gz: cdbbeb29175d88a6ebf7937189d77c3aba29373c
3
+ metadata.gz: f8c3a6ded406df00ec1ceedf13e6373b47a23549
4
+ data.tar.gz: 73d3694d8cafbdd2ec81d210f22e778ccf748f3f
5
5
  SHA512:
6
- metadata.gz: 3b1674f8d1d6376a5a099449790548d65795d239d73cccb224c2c2405c8a4e650859bfac13df36625d1464272b6cf112d5c6ad81620beda738313f817a31772e
7
- data.tar.gz: eb9c9e43b32ee23d8338f9d14272015bd5e7e72b84b229e01ea54e7d2ef84fcf8073f61849b82c264fc50c17d060f75f013c21919f280606e83d62dea86dd3e1
6
+ metadata.gz: c8434bdb90e5b603b79afb8ac8b5063e0df82aa76405b3ff3a56e43571f39db48058e7c2963247fe331975e715b24b59b70258fd3d6d3d71ae6711c55ab4f269
7
+ data.tar.gz: d83e0acd082bc21f66d7efb64111a582e89143be33334752e99a44564ad54bfe7d1276349050db3d4e9e378f950c15276b1e2e3c68e23bfde0bb39fea3cdbaef
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "capistrano-stretcher-rails"
7
- spec.version = "0.1.0"
7
+ spec.version = "0.2.0"
8
8
  spec.authors = ["SHIBATA Hiroshi", "Uchio Kondo"]
9
9
  spec.email = ["hsbt@ruby-lang.org", "udzura@udzura.jp"]
10
10
 
@@ -1,5 +1,11 @@
1
+ # Original source about assets precompile: https://github.com/capistrano-plugins/capistrano-faster-assets/blob/master/lib/capistrano/tasks/faster_assets.rake
2
+
1
3
  namespace :stretcher do
2
4
  set :exclude_dirs, fetch(:exclude_dirs) << "vendor/bundle" << "public/assets"
5
+ set :assets_dependencies, %w(app/assets lib/assets vendor/assets Gemfile.lock config/routes.rb)
6
+
7
+ class PrecompileRequired < StandardError;
8
+ end
3
9
 
4
10
  def local_bundle_path
5
11
  @_local_bundle_path ||= fetch(:local_bundle_path, "vendor/bundle")
@@ -17,16 +23,33 @@ namespace :stretcher do
17
23
  on application_builder_roles do
18
24
  within local_build_path do
19
25
  with rails_env: fetch(:rails_env) do
20
- execute :bundle, :exec, :rake, 'assets:precompile'
21
- end
22
- end
23
- end
24
- end
26
+ begin
27
+ checkout_dirs = capture(:ls, '-xr', local_checkout_path)
28
+ latest_path = "#{local_checkout_path}/#{checkout_dirs.split[0]}"
29
+ previous_path = "#{local_checkout_path}/#{checkout_dirs.split[1]}"
25
30
 
26
- task :cleanup_precompiled_assets do
27
- on application_builder_roles do
28
- within local_build_path do
29
- execute :rm, '-rf', "public/assets"
31
+ raise PrecompileRequired unless previous_path
32
+
33
+ execute :ls, "#{previous_path}/public/assets" rescue raise PrecompileRequired
34
+
35
+ fetch(:assets_dependencies).each do |dep|
36
+ latest = "#{latest_path}/#{dep}"
37
+ previous = "#{previous_path}/#{dep}"
38
+ next if [latest, previous].map{|d| test "[ -e #{d} ]"}.uniq == [false]
39
+
40
+ execute :diff, '-Nqr', latest, previous rescue raise PrecompileRequired
41
+ end
42
+
43
+ info('Skipping asset precompile, no asset diff found')
44
+
45
+ execute :cp, '-r', "#{previous_path}/public/assets", "#{latest_path}/public/"
46
+
47
+ rescue PrecompileRequired
48
+ execute :rm, '-rf', 'public/assets'
49
+ execute :bundle, :exec, :rake, 'assets:precompile'
50
+ execute :cp, '-r', 'public/assets', "#{latest_path}/public/"
51
+ end
52
+ end
30
53
  end
31
54
  end
32
55
  end
@@ -34,4 +57,3 @@ end
34
57
 
35
58
  after 'stretcher:checkout_local', 'stretcher:bundle'
36
59
  before 'stretcher:create_tarball', 'stretcher:asset_precompile'
37
- after 'stretcher:cleanup_dirs', 'stretcher:cleanup_precompiled_assets'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-stretcher-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - SHIBATA Hiroshi
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2015-12-10 00:00:00.000000000 Z
12
+ date: 2017-05-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: capistrano-stretcher
@@ -89,9 +89,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
89
  version: '0'
90
90
  requirements: []
91
91
  rubyforge_project:
92
- rubygems_version: 2.5.0
92
+ rubygems_version: 2.6.11
93
93
  signing_key:
94
94
  specification_version: 4
95
95
  summary: rails specific tasks for capistrano-stretcher
96
96
  test_files: []
97
- has_rdoc: