www-delicious 0.3.0 → 0.4.0

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.
@@ -1,8 +1,8 @@
1
- #
1
+ #
2
2
  # = WWW::Delicious
3
3
  #
4
4
  # Ruby client for del.icio.us API.
5
- #
5
+ #
6
6
  #
7
7
  # Category:: WWW
8
8
  # Package:: WWW::Delicious
@@ -10,7 +10,7 @@
10
10
  # License:: MIT License
11
11
  #
12
12
  #--
13
- # SVN: $Id$
13
+ #
14
14
  #++
15
15
 
16
16
 
@@ -22,24 +22,24 @@ module WWW
22
22
 
23
23
  #
24
24
  # = Delicious Bundle
25
- #
25
+ #
26
26
  # Represents a single Bundle element.
27
27
  #
28
28
  class Bundle < Element
29
-
29
+
30
30
  # The name of the bundle.
31
31
  attr_accessor :name
32
-
32
+
33
33
  # The collection of <tt>WWW::Delicious::Tags</tt>.
34
34
  attr_accessor :tags
35
-
36
-
35
+
36
+
37
37
  # Returns value for <tt>name</tt> attribute.
38
38
  # Value is always normalized as lower string.
39
39
  def name
40
40
  @name.to_s.strip unless @name.nil?
41
41
  end
42
-
42
+
43
43
  #
44
44
  # Returns a string representation of this Bundle.
45
45
  # In case name is nil this method will return an empty string.
@@ -47,15 +47,15 @@ module WWW
47
47
  def to_s
48
48
  name.to_s
49
49
  end
50
-
51
-
50
+
51
+
52
52
  class << self
53
53
 
54
- #
54
+ #
55
55
  # Creates and returns new instance from a REXML +element+.
56
- #
56
+ #
57
57
  # Implements Element#from_rexml.
58
- #
58
+ #
59
59
  def from_rexml(element)
60
60
  raise ArgumentError, "`element` expected to be a `REXML::Element`" unless element.kind_of? REXML::Element
61
61
  self.new do |instance|
@@ -1,8 +1,8 @@
1
- #
1
+ #
2
2
  # = WWW::Delicious
3
3
  #
4
4
  # Ruby client for del.icio.us API.
5
- #
5
+ #
6
6
  #
7
7
  # Category:: WWW
8
8
  # Package:: WWW::Delicious
@@ -10,42 +10,42 @@
10
10
  # License:: MIT License
11
11
  #
12
12
  #--
13
- # SVN: $Id$
13
+ #
14
14
  #++
15
15
 
16
16
 
17
17
  module WWW
18
18
  class Delicious
19
19
 
20
- #
20
+ #
21
21
  # = Abstract structure
22
- #
22
+ #
23
23
  # Represent the most basic structure all Struc(s) must inherith from.
24
- #
24
+ #
25
25
  class Element
26
-
26
+
27
27
  #
28
28
  # Initializes a new instance and populate attributes from +attrs+.
29
- #
29
+ #
30
30
  # class User < Element
31
31
  # attr_accessor :first_name
32
32
  # attr_accessor :last_name
33
33
  # end
34
- #
34
+ #
35
35
  # User.new
36
36
  # User.new(:first_name => 'foo')
37
37
  # User.new(:first_name => 'John', :last_name => 'Doe')
38
- #
38
+ #
39
39
  # You can even use a block.
40
40
  # The following statements are equals:
41
- #
41
+ #
42
42
  # User.new(:first_name => 'John', :last_name => 'Doe')
43
- #
43
+ #
44
44
  # User.new do |user|
45
45
  # user.first_name => 'John'
46
46
  # user.last_name => 'Doe'
47
47
  # end
48
- #
48
+ #
49
49
  # Warning. In order to set an attribute a valid attribute writer must be available,
50
50
  # otherwise this method will raise an exception.
51
51
  #
@@ -54,20 +54,20 @@ module WWW
54
54
  yield self if block_given?
55
55
  self
56
56
  end
57
-
58
-
57
+
58
+
59
59
  class << self
60
-
61
- #
60
+
61
+ #
62
62
  # Creates and returns new instance from a REXML +element+.
63
- #
63
+ #
64
64
  def from_rexml(element, options)
65
65
  raise NotImplementedError
66
66
  end
