less 2.2.2 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f8209d9c3cd23b895c33800822fee9609d0e1fd4
4
+ data.tar.gz: d7a7070cdd740d5e43b44b4dd9ccd1df943e5322
5
+ SHA512:
6
+ metadata.gz: 307bb3ad01064e296ee286dbaf18fb19057de032cbbf8984822996167c2017fca57993449ac779135173f689112e9750112675eefa0f16f6d9a8886933f35cbf
7
+ data.tar.gz: 6f815cc31388eebefec20a27d67d7ba5b835d54f67861dc0b3c6692d0894e19040d0bc12b0bfb2c37e41917e6feb49cc59cd275859d483735ecb221bec6c63c3
data/Gemfile CHANGED
@@ -1,7 +1,9 @@
1
- source :rubygems
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
-
6
- gem "therubyracer", "~> 0.10.0", :require => nil, :platforms => :ruby
5
+ gem "therubyracer", "~> 0.11.0", :require => nil, :platforms => :ruby
7
6
  gem "therubyrhino", "~> 1.73.3", :require => nil, :platforms => :jruby
7
+
8
+ gem "rake"
9
+ gem "rspec", "~> 2.0"
data/bin/lessc CHANGED
@@ -17,6 +17,8 @@ output = nil
17
17
  require 'optparse'
18
18
 
19
19
  opts = OptionParser.new do |opts|
20
+ opts.summary_width = 37
21
+
20
22
  opts.banner = 'Usage: lessc [options] [INPUT]'
21
23
 
22
24
  opts.on('-h', '--help', 'print this help') do
@@ -52,7 +54,7 @@ opts = OptionParser.new do |opts|
52
54
  require 'rbconfig'
53
55
  is_windows = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/)
54
56
  separator = is_windows ? ';' : ':'
