webpage 0.0.7 → 0.0.8
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/lib/webpage.rb +3 -0
- data/spec/webpage_spec.rb +3 -0
- data/webpage.gemspec +1 -1
- metadata +1 -1
data/lib/webpage.rb
CHANGED
@@ -37,6 +37,9 @@ class Webpage
|
|
37
37
|
def nodes_with(key)
|
38
38
|
@nokogiri.xpath("//@#{key}")
|
39
39
|
end
|
40
|
+
def xpath(xstring)
|
41
|
+
@nokogiri.xpath(xstring)
|
42
|
+
end
|
40
43
|
|
41
44
|
def keywords
|
42
45
|
@keywords ||= @nokogiri.xpath("//meta[@name='keywords']").map{|meta|meta['content']}.flatten.join.split(',')
|
data/spec/webpage_spec.rb
CHANGED
@@ -38,6 +38,9 @@ describe Webpage do
|
|
38
38
|
it "nodes_with should return an array with elements Nokogiri::XML::NodeSet" do
|
39
39
|
page.nodes_with('id').class.should == Nokogiri::XML::NodeSet
|
40
40
|
end
|
41
|
+
it "xpath should return an array with elements Nokogiri::XML::NodeSet" do
|
42
|
+
page.xpath('//id').class.should == Nokogiri::XML::NodeSet
|
43
|
+
end
|
41
44
|
it "links' elements should be Webpage::Link" do
|
42
45
|
page.links.each do |link|
|
43
46
|
link.class.should == Nokogiri::XML::Element
|
data/webpage.gemspec
CHANGED