rack-less 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -48,31 +48,31 @@ You should now see `Rack::Less` listed in the middleware pipeline:
48
48
  rake middleware
49
49
 
50
50
  == Available Options
51
- key: name [default]: description
52
51
 
53
- * *root* ["."]:
54
- the app root. the reference point for the source and public options.
52
+ * :*root* ["."]
53
+ - The app root. The reference point for the source and public options.
55
54
 
56
- * *source* ['app/stylesheets']:
57
- the path (relative to the root) where LESS source files are located
55
+ * :*source* ['app/stylesheets']
56
+ - The path (relative to the root) where LESS source files are located
58
57
 
59
- * *public* ['public']:
60
- the path (relative to the root) static files are located
58
+ * :*public* ['public']
59
+ - The path where static files are located
61
60
 
62
- * *hosted_at* ['/stylesheets']:
63
- the public HTTP path for hosted stylesheets
61
+ * :*hosted_at* ['/stylesheets']
62
+ - The public HTTP path for hosted stylesheets.
64
63
 
65
64
  == Available Configurations
66
- key: name [default]: description
67
65
 
68
- * *cache* [false]:
69
- whether to cache the compilation output to a corresponding static file
66
+ * .*cache* [false]
67
+ - Whether to cache the compilation output to a corresponding static file
70
68
 
71
- * *compress* [false]:
72
- whether to remove extraneous whitespace from compilation output
69
+ * .*compress* [false]
70
+ - Whether or not to apply compression to the concatenation output
71
+ - :*yui* - use YUI Compressor (gem install yui-compressor)
72
+ - :*whitespace* - remove extraneous whitespace only.
73
73
 
74
- * *combinations* [{}]:
75
- directives for combining the output of many stylesheets and serving them as a single resource
74
+ * .*combinations* [{}]
75
+ - Directives for combining the output of many stylesheets and serving them as a single resource.
76
76
 
77
77
  === Combinations
78
78
 
@@ -112,9 +112,11 @@ then the same stylesheet link tags behave like they have the :cache option set,
112
112
 
113
113
  == Links
114
114
 
115
- GitHub: http://github.com/kelredd/rack-less
115
+ * *GitHub*
116
+ - http://github.com/kelredd/rack-less
116
117
 
117
- Less: http://lesscss.org
118
+ * *Less* *CSS*
119
+ - http://lesscss.org
118
120
 
119
121
  == License
120
122
 
@@ -33,7 +33,6 @@ module Rack::Less
33
33
  def call!(env)
34
34
  @default_options.each { |k,v| env[k] ||= v }
35
35
  @env = env
36
- # TODO: get this going
37
36
 
38
37
  if (@request = Request.new(@env.dup.freeze)).for_less?
39
38
  Response.new(@env.dup.freeze, @request.source.to_css).to_rack
@@ -13,7 +13,6 @@ module Rack::Less
13
13
  class Request < Rack::Request
14
14
  include Rack::Less::Options
15
15
 
16
- CSS_PATH_REGEX = /\A.*\/(\w+)\.(\w+)\Z/
17
16
  CSS_PATH_FORMATS = ['.css']
18
17
 
19
18
  # The HTTP request method. This is the standard implementation of this
@@ -1,5 +1,11 @@
1
1
  require 'less'
2
- require 'rack/less'
2
+
3
+ begin
4
+ require "yui/compressor"
5
+ rescue LoadError
6
+ # only error about missing yui compressor if
7
+ # :yui compression is requested
8
+ end
3
9
 
4
10
  module Rack::Less
5
11
 
@@ -13,6 +19,8 @@ module Rack::Less
13
19
  # but also accept files with the .css extension
14
20
  PREFERRED_EXTENSIONS = [:less, :css]
15
21
 
22
+ YUI_OPTS = {}
23
+
16
24
  attr_reader :css_name
17
25
 
18
26
  def initialize(css_name, options={})
@@ -43,7 +51,19 @@ module Rack::Less
43
51
  Less::Engine.new(File.new(file_path)).to_css
44
52
  end.join("\n")
45
53
 
46
- compiled_css.delete!("\n") if compress?
54
+ compiled_css = case @compress
55
+ when :whitespace, true
56
+ compiled_css.delete("\n")
57
+ when :yui
58
+ if defined?(YUI::CssCompressor)
59
+ YUI::CssCompressor.new(YUI_OPTS).compress(compiled_css)
60
+ else
61
+ raise LoadError, "YUI::CssCompressor is not available. Install it with: gem install yui-compressor"
62
+ end
63
+ else
64
+ compiled_css
65
+ end
66
+
47
67
  if cache? && !File.exists?(cf = File.join(@cache, "#{@css_name}.css"))
48
68
  FileUtils.mkdir_p(@cache)
49
69
  File.open(cf, "w") do |file|
@@ -2,8 +2,8 @@ module RackLess
2
2
  module Version
3
3
 
4
4
  MAJOR = 1
5
- MINOR = 1
6
- TINY = 1
5
+ MINOR = 2
6
+ TINY = 0
7
7
 
8
8
  def self.to_s # :nodoc:
9
9
  [MAJOR, MINOR, TINY].join('.')
data/lib/rack/less.rb CHANGED
@@ -48,7 +48,6 @@ module Rack::Less
48
48
 
49
49
  # Create a new Rack::Less middleware component
50
50
  # => the +options+ Hash can be used to specify default configuration values
51
- # => a block can given as an alternate method for setting option values (see example above)
52
51
  # => (see Rack::Less::Options for possible key/values)
53
52
  def self.new(app, options={}, &block)
54
53
  Base.new(app, options, &block)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-less
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kelly Redding
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-02-09 00:00:00 -06:00
12
+ date: 2010-02-14 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency