Ridiculous 0.3 → 0.5

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/index.html CHANGED
@@ -7,24 +7,54 @@
7
7
  body {
8
8
  margin: 5px 5px 5px 5px;
9
9
  font-family: 'Trebuchet MS', 'Lucida Grande', 'Bitstream Vera Sans', Tahoma, Sans-Serif;
10
+ text-align: left;
10
11
  }
12
+
11
13
  h1 {
12
14
  font-size: 12px;
13
15
  text-transform: uppercase;
14
16
  }
17
+
18
+ h2 {
19
+ font-size: 18px;
20
+ }
21
+
15
22
  h2, h4 {
16
- margin: 0px 0px 8px 0px;
23
+ margin: 0px 0px 0px 0px;
17
24
  }
18
- h3 { margin: 10px 0px 8px 0px; }
25
+
26
+ h3 {
27
+ margin: 20px 0px 6px 0px;
28
+ display: block;
29
+ }
30
+
19
31
  pre { margin: 3px 0px 0px 0px; }
32
+
20
33
  li { margin: 0px 0px 3px 0px; }
34
+
21
35
  a, a:link, a:hover, a:visited, a:active { color: #000000 }
36
+
37
+ #container {
38
+ float: left;
39
+ display: inline;
40
+ width: 80%
41
+ }
42
+
43
+ #ads {
44
+ float: right;
45
+ display: inline;
46
+ }
47
+
48
+ #logo {
49
+ display:inline;
50
+ margin: 3px 3px 20px 0px;
51
+ }
22
52
  </style>
23
53
 
24
54
  </head>
25
55
  <body>
26
-
27
- <h1>Ridiculous</h1>
56
+ <div id="container">
57
+ <a href="./index.html" title="Ridiculous"><img src="./ridiculous_logo.png" alt="Ridicuous" border="0" id="logo" /></a>
28
58
  <h2>Ridiculous is a simple wrapper for del.icio.us API writing in Ruby.</h2>
29
59
  <br clear="all" />
30
60
 