55
- opts.on('--paths', '--include-path',
57
+ opts.on('--paths PATHS', '--include-path PATHS',
56
58
  "paths to include separated by '#{separator}'") do |paths|
57
59
  paths = paths.split(separator).map do |path|
58
60
  path.empty? ? nil : File.expand_path(path)
data/less.gemspec CHANGED
@@ -23,8 +23,4 @@ Gem::Specification.new do |s|
23
23
  s.require_paths = ["lib"]
24
24
 
25
25
  s.add_dependency "commonjs", "~> 0.2.6"
26
- s.add_development_dependency "rake"
27
- s.add_development_dependency "rspec", "~> 2.0"
28
-
29
26
  end
30
-
data/lib/less/defaults.rb CHANGED
@@ -2,7 +2,7 @@ module Less
2
2
  module Defaults
3
3
 
4
4
  def defaults
5
- @defaults ||= { :paths => [] }
5
+ @defaults ||= { :paths => [], :relativeUrls => true }
6
6
  end
7
7
 
8
8
  def paths
@@ -74,7 +74,7 @@ module Less
74
74
  if e.value && ( e.value['message'] || e.value['type'].is_a?(String) )
75
75
  raise Less::ParseError.new(e, e.value) # LessError
76
76
  end
77
- if e.unwrap.to_s == "missing closing `}`"
77
+ if e.unwrap.to_s =~ /missing closing `}`/
78
78
  raise Less::ParseError.new(e.unwrap.to_s)
79
79
  end
80
80
  if e.message && e.message[0, 12] == "Syntax Error"
@@ -14,7 +14,7 @@ module Less
14
14
  def self.instance
15
15
  return new
16
16
  end
17
-
17
+
18
18
  def initialize(globals = nil)
19
19
  lock do
20
20
  @v8_context = V8::Context.new
@@ -25,7 +25,7 @@ module Less
25
25
  def unwrap
26
26
  @v8_context
27
27
  end
28
-
28
+
29
29
  def exec(&block)
30
30
  lock(&block)
31
31
  end
@@ -53,9 +53,9 @@ module Less
53
53
  super
54
54
  end
55
55
  end
56
-
56
+
57
57
  private
58
-
58
+
59
59
  def lock(&block)
60
60
  do_lock(&block)
61
61
  rescue V8::JSError => e
@@ -63,26 +63,26 @@ module Less
63
63
  js_value = e.value.respond_to?(:'[]')
64
64
  name = js_value && e.value["name"]
65
65
  constructor = js_value && e.value['constructor']
66
- if name == "SyntaxError" ||
66
+ if name == "SyntaxError" ||
67
67
  ( constructor && constructor.name == "LessError" )
68
68
  raise Less::ParseError.new(e, js_value ? e.value : nil)
69
69
  end
70
70
  # NOTE: less/parser.js :
71
- #
71
+ #
72
72
  # error = new(LessError)({
73
73
  # index: i,
74
74
  # type: 'Parse',
75
75
  # message: "missing closing `}`",
76
76
  # filename: env.filename
77
77
  # }, env);
78
- #
78
+ #
79
79
  # comes back as value: RuntimeError !
80
- elsif e.value.to_s == "missing closing `}`"
80
+ elsif e.value.to_s =~ /missing closing `}`/
81
81
  raise Less::ParseError.new(e.value.to_s)
82
82
  end
83
83
  raise Less::Error.new(e)
84
84
  end
85
-
85
+
86
86
  def do_lock
87
87
  result, exception = nil, nil
88
88
  V8::C::Locker() do
@@ -99,7 +99,7 @@ module Less
99
99
  result
100
100
  end
101
101
  end
102
-
102
+
103
103
  end
104
104
  end
105
- end
105
+ end
data/lib/less/loader.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  require 'pathname'
2
2
  require 'commonjs'
3
+ require 'net/http'
4
+ require 'uri'
3
5
 
4
6
  module Less
5
7
  class Loader
@@ -15,7 +17,10 @@ module Less
15
17
  @environment = CommonJS::Environment.new(@context, :path => path.to_s)
16
18
  @environment.native('path', Path.new)
17
19
  @environment.native('util', Sys.new)
20
+ @environment.native('url', Url.new)
21
+ @environment.native('http', Http.new)
18
22
  @environment.native('fs', Fs.new)
23
+
19
24
  end
20
25
 
21
26
  def require(module_id)
@@ -26,7 +31,8 @@ module Less
26
31
 
27
32
  class Path
28
33
  def join(*components)
29
- File.join(*components)
34
+ # node.js expands path on join
35
+ File.expand_path(File.join(*components))
30
36
  end
31
37
 
32
38
  def dirname(path)
@@ -60,10 +66,108 @@ module Less
60
66
  end
61
67
 
62
68
  class Console
63
- def self.log(*msgs)
69
+ def log(*msgs)
64
70
  puts msgs.join(', ')
65
71
  end
66
72
  end
73
+
74
+ class Url
75
+ def resolve(*args)
76
+ URI.join(*args)
77
+ end
78
+
79
+ def parse(url_string)
80
+ u = URI.parse(url_string)
81
+ result = {}
82
+ result['protocol'] = u.scheme + ':' if u.scheme
83
+ result['hostname'] = u.host if u.host
84
+ result['pathname'] = u.path if u.path
85
+ result['port'] = u.port if u.port
86
+ result['query'] = u.query if u.query
87
+ result['search'] = '?' + u.query if u.query
88
+ result['hash'] = '#' + u.fragment if u.fragment
89
+ result
90
+ end
91
+ end
67
92
 
93
+ class Http
94
+ def get(options, callback)
95
+ err = nil
96
+ begin
97
+ #less always sends options as an object, so no need to check for string
98
+ uri_hash = {}
99
+ uri_hash[:host] = options['hostname'] ? options['hostname'] : options['host']
100
+ path_components = options['path'] ? options['path'].split('?', 2) : [''] #have to do this because node expects path and query to be combined
101
+ if path_components.length > 1
102
+ uri_hash[:path] = path_components[0]
103
+ uri_hash[:query] = path_components[0]
104
+ else
105
+ uri_hash[:path] = path_components[0]
106
+ end
107
+ uri_hash[:port] = options['port'] ? options['port'] : Net::HTTP.http_default_port
108
+ uri_hash[:scheme] = uri_hash[:port] == Net::HTTP.https_default_port ? 'https' : 'http' #have to check this way because of node's http.get
109
+ case uri_hash[:scheme]
110
+ when 'http'
111
+ uri = URI::HTTP.build(uri_hash)
112
+ when 'https'
113
+ uri = URI::HTTPS.build(uri_hash)
114
+ else
115
+ raise Exception, 'Less import only supports http and https'
116
+ end
117
+ http = Net::HTTP.new uri.host, uri.port
118
+ if uri.scheme == 'https'
119
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
120
+ http.use_ssl = true
121
+ end
122
+ response = nil
123
+ http.start do |req|
124
+ response = req.get(uri.to_s)
125
+ end
126
+ sr = ServerResponse.new(response.read_body, response.code.to_i)
127
+ callback.call(sr)
128
+ rescue => e
129
+ err = e.message
130
+ ensure
131
+ ret = HttpNodeObj.new(err)
132
+ end
133
+ ret
134
+ end
135
+ end
136
+
137
+ class HttpNodeObj
138
+ attr_accessor :err
139
+
140
+ def initialize(err)
141
+ @err = err
142
+ end
143
+
144
+ def on(event, callback)
145
+ case event
146
+ when 'error'
147
+ callback.call(@err) if @err #only call when error exists
148
+ else
149
+ callback.call()
150
+ end
151
+ end
152
+ end
153
+
154
+ class ServerResponse
155
+ attr_accessor :statusCode
156
+ attr_accessor :data #faked because ServerResponse acutally implements WriteableStream
157
+
158
+ def initialize(data, status_code)
159
+ @data = data
160
+ @statusCode = status_code
161
+ end
162
+
163
+ def on(event, callback)
164
+ case event
165
+ when 'data'
166
+ callback.call(@data)
167
+ else
168
+ callback.call()
169
+ end
170
+ end
171
+ end
68
172
  end
69
173
  end
data/lib/less/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Less
2
- VERSION = '2.2.2'
3
- end
2
+ VERSION = '2.3.0'
3
+ end
@@ -42,8 +42,9 @@ describe Less::Parser do
42
42
  it "will track imported files" do
43
43
  subject.parse('@import "one.less";')
44
44
  subject.parse('@import "two.less";')
45
- subject.imports.should include("one.less")
46
- subject.imports.should include("two.less")
45
+ # Parser#imports returns full path names
46
+ subject.imports.grep(/one\.less$/).should_not be_empty
47
+ subject.imports.grep(/two\.less$/).should_not be_empty
47
48
  end
48
49
 
49
50
  it "reports type, line, column and filename of (parse) error" do
metadata CHANGED
@@ -1,20 +1,39 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: less
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.2
5
- prerelease:
4
+ version: 2.3.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Charles Lowell
9
8
  autorequire:
10
9
  bindir: bin
11
- cert_chain: []
12
- date: 2012-09-04 00:00:00.000000000 Z
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDPjCCAiagAwIBAgIBADANBgkqhkiG9w0BAQUFADBFMRAwDgYDVQQDDAdjb3di
14
+ b3lkMRwwGgYKCZImiZPyLGQBGRYMdGhlZnJvbnRzaWRlMRMwEQYKCZImiZPyLGQB
15
+ GRYDbmV0MB4XDTEzMDEzMDIxMDYwNFoXDTE0MDEzMDIxMDYwNFowRTEQMA4GA1UE
16
+ AwwHY293Ym95ZDEcMBoGCgmSJomT8ixkARkWDHRoZWZyb250c2lkZTETMBEGCgmS
17
+ JomT8ixkARkWA25ldDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAO45
18
+ CUxpETDGYXjCCy2dMg/aIrdrTqBqQW5ZrzhHxF9EkcdmWFr0z/qMz0JSpZ3pF11Z
19
+ KYaj5PaQQpjZfLPwbuiGGkuSWi+UAac//V18xo6S4lzRBjO+gpzG9f2AOzt9b+SR
20
+ Uc8UhO7QBZ5edUDxMxw9QstD+U0YBAlzsPJbHuUOqdtxXmNQCds3ZnqTgZaIpdUy
21
+ CSejtrukSmlthxFzwgMezYQhcYxmkl+Q475JUodnI6Pjc6nja/Or8Y6cEWiLgeUa
22
+ a+efcPGLDEbwJC7TGRrvk8yassMByBEJ3XueTMzeqWFd+665ptciojYo6BvIAR0N
23
+ iLwks0x567FZyS8SqTcCAwEAAaM5MDcwCQYDVR0TBAIwADAdBgNVHQ4EFgQUxVgR
24
+ 5TUqf7Hd24ICb3g4FNbM7oYwCwYDVR0PBAQDAgSwMA0GCSqGSIb3DQEBBQUAA4IB
25
+ AQDdJj+NzZhiYXA56z0wzRUA/Fcf6CYqKB+RFRlPssDEcHTor5SnwdWgQof/gNLi
26
+ Qel1Om4zO0Shcp89jxaUqtvEdYVhmyfc0vycHmemKttNBT734yMrEJtF8Hhy+Dnz
27
+ 9CzixXLvgGaRH+mf3M0+l+zIDJJr2L+39L8cyTSSRnp/srfI8aSmJKhGshudBKoC
28
+ Ty6Gi071pwoJXvdMaE/6iPy7bUzlndYdHyYuWSKaO9N47HqQ62oEnBraglw6ghoi
29
+ UgImJlChAzCoDP9zi9tdm6jAr7ttF25R9PPYr11ILb7dYe3qUzlNlM6zJx/nb31b
30
+ IhdyRVup4qLcqYSTPsm6u7VA
31
+ -----END CERTIFICATE-----
32
+ date: 2013-03-04 00:00:00.000000000 Z
13
33
  dependencies:
14
34
  - !ruby/object:Gem::Dependency
15
35
  name: commonjs
16
36
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
37
  requirements:
19
38
  - - ~>
20
39
  - !ruby/object:Gem::Version
@@ -22,43 +41,10 @@ dependencies:
22
41
  type: :runtime
23
42
  prerelease: false
24
43
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
44
  requirements:
27
45
  - - ~>
28
46
  - !ruby/object:Gem::Version
29
47
  version: 0.2.6
30
- - !ruby/object:Gem::Dependency
31
- name: rake
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: '0'
38
- type: :development
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
46
- - !ruby/object:Gem::Dependency
47
- name: rspec
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ~>
52
- - !ruby/object:Gem::Version
53
- version: '2.0'
54
- type: :development
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ~>
60
- - !ruby/object:Gem::Version
61
- version: '2.0'
62
48
  description: Invoke the Less CSS compiler from Ruby
63
49
  email:
64
50
  - cowboyd@thefrontside.net
@@ -219,33 +205,26 @@ files:
219
205
  - lib/less/js/test/less/whitespace.less
220
206
  homepage: http://lesscss.org
221
207
  licenses: []
208
+ metadata: {}
222
209
  post_install_message:
223
210
  rdoc_options: []
224
211
  require_paths:
225
212
  - lib
226
213
  required_ruby_version: !ruby/object:Gem::Requirement
227
- none: false
228
214
  requirements:
229
- - - ! '>='
215
+ - - '>='
230
216
  - !ruby/object:Gem::Version
231
217
  version: '0'
232
- segments:
233
- - 0
234
- hash: -3584122421188710040
235
218
  required_rubygems_version: !ruby/object:Gem::Requirement
236
- none: false
237
219
  requirements:
238
- - - ! '>='
220
+ - - '>='
239
221
  - !ruby/object:Gem::Version
240
222
  version: '0'
241
- segments:
242
- - 0
243
- hash: -3584122421188710040
244
223
  requirements: []
245
224
  rubyforge_project: less
246
- rubygems_version: 1.8.24
225
+ rubygems_version: 2.0.0
247
226
  signing_key:
248
- specification_version: 3
227
+ specification_version: 4
249
228
  summary: Leaner CSS, in your browser or Ruby (via less.js)
250
229
  test_files:
251
230
  - spec/less/faulty/faulty.less