lux_assets 0.1.9 → 0.1.10

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
  SHA256:
3
- metadata.gz: 19e3444190ac43795cf9324c49254bb488bc0a0389183023fe26a74cd16bf4a1
4
- data.tar.gz: c3a57a2171d34b41ddae69ab0fc3222345818461bb6921d4886178e169c09b37
3
+ metadata.gz: 6e9d15d2c4bfdb7f1602ffd686cf450911f21a6ea4780ee785b70ef0b12c40f0
4
+ data.tar.gz: 549f988a12e302f0b670579e3cf3f4eb619a46a3e798292f7b2ae04049b38623
5
5
  SHA512:
6
- metadata.gz: a1e7bb7e258f08b3ac474394ab5bb31a94a0a5728c438b70085b4c4f874d1257f58922e0089e5b29f9936bce5fc7a15601233b032706ffc33aa77cd9fc25b97b
7
- data.tar.gz: ad79d073f0328fbb30d1d0d39ae67c5edd4c1c0388ea8043f35685dcb0dc77f586895eeab4bc5eb79ec3a8588220af223aa3b2e7e2d9837ca5da41140d2bf571
6
+ metadata.gz: e6fbc3503491dccccc6187399eb76483321e7f4be59d36d4419df23b7f9a366b901c5a869a3e87a3b26fae968f612fe14a6db9ec2e0dfe9d0d3229d281dcbc02
7
+ data.tar.gz: 2b82ca254793e3fb1e0bb3ecaa2d56981a07c744b7cf35548723c7523446ddc0a0e1266177d9bb06068c73517c63ab7462a07e0ba8f1f9777bcae1cd279d9a87
data/bin/lux_assets CHANGED
@@ -55,7 +55,7 @@ class AssetsCli < Thor
55
55
 
56
56
  desc :show, 'Show all files/data in manifest'
57
57
  def show
58
- ap LuxAssets.to_h
58
+ LuxAssets.examine
59
59
  end
60
60
 
61
61
  desc :compile, 'Compile assets for production'
@@ -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
 
@@ -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
@@ -8,13 +8,12 @@ module LuxAssets::Manifest
8
8
  def add name, path
9
9
  json = JSON.load MANIFEST.read
10
10
 
11
- return false if json['files'][name] == path
11
+ unless json['files'][name] == path
12
+ json['files'][name] = path
13
+ MANIFEST.write JSON.pretty_generate(json)
14
+ end
12
15
 
13
- json['files'][name] = path
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
@@ -25,7 +25,7 @@ namespace :assets do
25
25
 
26
26
  desc 'Show all files/data in manifest'
27
27
  task show: :env do
28
- ap LuxAssets.to_h
28
+ LuxAssets.examine
29
29
  end
30
30
 
31
31
  desc 'Upload assets to S3'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lux_assets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dino Reic