67
-
67
+
68
68
  end
69
-
69
+
70
70
  end
71
-
71
+
72
72
  end
73
73
  end
@@ -1,8 +1,8 @@
1
- #
1
+ #
2
2
  # = WWW::Delicious
3
3
  #
4
4
  # Ruby client for del.icio.us API.
5
- #
5
+ #
6
6
  #
7
7
  # Category:: WWW
8
8
  # Package:: WWW::Delicious
@@ -10,37 +10,38 @@
10
10
  # License:: MIT License
11
11
  #
12
12
  #--
13
- # SVN: $Id$
13
+ #
14
14
  #++
15
15
 
16
16
 
17
17
  module WWW
18
18
  class Delicious
19
19
 
20
-
21
20
  #
22
21
  # = WWW::Delicious::Error
23
22
  #
24
23
  # Base exception for all WWW::Delicious errors.
25
24
  #
26
- class Error < StandardError; end
25
+ class Error < StandardError
26
+ end
27
27
 
28
28
  #
29
29
  # = WWW::Delicious::HTTPError
30
- #
30
+ #
31
31
  # HTTP connection related error.
32
32
  # Raised when an HTTP request fails or in case of unexpected behavior.
33
33
  #
34
- class HTTPError < Error; end
34
+ class HTTPError < Error
35
+ end
35
36
 
36
37
  #
37
38
  # = WWW::Delicious::ResponseError
38
- #
39
+ #
39
40
  # Response related error.
40
41
  # Usually raised in case of a malformed, invalid or empty XML response.
41
42
  #
42
- class ResponseError < Error; end
43
-
44
-
43
+ class ResponseError < Error
44
+ end
45
+
45
46
  end
46
47
  end
@@ -1,8 +1,8 @@
1
- #
1
+ #
2
2
  # = WWW::Delicious
3
3
  #
4
4
  # Ruby client for del.icio.us API.
5
- #
5
+ #
6
6
  #
7
7
  # Category:: WWW
8
8
  # Package:: WWW::Delicious
@@ -10,7 +10,7 @@
10
10
  # License:: MIT License
11
11
  #
12
12
  #--
13
- # SVN: $Id$
13
+ #
14
14
  #++
15
15
 
16
16
 
@@ -19,47 +19,47 @@ require 'www/delicious/element'
19
19
 
20
20
  module WWW
21
21
  class Delicious
22
-
22
+
23
23
  class Post < Element
24
-
24
+
25
25
  # The Post URL
26
26
  attr_accessor :url
27
-
27
+
28
28
  # The title of the Post
29
29
  attr_accessor :title
30
-
30
+
31
31
  # The extended description for the Post
32
32
  attr_accessor :notes
33
-
33
+
34
34
  # The number of other users who saved this Post
35
35
  attr_accessor :others
36
-
36
+
37
37
  # The unique Id for this Post
38
38
  attr_accessor :uid
39
-
39
+
40
40
  # Tags for this Post
41
41
  attr_accessor :tags
42
-
42
+
43
43
  # Timestamp this Post was last saved at
44
44
  attr_accessor :time
45
-
45
+
46
46
  # Whether this Post must replace previous version of the same Post.
47
47
  attr_accessor :replace
48
-
48
+
49
49
  # Whether this Post is private
50
50
  attr_accessor :shared
51
-
52
-
51
+
52
+
53
53
  # Returns the value for <tt>shared</tt> attribute.
54
54
  def shared
55
55
  !(@shared == false)
56
56
  end
57
-
57
+
58
58
  # Returns the value for <tt>replace</tt> attribute.
59
59
  def replace
60
60
  !(@replace == false)
61
61
  end
62
-
62
+
63
63
  # Returns a params-style representation suitable for API calls.
64
64
  def to_params()
65
65
  params = {}
@@ -72,15 +72,15 @@ module WWW
72
72
  params[:dt] = WWW::Delicious::TIME_CONVERTER.call(time) if time
73
73
  params
74
74
  end
75
-
76
-
75
+
76
+
77
77
  #
78
78
  # Returns whether this object is valid for an API request.
79
- #
79
+ #
80
80
  # To be valid +url+ and +title+ must not be empty.
81
- #
81
+ #
82
82
  # === Examples
83
- #
83
+ #
84
84
  # post = WWW::Delicious::Post.new(:url => 'http://localhost', :title => 'foo')
85
85
  # post.api_valid?
86
86
  # # => true
@@ -92,15 +92,15 @@ module WWW
92
92
  def api_valid?
93
93
  return !(url.nil? or url.empty? or title.nil? or title.empty?)
94
94
  end
95
-
96
-
95
+
96
+
97
97
  class << self
98
-
99
- #
98
+
99
+ #
100
100
  # Creates and returns new instance from a REXML +element+.
101
- #
101
+ #
102
102
  # Implements Element#from_rexml.
103
- #
103
+ #
104
104
  def from_rexml(element)
105
105
  raise ArgumentError, "`element` expected to be a `REXML::Element`" unless element.kind_of? REXML::Element
106
106
  self.new do |instance|
@@ -114,10 +114,10 @@ module WWW
114
114
  instance.shared = element.if_attribute_value(:shared) { |v| v == 'no' ? false : true }
115
115
  end
116
116
  end
117
-
117
+
118
118
  end
119
-
119
+
120
120
  end
121
-
121
+
122
122
  end
123
123
  end
@@ -1,8 +1,8 @@
1
- #
1
+ #
2
2
  # = WWW::Delicious
3
3
  #
4
4
  # Ruby client for del.icio.us API.
5
- #
5
+ #
6
6
  #
7
7
  # Category:: WWW
8
8
  # Package:: WWW::Delicious
@@ -10,7 +10,7 @@
10
10
  # License:: MIT License
11
11
  #
12
12
  #--
13
- # SVN: $Id$
13
+ #
14
14
  #++
15
15
 
16
16
 
@@ -22,31 +22,31 @@ module WWW
22
22
 
23
23
  #
24
24
  # = Delicious Tag
25
- #
25
+ #
26
26
  # Represents a single Tag element.
27
27
  #
28
28
  class Tag < Element
29
-
29
+
30
30
  # The name of the tag.
31
31
  attr_accessor :name
32
-
32
+
33
33
  # The number of links tagged with this tag.
34
34
  # It should be set only from an API response.
35
35
  attr_accessor :count
36
-
37
-
36
+
37
+
38
38
  # Returns value for <tt>name</tt> attribute.
39
39
  # Value is always normalized as lower string.
40
40
  def name
41
41
  @name.to_s.strip unless @name.nil?
42
42
  end
43
-
43
+
44
44
  # Returns value for <tt>count</tt> attribute.
45
45
  # Value is always normalized to Fixnum.
46
46
  def count
47
47
  @count.to_i
48
48
  end
49
-
49
+
50
50
  #
51
51
  # Returns a string representation of this Tag.
52
52
  # In case name is nil this method will return an empty string.
@@ -54,17 +54,16 @@ module WWW
54
54
  def to_s
55
55
  name.to_s
56
56
  end
57
-
58
-
59
- public
57
+
58
+
59
+ #
60
+ # Returns whether this object is valid for an API request.
60
61
  #
61
- # Returns wheter this object is valid for an API request.
62
- #
63
62
  # To be valid +name+ must not be empty.
64
63
  # +count+ can be 0.
65
- #
64
+ #
66
65
  # === Examples
67
- #
66
+ #
68
67
  # tag = WWW::Delicious::Tag.new(:name => 'foo')
69
68
  # tag.api_api_valid?
70
69
  # # => true
@@ -76,15 +75,15 @@ module WWW
76
75
  def api_valid?
77
76
  return !name.empty?
78
77
  end
79
-
80
-
78
+
79
+
81
80
  class << self
82
-
83
- #
81
+
82
+ #
84
83
  # Creates and returns new instance from a REXML +element+.
85
- #
84
+ #
86
85
  # Implements Element#from_rexml.
87
- #
86
+ #
88
87
  def from_rexml(element)
89
88
  raise ArgumentError, "`element` expected to be a `REXML::Element`" unless element.kind_of? REXML::Element
90
89
  self.new do |instance|
@@ -92,10 +91,10 @@ module WWW
92
91
  instance.count = element.if_attribute_value(:count) { |value| value.to_i }
93
92
  end
94
93
  end
95
-
94
+
96
95
  end
97
-
96
+
98
97
  end
99
-
98
+
100
99
  end
101
100
  end