rind 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +5 -0
- data/README.rdoc +4 -0
- data/lib/rind/nodes.rb +3 -3
- data/lib/rind/parser.rb +1 -1
- data/lib/rind/xpath.rb +1 -1
- data/test/element_test.rb +13 -2
- metadata +5 -4
data/CHANGELOG.rdoc
ADDED
data/README.rdoc
CHANGED
@@ -7,9 +7,13 @@ app devs as an object. This project is just getting started so watch
|
|
7
7
|
out for sharp corners and unfinished rooms. Enough of that, let's talk
|
8
8
|
about what's done.
|
9
9
|
|
10
|
+
== Installation
|
11
|
+
gem install rind
|
12
|
+
|
10
13
|
== Come say "Hello".
|
11
14
|
|
12
15
|
# example.rb
|
16
|
+
require 'rubygems'
|
13
17
|
require 'rind'
|
14
18
|
|
15
19
|
# Create a new document and load your template.
|
data/lib/rind/nodes.rb
CHANGED
@@ -103,9 +103,9 @@ module Rind
|
|
103
103
|
@attributes[k.to_s] = v
|
104
104
|
end
|
105
105
|
elsif options[:attributes].is_a? String
|
106
|
-
|
107
|
-
|
108
|
-
@attributes[name] = value.
|
106
|
+
# scan for attr=value|"value1 'value2'"|'"value1" value2' or attr by itself
|
107
|
+
options[:attributes].scan(/([\w-]+)(?:=(\w+|"[^"]+?"|'[^']+?'))?/) do |name, value|
|
108
|
+
@attributes[name] = value.nil? ? '' : value.sub(/\A(["'])([^\1]+)\1\z/, '\2')
|
109
109
|
end
|
110
110
|
end
|
111
111
|
|
data/lib/rind/parser.rb
CHANGED
data/lib/rind/xpath.rb
CHANGED
data/test/element_test.rb
CHANGED
@@ -6,15 +6,26 @@ class ElementTest < Test::Unit::TestCase
|
|
6
6
|
@element = Rind::Element.new(
|
7
7
|
:attributes => {:class => "foo", :id => 'bar'},
|
8
8
|
:children => ['This is some text!', Rind::Element.new()]
|
9
|
-
)
|
9
|
+
)
|
10
10
|
end
|
11
11
|
|
12
12
|
def test_attribute_parsing
|
13
13
|
element2 = Rind::Element.new(
|
14
14
|
:attributes => 'class="foo" id="bar"',
|
15
15
|
:children => ['This is some text!', Rind::Element.new()]
|
16
|
-
)
|
16
|
+
)
|
17
17
|
assert_equal(element2, @element)
|
18
|
+
|
19
|
+
element3 = Rind::Element.new(
|
20
|
+
:attributes => 'id=foo class="hi bye" selected one=\'1\' other="\'first\' second" http-equiv="boo" type="text/css"'
|
21
|
+
)
|
22
|
+
assert_equal(element3[:id], 'foo')
|
23
|
+
assert_equal(element3[:class], 'hi bye')
|
24
|
+
assert_equal(element3[:selected], '')
|
25
|
+
assert_equal(element3[:one], '1')
|
26
|
+
assert_equal(element3[:other], "'first' second")
|
27
|
+
assert_equal(element3['http-equiv'], "boo")
|
28
|
+
assert_equal(element3[:type], "text/css")
|
18
29
|
end
|
19
30
|
|
20
31
|
def test_accessor
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rind
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
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
13
|
- Aaron Lasseigne
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-06-
|
18
|
+
date: 2010-06-14 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -40,6 +40,7 @@ files:
|
|
40
40
|
- lib/rind.rb
|
41
41
|
- README.rdoc
|
42
42
|
- LICENSE
|
43
|
+
- CHANGELOG.rdoc
|
43
44
|
- test/children_test.rb
|
44
45
|
- test/xml_test.rb
|
45
46
|
- test/traverse_test.rb
|