xfn_stone 0.0.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/History.txt +5 -0
- data/Manifest.txt +9 -0
- data/README.txt +52 -0
- data/Rakefile +17 -0
- data/lib/xfn_stone/document.rb +14 -0
- data/lib/xfn_stone/person.rb +17 -0
- data/lib/xfn_stone.rb +12 -0
- data/spec/person.rb +30 -0
- data/spec/spec_helper.rb +3 -0
- metadata +72 -0
data/History.txt
ADDED
data/Manifest.txt
ADDED
data/README.txt
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
= xfn_stone
|
|
2
|
+
|
|
3
|
+
* http://rubyforge.org/projects/foafstone/
|
|
4
|
+
|
|
5
|
+
== DESCRIPTION:
|
|
6
|
+
|
|
7
|
+
XfnStone provides helper methods to make simple the processing
|
|
8
|
+
of XML documents that contain HTML with XFN (XHTML Friends Network)
|
|
9
|
+
attributes on its tags.
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
== FEATURES/PROBLEMS:
|
|
13
|
+
|
|
14
|
+
* XFN processing
|
|
15
|
+
|
|
16
|
+
== SYNOPSIS:
|
|
17
|
+
|
|
18
|
+
person = XfnStone::Person.new("http://example.com/myblog")
|
|
19
|
+
person.friends => [ array of Person objects for friends listed on myblog ]
|
|
20
|
+
|
|
21
|
+
== REQUIREMENTS:
|
|
22
|
+
|
|
23
|
+
* REXML
|
|
24
|
+
|
|
25
|
+
== INSTALL:
|
|
26
|
+
|
|
27
|
+
* sudo gem install xfn_friends
|
|
28
|
+
|
|
29
|
+
== LICENSE:
|
|
30
|
+
|
|
31
|
+
(The MIT License)
|
|
32
|
+
|
|
33
|
+
Copyright (c) 2008
|
|
34
|
+
|
|
35
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
36
|
+
a copy of this software and associated documentation files (the
|
|
37
|
+
'Software'), to deal in the Software without restriction, including
|
|
38
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
39
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
40
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
41
|
+
the following conditions:
|
|
42
|
+
|
|
43
|
+
The above copyright notice and this permission notice shall be
|
|
44
|
+
included in all copies or substantial portions of the Software.
|
|
45
|
+
|
|
46
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
47
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
48
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
49
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
50
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
51
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
52
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# -*- ruby -*-
|
|
2
|
+
|
|
3
|
+
require 'rubygems'
|
|
4
|
+
require 'hoe'
|
|
5
|
+
require './lib/xfn_stone.rb'
|
|
6
|
+
|
|
7
|
+
Hoe.new('xfn_stone', XfnStone::VERSION) do |p|
|
|
8
|
+
p.rubyforge_name = 'foafstone'
|
|
9
|
+
p.author = 'Don Park'
|
|
10
|
+
p.email = 'don.park@gmail.com'
|
|
11
|
+
p.summary = 'XHTML Frinds Network helper library'
|
|
12
|
+
p.description = p.paragraphs_of('README.txt', 2..5).join("\n\n")
|
|
13
|
+
p.url = p.paragraphs_of('README.txt', 0).first.split(/\n/)[1..-1]
|
|
14
|
+
p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# vim: syntax=Ruby
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require 'rexml/document'
|
|
2
|
+
|
|
3
|
+
module XfnStone
|
|
4
|
+
# This is an empty subclass of REXML::Document. Substuting a
|
|
5
|
+
# different XML parser in the future will be easier this way.
|
|
6
|
+
# Also a useful spot for future helpers.
|
|
7
|
+
class Document < REXML::Document
|
|
8
|
+
def self.load(uri)
|
|
9
|
+
Document.new(open(uri.to_s))
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
class Element < REXML::Element
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module XfnStone
|
|
2
|
+
class Person
|
|
3
|
+
def initialize(url)
|
|
4
|
+
@uri = URI.parse(url)
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def refresh
|
|
8
|
+
@document = Document.load(@uri)
|
|
9
|
+
@document_root = @document.elements["/"]
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def friends
|
|
13
|
+
@document_root.elements.to_a("//a[@rel=\"friend\"]")
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
data/lib/xfn_stone.rb
ADDED
data/spec/person.rb
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require File.join(File.dirname(__FILE__), *%w[spec_helper])
|
|
2
|
+
require File.join(File.dirname(__FILE__), *%w[../lib/xfn_stone.rb])
|
|
3
|
+
|
|
4
|
+
describe XfnStone::Person do
|
|
5
|
+
it "should take an initial URL" do
|
|
6
|
+
person = XfnStone::Person.new("http://localhost")
|
|
7
|
+
person.is_a?(XfnStone::Person).should be_true
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it "should parse the XML loaded from the inital URL" do
|
|
11
|
+
url = "http://localhost"
|
|
12
|
+
person = XfnStone::Person.new(url)
|
|
13
|
+
XfnStone::Document.should_receive(:load).and_return(XfnStone::Document.new)
|
|
14
|
+
person.refresh
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "should return the friends found in the document" do
|
|
18
|
+
url = "http://localhost"
|
|
19
|
+
person = XfnStone::Person.new(url)
|
|
20
|
+
XfnStone::Document.should_receive(:load).and_return(XfnStone::Document.new("
|
|
21
|
+
<?xml ?>
|
|
22
|
+
<persons>
|
|
23
|
+
<a rel=\"friend\">bob</a>
|
|
24
|
+
<a rel=\"friend\">jane</a>
|
|
25
|
+
</persons>"))
|
|
26
|
+
person.refresh
|
|
27
|
+
person.friends.size.should == 2
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: xfn_stone
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Don Park
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
|
|
12
|
+
date: 2008-02-19 00:00:00 -08:00
|
|
13
|
+
default_executable:
|
|
14
|
+
dependencies:
|
|
15
|
+
- !ruby/object:Gem::Dependency
|
|
16
|
+
name: hoe
|
|
17
|
+
version_requirement:
|
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
19
|
+
requirements:
|
|
20
|
+
- - ">="
|
|
21
|
+
- !ruby/object:Gem::Version
|
|
22
|
+
version: 1.5.0
|
|
23
|
+
version:
|
|
24
|
+
description: "== DESCRIPTION: XfnStone provides helper methods to make simple the processing of XML documents that contain HTML with XFN (XHTML Friends Network) attributes on its tags. == FEATURES/PROBLEMS: * XFN processing"
|
|
25
|
+
email: don.park@gmail.com
|
|
26
|
+
executables: []
|
|
27
|
+
|
|
28
|
+
extensions: []
|
|
29
|
+
|
|
30
|
+
extra_rdoc_files:
|
|
31
|
+
- History.txt
|
|
32
|
+
- Manifest.txt
|
|
33
|
+
- README.txt
|
|
34
|
+
files:
|
|
35
|
+
- History.txt
|
|
36
|
+
- Manifest.txt
|
|
37
|
+
- README.txt
|
|
38
|
+
- Rakefile
|
|
39
|
+
- lib/xfn_stone.rb
|
|
40
|
+
- lib/xfn_stone/document.rb
|
|
41
|
+
- lib/xfn_stone/person.rb
|
|
42
|
+
- spec/person.rb
|
|
43
|
+
- spec/spec_helper.rb
|
|
44
|
+
has_rdoc: true
|
|
45
|
+
homepage:
|
|
46
|
+
post_install_message:
|
|
47
|
+
rdoc_options:
|
|
48
|
+
- --main
|
|
49
|
+
- README.txt
|
|
50
|
+
require_paths:
|
|
51
|
+
- lib
|
|
52
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
53
|
+
requirements:
|
|
54
|
+
- - ">="
|
|
55
|
+
- !ruby/object:Gem::Version
|
|
56
|
+
version: "0"
|
|
57
|
+
version:
|
|
58
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
59
|
+
requirements:
|
|
60
|
+
- - ">="
|
|
61
|
+
- !ruby/object:Gem::Version
|
|
62
|
+
version: "0"
|
|
63
|
+
version:
|
|
64
|
+
requirements: []
|
|
65
|
+
|
|
66
|
+
rubyforge_project: foafstone
|
|
67
|
+
rubygems_version: 1.0.1
|
|
68
|
+
signing_key:
|
|
69
|
+
specification_version: 2
|
|
70
|
+
summary: XHTML Frinds Network helper library
|
|
71
|
+
test_files: []
|
|
72
|
+
|