xbel 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/nokogiri/decorators/xbel/folder.rb +22 -11
- data/test/test_xbel.rb +3 -2
- data/xbel.gemspec +2 -2
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.3
|
@@ -34,27 +34,31 @@ module Nokogiri::Decorators::XBEL
|
|
34
34
|
super
|
35
35
|
end
|
36
36
|
|
37
|
+
def build(type, attributes = {}, &block)
|
38
|
+
child = Nokogiri::XML::Node.new(type.to_s, document)
|
39
|
+
assign_to child, attributes, &block
|
40
|
+
|
41
|
+
add_child child
|
42
|
+
end
|
43
|
+
|
37
44
|
# Builds a bookmark with given attributes and add it.
|
38
45
|
def build_bookmark(title, href, attributes = {}, &block)
|
39
|
-
|
40
|
-
|
46
|
+
build :bookmark,
|
47
|
+
attributes.merge(:title => title, :href => href),
|
41
48
|
&block
|
42
|
-
|
43
|
-
add_child node
|
44
49
|
end
|
45
50
|
# Builds a folder with given attributes and add it.
|
46
51
|
def build_folder(title, attributes = {}, &block)
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
add_child node
|
52
|
+
build :folder,
|
53
|
+
attributes.merge(:title => title),
|
54
|
+
&block
|
51
55
|
end
|
52
56
|
# Builds an alias with given attributes and add it.
|
53
57
|
def build_alias(ref)
|
54
|
-
|
55
|
-
|
58
|
+
child = Nokogiri::XML::Node.new('alias', document)
|
59
|
+
child.ref = (Entry === ref) ? ref.id : ref.to_s
|
56
60
|
|
57
|
-
add_child
|
61
|
+
add_child child
|
58
62
|
end
|
59
63
|
# Builds a saperator with given attributes and add it.
|
60
64
|
def add_separator
|
@@ -64,9 +68,16 @@ module Nokogiri::Decorators::XBEL
|
|
64
68
|
protected
|
65
69
|
|
66
70
|
def assign_to(node, attributes) #:nodoc:
|
71
|
+
attributes[:id] ||= "#{ id }." << xpath('./bookmark | ./folder').
|
72
|
+
inject(0) { |next_id, child|
|
73
|
+
succ_num_id = child.id[/(\d+)$/, 1].to_i.succ
|
74
|
+
succ_num_id > next_id ? succ_num_id : next_id
|
75
|
+
}.to_s
|
76
|
+
|
67
77
|
attributes.each do |key, value|
|
68
78
|
node.send "#{ key }=", value
|
69
79
|
end
|
80
|
+
|
70
81
|
yield node if block_given?
|
71
82
|
end
|
72
83
|
|
data/test/test_xbel.rb
CHANGED
@@ -86,6 +86,7 @@ context 'XBEL' do
|
|
86
86
|
|
87
87
|
asserts('added') { topic.added }.equals Date.today
|
88
88
|
asserts('title') { topic.title }.equals 'boof\'s xbel'
|
89
|
+
asserts('next id') { topic.id }.equals 'f0.2'
|
89
90
|
asserts('href') { topic.href }.
|
90
91
|
equals 'http://www.github.com/boof/xbel'
|
91
92
|
asserts('description') { topic.description }.
|
@@ -93,12 +94,12 @@ context 'XBEL' do
|
|
93
94
|
end
|
94
95
|
|
95
96
|
context 'new Folder' do
|
96
|
-
setup { topic.build_folder 'sub', :
|
97
|
+
setup { topic.build_folder 'sub', :desc => 'desc' }
|
97
98
|
should('be a folder') { topic.folder? }
|
98
99
|
|
99
100
|
asserts('added') { topic.added }.equals Date.today
|
100
101
|
asserts('title') { topic.title }.equals 'sub'
|
101
|
-
asserts('id') { topic.id }.equals '
|
102
|
+
asserts('next id') { topic.id }.equals 'f0.2'
|
102
103
|
asserts('desc') { topic.desc }.equals 'desc'
|
103
104
|
end
|
104
105
|
|
data/xbel.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{xbel}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Florian A\303\237mann"]
|
12
|
-
s.date = %q{2009-11-
|
12
|
+
s.date = %q{2009-11-16}
|
13
13
|
s.description = %q{}
|
14
14
|
s.email = %q{florian.assmann@email.de}
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xbel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "Florian A\xC3\x9Fmann"
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-11-
|
12
|
+
date: 2009-11-16 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|