slight_assets 0.3.1 → 0.4.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.
- data/bin/slight +40 -0
- data/lib/slight_assets/settings.rb +13 -5
- metadata +8 -7
data/bin/slight
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "optparse"
|
4
|
+
|
5
|
+
options = {
|
6
|
+
:js_reducer => false,
|
7
|
+
:maximum_embedded_file_size => "32kb"
|
8
|
+
}
|
9
|
+
optparse = ARGV.options do |opt|
|
10
|
+
opt.banner = <<BANNER
|
11
|
+
Asset minifier.
|
12
|
+
Usage: #{File.basename __FILE__} [options] <asset-file-path>
|
13
|
+
BANNER
|
14
|
+
opt.on("-o", "--obfuscate-js", "Enables obfuscation for JS minification") do
|
15
|
+
options[:js_reducer] = true
|
16
|
+
end
|
17
|
+
opt.on("-s", "--size SIZE_IN_KBYTES", "Maximum embedded file size for CSS minification") do |size|
|
18
|
+
size = "#{size}kb" if size =~ /\A\d+\z/
|
19
|
+
options[:maximum_embedded_file_size] = size
|
20
|
+
end
|
21
|
+
opt.on_tail("-h", "--help", "Display this help") do
|
22
|
+
puts opt
|
23
|
+
exit 1
|
24
|
+
end
|
25
|
+
end
|
26
|
+
optparse.parse!
|
27
|
+
|
28
|
+
assetfile = ARGV.pop
|
29
|
+
|
30
|
+
if assetfile.nil? || assetfile !~ /(\.min)?\.(?:js|css)\z/ || $1 || ! File.exists?(assetfile)
|
31
|
+
puts optparse
|
32
|
+
exit 1
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
require "rubygems"
|
37
|
+
require "slight_assets"
|
38
|
+
|
39
|
+
SlightAssets::Cfg.load_config(options)
|
40
|
+
SlightAssets::Util.write_static_compressed_file(assetfile)
|
@@ -21,10 +21,18 @@ module SlightAssets
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def load_config(path)
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
if path.is_a?(Hash)
|
25
|
+
path.each_pair do |key, value|
|
26
|
+
k = key.to_s
|
27
|
+
v = value.nil? ? @config[k] : value
|
28
|
+
@config[k] = v if @config.has_key?(k)
|
29
|
+
end
|
30
|
+
else
|
31
|
+
return @config unless File.exists? path
|
32
|
+
hash = YAML.load_file(path)
|
33
|
+
hash = hash[::Rails.env] || hash if defined?(::Rails)
|
34
|
+
@config.merge! hash["slight_asset"] if hash.has_key?("slight_asset")
|
35
|
+
end
|
28
36
|
rescue TypeError => e
|
29
37
|
puts "could not load #{path}: #{e.inspect}"
|
30
38
|
end
|
@@ -37,7 +45,7 @@ module SlightAssets
|
|
37
45
|
elsif c =~ /\A(\d+)\s*(\w+)\z/
|
38
46
|
c = $1.to_i
|
39
47
|
case $2
|
40
|
-
when "kB", "kb"
|
48
|
+
when "kB", "kb", "k", "K"
|
41
49
|
c = c * 1_024
|
42
50
|
end
|
43
51
|
@maximum_embedded_file_size = [c, 32 * 1_024].min
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slight_assets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 4
|
9
|
+
- 0
|
10
|
+
version: 0.4.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Marcelo Manzan
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-07-
|
18
|
+
date: 2011-07-26 00:00:00 -03:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -95,8 +95,8 @@ dependencies:
|
|
95
95
|
description: Optimize the assets of your Rails application without change any line of code.
|
96
96
|
email:
|
97
97
|
- manzan@gmail.com
|
98
|
-
executables:
|
99
|
-
|
98
|
+
executables:
|
99
|
+
- slight
|
100
100
|
extensions: []
|
101
101
|
|
102
102
|
extra_rdoc_files: []
|
@@ -114,6 +114,7 @@ files:
|
|
114
114
|
- lib/slight_assets/version.rb
|
115
115
|
- templates/install/config/assets.yml
|
116
116
|
- templates/install/config/initializers/assets.rb
|
117
|
+
- bin/slight
|
117
118
|
has_rdoc: true
|
118
119
|
homepage: http://kawamanza.github.com/slight_assets
|
119
120
|
licenses: []
|