lux_assets 0.1.9 → 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/lux_assets +1 -1
- data/lib/lux_assets/asset.rb +1 -5
- data/lib/lux_assets/base.rb +29 -1
- data/lib/lux_assets/manifest.rb +5 -6
- data/lib/vendor/tasks.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e9d15d2c4bfdb7f1602ffd686cf450911f21a6ea4780ee785b70ef0b12c40f0
|
4
|
+
data.tar.gz: 549f988a12e302f0b670579e3cf3f4eb619a46a3e798292f7b2ae04049b38623
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6fbc3503491dccccc6187399eb76483321e7f4be59d36d4419df23b7f9a366b901c5a869a3e87a3b26fae968f612fe14a6db9ec2e0dfe9d0d3229d281dcbc02
|
7
|
+
data.tar.gz: 2b82ca254793e3fb1e0bb3ecaa2d56981a07c744b7cf35548723c7523446ddc0a0e1266177d9bb06068c73517c63ab7462a07e0ba8f1f9777bcae1cd279d9a87
|
data/bin/lux_assets
CHANGED
data/lib/lux_assets/asset.rb
CHANGED
@@ -48,13 +48,9 @@ class LuxAssets::Asset
|
|
48
48
|
@asset_file = '/assets/%s' % (@target.sub('/', '-') + '-' + Digest::SHA1.hexdigest(data) + '.' + @ext.to_s)
|
49
49
|
@asset_path = "./public#{@asset_file}"
|
50
50
|
|
51
|
-
File.write(@asset_path, data)
|
52
|
-
|
53
51
|
if LuxAssets::Manifest.add(@target, @asset_file)
|
52
|
+
File.write(@asset_path, data)
|
54
53
|
yield
|
55
|
-
|
56
|
-
LuxAssets.run 'touch -t 201001010101 %s' % @asset_path
|
57
|
-
LuxAssets.run 'gzip -k %s' % @asset_path
|
58
54
|
end
|
59
55
|
end
|
60
56
|
|
data/lib/lux_assets/base.rb
CHANGED
@@ -125,13 +125,23 @@ module LuxAssets
|
|
125
125
|
end
|
126
126
|
|
127
127
|
def compile_all
|
128
|
+
# generate master file for every resource
|
128
129
|
for ext in [:js, :css]
|
129
130
|
for name in to_h[ext].keys
|
130
131
|
path = LuxAssets.send(ext, name).compile
|
131
|
-
|
132
132
|
yield "#{ext}/#{name}", path if block_given?
|
133
133
|
end
|
134
134
|
end
|
135
|
+
|
136
|
+
# gzip if needed
|
137
|
+
files = Dir['./public/assets/*.css'] + Dir['./public/assets/*.js']
|
138
|
+
files.each do |file|
|
139
|
+
LuxAssets.run 'gzip -k %s' % file unless File.exist?('%s.gz' % file)
|
140
|
+
end
|
141
|
+
|
142
|
+
# touch all files reset timestamp
|
143
|
+
Dir['./public/assets/*']
|
144
|
+
.each { |file| system 'touch -t 201001010101 %s' % file }
|
135
145
|
end
|
136
146
|
|
137
147
|
def to_h
|
@@ -144,6 +154,24 @@ module LuxAssets
|
|
144
154
|
@assets
|
145
155
|
end
|
146
156
|
|
157
|
+
# show files and file sizes
|
158
|
+
def examine
|
159
|
+
data = to_h.dup
|
160
|
+
data.each do |ext, value_hash|
|
161
|
+
puts ext.to_s.upcase.green
|
162
|
+
value_hash.each do |key, files|
|
163
|
+
puts ' %s' % key.green
|
164
|
+
files.each_with_index do |file, i|
|
165
|
+
if File.exist?(file)
|
166
|
+
puts ' %s kb - %s' % [(File.size(file)/1024.to_f).round(1).to_s.rjust(6), file]
|
167
|
+
else
|
168
|
+
puts ' %s' % file
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
147
175
|
private
|
148
176
|
|
149
177
|
def add_local_files files
|
data/lib/lux_assets/manifest.rb
CHANGED
@@ -8,13 +8,12 @@ module LuxAssets::Manifest
|
|
8
8
|
def add name, path
|
9
9
|
json = JSON.load MANIFEST.read
|
10
10
|
|
11
|
-
|
11
|
+
unless json['files'][name] == path
|
12
|
+
json['files'][name] = path
|
13
|
+
MANIFEST.write JSON.pretty_generate(json)
|
14
|
+
end
|
12
15
|
|
13
|
-
|
14
|
-
|
15
|
-
MANIFEST.write JSON.pretty_generate(json)
|
16
|
-
|
17
|
-
true
|
16
|
+
!File.exist?('./public'+path)
|
18
17
|
end
|
19
18
|
|
20
19
|
def get name
|
data/lib/vendor/tasks.rb
CHANGED