less 1.2.19 → 1.2.20

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.19
1
+ 1.2.20
data/less.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{less}
8
- s.version = "1.2.19"
8
+ s.version = "1.2.20"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["cloudhead"]
12
- s.date = %q{2009-12-02}
12
+ s.date = %q{2009-12-14}
13
13
  s.default_executable = %q{lessc}
14
14
  s.description = %q{LESS is leaner CSS}
15
15
  s.email = %q{self@cloudhead.net}
@@ -51,6 +51,8 @@ Gem::Specification.new do |s|
51
51
  "spec/css/css.css",
52
52
  "spec/css/dash-prefix.css",
53
53
  "spec/css/functions.css",
54
+ "spec/css/import-with-extra-paths.css",
55
+ "spec/css/import-with-partial-in-extra-path.css",
54
56
  "spec/css/import.css",
55
57
  "spec/css/lazy-eval.css",
56
58
  "spec/css/mixins-args.css",
@@ -74,8 +76,12 @@ Gem::Specification.new do |s|
74
76
  "spec/less/exceptions/mixed-units-error.less",
75
77
  "spec/less/exceptions/name-error-1.0.less",
76
78
  "spec/less/exceptions/syntax-error-1.0.less",
79
+ "spec/less/extra_import_path/extra.less",
80
+ "spec/less/extra_import_path/import/import-test-a.css",
81
+ "spec/less/extra_import_path/import/import-test-a.less",
77
82
  "spec/less/functions.less",
78
83
  "spec/less/hidden.less",
84
+ "spec/less/import-with-extra-paths.less",
79
85
  "spec/less/import.less",
80
86
  "spec/less/import/import-test-a.less",
81
87
  "spec/less/import/import-test-b.less",
data/lib/less.rb CHANGED
@@ -7,6 +7,8 @@ LESS_ROOT = File.expand_path(File.dirname(__FILE__))
7
7
  LESS_PARSER = File.join(LESS_ROOT, 'less', 'engine', 'parser.rb')
8
8
  LESS_GRAMMAR = File.join(LESS_ROOT, 'less', 'engine', 'grammar')
9
9
 
10
+ $LESS_LOAD_PATH = []
11
+
10
12
  $:.unshift File.dirname(__FILE__)
11
13
 
12
14
  require 'less/ext'
@@ -123,16 +123,27 @@ module Less
123
123
  rule import
124
124
  ws "@import" S url:(string / url) medias? s ';' ws {
125
125
  def build env
126
- path = File.join(env.root.file || Dir.pwd, url.value)
127
- path += '.less' unless path =~ /\.(le|c)ss$/
128
- if File.exist? path
126
+ standard_path = File.join(env.root.file || Dir.pwd, url.value)
127
+
128
+ # Compile a list of possible paths for this file
129
+ paths = $LESS_LOAD_PATH.map { |p| File.join(p, url.value) } + [standard_path]
130
+ # Standardize and make uniq
131
+ paths = paths.map do |p|
132
+ p = File.expand_path(p)
133
+ p += '.less' unless p =~ /\.(le|c)ss$/
134
+ p
135
+ end.uniq
136
+
137
+ # Use the first that exists if any
138
+ if path = paths.detect {|p| File.exists?(p)}
129
139
  unless env.root.imported.include?(path)
130
140
  env.root.imported << path
131
141
  env.rules += Less::Engine.new(File.new(path)).to_tree.rules
132
142
  end
133
143
  else
134
- raise ImportError, path
144
+ raise ImportError, standard_path
135
145
  end
146
+
136
147
  end
137
148
  }
138
149
  end
@@ -0,0 +1,8 @@
1
+ #css { color: yellow; }
2
+ #import { color: red; }
3
+ .mixin {
4
+ height: 10px;
5
+ color: red;
6
+ }
7
+ body { font-size: 0.75em; }
8
+ h2 { font-size: 2em; }
@@ -0,0 +1,6 @@
1
+ .mixin { font-size: 0.75em; }
2
+ #import-test {
3
+ font-size: 0.75em;
4
+ width: 10px;
5
+ height: 30%;
6
+ }
data/spec/engine_spec.rb CHANGED
@@ -107,6 +107,17 @@ describe Less::Engine do
107
107
  it "should work with import" do
108
108
  lessify(:import).should == css(:import)
109
109
  end
110
+
111
+ it "should work tih import using extra paths" do
112
+ lambda {
113
+ lessify(:import_with_extra_paths).should == css(:import_with_extra_paths)
114
+ }.should raise_error(Less::ImportError)
115
+ # finding a partial in another location
116
+ $LESS_LOAD_PATH = ["spec/less/extra_import_path"]
117
+ lessify(:import_with_extra_paths).should == css(:import_with_extra_paths)
118
+ # overriding a partial in another location so this takes priority over the same named partial in the same directory
119
+ lessify(:import).should == css(:import_with_partial_in_extra_path)
120
+ end
110
121
 
111
122
  it "should parse a big file"
112
123
  it "should handle complex color operations"
@@ -0,0 +1 @@
1
+ body { font-size: 0.75em; }
@@ -0,0 +1 @@
1
+ .mixin { font-size: 0.75em; }
@@ -0,0 +1,4 @@
1
+ @a: 20%;
2
+ .mixin {
3
+ font-size: 0.75em;
4
+ }
@@ -0,0 +1,4 @@
1
+ @import url("import/import-test-b.less");
2
+ @import url("extra.less");
3
+
4
+ h2 { font-size: 2em; }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: less
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.19
4
+ version: 1.2.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - cloudhead
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-02 00:00:00 -05:00
12
+ date: 2009-12-14 00:00:00 -05:00
13
13
  default_executable: lessc
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -74,6 +74,8 @@ files:
74
74
  - spec/css/css.css
75
75
  - spec/css/dash-prefix.css
76
76
  - spec/css/functions.css
77
+ - spec/css/import-with-extra-paths.css
78
+ - spec/css/import-with-partial-in-extra-path.css
77
79
  - spec/css/import.css
78
80
  - spec/css/lazy-eval.css
79
81
  - spec/css/mixins-args.css
@@ -97,8 +99,12 @@ files:
97
99
  - spec/less/exceptions/mixed-units-error.less
98
100
  - spec/less/exceptions/name-error-1.0.less
99
101
  - spec/less/exceptions/syntax-error-1.0.less
102
+ - spec/less/extra_import_path/extra.less
103
+ - spec/less/extra_import_path/import/import-test-a.css
104
+ - spec/less/extra_import_path/import/import-test-a.less
100
105
  - spec/less/functions.less
101
106
  - spec/less/hidden.less
107
+ - spec/less/import-with-extra-paths.less
102
108
  - spec/less/import.less
103
109
  - spec/less/import/import-test-a.less
104
110
  - spec/less/import/import-test-b.less