less-rails 2.1.5 → 2.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +2 -0
- data/CHANGELOG.md +6 -1
- data/lib/less/rails/import_processor.rb +9 -3
- data/lib/less/rails/version.rb +1 -1
- data/test/cases/basics_spec.rb +29 -11
- data/test/dummy_app/app/assets/stylesheets/basics.css.less +1 -2
- data/test/dummy_app/app/assets/stylesheets/frameworks/bootstrap/mixins.less +6 -0
- data/test/dummy_app/app/assets/stylesheets/frameworks/bootstrap/variables.less +4 -0
- metadata +7 -6
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -7,15 +7,21 @@ module Less
|
|
7
7
|
def prepare
|
8
8
|
end
|
9
9
|
|
10
|
-
def evaluate(
|
10
|
+
def evaluate(scope, locals, &block)
|
11
|
+
depend_on scope, data
|
12
|
+
data
|
13
|
+
end
|
14
|
+
|
15
|
+
def depend_on(scope, data)
|
11
16
|
import_paths = data.scan(IMPORT_SCANNER).flatten.compact.uniq
|
12
17
|
import_paths.each do |path|
|
13
18
|
pathname = begin
|
14
|
-
|
19
|
+
scope.resolve(path)
|
15
20
|
rescue Sprockets::FileNotFound
|
16
21
|
nil
|
17
22
|
end
|
18
|
-
|
23
|
+
scope.depend_on(path) if pathname && pathname.to_s.ends_with?('.less')
|
24
|
+
depend_on scope, File.read(pathname) if pathname
|
19
25
|
end
|
20
26
|
data
|
21
27
|
end
|
data/lib/less/rails/version.rb
CHANGED
data/test/cases/basics_spec.rb
CHANGED
@@ -13,14 +13,27 @@ class BasicsSpec < Less::Rails::Spec
|
|
13
13
|
it 'must be able to use vendored less files' do
|
14
14
|
basics.must_match %r{#test-vendored\{border-radius:10px;\}}
|
15
15
|
end
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
16
|
+
|
17
|
+
describe 'less import dependency hooks' do
|
18
|
+
|
19
|
+
it 'must update when imported file changes' do
|
20
|
+
basics.must_match %r{#test-radiused\{border-radius:5px;\}}, 'default is 5px'
|
21
|
+
safely_edit(:mixins) do |data, asset|
|
22
|
+
data.gsub! '5px', '10px'
|
23
|
+
File.open(asset.pathname,'w') { |f| f.write(data) }
|
24
|
+
basics.must_match %r{#test-radiused\{border-radius:10px;\}}, 'mixins.less should be a sprockets context dependency'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'must update when an imported file of another imported file changes' do
|
29
|
+
basics.must_match %r{#test-variable-colored\{color:#424242;\}}, 'default is #424242'
|
30
|
+
safely_edit(:variables) do |data, asset|
|
31
|
+
data.gsub! '424242', '666666'
|
32
|
+
File.open(asset.pathname,'w') { |f| f.write(data) }
|
33
|
+
basics.must_match %r{#test-variable-colored\{color:#666666;\}}, 'variables.less should be a sprockets context dependency'
|
34
|
+
end
|
23
35
|
end
|
36
|
+
|
24
37
|
end
|
25
38
|
|
26
39
|
protected
|
@@ -33,12 +46,17 @@ class BasicsSpec < Less::Rails::Spec
|
|
33
46
|
dummy_assets['frameworks/bootstrap/mixins.less']
|
34
47
|
end
|
35
48
|
|
36
|
-
def
|
37
|
-
|
49
|
+
def variables_asset
|
50
|
+
dummy_assets['frameworks/bootstrap/variables.less']
|
51
|
+
end
|
52
|
+
|
53
|
+
def safely_edit(name)
|
54
|
+
asset = send :"#{name}_asset"
|
55
|
+
data = File.read(asset.pathname)
|
38
56
|
begin
|
39
|
-
yield data.dup
|
57
|
+
yield data.dup, asset
|
40
58
|
ensure
|
41
|
-
File.open(
|
59
|
+
File.open(asset.pathname,'w') { |f| f.write(data) }
|
42
60
|
end
|
43
61
|
end
|
44
62
|
end
|
@@ -1,17 +1,16 @@
|
|
1
1
|
|
2
2
|
// Variables
|
3
|
-
|
4
3
|
@color: #4D926F;
|
5
4
|
#test-variable { color: @color; }
|
6
5
|
|
7
6
|
// Mixins
|
8
|
-
|
9
7
|
.bordered { border: 1px solid black; }
|
10
8
|
#test-mixin span { .bordered; }
|
11
9
|
|
12
10
|
// Frameworks
|
13
11
|
@import "frameworks/bootstrap/mixins";
|
14
12
|
#test-radiused { .radiused; }
|
13
|
+
#test-variable-colored { .variableColored; }
|
15
14
|
|
16
15
|
// Vendored
|
17
16
|
@import "vendored";
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: less-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 7
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 2.1.
|
9
|
+
- 6
|
10
|
+
version: 2.1.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Ken Collins
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-02-16 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: less
|
@@ -130,6 +130,7 @@ files:
|
|
130
130
|
- test/dummy_app/app/assets/images/rails.png
|
131
131
|
- test/dummy_app/app/assets/stylesheets/basics.css.less
|
132
132
|
- test/dummy_app/app/assets/stylesheets/frameworks/bootstrap/mixins.less
|
133
|
+
- test/dummy_app/app/assets/stylesheets/frameworks/bootstrap/variables.less
|
133
134
|
- test/dummy_app/app/assets/stylesheets/helpers.css.less
|
134
135
|
- test/dummy_app/init.rb
|
135
136
|
- test/dummy_app/tmp/.gitkeep
|
@@ -165,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
165
166
|
requirements: []
|
166
167
|
|
167
168
|
rubyforge_project:
|
168
|
-
rubygems_version: 1.8.
|
169
|
+
rubygems_version: 1.8.15
|
169
170
|
signing_key:
|
170
171
|
specification_version: 3
|
171
172
|
summary: The dynamic stylesheet language for the Rails asset pipeline.
|
@@ -178,10 +179,10 @@ test_files:
|
|
178
179
|
- test/dummy_app/app/assets/images/rails.png
|
179
180
|
- test/dummy_app/app/assets/stylesheets/basics.css.less
|
180
181
|
- test/dummy_app/app/assets/stylesheets/frameworks/bootstrap/mixins.less
|
182
|
+
- test/dummy_app/app/assets/stylesheets/frameworks/bootstrap/variables.less
|
181
183
|
- test/dummy_app/app/assets/stylesheets/helpers.css.less
|
182
184
|
- test/dummy_app/init.rb
|
183
185
|
- test/dummy_app/tmp/.gitkeep
|
184
186
|
- test/dummy_app/tmp/cache/.gitkeep
|
185
187
|
- test/dummy_app/vendor/assets/stylesheets/vendored.less
|
186
188
|
- test/spec_helper.rb
|
187
|
-
has_rdoc:
|