ruby-gumbo 1.0.1 → 1.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9f5c5ba70ffb487659a2aadc0e9cf5677beef932
4
- data.tar.gz: 6c4be899d6d729cf8070978c959ec076b2f2f155
3
+ metadata.gz: 9f4e6f145bffad000b1a79454df8189d97e7f735
4
+ data.tar.gz: 0bc3d6ba9be13e78e8cf204b8ae19c8346bb9943
5
5
  SHA512:
6
- metadata.gz: 0005f69394bedd851e92092ddf18169322b9c3748ecbdf478d9f15af1d2a5200cbc8334caa1c60a9cb3fd3d4de74f5d3b2d8d82360eb562db8c636da17ccc8ed
7
- data.tar.gz: 31444aaed773d14e08862350b5a6af88284e96267d89ba03732eeaf5203f1351cfee18a2e36eb58e681d1f0c0d93aeb6bfe39b139fd5c82544f6f257a5f77f2b
6
+ metadata.gz: 10180229daad4eb0ccfa1207cc92e85cac055c58d1dca7e7e335258ab6bdbaf095c0acb8f1cb06a7b372fc7c37fcc00811c9f89853676be6935942e96fb54eb9
7
+ data.tar.gz: 77e50622078d2275fd0c5c847610d1f2dd4b23871ad6b459c65d93085059c38102abb0ac75bf684ab042486c693939b090527803587350b9104fd83a47264e23
data/README.mkd CHANGED
@@ -6,8 +6,41 @@
6
6
 
7
7
  ## Installation
8
8
 
9
- Create the gem with `rake package`, then install it with `gem install` (the
10
- gem file is in the `pkg` directory).
9
+ `ruby-gumbo` can be directly installed from http://rubygems.org:
10
+
11
+ gem install ruby-gumbo
12
+
13
+ Or you can create the gem with `rake package`, then install it with `gem
14
+ install` (the gem file is in the `pkg` directory).
15
+
16
+ ## Example
17
+
18
+ ```ruby
19
+ require 'net/http'
20
+
21
+ html = Net::HTTP.get URI.parse('http://example.org')
22
+ Gumbo::parse(html) {|doc| doc.dump_tree}
23
+ ```
24
+
25
+ Result:
26
+
27
+ ```
28
+ <HTML>
29
+ <HEAD>
30
+ <TITLE>
31
+ <META charset>
32
+ <META http-equiv content>
33
+ <META name content>
34
+ <STYLE type>
35
+ <BODY>
36
+ <DIV>
37
+ <H1>
38
+ <P>
39
+ <P>
40
+ <A href>
41
+ ```
42
+
43
+ You can find more examples in the `examples` directory.
11
44
 
12
45
  ## Contact
13
46
 
data/Rakefile CHANGED
@@ -7,7 +7,7 @@ require 'rubygems/package_task'
7
7
 
8
8
 
9
9
  PKG_NAME = "ruby-gumbo"
10
- PKG_VERSION = "1.0.1"
10
+ PKG_VERSION = "1.0.2"
11
11
 
12
12
  EXT_CONF = "ext/extconf.rb"
13
13
  MAKEFILE = "ext/Makefile"
data/ext/extconf.h ADDED
@@ -0,0 +1,3 @@
1
+ #ifndef EXTCONF_H
2
+ #define EXTCONF_H
3
+ #endif
data/ext/gumbo.c CHANGED
@@ -75,6 +75,7 @@ Init_gumbo(void) {
75
75
  c_element = rb_define_class_under(m_gumbo, "Element", c_node);
76
76
  rb_define_attr(c_element, "tag", 1, 0);
77
77
  rb_define_attr(c_element, "original_tag", 1, 0);
78
+ rb_define_attr(c_element, "original_tag_name", 1, 0);
78
79
  rb_define_attr(c_element, "tag_namespace", 1, 0);
79
80
  rb_define_attr(c_element, "attributes", 1, 0);
80
81
  rb_define_attr(c_element, "children", 1, 0);
@@ -432,6 +433,10 @@ r_gumbo_node_to_value(GumboNode *node) {
432
433
  rb_iv_set(r_node, "@original_tag",
433
434
  r_tainted_str_new(element->original_tag.data,
434
435
  element->original_tag.length));
436
+ gumbo_tag_from_original_text(&element->original_tag);
437
+ rb_iv_set(r_node, "@original_tag_name",
438
+ r_tainted_str_new(element->original_tag.data,
439
+ element->original_tag.length));
435
440
  rb_iv_set(r_node, "@tag_namespace",
436
441
  r_gumbo_namespace_to_symbol(element->tag_namespace));
437
442
  rb_iv_set(r_node, "@start_pos",
data/lib/gumbo/extra.rb CHANGED
@@ -26,9 +26,11 @@ module Gumbo
26
26
  output.write (" " * indent)
27
27
 
28
28
  if node.type == :element
29
- tag = (node.tag == :unknown) ? node.original_tag : node.tag.to_s
29
+ tag = (node.tag == :unknown) ? node.original_tag_name : node.tag.to_s
30
30
  attributes = node.attributes.map(&:name)
31
- output.puts "<" + tag.upcase() + " " + attributes.join(" ") + ">"
31
+ output.write "<" + tag.upcase()
32
+ output.write(" " + attributes.join(" ")) unless attributes.empty?
33
+ output.puts ">"
32
34
 
33
35
  indent += 2
34
36
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-gumbo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicolas Martyanoff
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-18 00:00:00.000000000 Z
11
+ date: 2013-09-17 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: khaelin@gmail.com
@@ -22,6 +22,7 @@ files:
22
22
  - README.mkd
23
23
  - lib/gumbo/extra.rb
24
24
  - ext/extconf.rb
25
+ - ext/extconf.h
25
26
  - ext/gumbo.c
26
27
  homepage:
27
28
  licenses: