rack-less 3.0.1 → 3.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +6 -3
- data/lib/rack/less/request.rb +0 -2
- data/lib/rack/less/source.rb +3 -5
- data/lib/rack/less/version.rb +1 -1
- data/test/source_test.rb +10 -0
- metadata +4 -4
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rack-less (3.0.
|
4
|
+
rack-less (3.0.2)
|
5
5
|
less (~> 2.0)
|
6
6
|
rack (~> 1.0)
|
7
7
|
|
@@ -18,9 +18,12 @@ GEM
|
|
18
18
|
assert-view (0.4.2)
|
19
19
|
ansi (~> 1.3)
|
20
20
|
undies (~> 1.1)
|
21
|
+
commonjs (0.2.0)
|
22
|
+
therubyracer (~> 0.9.9)
|
21
23
|
differ (0.1.2)
|
22
|
-
less (2.0.
|
23
|
-
|
24
|
+
less (2.0.8)
|
25
|
+
commonjs (~> 0.2.0)
|
26
|
+
therubyracer (~> 0.9.9)
|
24
27
|
libv8 (3.3.10.4)
|
25
28
|
nokogiri (1.5.0)
|
26
29
|
open4 (1.1.0)
|
data/lib/rack/less/request.rb
CHANGED
@@ -90,13 +90,11 @@ module Rack::Less
|
|
90
90
|
# Determine if the request is for a non-cached existing LESS CSS source file
|
91
91
|
# This will be called on every request so speed is an issue
|
92
92
|
# => first check if the request is a GET on a css resource in :hosted_at (fast)
|
93
|
-
# => don't process if a file has already been cached
|
94
93
|
# => otherwise, check for less source files that match the request (slow)
|
95
94
|
def for_less?
|
96
95
|
get? && # GET on css resource in :hosted_at (fast, check first)
|
97
96
|
for_css? &&
|
98
97
|
hosted_at? &&
|
99
|
-
!cached? && # resource not cached (little slower)
|
100
98
|
!source.files.empty? # there is source for the resource (slow, check last)
|
101
99
|
end
|
102
100
|
|
data/lib/rack/less/source.rb
CHANGED
@@ -53,7 +53,7 @@ module Rack::Less
|
|
53
53
|
:filename => File.basename(file_path)
|
54
54
|
}
|
55
55
|
less = File.send(File.respond_to?(:binread) ? :binread : :read, file_path.to_s)
|
56
|
-
Less::Parser.new(opts).parse(less).to_css(:compress =>
|
56
|
+
Less::Parser.new(opts).parse(less).to_css(:compress => compress?)
|
57
57
|
end.join("\n")
|
58
58
|
|
59
59
|
compiled_css = case @compress
|
@@ -69,11 +69,9 @@ module Rack::Less
|
|
69
69
|
compiled_css
|
70
70
|
end
|
71
71
|
|
72
|
-
if cache? &&
|
72
|
+
if cache? && (cf = File.join(@cache, "#{@css_resource}.css"))
|
73
73
|
FileUtils.mkdir_p(File.dirname(cf))
|
74
|
-
File.open(cf, "w")
|
75
|
-
file.write(compiled_css)
|
76
|
-
end
|
74
|
+
File.open(cf, "w") { |file| file.write(compiled_css) }
|
77
75
|
end
|
78
76
|
|
79
77
|
compiled_css
|
data/lib/rack/less/version.rb
CHANGED
data/test/source_test.rb
CHANGED
@@ -138,6 +138,15 @@ module Rack::Less
|
|
138
138
|
:cache => @cache
|
139
139
|
}).to_css
|
140
140
|
@cached_file = File.join(@cache, "normal.css")
|
141
|
+
@cached_file_time = File.mtime(@cached_file)
|
142
|
+
# shall wait some time to get a new mtime - sorry for letting you wait
|
143
|
+
sleep 2
|
144
|
+
|
145
|
+
Rack::Less::Source.new('normal', {
|
146
|
+
:folder => @source_folder,
|
147
|
+
:cache => @cache
|
148
|
+
}).to_css
|
149
|
+
@updated_cached_file_time = File.mtime(@cached_file)
|
141
150
|
end
|
142
151
|
teardown do
|
143
152
|
if File.exists?(File.dirname(@cache))
|
@@ -149,6 +158,7 @@ module Rack::Less
|
|
149
158
|
assert File.exists?(@cache), 'the cache folder does not exist'
|
150
159
|
assert File.exists?(@cached_file), 'the css was not cached to a file'
|
151
160
|
assert_equal @expected.strip, File.read(@cached_file).strip, "the compiled css is incorrect"
|
161
|
+
assert @cached_file_time < @updated_cached_file_time, 'the cached file was not updated ' + @cached_file_time.to_s + ' >= ' + @updated_cached_file_time.to_s
|
152
162
|
end
|
153
163
|
end
|
154
164
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-less
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 3
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 3
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 3.0.
|
9
|
+
- 2
|
10
|
+
version: 3.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Kelly Redding
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-12-10 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
type: :development
|