@@ -33,15 +63,31 @@ a, a:link, a:hover, a:visited, a:active { color: #000000 }
33
63
  <li><a href="http://rubyforge.org/frs/download.php/9464/ridiculous-0.3.tar.bz2">get the source code</a></li>
34
64
  <li>install using RubyGems
35
65
  <pre>$ gem install ridiculous</pre></li>
36
- <li>get the latest development version (0.5) from subversion
66
+ <li>get the latest development version from subversion
37
67
  <pre>$ svn co svn://rubyforge.org//var/svn/ridiculous</pre>
38
68
  </li>
39
69
  </ul>
40
- <br clear="all" />
41
70
 
42
71
  <h3>usage</h3>
72
+ <p>Ridiculous is easy to use, see:</p>
73
+ <pre>
74
+ require 'ridiculous'
75
+ include 'Ridiculous'
43
76
 
44
- <h4>Read the <a href="./doc">API documentation</a></h4>
77
+ Ridiculous::USERNAME = 'joao'
78
+ Ridiculous::PASSWORD = 'bluh!'
79
+
80
+ post = Post.new
81
+ post.recent(:tag => 'foo', :count => 3).each {
82
+ |p| puts "#{p['description']}\n"
83
+ }
84
+ </pre>
85
+ <p>will list the last tree posts tagged as 'foo' by joao.</p>
86
+ <h4>for further information</h4>
87
+ <ul>
88
+ <li>read the <a href="./doc">API documentation</a></a>
89
+ <li>take a look at <a href="http://del.icio.us/help/api/">del.icio.us help pages</a></li>
90
+ </ul>
45
91
 
46
92
  <!--
47
93
  <h4>posts</h4>
@@ -50,22 +96,20 @@ a, a:link, a:hover, a:visited, a:active { color: #000000 }
50
96
  <h4>tags</h4>
51
97
  <pre>xx</pre>
52
98
  -->
53
- <br clear="all" />
54
99
 
55
100
  <h3>license</h3>
56
101
  <p><a href="http://www.opensource.org/licenses/bsd-license.php">BSD License</a></p>
57
- <br clear="all" />
58
102
 
59
103
  <h3>feedback</h3>
60
- <p>Please, send your feedbacks to lupeke [ at ] gmail.com</p>
61
-
62
- <br clear="all" />
104
+ <p>Please, send your feedback to lupeke at gmail dot com</p>
63
105
 
106
+ </div>
107
+ <div id="ads">
64
108
  <script type="text/javascript"><!--
65
109
  google_ad_client = "pub-6740369207822774";
66
- google_ad_width = 728;
67
- google_ad_height = 90;
68
- google_ad_format = "728x90_as";
110
+ google_ad_width = 120;
111
+ google_ad_height = 600;
112
+ google_ad_format = "120x600_as";
69
113
  google_ad_type = "text";
70
114
  google_ad_channel ="";
71
115
  google_color_border = "336699";
@@ -77,6 +121,6 @@ google_color_text = "000000";
77
121
  <script type="text/javascript"
78
122
  src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
79
123
  </script>
80
-
124
+ </div>
81
125
  </body>
82
126
  </html>
@@ -4,7 +4,7 @@ gemspec = Gem::Specification.new { |spec|
4
4
 
5
5
  spec.name = 'Ridiculous'
6
6
  spec.summary = 'Ridiculous is a simple wrapper for del.icio.us API writing in Ruby'
7
- spec.version = '0.3'
7
+ spec.version = '0.5'
8
8
 
9
9
  spec.required_ruby_version = '>= 1.8'
10
10
  spec.rubyforge_project = 'ridiculous'
@@ -20,7 +20,7 @@
20
20
  # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21
21
  # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22
22
  # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23
- # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23
+ # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24
24
  # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25
25
  # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26
26
  # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
@@ -28,7 +28,7 @@
28
28
  # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
29
 
30
30
 
31
- require 'open-uri'
31
+ require 'net/http'
32
32
  require 'rexml/document'
33
33
 
34
34
  include REXML
@@ -47,19 +47,24 @@ include REXML
47
47
  #
48
48
  module Ridiculous
49
49
 
50
- BASE_URI = "http://del.icio.us/api/"
51
- VERSION = "0.3"
50
+ BASE_URI = "https://api.del.icio.us/v1/"
51
+ VERSION = "0.5"
52
52
 
53
53
  #
54
54
  # Handle HTTP requests
55
55
  #
56
56
  def request(resource)
57
- uri = BASE_URI + resource
58
-
59
57
  begin
60
- recource = open(URI.parse(uri),
61
- :http_basic_authentication => [USERNAME,PASSWORD]).read
62
- rescue OpenURI::HTTPError
58
+
59
+ url = URI.parse(BASE_URI + resource)
60
+ req = Net::HTTP::Get.new(url.path + "?" + url.query)
61
+ req.basic_auth USERNAME, PASSWORD
62
+ res = Net::HTTP.start(url.host, url.port) { |http|
63
+ http.use_ssl = true
64
+ http.request(req)
65
+ }
66
+ res.body
67
+ rescue Net::HTTPError
63
68
  raise "Can't connect to the server, please check the username/password.\nError: #{$!} \n"
64
69
  end
65
70
  end
@@ -126,8 +131,10 @@ module Ridiculous
126
131
  end
127
132
  end
128
133
  @posts
129
- rescue RuntimeError, NoMethodError
130
- raise "\nPosts#find failed!\nError: #{$!}\n"
134
+ # rescue RuntimeError, NoMethodError
135
+ # raise "\nPosts#find failed!\nError: #{$!}\n"
136
+ rescue REXML::ParseException
137
+ raise "\nPosts#find XML parsing failed\nError: #{$!}\n"
131
138
  end
132
139
  end
133
140
 
@@ -157,6 +164,19 @@ module Ridiculous
157
164
  end
158
165
  end
159
166
 
167
+ # Deletes a bookmark
168
+ #
169
+ # Post.delete(:url=>"http://mydomain.com")
170
+ #
171
+ # The :url parameter is required
172
+ def delete(args={})
173
+ nil if args[:url].nil?
174
+ @resource = "posts/delete?" << format_args(args)
175
+ @request = request(URI.escape(@resource))
176
+ @doc = Document.new(@request).root
177
+ @doc.attributes["code"] == "done"
178
+ end
179
+
160
180
  private :find
161
181
 
162
182
  end
@@ -210,4 +230,4 @@ module Ridiculous
210
230
  private :find
211
231
 
212
232
  end
213
- end
233
+ end
Binary file
data/tests.rb CHANGED
@@ -5,8 +5,8 @@ require "ridiculous"
5
5
  include Ridiculous
6
6
 
7
7
  # define username and password (it must change in the next version)
8
- Ridiculous::USERNAME = "YOUR_USER"
9
- Ridiculous::PASSWORD = "YOUR_PASS"
8
+ Ridiculous::USERNAME = "yourusernamehere"
9
+ Ridiculous::PASSWORD = "youroasswordhere"
10
10
 
11
11
  # testing posts
12
12
  puts "\nTESTING POSTS...\n\n"
@@ -15,7 +15,7 @@ puts "\nTESTING POSTS...\n\n"
15
15
 
16
16
  puts "\nRETRIEVING THE LAST 5 POSTS TAGGED AS `ruby`\n"
17
17
 
18
- @post.recent(:tag => 'ruby', :count => '5').each { |p|
18
+ @post.recent(:tag => 'ruby', :count => 5).each { |p|
19
19
  puts "#{p['description']}\n"
20
20
  puts "#{p['href']}\n"
21
21
  puts "#{p['tags']}\n\n"
@@ -56,4 +56,4 @@ else
56
56
  puts "Oh... failed!\n"
57
57
  end
58
58
 
59
- puts "." * 60
59
+ puts "." * 60
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.11
2
+ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: Ridiculous
5
5
  version: !ruby/object:Gem::Version
6
- version: "0.3"
7
- date: 2006-04-03 00:00:00 -03:00
6
+ version: "0.5"
7
+ date: 2006-12-29 00:00:00 -05:00
8
8
  summary: Ridiculous is a simple wrapper for del.icio.us API writing in Ruby
9
9
  require_paths:
10
10
  - lib
@@ -25,14 +25,16 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
25
25
  platform: ruby
26
26
  signing_key:
27
27
  cert_chain:
28
+ post_install_message:
28
29
  authors:
29
30
  - Daniel Dias
30
31
  files:
31
32
  - ridiculous.rb
32
33
  - index.html
34
+ - doc
33
35
  - ridiculous.gemspec
34
36
  - tests.rb
35
- - doc
37
+ - ridiculous_logo.png
36
38
  test_files:
37
39
  - tests.rb
38
40
  rdoc_options: []