rind 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/CHANGELOG.rdoc ADDED
@@ -0,0 +1,5 @@
1
+ == 0.1.1 - 2010.06.14
2
+ * Attributes without a value or with a value containing a space broke the parser.
3
+
4
+ == 0.1.0 - 2010.06.12
5
+ * Initial release.
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
- options[:attributes].split(/\s+/).each do |attribute|
107
- name, value = attribute.split(/=/)
108
- @attributes[name] = value.scan(/\"(.*?)\"/).to_s
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
@@ -36,7 +36,7 @@ module Rind
36
36
  text_end = match.begin(0)
37
37
  if text_start < text_end
38
38
  text = content[text_start...text_end]
39
- tokens.push([TEXT, text]) if text !~ /^\s*$/
39
+ tokens.push([TEXT, text]) if text !~ /\A\s*\z/
40
40
  end
41
41
  text_start = match.end(0)
42
42
 
data/lib/rind/xpath.rb CHANGED
@@ -4,7 +4,7 @@
4
4
  module Xpath
5
5
  # Xpath search of a node that returns a list of matching nodes.
6
6
  def s(path)
7
- node = self.clone;
7
+ node = self;
8
8
 
9
9
  # absolute paths to the top
10
10
  if '/' == path[0,1]
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: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
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-12 00:00:00 -05:00
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