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 CHANGED
@@ -3,6 +3,8 @@ rvm:
3
3
  - 1.9.2
4
4
  - 1.9.3
5
5
  - ree
6
+ before_install:
7
+ - gem update --system
6
8
  gemfile:
7
9
  - Gemfile.rails-3.1
8
10
  - Gemfile.rails-3.2
data/CHANGELOG.md CHANGED
@@ -1,7 +1,12 @@
1
1
  CHANGELOG
2
2
  =========
3
3
 
4
- 2.1.4, 2.1.5 - =01/31/2012
4
+ 2.1.6 - 02/16/2012
5
+
6
+ * Nested imports recursively declare sprockets dependencies. Fixes #26.
7
+
8
+
9
+ 2.1.4, 2.1.5 - 01/31/2012
5
10
 
6
11
  * More friendly import processor with missing files. Fixes #13.
7
12
 
@@ -7,15 +7,21 @@ module Less
7
7
  def prepare
8
8
  end
9
9
 
10
- def evaluate(context, locals, &block)
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
- context.resolve(path)
19
+ scope.resolve(path)
15
20
  rescue Sprockets::FileNotFound
16
21
  nil
17
22
  end
18
- context.depend_on(path) if pathname && pathname.to_s.ends_with?('.less')
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
@@ -1,5 +1,5 @@
1
1
  module Less
2
2
  module Rails
3
- VERSION = "2.1.5"
3
+ VERSION = "2.1.6"
4
4
  end
5
5
  end
@@ -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
- it 'must hook into less import so that imported paths are declared as sprocket dependencies of the source file' do
18
- basics.must_match %r{#test-radiused\{border-radius:5px;\}}, 'default is 5px'
19
- safely_edit_mixins do |d|
20
- d.gsub! '5px', '10px'
21
- File.open(mixins_asset.pathname,'w') { |f| f.write(d) }
22
- basics.must_match %r{#test-radiused\{border-radius:10px;\}}, 'mixins.less should be a sprockets context dependency'
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 safely_edit_mixins
37
- data = File.read(mixins_asset.pathname)
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(mixins_asset.pathname,'w') { |f| f.write(data) }
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";
@@ -1,4 +1,10 @@
1
1
 
2
+ @import "frameworks/bootstrap/variables";
3
+
2
4
  .radiused(@radius: 5px) {
3
5
  border-radius: @radius;
4
6
  }
7
+
8
+ .variableColored() {
9
+ color: @variableColor;
10
+ }
@@ -0,0 +1,4 @@
1
+
2
+ @variableColor: #424242;
3
+
4
+
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: 1
4
+ hash: 7
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
8
  - 1
9
- - 5
10
- version: 2.1.5
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-01-31 00:00:00 Z
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.12
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: