julienXX-www-delicious 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +61 -0
- data/LICENSE.rdoc +25 -0
- data/Manifest +46 -0
- data/README.rdoc +201 -0
- data/Rakefile +57 -0
- data/lib/www/delicious/bundle.rb +73 -0
- data/lib/www/delicious/element.rb +73 -0
- data/lib/www/delicious/errors.rb +46 -0
- data/lib/www/delicious/post.rb +123 -0
- data/lib/www/delicious/tag.rb +101 -0
- data/lib/www/delicious/version.rb +33 -0
- data/lib/www/delicious.rb +941 -0
- data/setup.rb +1585 -0
- data/test/bundle_test.rb +63 -0
- data/test/delicious_test.rb +372 -0
- data/test/fixtures/net_response_invalid_account.yml +25 -0
- data/test/fixtures/net_response_success.yml +23 -0
- data/test/online_test.rb +147 -0
- data/test/post_test.rb +68 -0
- data/test/tag_test.rb +69 -0
- data/test/test_all.rb +19 -0
- data/test/test_helper.rb +43 -0
- data/test/testcases/element/bundle.xml +1 -0
- data/test/testcases/element/invalid_root.xml +2 -0
- data/test/testcases/element/post.xml +2 -0
- data/test/testcases/element/post_unshared.xml +2 -0
- data/test/testcases/element/tag.xml +1 -0
- data/test/testcases/response/bundles_all.xml +5 -0
- data/test/testcases/response/bundles_all_empty.xml +2 -0
- data/test/testcases/response/bundles_delete.xml +2 -0
- data/test/testcases/response/bundles_set.xml +2 -0
- data/test/testcases/response/bundles_set_error.xml +2 -0
- data/test/testcases/response/posts_add.xml +2 -0
- data/test/testcases/response/posts_all.xml +12 -0
- data/test/testcases/response/posts_dates.xml +14 -0
- data/test/testcases/response/posts_dates_with_tag.xml +14 -0
- data/test/testcases/response/posts_delete.xml +2 -0
- data/test/testcases/response/posts_get.xml +7 -0
- data/test/testcases/response/posts_get_with_tag.xml +6 -0
- data/test/testcases/response/posts_recent.xml +19 -0
- data/test/testcases/response/posts_recent_with_tag.xml +19 -0
- data/test/testcases/response/tags_get.xml +5 -0
- data/test/testcases/response/tags_get_empty.xml +2 -0
- data/test/testcases/response/tags_rename.xml +2 -0
- data/test/testcases/response/update.delicious1.xml +2 -0
- data/test/testcases/response/update.xml +3 -0
- data/www-delicious.gemspec +44 -0
- metadata +151 -0
data/CHANGELOG.rdoc
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
= Changelog
|
2
|
+
|
3
|
+
|
4
|
+
== julienXX
|
5
|
+
|
6
|
+
* FIXED: tags are now written in del.icio.us
|
7
|
+
|
8
|
+
== master
|
9
|
+
|
10
|
+
* FIXED: A trivial bug causes the test `test_request_waits_necessary_time_between_requests` to fail in case the subsequent request is sent exactly 1 second after the prior one.
|
11
|
+
|
12
|
+
* FIXED: Object#blank? is always redefined regardless already defined before.
|
13
|
+
|
14
|
+
|
15
|
+
== Release 0.3.0
|
16
|
+
|
17
|
+
* FIXED: Compatibility fixes for Ruby 1.9. WWW::Delicious is now 100% compatible with 1.9. You should remember to define the proper content encoding with magic comments when working with UTF-8/MultiByte XML or Ruby files, see http://redmine.ruby-lang.org/wiki/ruby-19/ScriptEncoding (closes #142).
|
18
|
+
|
19
|
+
* FIXED: Forced Rakefile to require Echoe >= 3.1 to prevent outdated .gemspec files (closes #143).
|
20
|
+
|
21
|
+
* CHANGED: Don't use File.dirname(__FILE__) in require statement to prevent recursive inclusions.
|
22
|
+
|
23
|
+
|
24
|
+
== Release 0.2.0
|
25
|
+
|
26
|
+
* ADDED: :base_uri initialization option allows to create a new instance specifying a custom base_uri for all API calls. This is useful, for example, if you want to use ma.gno.lia Mirror'd APIs (http://wiki.ma.gnolia.com/Mirror%27d_API) instead the del.icio.us one (thanks to Jörg Battermann).
|
27
|
+
|
28
|
+
* ADDED: two new REXML::Element core extension elements to enhance interaction with node elements.
|
29
|
+
|
30
|
+
* FIXED: a wrong indentation in README file causes all list items to be rendered as source code.
|
31
|
+
|
32
|
+
* FIXED: Missing WWW::Delicious::Bundle#to_s method causes a class ID representation to be returned.
|
33
|
+
|
34
|
+
* FIXED: Missing unit tests for post_ calls (closes #18).
|
35
|
+
|
36
|
+
* FIXED: Added test for `shared` Post attribute and fixed an issue with duplicate `replace` method definition (closes #11).
|
37
|
+
|
38
|
+
* CHANGED: improved documentation and added more examples (closes #21).
|
39
|
+
|
40
|
+
* CHANGED: REXML::Element#attribute_value core extension has been renamed to REXML::Element#if_attribute_value.
|
41
|
+
|
42
|
+
* CHANGED: Renamed TESTCASE_PATH to TESTCASES_PATH.
|
43
|
+
|
44
|
+
* CHANGED: WWW::Delicious::Tag, WWW::Delicious::Bundle, WWW::Delicious::Post now extend WWW::Delicious::Element. Simplified classes.
|
45
|
+
|
46
|
+
* CHANGED: WWW::Delicious::Tag#to_s always returns a string even if name is nil.
|
47
|
+
|
48
|
+
* CHANGED: WWW::Delicious::Tag :count attribute is now stored and returned as Fixnum instead of String.
|
49
|
+
|
50
|
+
* CHANGED: Unit test reorganization (closes #22).
|
51
|
+
|
52
|
+
* CHANGED: Simplified and tidyfied test system with Mocha (closes #19).
|
53
|
+
|
54
|
+
* CHANGED: Various internal API methods have been renamed for coherence with their new scope.
|
55
|
+
|
56
|
+
* CHANGED: Integrated Echoe, cleaned Rakefile (closes #23).
|
57
|
+
|
58
|
+
|
59
|
+
== Release 0.1.0 (2008-05-11)
|
60
|
+
|
61
|
+
* Initial public release.
|
data/LICENSE.rdoc
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
= License
|
2
|
+
|
3
|
+
(The MIT License)
|
4
|
+
|
5
|
+
Copyright (c) 2008-2009 Simone Carletti <weppos@weppos.net>
|
6
|
+
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
8
|
+
a copy of this software and associated documentation files (the
|
9
|
+
"Software"), to deal in the Software without restriction, including
|
10
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
11
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
12
|
+
permit persons to whom the Software is furnished to do so, subject to
|
13
|
+
the following conditions:
|
14
|
+
|
15
|
+
The above copyright notice and this permission notice shall be
|
16
|
+
included in all copies or substantial portions of the Software.
|
17
|
+
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
19
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
20
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
21
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
22
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
23
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
24
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
25
|
+
|
data/Manifest
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
CHANGELOG.rdoc
|
2
|
+
lib/www/delicious/bundle.rb
|
3
|
+
lib/www/delicious/element.rb
|
4
|
+
lib/www/delicious/errors.rb
|
5
|
+
lib/www/delicious/post.rb
|
6
|
+
lib/www/delicious/tag.rb
|
7
|
+
lib/www/delicious/version.rb
|
8
|
+
lib/www/delicious.rb
|
9
|
+
LICENSE.rdoc
|
10
|
+
Rakefile
|
11
|
+
README.rdoc
|
12
|
+
setup.rb
|
13
|
+
test/bundle_test.rb
|
14
|
+
test/delicious_test.rb
|
15
|
+
test/fixtures/net_response_invalid_account.yml
|
16
|
+
test/fixtures/net_response_success.yml
|
17
|
+
test/online_test.rb
|
18
|
+
test/post_test.rb
|
19
|
+
test/tag_test.rb
|
20
|
+
test/test_all.rb
|
21
|
+
test/test_helper.rb
|
22
|
+
test/testcases/element/bundle.xml
|
23
|
+
test/testcases/element/invalid_root.xml
|
24
|
+
test/testcases/element/post.xml
|
25
|
+
test/testcases/element/post_unshared.xml
|
26
|
+
test/testcases/element/tag.xml
|
27
|
+
test/testcases/response/bundles_all.xml
|
28
|
+
test/testcases/response/bundles_all_empty.xml
|
29
|
+
test/testcases/response/bundles_delete.xml
|
30
|
+
test/testcases/response/bundles_set.xml
|
31
|
+
test/testcases/response/bundles_set_error.xml
|
32
|
+
test/testcases/response/posts_add.xml
|
33
|
+
test/testcases/response/posts_all.xml
|
34
|
+
test/testcases/response/posts_dates.xml
|
35
|
+
test/testcases/response/posts_dates_with_tag.xml
|
36
|
+
test/testcases/response/posts_delete.xml
|
37
|
+
test/testcases/response/posts_get.xml
|
38
|
+
test/testcases/response/posts_get_with_tag.xml
|
39
|
+
test/testcases/response/posts_recent.xml
|
40
|
+
test/testcases/response/posts_recent_with_tag.xml
|
41
|
+
test/testcases/response/tags_get.xml
|
42
|
+
test/testcases/response/tags_get_empty.xml
|
43
|
+
test/testcases/response/tags_rename.xml
|
44
|
+
test/testcases/response/update.delicious1.xml
|
45
|
+
test/testcases/response/update.xml
|
46
|
+
Manifest
|
data/README.rdoc
ADDED
@@ -0,0 +1,201 @@
|
|
1
|
+
= WWW::Delicious
|
2
|
+
|
3
|
+
WWW::Delicious is a Ruby client for http://del.icio.us XML API.
|
4
|
+
|
5
|
+
It provides both read and write functionality. You can read user Posts, Tags
|
6
|
+
and Bundles but you can create new Posts, Tags and Bundles as well.
|
7
|
+
|
8
|
+
|
9
|
+
== Overview
|
10
|
+
|
11
|
+
WWW::Delicious maps all the original del.icio.us API calls and provides some
|
12
|
+
additional convenient methods to perform common tasks.
|
13
|
+
Please read the official documentation (http://del.icio.us/help/api/)
|
14
|
+
to learn more about del.icio.us API.
|
15
|
+
|
16
|
+
WWW::Delicious is 100% compatible with all del.icio.us API constraints,
|
17
|
+
including the requirement to set a valid user agent or wait at least
|
18
|
+
one second between queries.
|
19
|
+
Basically, the main benefit from using this library is that you don't need
|
20
|
+
to take care of all these low level details, if you don't want:
|
21
|
+
WWW::Delicious will try to give you the most with less efforts.
|
22
|
+
|
23
|
+
|
24
|
+
== Dependencies
|
25
|
+
|
26
|
+
* Ruby >= 1.8.6 (not tested with previous versions)
|
27
|
+
|
28
|
+
As of release 0.3.0, WWW::Delicious is compatible with Ruby 1.9.1.
|
29
|
+
|
30
|
+
|
31
|
+
== Download and Installation
|
32
|
+
|
33
|
+
RubyGems[http://rubyforge.org/projects/rubygems/] is the preferred install method.
|
34
|
+
To get the latest version, simply type the following instruction into your command prompt:
|
35
|
+
|
36
|
+
$ sudo gem install www-delicious
|
37
|
+
|
38
|
+
Depending on your system, you might need su privileges.
|
39
|
+
|
40
|
+
To install the library manually, downlad the latest version from
|
41
|
+
navigate to the root library directory and enter:
|
42
|
+
|
43
|
+
$ sudo ruby setup.rb
|
44
|
+
|
45
|
+
If you need the latest development version you can download the source code
|
46
|
+
from one of the GIT repositories listed above.
|
47
|
+
Beware that the code might not be as stable as the official release.
|
48
|
+
|
49
|
+
|
50
|
+
== Getting Started
|
51
|
+
|
52
|
+
In order to use this library you need a valid del.icio.us account.
|
53
|
+
Go to http://del.icio.us and register for a new account if you don't already have one.
|
54
|
+
|
55
|
+
Then create a valid instance of WWW::Delicious providing your account credentials.
|
56
|
+
|
57
|
+
require 'www/delicious'
|
58
|
+
|
59
|
+
# create a new instance with given username and password
|
60
|
+
d = WWW::Delicious.new('username', 'password')
|
61
|
+
|
62
|
+
Now you can use your instance to interact with the API interface.
|
63
|
+
|
64
|
+
|
65
|
+
=== Last account update
|
66
|
+
|
67
|
+
The following example show you how to get the last account update Time.
|
68
|
+
|
69
|
+
require 'www/delicious'
|
70
|
+
d = WWW::Delicious.new('username', 'password')
|
71
|
+
|
72
|
+
time = d.update # => Fri May 02 18:02:48 UTC 2008
|
73
|
+
|
74
|
+
|
75
|
+
=== Reading Posts
|
76
|
+
|
77
|
+
You can fetch your posts in 3 different ways:
|
78
|
+
|
79
|
+
require 'www/delicious'
|
80
|
+
d = WWW::Delicious.new('username', 'password')
|
81
|
+
|
82
|
+
# 1. get all posts
|
83
|
+
posts = d.posts_all
|
84
|
+
|
85
|
+
# 2. get recent posts
|
86
|
+
posts = d.posts_recent
|
87
|
+
|
88
|
+
# 3. get a single post (the latest one if no criteria is given)
|
89
|
+
posts = d.posts_get(:tag => 'ruby')
|
90
|
+
|
91
|
+
Each post call accepts some options to refine your search.
|
92
|
+
For example, you can always search for posts matching a specific tag.
|
93
|
+
|
94
|
+
posts = d.posts_all(:tag => 'ruby')
|
95
|
+
posts = d.posts_recent(:tag => 'ruby')
|
96
|
+
posts = d.posts_get(:tag => 'ruby')
|
97
|
+
|
98
|
+
|
99
|
+
=== Creating a new Post
|
100
|
+
|
101
|
+
require 'www/delicious'
|
102
|
+
d = WWW::Delicious.new('username', 'password')
|
103
|
+
|
104
|
+
# add a post from options
|
105
|
+
d.posts_add(:url => 'http://www.simonecarletti.com/', :title => 'Cool site!')
|
106
|
+
|
107
|
+
# add a post from WWW::Delicious::Post
|
108
|
+
d.posts_add(WWW::Delicious::Post.new(:url => 'http://www.simonecarletti.com/', :title => 'Cool site!'))
|
109
|
+
|
110
|
+
|
111
|
+
=== Deleting a Posts
|
112
|
+
|
113
|
+
require 'www/delicious'
|
114
|
+
d = WWW::Delicious.new('username', 'password')
|
115
|
+
|
116
|
+
# delete given post (the URL can be either a string or an URI)
|
117
|
+
d.posts_delete('http://www.foobar.com/')
|
118
|
+
|
119
|
+
Note. Actually you cannot delete a post from a WWW::Delicious::Post instance.
|
120
|
+
It means, the following example doesn't work as some ActiveRecord user might expect.
|
121
|
+
|
122
|
+
post = WWW::Delicious::Post.new(:url => 'http://www.foobar.com/')
|
123
|
+
post.delete
|
124
|
+
|
125
|
+
This feature is already in the TODO list. For now, use the following workaround
|
126
|
+
to delete a given Post.
|
127
|
+
|
128
|
+
# delete a post from an existing post = WWW::Delicious::Post
|
129
|
+
d.posts_delete(post.url)
|
130
|
+
|
131
|
+
|
132
|
+
=== Tags
|
133
|
+
|
134
|
+
Working with tags it's really easy. You can get all your tags or rename an existing tag.
|
135
|
+
|
136
|
+
require 'www/delicious'
|
137
|
+
d = WWW::Delicious.new('username', 'password')
|
138
|
+
|
139
|
+
# get all tags
|
140
|
+
tags = d.tags_get
|
141
|
+
|
142
|
+
# print all tag names
|
143
|
+
tags.each { |t| puts t.name }
|
144
|
+
|
145
|
+
# rename the tag gems to gem
|
146
|
+
d.tags_rename('gems', 'gem')
|
147
|
+
|
148
|
+
|
149
|
+
=== Bundles
|
150
|
+
|
151
|
+
WWW::Delicious enables you to get all bundles from given account.
|
152
|
+
|
153
|
+
require 'www/delicious'
|
154
|
+
d = WWW::Delicious.new('username', 'password')
|
155
|
+
|
156
|
+
# get all bundles
|
157
|
+
bundles = d.bundles_all
|
158
|
+
|
159
|
+
# print all bundle names
|
160
|
+
bundles.each { |b| puts b.name }
|
161
|
+
|
162
|
+
You can also create new bundles or delete existing ones.
|
163
|
+
|
164
|
+
require 'www/delicious'
|
165
|
+
d = WWW::Delicious.new('username', 'password')
|
166
|
+
|
167
|
+
# set a new bundle for tags ruby, rails and gem
|
168
|
+
d.bundles_set('MyBundle', %w(ruby rails gem))
|
169
|
+
|
170
|
+
# delete the old bundle
|
171
|
+
d.bundles_delete('OldBundle')
|
172
|
+
|
173
|
+
|
174
|
+
== Credits
|
175
|
+
|
176
|
+
Author:: {Simone Carletti}[http://www.simonecarletti.com/] <weppos@weppos.net>
|
177
|
+
|
178
|
+
|
179
|
+
== Resources
|
180
|
+
|
181
|
+
* {Homepage}[http://code.simonecarletti.com/www-delicious]
|
182
|
+
* {API}[http://www-delicious.rubyforge.org/]
|
183
|
+
* {GitHub}[http://github.com/weppos/www-delicious/]
|
184
|
+
* {RubyForge}[http://rubyforge.org/projects/www-delicious/]
|
185
|
+
|
186
|
+
|
187
|
+
== FeedBack and Bug reports
|
188
|
+
|
189
|
+
Feel free to email {Simone Carletti}[mailto:weppos@weppos.net] with any questions or feedback.
|
190
|
+
Please use the {Ticket System}[http://code.simonecarletti.com/projects/show/www-delicious] to submit bug reports or feature request.
|
191
|
+
|
192
|
+
|
193
|
+
== Changelog
|
194
|
+
|
195
|
+
See the CHANGELOG.rdoc file for details.
|
196
|
+
|
197
|
+
|
198
|
+
== License
|
199
|
+
|
200
|
+
Copyright (c) 2008-2009 Simone Carletti, WWW::Delicious is released under the MIT license.
|
201
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
gem 'echoe', '>= 3.1'
|
5
|
+
require 'echoe'
|
6
|
+
|
7
|
+
$:.unshift(File.dirname(__FILE__) + "/lib")
|
8
|
+
require 'www/delicious'
|
9
|
+
|
10
|
+
|
11
|
+
# Common package properties
|
12
|
+
PKG_NAME = ENV['PKG_NAME'] || WWW::Delicious::GEM
|
13
|
+
PKG_VERSION = ENV['PKG_VERSION'] || WWW::Delicious::VERSION
|
14
|
+
PKG_SUMMARY = "Ruby client for del.icio.us API."
|
15
|
+
PKG_FILES = FileList.new("{lib,test}/**/*.rb") do |files|
|
16
|
+
files.include %w(README.rdoc CHANGELOG.rdoc LICENSE.rdoc)
|
17
|
+
files.include %w(Rakefile setup.rb)
|
18
|
+
end
|
19
|
+
RUBYFORGE_PROJECT = 'www-delicious'
|
20
|
+
|
21
|
+
if ENV['SNAPSHOT'].to_i == 1
|
22
|
+
PKG_VERSION << "." << Time.now.utc.strftime("%Y%m%d%H%M%S")
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
Echoe.new(PKG_NAME, PKG_VERSION) do |p|
|
27
|
+
p.author = "Simone Carletti"
|
28
|
+
p.email = "weppos@weppos.net"
|
29
|
+
p.summary = PKG_SUMMARY
|
30
|
+
p.description = <<-EOD
|
31
|
+
WWW::Delicious is a del.icio.us API client implemented in Ruby. \
|
32
|
+
It provides access to all available del.icio.us API queries \
|
33
|
+
and returns the original XML response as a friendly Ruby object.
|
34
|
+
EOD
|
35
|
+
p.url = "http://code.simonecarletti.com/www-delicious"
|
36
|
+
p.project = RUBYFORGE_PROJECT
|
37
|
+
|
38
|
+
p.need_zip = true
|
39
|
+
p.rcov_options = ["--main << README.rdoc -x Rakefile -x mocha -x rcov"]
|
40
|
+
p.rdoc_pattern = /^(lib|CHANGELOG.rdoc|README.rdoc)/
|
41
|
+
|
42
|
+
p.development_dependencies += ["rake >=0.8",
|
43
|
+
"echoe >=3.1",
|
44
|
+
"mocha >=0.9"]
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
begin
|
49
|
+
require 'code_statistics'
|
50
|
+
desc "Show library's code statistics"
|
51
|
+
task :stats do
|
52
|
+
CodeStatistics.new(["WWW::Delicious", "lib"],
|
53
|
+
["Tests", "test"]).to_s
|
54
|
+
end
|
55
|
+
rescue LoadError
|
56
|
+
puts "CodeStatistics (Rails) is not available"
|
57
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
#
|
2
|
+
# = WWW::Delicious
|
3
|
+
#
|
4
|
+
# Ruby client for del.icio.us API.
|
5
|
+
#
|
6
|
+
#
|
7
|
+
# Category:: WWW
|
8
|
+
# Package:: WWW::Delicious
|
9
|
+
# Author:: Simone Carletti <weppos@weppos.net>
|
10
|
+
# License:: MIT License
|
11
|
+
#
|
12
|
+
#--
|
13
|
+
#
|
14
|
+
#++
|
15
|
+
|
16
|
+
|
17
|
+
require 'www/delicious/element'
|
18
|
+
|
19
|
+
|
20
|
+
module WWW
|
21
|
+
class Delicious
|
22
|
+
|
23
|
+
#
|
24
|
+
# = Delicious Bundle
|
25
|
+
#
|
26
|
+
# Represents a single Bundle element.
|
27
|
+
#
|
28
|
+
class Bundle < Element
|
29
|
+
|
30
|
+
# The name of the bundle.
|
31
|
+
attr_accessor :name
|
32
|
+
|
33
|
+
# The collection of <tt>WWW::Delicious::Tags</tt>.
|
34
|
+
attr_accessor :tags
|
35
|
+
|
36
|
+
|
37
|
+
# Returns value for <tt>name</tt> attribute.
|
38
|
+
# Value is always normalized as lower string.
|
39
|
+
def name
|
40
|
+
@name.to_s.strip unless @name.nil?
|
41
|
+
end
|
42
|
+
|
43
|
+
#
|
44
|
+
# Returns a string representation of this Bundle.
|
45
|
+
# In case name is nil this method will return an empty string.
|
46
|
+
#
|
47
|
+
def to_s
|
48
|
+
name.to_s
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
class << self
|
53
|
+
|
54
|
+
#
|
55
|
+
# Creates and returns new instance from a REXML +element+.
|
56
|
+
#
|
57
|
+
# Implements Element#from_rexml.
|
58
|
+
#
|
59
|
+
def from_rexml(element)
|
60
|
+
raise ArgumentError, "`element` expected to be a `REXML::Element`" unless element.kind_of? REXML::Element
|
61
|
+
self.new do |instance|
|
62
|
+
instance.name = element.if_attribute_value(:name)
|
63
|
+
# FIXME: value must be converted to array of Tag
|
64
|
+
instance.tags = element.if_attribute_value(:tags) { |value| value.split(' ') }
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
end
|