fingerjam 0.8.1 → 0.8.2

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.
@@ -127,26 +127,43 @@ module Fingerjam
127
127
 
128
128
  def symlink
129
129
  cached_paths.each_pair do |relative_path, cached_path|
130
- # Strip leading / from relative path to determine absolute path
131
- src_u_path = File.join(public_path, relative_path[1..relative_path.length])
132
- dst_u_path = File.join(public_path, cached_path[1..cached_path.length])
130
+ # Create relative symlink from RAILS_ROOT/public/cache/$MD5SUM.$EXT to original file
131
+ begin
132
+ # Strip leading / from relative path to determine absolute path
133
+ src_u_path = File.join(public_path, relative_path[1..relative_path.length])
134
+ dst_u_path = File.join(public_path, cached_path[1..cached_path.length])
133
135
 
134
- # Gzip version of asset
135
- src_c_path = File.join(public_path, (relative_path[1..relative_path.length] + ".gz"))
136
- dst_c_path = File.join(public_path, (cached_path[1..cached_path.length] + ".gz"))
136
+ # Create root directory
137
+ FileUtils.mkdir_p(File.dirname(dst_u_path))
137
138
 
138
- # Create root directory
139
- FileUtils.mkdir_p(File.dirname(dst_u_path))
139
+ old_path = ".." + relative_path
140
+ new_path = dst_u_path.to_s
140
141
 
141
- # Create relative symlink from RAILS_ROOT/public/cache/$MD5SUM.$EXT to original file
142
- begin
143
- File.symlink(".." + relative_path, dst_u_path.to_s) if !File.exists?(dst_u_path)
144
- rescue Errno::EEXIST
142
+ # puts "symlink #{old_path} to #{new_path}"
143
+
144
+ if !File.exists?(new_path) && File.exists?(src_u_path)
145
+ File.symlink(old_path, new_path)
146
+ end
147
+ rescue Errno::EEXIST => error
148
+ # puts error.message
145
149
  end
146
150
 
151
+ # Create relative symlink from RAILS_ROOT/public/cache/$MD5SUM.$EXT.gz to original file
147
152
  begin
148
- File.symlink(".." + relative_path + ".gz", dst_c_path.to_s) if !File.exists?(dst_c_path) && File.exists?(src_c_path)
149
- rescue Errno::EEXIST
153
+ # Gzip version of asset
154
+ src_c_path = File.join(public_path, (relative_path[1..relative_path.length] + ".gz"))
155
+ dst_c_path = File.join(public_path, (cached_path[1..cached_path.length] + ".gz"))
156
+
157
+ old_path = ".." + relative_path + ".gz"
158
+ new_path = dst_c_path.to_s
159
+
160
+ # puts "symlink #{old_path} to #{new_path}"
161
+
162
+ if !File.exists?(new_path) && File.exists?(src_c_path)
163
+ File.symlink(old_path, new_path)
164
+ end
165
+ rescue Errno::EEXIST => error
166
+ # puts error.message
150
167
  end
151
168
 
152
169
  cached_urls[relative_path] = generate_cached_url(relative_path)
@@ -154,7 +171,7 @@ module Fingerjam
154
171
  end
155
172
 
156
173
  def write_lockfile
157
- puts "writing lockfile #{lock_yml_path}"
174
+ # puts "writing lockfile #{lock_yml_path}"
158
175
 
159
176
  File.open(lock_yml_path, "w") do |lockfile|
160
177
  lockfile.puts cached_urls.to_yaml
@@ -22,6 +22,8 @@ module Capistrano
22
22
  raise Capistrano::Error, "shell command failed with return code #{$?}"
23
23
  end
24
24
 
25
+ setup_fingerjam
26
+
25
27
  logger.debug "copying cache to deployment staging area #{destination}"
26
28
  Dir.chdir(copy_cache) do
27
29
  FileUtils.mkdir_p(destination)
@@ -34,7 +36,12 @@ module Capistrano
34
36
  next if copy_exclude.any? { |pattern| File.fnmatch(pattern, item) }
35
37
 
36
38
  if File.symlink?(item)
