BOBrb 0.1.2 → 0.1.3
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.
- checksums.yaml +4 -4
- data/README.md +29 -3
- data/lib/BOBrb/child_array.rb +2 -2
- data/lib/BOBrb/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ffe777992daced1102dbe4563326c03c86730c8
|
4
|
+
data.tar.gz: 320ad765ab0f3158e1b12292a68c1ca4598ee02b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c14f88296db65b641cd15c2ade161723682e11dda9e3b76d2e8309b5834c365166aea3a8e63b3f55aab8a4206d395c07e67f971cec633db70116fe2d9456a28c
|
7
|
+
data.tar.gz: a75c813bdfd48cd67c5f7a64f122567fc360e1454ae6b97ac3174b239558c6fae004837f2d85bc35064c9ad55b2e5e2814a24206fb10c712cea59f9cf1e2ff65
|
data/README.md
CHANGED
@@ -51,14 +51,14 @@ BOB is a pipe system for generating html structures.
|
|
51
51
|
###Building a simple tag:
|
52
52
|
```ruby
|
53
53
|
|
54
|
-
BOBrb.new("div").toString
|
54
|
+
BOBrb.new("div").toString
|
55
55
|
#=> "<div></div>"
|
56
56
|
```
|
57
57
|
You can also use the shorthand method "s". For a full list see [the shorthand section](#shorthand)
|
58
58
|
|
59
59
|
```ruby
|
60
60
|
|
61
|
-
BOBrb.new("div").s
|
61
|
+
BOBrb.new("div").s
|
62
62
|
#=> "<div></div>"
|
63
63
|
```
|
64
64
|
|
@@ -163,7 +163,7 @@ However, if you use the `up` command and go out of the scope of `do`, `BOBrb.dat
|
|
163
163
|
```
|
164
164
|
|
165
165
|
###Processing data and BOBrb.data
|
166
|
-
BOBrb.data is a function, so **you cannot manipulate `BOBrb.data` directly.**
|
166
|
+
BOBrb.data is a function, so **you cannot manipulate `BOBrb.data` directly.** (restriction from Javascript BOB. Will be updated in BOBrb)
|
167
167
|
|
168
168
|
It is adviced to do the data manipulation prior to the `do` pipe. However it is possible to manipulate BOBrb.data inline like this:
|
169
169
|
|
@@ -177,6 +177,31 @@ It is adviced to do the data manipulation prior to the `do` pipe. However it is
|
|
177
177
|
#=> <ul><li>3</li><li>4</li><li>5</li></ul>
|
178
178
|
```
|
179
179
|
|
180
|
+
###Pretty Printing
|
181
|
+
It is possible get a pretty printed version of the XML/HTML, with the `.prettyPrint()` method, or the `.pp` shorthand.
|
182
|
+
|
183
|
+
```ruby
|
184
|
+
|
185
|
+
BOBrb.new("article").a("lol").i("photo").co("test").a("test2").i("price").co("200euro").pp()
|
186
|
+
#=> "</article>\n<lol>\n\t<photo>\n\t\ttest\n\t</photo>\n\t<test2>\n\t\t<price>\n\t\t\t200euro\n\t\t</price>\n\t</test2>\n</lol>"
|
187
|
+
|
188
|
+
```
|
189
|
+
|
190
|
+
This string will print as the following:
|
191
|
+
|
192
|
+
```
|
193
|
+
</article>
|
194
|
+
<lol>
|
195
|
+
<photo>
|
196
|
+
test
|
197
|
+
</photo>
|
198
|
+
<test2>
|
199
|
+
<price>
|
200
|
+
200euro
|
201
|
+
</price>
|
202
|
+
</test2>
|
203
|
+
</lol>
|
204
|
+
```
|
180
205
|
|
181
206
|
<a name="shorthand"></a>
|
182
207
|
###Short hand syntax
|
@@ -196,6 +221,7 @@ Long Version | Short Version
|
|
196
221
|
.do | .d
|
197
222
|
.up | .u
|
198
223
|
BOBrb.data | BOBrb.d
|
224
|
+
.prettyPrint | .pp
|
199
225
|
|
200
226
|
Now you can get tight and cozy syntax like this:
|
201
227
|
|
data/lib/BOBrb/child_array.rb
CHANGED
@@ -116,7 +116,7 @@ module BOBrb
|
|
116
116
|
self.d(data)
|
117
117
|
end
|
118
118
|
def d (data)
|
119
|
-
|
119
|
+
@bobs.each_with_index do |bob, i|
|
120
120
|
BOBrb::Element.data = item
|
121
121
|
if @bobs[i]
|
122
122
|
@bobs[i] = @bobs[i].d(data)
|
@@ -135,7 +135,7 @@ module BOBrb
|
|
135
135
|
BOBrb::Element.data = nil
|
136
136
|
return @parent
|
137
137
|
end
|
138
|
-
|
138
|
+
@bobs.each_with_index do |bob, i|
|
139
139
|
@bobs[i] = @bobs[i].u()
|
140
140
|
end
|
141
141
|
if @bobs[0] == @parent
|
data/lib/BOBrb/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: BOBrb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephan Nordnes Eriksen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|