less-js 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +0 -2
- data/README.md +0 -7
- data/lib/less_js.rb +20 -28
- data/ruby-less-js.gemspec +3 -3
- data/test/test_less_js.rb +1 -1
- metadata +5 -3
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -24,13 +24,6 @@ the `less-js-source` gem.
|
|
24
24
|
|
25
25
|
*Note: verion 1.1.1 is tagged as 1.1.1.1 on the `less-js-source` gem.*
|
26
26
|
|
27
|
-
### JSON
|
28
|
-
|
29
|
-
The `json` library is also required but is not explicitly stated as a
|
30
|
-
gem dependency. If you're on Ruby 1.8 you'll need to install the
|
31
|
-
`json` or `json_pure` gem. On Ruby 1.9, `json` is included in the
|
32
|
-
standard library.
|
33
|
-
|
34
27
|
### ExecJS
|
35
28
|
|
36
29
|
The [ExecJS](https://github.com/sstephenson/execjs) library is used to automatically choose the best JavaScript engine for your platform. Check out its [README](https://github.com/sstephenson/execjs/blob/master/README.md) for a complete list of supported engines.
|
data/lib/less_js.rb
CHANGED
@@ -2,8 +2,7 @@ require 'execjs'
|
|
2
2
|
require 'less_js/source'
|
3
3
|
|
4
4
|
module LessJs
|
5
|
-
|
6
|
-
CompilationError = ExecJS::ProgramError
|
5
|
+
class ParseError < StandardError; end
|
7
6
|
|
8
7
|
module Source
|
9
8
|
def self.path
|
@@ -11,7 +10,7 @@ module LessJs
|
|
11
10
|
end
|
12
11
|
|
13
12
|
def self.path=(path)
|
14
|
-
@contents = @version = @
|
13
|
+
@contents = @version = @context = nil
|
15
14
|
@path = path
|
16
15
|
end
|
17
16
|
|
@@ -20,46 +19,39 @@ module LessJs
|
|
20
19
|
end
|
21
20
|
|
22
21
|
def self.version
|
23
|
-
@version ||= contents[/
|
22
|
+
@version ||= contents[/LESS - Leaner CSS v([\d.]+)/, 1]
|
24
23
|
end
|
25
24
|
|
26
25
|
def self.context
|
27
|
-
@context ||= ExecJS.compile
|
26
|
+
@context ||= ExecJS.compile <<-EOS
|
27
|
+
#{contents}
|
28
|
+
|
29
|
+
function compile(data) {
|
30
|
+
var result;
|
31
|
+
new less.Parser().parse(data, function(error, tree) {
|
32
|
+
result = [error, tree.toCSS()];
|
33
|
+
});
|
34
|
+
return result;
|
35
|
+
}
|
36
|
+
EOS
|
28
37
|
end
|
29
38
|
end
|
30
39
|
|
31
40
|
class << self
|
32
|
-
def engine
|
33
|
-
end
|
34
|
-
|
35
|
-
def engine=(engine)
|
36
|
-
end
|
37
|
-
|
38
41
|
def version
|
39
42
|
Source.version
|
40
43
|
end
|
41
44
|
|
42
|
-
def callback(error, tree)
|
43
|
-
puts tree.inspect
|
44
|
-
end
|
45
|
-
|
46
45
|
# Compile a script (String or IO) to CSS.
|
47
46
|
def compile(script, options = {})
|
48
47
|
script = script.read if script.respond_to?(:read)
|
48
|
+
error, data = Source.context.call('compile', script)
|
49
49
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
});
|
56
|
-
return resp;
|
57
|
-
})
|
58
|
-
EOS
|
59
|
-
|
60
|
-
(error, response) = Source.context.call(code, script)
|
61
|
-
raise CompilationError, error if error
|
62
|
-
response
|
50
|
+
if error
|
51
|
+
raise ParseError, error['message']
|
52
|
+
else
|
53
|
+
data
|
54
|
+
end
|
63
55
|
end
|
64
56
|
end
|
65
57
|
end
|
data/ruby-less-js.gemspec
CHANGED
@@ -3,10 +3,10 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "less-js"
|
6
|
-
s.version = '0.1.
|
6
|
+
s.version = '0.1.1'
|
7
7
|
|
8
|
-
s.authors = ["Adnan Ali"]
|
9
|
-
s.email = ["adnan.ali@gmail.com"]
|
8
|
+
s.authors = ["Joshua Peek", "Adnan Ali"]
|
9
|
+
s.email = ["josh@joshpeek.com", "adnan.ali@gmail.com"]
|
10
10
|
s.homepage = "https://github.com/thisduck/ruby-less-js"
|
11
11
|
s.summary = "Ruby Less.js Compiler"
|
12
12
|
s.description = <<-EOS
|
data/test/test_less_js.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: less-js
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
|
+
- Joshua Peek
|
13
14
|
- Adnan Ali
|
14
15
|
autorequire:
|
15
16
|
bindir: bin
|
@@ -48,6 +49,7 @@ dependencies:
|
|
48
49
|
version_requirements: *id002
|
49
50
|
description: "\t\tRuby Less.js is a bridge to the JS Less.js compiler.\n"
|
50
51
|
email:
|
52
|
+
- josh@joshpeek.com
|
51
53
|
- adnan.ali@gmail.com
|
52
54
|
executables: []
|
53
55
|
|