37
- FileUtils.ln_s(File.readlink(File.join(copy_cache, item)), File.join(destination, item))
39
+ old_name = File.readlink(File.join(copy_cache, item))
40
+ new_name = File.join(destination, item)
41
+
42
+ if File.exists?(old_name)
43
+ FileUtils.ln_s(old_name, new_name)
44
+ end
38
45
  elsif File.directory?(item)
39
46
  queue += Dir.glob("#{item}/*", File::FNM_DOTMATCH)
40
47
  FileUtils.mkdir(File.join(destination, item))
@@ -46,7 +53,7 @@ module Capistrano
46
53
 
47
54
  File.open(File.join(destination, "REVISION"), "w") { |f| f.puts(revision) }
48
55
 
49
- fingerjam
56
+ process_fingerjam
50
57
 
51
58
  logger.trace "compressing #{destination} to #{filename}"
52
59
  Dir.chdir(copy_dir) { system(compress(File.basename(destination), File.basename(filename)).join(" ")) }
@@ -58,14 +65,16 @@ module Capistrano
58
65
  FileUtils.rm_rf destination rescue nil
59
66
  end
60
67
 
61
- def fingerjam
62
- logger.trace "packaging assets with fingerjam for #{cache_host} to #{destination}"
63
-
68
+ def setup_fingerjam
64
69
  ::Fingerjam::Base.configure(
65
70
  :host => cache_host,
66
71
  :protocol => cache_protocol,
67
72
  :root_path => destination
68
73
  )
74
+ end
75
+
76
+ def process_fingerjam
77
+ logger.trace "packaging assets with fingerjam for #{cache_host} to #{destination}"
69
78
 
70
79
  ::Fingerjam::Base.package_and_lock!
71
80
  end
@@ -73,4 +82,4 @@ module Capistrano
73
82
  end
74
83
  end
75
84
  end
76
- end
85
+ end
@@ -1,3 +1,3 @@
1
1
  module Fingerjam
2
- VERSION = "0.8.1"
3
- end
2
+ VERSION = "0.8.2"
3
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fingerjam
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-26 00:00:00.000000000Z
12
+ date: 2012-02-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &70302259244820 !ruby/object:Gem::Requirement
16
+ requirement: &70363221433020 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '3.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70302259244820
24
+ version_requirements: *70363221433020
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: capistrano
27
- requirement: &70302259244320 !ruby/object:Gem::Requirement
27
+ requirement: &70363221432500 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '2.6'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70302259244320
35
+ version_requirements: *70363221432500
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: jammit
38
- requirement: &70302243759420 !ruby/object:Gem::Requirement
38
+ requirement: &70363221432000 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0.6'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70302243759420
46
+ version_requirements: *70363221432000
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: activesupport
49
- requirement: &70302243758960 !ruby/object:Gem::Requirement
49
+ requirement: &70363221431420 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '3.0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70302243758960
57
+ version_requirements: *70363221431420
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: actionpack
60
- requirement: &70302243758500 !ruby/object:Gem::Requirement
60
+ requirement: &70363221430880 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '3.0'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70302243758500
68
+ version_requirements: *70363221430880
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: yui-compressor
71
- requirement: &70302243758040 !ruby/object:Gem::Requirement
71
+ requirement: &70363221430160 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0.9'
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *70302243758040
79
+ version_requirements: *70363221430160
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: rspec
82
- requirement: &70302243757580 !ruby/object:Gem::Requirement
82
+ requirement: &70363221429240 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ~>
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '2.5'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70302243757580
90
+ version_requirements: *70363221429240
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: bundler
93
- requirement: &70302243757120 !ruby/object:Gem::Requirement
93
+ requirement: &70363221428780 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ~>
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '1.0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *70302243757120
101
+ version_requirements: *70363221428780
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: rcov
104
- requirement: &70302243756660 !ruby/object:Gem::Requirement
104
+ requirement: &70363221428260 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,7 +109,7 @@ dependencies:
109
109
  version: '0'
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *70302243756660
112
+ version_requirements: *70363221428260
113
113
  description: Fingerjam uploads your Jammit-compressed assets with fingerprinted filenames
114
114
  so they can be cached indefinitely
115
115
  email: