rp 0.1.0 → 0.1.1
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/lib/rp.rb +30 -0
- data/lib/rp/version.rb +1 -1
- metadata +2 -2
data/lib/rp.rb
CHANGED
@@ -17,6 +17,33 @@ module Rp
|
|
17
17
|
n.times {|i| @doc << "\n" << INDENT*(s-i) << "end"} if s >= 0
|
18
18
|
end
|
19
19
|
|
20
|
+
def class_and_id l, i
|
21
|
+
cls = ""
|
22
|
+
id = ""
|
23
|
+
|
24
|
+
parts = l.split(" ", 1)
|
25
|
+
t1, t2 = parts[0].split("#")
|
26
|
+
tmp = t1.split(".")
|
27
|
+
tag_name = tmp.shift
|
28
|
+
cls << tmp.join(" ").strip if tmp.any?
|
29
|
+
if t2
|
30
|
+
tmp = t2.split(".")
|
31
|
+
id = tmp.shift.strip
|
32
|
+
cls << " " << tmp.join(" ").strip if tmp.any?
|
33
|
+
end
|
34
|
+
|
35
|
+
l = if parts[1]
|
36
|
+
tag_name + " " + parts[1]
|
37
|
+
else
|
38
|
+
tag_name
|
39
|
+
end
|
40
|
+
|
41
|
+
t = ""
|
42
|
+
t << "#{INDENT*i}@cls = '#{cls}'\n" if cls.size != 0
|
43
|
+
t << "#{INDENT*i}@id = '#{id}'\n" if id.size != 0
|
44
|
+
t << INDENT*i << l
|
45
|
+
end
|
46
|
+
|
20
47
|
def parse(lines)
|
21
48
|
@doc = ""
|
22
49
|
@indent = 0
|
@@ -31,6 +58,8 @@ module Rp
|
|
31
58
|
next
|
32
59
|
end
|
33
60
|
|
61
|
+
l = class_and_id l, i
|
62
|
+
|
34
63
|
if i > @indent
|
35
64
|
# do
|
36
65
|
@doc << " do\n" << l
|
@@ -49,3 +78,4 @@ module Rp
|
|
49
78
|
eval(@doc)
|
50
79
|
end
|
51
80
|
end
|
81
|
+
# print Rp.parse(File.open(File.expand_path("../tmp/test.r")).readlines)
|
data/lib/rp/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-07-
|
12
|
+
date: 2013-07-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|