rp 0.0.5 → 0.1.0

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.
Files changed (4) hide show
  1. data/README.md +45 -1
  2. data/lib/rp.rb +9 -3
  3. data/lib/rp/version.rb +1 -1
  4. metadata +1 -1
data/README.md CHANGED
@@ -18,7 +18,51 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- TODO: Write usage instructions here
21
+ ```yaml
22
+ html!
23
+ p "hello world"
24
+ div class: "user-name", id: "first-one"
25
+ title "hello title"
26
+ >> a = "hell world"
27
+ >> (1..4).each do |x|
28
+ >> a << " again"
29
+ div a
30
+ >> end
31
+ div class: "nothing"
32
+ p "done"
33
+ ```
34
+
35
+ output
36
+
37
+ ```html
38
+ <html>
39
+ <p>
40
+ hello world
41
+ </p>
42
+ <div class='user-name' id='first-one'>
43
+ <title>
44
+ hello title
45
+ </title>
46
+ <div>
47
+ hell world again
48
+ </div>
49
+ <div>
50
+ hell world again again
51
+ </div>
52
+ <div>
53
+ hell world again again again
54
+ </div>
55
+ <div>
56
+ hell world again again again again
57
+ </div>
58
+ </div>
59
+ <div class='nothing'>
60
+ </div>
61
+ <p>
62
+ done
63
+ </p>
64
+ </html>
65
+ ```
22
66
 
23
67
  ## Contributing
24
68
 
data/lib/rp.rb CHANGED
@@ -7,6 +7,7 @@ module Rp
7
7
 
8
8
  INDENT_SIZE = 2
9
9
  INDENT = " " * INDENT_SIZE
10
+ CODE_MARK = ">>"
10
11
 
11
12
  def indent(line)
12
13
  (line.size - line.lstrip.size)/INDENT_SIZE
@@ -20,9 +21,15 @@ module Rp
20
21
  @doc = ""
21
22
  @indent = 0
22
23
  lines.each do |l|
23
- l.chomp!
24
- next if l.empty?
25
24
  i = indent l
25
+ l.strip!
26
+ next if l.empty?
27
+
28
+ if l[0..1] == CODE_MARK
29
+ l.gsub!(/#{CODE_MARK} */, INDENT * i)
30
+ @doc << "\n#{l}"
31
+ next
32
+ end
26
33
 
27
34
  if i > @indent
28
35
  # do
@@ -40,6 +47,5 @@ module Rp
40
47
 
41
48
  ends(@indent-1, @indent)
42
49
  eval(@doc)
43
-
44
50
  end
45
51
  end
@@ -1,3 +1,3 @@
1
1
  module Rp
2
- VERSION = "0.0.5"
2
+ VERSION = "0.1.0"
3
3
  end
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.0.5
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: