visionmedia-lightr 0.0.3 → 0.0.4
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/History.rdoc +6 -0
- data/examples/ruby.rb +4 -0
- data/lib/lightr/grammars/c.rb +2 -1
- data/lib/lightr/grammars/javascript.rb +1 -1
- data/lib/lightr/grammars/ruby.rb +5 -3
- data/lib/lightr/version.rb +1 -1
- data/lightr.gemspec +1 -1
- data/spec/grammars/ruby_spec.rb +9 -0
- metadata +1 -1
data/History.rdoc
CHANGED
data/examples/ruby.rb
CHANGED
data/lib/lightr/grammars/c.rb
CHANGED
@@ -4,7 +4,8 @@
|
|
4
4
|
|
5
5
|
module Lightr
|
6
6
|
class C
|
7
|
-
include Grammar
|
7
|
+
include Grammar
|
8
|
+
id = /\w[\w\d]*/
|
8
9
|
int = /\d+/
|
9
10
|
match :keyword, /(NULL|if|else|asm|auto|break|case|char|const|continue|default|do|double|enum|extern|float|for|goto|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|union|unsigned|void|volatile|while)(?:\n|\z| )/
|
10
11
|
match :string, /'.*?'|".*?"/
|
@@ -2,7 +2,7 @@
|
|
2
2
|
module Lightr
|
3
3
|
class JavaScript
|
4
4
|
include Grammar
|
5
|
-
id =
|
5
|
+
id = /\w[\w\d]*/
|
6
6
|
int = /\d+/
|
7
7
|
match :keyword, /(if|else|throw|break|case|catch|continue|default|delete|do|double|true|false|final|finally|float|for|function|int|instanceof|in|long|new|null|return|short|switch|throw|try|typeof|var|void|while|with)(?:\n|\z| )/
|
8
8
|
match :string, /'.*?'|".*?"/
|
data/lib/lightr/grammars/ruby.rb
CHANGED
@@ -10,15 +10,17 @@
|
|
10
10
|
module Lightr
|
11
11
|
class Ruby
|
12
12
|
include Grammar
|
13
|
-
id =
|
13
|
+
id = /\w[\w\d]*/
|
14
14
|
int = /\d[\d_]*/
|
15
|
+
string = /'.*?'|".*?"/
|
15
16
|
match :keyword, /(if|else|elsif|unless|retry|super|then|true|while|until|class|module|defined|end|in|alias|BEGIN|END|begin|break|def|do|nil|not|or|and|redo|rescue|return|yield)(?:\n|\z| )/
|
16
|
-
match :
|
17
|
+
match :symbol, /:(#{id}|#{string})/
|
18
|
+
match :string, string
|
17
19
|
match :regexp, %r{/.*?/[\w]*}
|
18
20
|
match :self, /self/
|
19
21
|
match :comment, /#.*?(\n|\z)/
|
20
22
|
match :constant, /[A-Z]#{id}/
|
21
|
-
match :
|
23
|
+
match :variable, /@@?#{id}/
|
22
24
|
match :number, /-?#{int}(?:\.#{int})?/
|
23
25
|
match nil, /\n|\s|.+?/
|
24
26
|
end
|
data/lib/lightr/version.rb
CHANGED
data/lightr.gemspec
CHANGED
data/spec/grammars/ruby_spec.rb
CHANGED
@@ -9,6 +9,7 @@ describe Lightr::Ruby do
|
|
9
9
|
|
10
10
|
it 'symbols' do
|
11
11
|
parse('a :symbol').should include('class="symbol">:symbol')
|
12
|
+
parse(':"foo bar" test').should include('class="symbol">:"foo bar"<')
|
12
13
|
end
|
13
14
|
|
14
15
|
it 'strings' do
|
@@ -33,6 +34,14 @@ describe Lightr::Ruby do
|
|
33
34
|
parse('/test/sex test').should include('class="regexp">/test/sex<')
|
34
35
|
end
|
35
36
|
|
37
|
+
it "instance variables" do
|
38
|
+
parse('@foo_1').should include('class="variable">@foo_1<')
|
39
|
+
end
|
40
|
+
|
41
|
+
it "class variables" do
|
42
|
+
parse('@@__bar').should include('class="variable">@@__bar<')
|
43
|
+
end
|
44
|
+
|
36
45
|
%w( 11 1_000 1.1 1.100_00 ).each do |number|
|
37
46
|
it "#{number} as number" do
|
38
47
|
parse(number).should include('class="number"')
|