dozuki 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/README.markdown +9 -0
- data/lib/dozuki/html.rb +7 -0
- data/lib/dozuki/version.rb +1 -1
- data/lib/dozuki.rb +11 -0
- data/spec/dozuki/dozuki_spec.rb +22 -0
- data/spec/dozuki/html_spec.rb +32 -0
- metadata +6 -1
data/Gemfile.lock
CHANGED
data/README.markdown
CHANGED
@@ -29,9 +29,18 @@ parse method](http://nokogiri.org/Nokogiri/XML/Document.html#parse):
|
|
29
29
|
|
30
30
|
# simple usage
|
31
31
|
doc = Dozuki::XML.parse(string_or_io)
|
32
|
+
|
33
|
+
# HTML
|
34
|
+
html = Dozuki::HTML.parse(string_or_io)
|
32
35
|
|
33
36
|
# or the full parameter list
|
34
37
|
doc = Dozuki::XML.parse(string_or_io, url = nil, encoding = nil, options = ParseOptions::DEFAULT_XML)
|
38
|
+
doc = Dozuki::HTML.parse(string_or_io, url = nil, encoding = nil, options = ParseOptions::DEFAULT_XML)
|
39
|
+
|
40
|
+
# or using the quick methods
|
41
|
+
doc = Dozuki::XML(string_or_io, ...)
|
42
|
+
html = Dozuki::HTML(string_or_io, ...)
|
43
|
+
|
35
44
|
|
36
45
|
This documents supports the Dozuki extensions for:
|
37
46
|
|
data/lib/dozuki/html.rb
ADDED
data/lib/dozuki/version.rb
CHANGED
data/lib/dozuki.rb
CHANGED
@@ -4,4 +4,15 @@ require 'dozuki/exceptions'
|
|
4
4
|
require 'dozuki/parsers'
|
5
5
|
require 'dozuki/node'
|
6
6
|
require 'dozuki/node_collection'
|
7
|
+
|
7
8
|
require 'dozuki/xml'
|
9
|
+
require 'dozuki/html'
|
10
|
+
|
11
|
+
module Dozuki
|
12
|
+
def self.HTML(*args)
|
13
|
+
HTML.parse(*args)
|
14
|
+
end
|
15
|
+
def self.XML(*args)
|
16
|
+
XML.parse(*args)
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Dozuki do
|
4
|
+
describe "HTML()" do
|
5
|
+
let(:args){[1,2,3]}
|
6
|
+
subject{ Dozuki::HTML(*args)}
|
7
|
+
it "should proxy to the parse method" do
|
8
|
+
node = mock(:node)
|
9
|
+
Dozuki::HTML.should_receive(:parse).with(*args).and_return(node)
|
10
|
+
subject.should == node
|
11
|
+
end
|
12
|
+
end
|
13
|
+
describe "XML()" do
|
14
|
+
let(:args){[1,2,3]}
|
15
|
+
subject{ Dozuki::XML(*args)}
|
16
|
+
it "should proxy to the parse method" do
|
17
|
+
node = mock(:node)
|
18
|
+
Dozuki::XML.should_receive(:parse).with(*args).and_return(node)
|
19
|
+
subject.should == node
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Dozuki
|
4
|
+
describe HTML do
|
5
|
+
describe '.parse' do
|
6
|
+
|
7
|
+
let(:args){["xml", :other, :args]}
|
8
|
+
let(:nokogiri_node) {mock "nokogiri node"}
|
9
|
+
let(:dozuki_html_node) {mock "dozuki html node"}
|
10
|
+
|
11
|
+
before(:each) do
|
12
|
+
Nokogiri::HTML.stub(:parse).and_return(nokogiri_node)
|
13
|
+
Node.stub(:new).and_return(dozuki_html_node)
|
14
|
+
end
|
15
|
+
|
16
|
+
subject{HTML.parse(*args)}
|
17
|
+
|
18
|
+
it "should parse the HTML using nokogiri" do
|
19
|
+
Nokogiri::HTML.should_receive(:parse).with(*args).and_return(nokogiri_node)
|
20
|
+
subject
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should create a new Node with the nokogiri doc" do
|
24
|
+
Node.should_receive(:new).with(nokogiri_node).and_return(dozuki_html_node)
|
25
|
+
subject
|
26
|
+
end
|
27
|
+
|
28
|
+
it {should == dozuki_html_node}
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: dozuki
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 0.2.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- James Almond
|
@@ -111,11 +111,14 @@ files:
|
|
111
111
|
- features/support/env.rb
|
112
112
|
- lib/dozuki.rb
|
113
113
|
- lib/dozuki/exceptions.rb
|
114
|
+
- lib/dozuki/html.rb
|
114
115
|
- lib/dozuki/node.rb
|
115
116
|
- lib/dozuki/node_collection.rb
|
116
117
|
- lib/dozuki/parsers.rb
|
117
118
|
- lib/dozuki/version.rb
|
118
119
|
- lib/dozuki/xml.rb
|
120
|
+
- spec/dozuki/dozuki_spec.rb
|
121
|
+
- spec/dozuki/html_spec.rb
|
119
122
|
- spec/dozuki/node_collection_spec.rb
|
120
123
|
- spec/dozuki/node_spec.rb
|
121
124
|
- spec/dozuki/parsers_spec.rb
|
@@ -162,6 +165,8 @@ test_files:
|
|
162
165
|
- features/steps/xml_steps.rb
|
163
166
|
- features/string_accessor.feature
|
164
167
|
- features/support/env.rb
|
168
|
+
- spec/dozuki/dozuki_spec.rb
|
169
|
+
- spec/dozuki/html_spec.rb
|
165
170
|
- spec/dozuki/node_collection_spec.rb
|
166
171
|
- spec/dozuki/node_spec.rb
|
167
172
|
- spec/dozuki/parsers_spec.rb
|