padrino-contrib 0.0.4 → 0.0.5
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.
Potentially problematic release.
This version of padrino-contrib might be problematic. Click here for more details.
- data/Rakefile +2 -0
- data/lib/padrino-contrib/helpers/assets_compressor.rb +11 -9
- data/lib/padrino-contrib/version.rb +1 -1
- metadata +4 -4
data/Rakefile
CHANGED
@@ -20,7 +20,8 @@ module Padrino
|
|
20
20
|
module AssetsCompressor
|
21
21
|
def self.registered(app)
|
22
22
|
raise "You need to add in your Gemfile: gem 'yui-compressor', :require => 'yui/compressor'" unless defined?(YUI)
|
23
|
-
app.helpers Padrino::Contrib::Helpers::AssetsCompressor::Helpers
|
23
|
+
app.helpers Padrino::Contrib::Helpers::AssetsCompressor::Helpers unless app.respond_to?(:compressor)
|
24
|
+
app.set :compressor, {}
|
24
25
|
end
|
25
26
|
|
26
27
|
module Helpers
|
@@ -38,16 +39,15 @@ module Padrino
|
|
38
39
|
end
|
39
40
|
|
40
41
|
def assets_compressor(kind, sources)
|
41
|
-
began_at = Time.now
|
42
|
-
asset_folder, compressor = *case kind
|
43
|
-
# 8000 for line break is more browser and texmate friendly
|
44
|
-
when :css then ['stylesheets', YUI::CssCompressor.new(:line_break => 8000)]
|
45
|
-
when :js then ['javascripts', YUI::JavaScriptCompressor.new(:line_break => 8000)]
|
46
|
-
else raise "YUI Compressor didn't support yet #{kind} compression"
|
47
|
-
end
|
48
42
|
options = sources.extract_options!.symbolize_keys
|
49
43
|
bundle = options.delete(:cache)
|
50
44
|
return sources if bundle.nil?
|
45
|
+
began_at = Time.now
|
46
|
+
asset_folder = case kind
|
47
|
+
when :css then 'stylesheets'
|
48
|
+
when :js then 'javascripts'
|
49
|
+
else raise "YUI Compressor didn't support yet #{kind} compression"
|
50
|
+
end
|
51
51
|
bundle = settings.app_name if bundle.is_a?(TrueClass)
|
52
52
|
path = Padrino.root("public", uri_root_path(asset_folder, bundle.to_s))
|
53
53
|
path += ".#{kind}" unless path =~ /\.#{kind}/
|
@@ -64,8 +64,10 @@ module Padrino
|
|
64
64
|
end
|
65
65
|
source
|
66
66
|
end
|
67
|
+
settings.compressor[:css] ||= YUI::CssCompressor.new(:line_break => 8000)
|
68
|
+
settings.compressor[:js] ||= YUI::JavaScriptCompressor.new(:line_break => 8000)
|
67
69
|
Dir.mkdir(File.dirname(path)) unless File.exist?(File.dirname(path))
|
68
|
-
File.open(path, "w") { |f| f.write(compressor.compress(sources.join("\n"))) }
|
70
|
+
File.open(path, "w") { |f| f.write(settings.compressor[kind].compress(sources.join("\n"))) }
|
69
71
|
logger.debug "Compressed (%0.2fms) %s" % [Time.now-began_at, path] if defined?(logger)
|
70
72
|
bundle
|
71
73
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: padrino-contrib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 5
|
10
|
+
version: 0.0.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Padrino Team
|
@@ -18,7 +18,7 @@ autorequire:
|
|
18
18
|
bindir: bin
|
19
19
|
cert_chain: []
|
20
20
|
|
21
|
-
date: 2011-04-
|
21
|
+
date: 2011-04-04 00:00:00 +02:00
|
22
22
|
default_executable:
|
23
23
|
dependencies: []
|
24
24
|
|