ideaoforder-www-delicious 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. data/CHANGELOG.rdoc +46 -0
  2. data/Manifest +49 -0
  3. data/README.rdoc +209 -0
  4. data/Rakefile +55 -0
  5. data/lib/www/delicious/bundle.rb +73 -0
  6. data/lib/www/delicious/element.rb +73 -0
  7. data/lib/www/delicious/errors.rb +46 -0
  8. data/lib/www/delicious/post.rb +123 -0
  9. data/lib/www/delicious/tag.rb +101 -0
  10. data/lib/www/delicious/version.rb +29 -0
  11. data/lib/www/delicious.rb +949 -0
  12. data/setup.rb +1585 -0
  13. data/test/fixtures/net_response_invalid_account.yml +25 -0
  14. data/test/fixtures/net_response_success.yml +23 -0
  15. data/test/helper.rb +49 -0
  16. data/test/test_all.rb +18 -0
  17. data/test/test_offline.rb +18 -0
  18. data/test/test_online.rb +20 -0
  19. data/test/testcases/element/bundle.xml +1 -0
  20. data/test/testcases/element/invalid_root.xml +2 -0
  21. data/test/testcases/element/post.xml +2 -0
  22. data/test/testcases/element/post_unshared.xml +2 -0
  23. data/test/testcases/element/tag.xml +1 -0
  24. data/test/testcases/response/bundles_all.xml +5 -0
  25. data/test/testcases/response/bundles_all_empty.xml +2 -0
  26. data/test/testcases/response/bundles_delete.xml +2 -0
  27. data/test/testcases/response/bundles_set.xml +2 -0
  28. data/test/testcases/response/bundles_set_error.xml +2 -0
  29. data/test/testcases/response/posts_add.xml +2 -0
  30. data/test/testcases/response/posts_all.xml +12 -0
  31. data/test/testcases/response/posts_dates.xml +14 -0
  32. data/test/testcases/response/posts_dates_with_tag.xml +14 -0
  33. data/test/testcases/response/posts_delete.xml +2 -0
  34. data/test/testcases/response/posts_get.xml +7 -0
  35. data/test/testcases/response/posts_get_with_tag.xml +6 -0
  36. data/test/testcases/response/posts_recent.xml +19 -0
  37. data/test/testcases/response/posts_recent_with_tag.xml +19 -0
  38. data/test/testcases/response/tags_get.xml +5 -0
  39. data/test/testcases/response/tags_get_empty.xml +2 -0
  40. data/test/testcases/response/tags_rename.xml +2 -0
  41. data/test/testcases/response/update.delicious1.xml +2 -0
  42. data/test/testcases/response/update.xml +3 -0
  43. data/test/unit/bundle_test.rb +63 -0
  44. data/test/unit/delicious_test.rb +369 -0
  45. data/test/unit/online/online_test.rb +148 -0
  46. data/test/unit/post_test.rb +68 -0
  47. data/test/unit/tag_test.rb +69 -0
  48. data/www-delicious.gemspec +146 -0
  49. metadata +143 -0
@@ -0,0 +1,101 @@
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
+ # SVN: $Id$
14
+ #++
15
+
16
+
17
+ require 'www/delicious/element'
18
+
19
+
20
+ module WWW
21
+ class Delicious
22
+
23
+ #
24
+ # = Delicious Tag
25
+ #
26
+ # Represents a single Tag element.
27
+ #
28
+ class Tag < Element
29
+
30
+ # The name of the tag.
31
+ attr_accessor :name
32
+
33
+ # The number of links tagged with this tag.
34
+ # It should be set only from an API response.
35
+ attr_accessor :count
36
+
37
+
38
+ # Returns value for <tt>name</tt> attribute.
39
+ # Value is always normalized as lower string.
40
+ def name
41
+ @name.to_s.strip unless @name.nil?
42
+ end
43
+
44
+ # Returns value for <tt>count</tt> attribute.
45
+ # Value is always normalized to Fixnum.
46
+ def count
47
+ @count.to_i
48
+ end
49
+
50
+ #
51
+ # Returns a string representation of this Tag.
52
+ # In case name is nil this method will return an empty string.
53
+ #
54
+ def to_s
55
+ name.to_s
56
+ end
57
+
58
+
59
+ public
60
+ #
61
+ # Returns wheter this object is valid for an API request.
62
+ #
63
+ # To be valid +name+ must not be empty.
64
+ # +count+ can be 0.
65
+ #
66
+ # === Examples
67
+ #
68
+ # tag = WWW::Delicious::Tag.new(:name => 'foo')
69
+ # tag.api_api_valid?
70
+ # # => true
71
+ #
72
+ # tag = WWW::Delicious::Tag.new(:name => ' ')
73
+ # tag.api_api_valid?
74
+ # # => false
75
+ #
76
+ def api_valid?
77
+ return !name.empty?
78
+ end
79
+
80
+
81
+ class << self
82
+
83
+ #
84
+ # Creates and returns new instance from a REXML +element+.
85
+ #
86
+ # Implements Element#from_rexml.
87
+ #
88
+ def from_rexml(element)
89
+ raise ArgumentError, "`element` expected to be a `REXML::Element`" unless element.kind_of? REXML::Element
90
+ self.new do |instance|
91
+ instance.name = element.if_attribute_value(:tag)
92
+ instance.count = element.if_attribute_value(:count) { |value| value.to_i }
93
+ end
94
+ end
95
+
96
+ end
97
+
98
+ end
99
+
100
+ end
101
+ end
@@ -0,0 +1,29 @@
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
+ # SVN: $Id$
14
+ #++
15
+
16
+
17
+ module WWW
18
+ class Delicious
19
+
20
+ module Version
21
+ MAJOR = 0
22
+ MINOR = 2
23
+ TINY = 0
24
+
25
+ STRING = [MAJOR, MINOR, TINY].join('.')
26
+ end
27
+
28
+ end
29
+ end