ldclip 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ == 0.0.3 2008-02-17
2
+
3
+ * utadaq
4
+ * bug(not work when url has '#' or '+') fix
5
+
1
6
  == 0.0.2 2008-02-11
2
7
 
3
8
  * utadaq
@@ -8,4 +13,4 @@
8
13
  * utadaq
9
14
  * first release
10
15
 
11
- $Id: History.txt 9 2008-02-11 04:44:09Z utadaq $
16
+ $Id: History.txt 13 2008-02-17 02:31:40Z utadaq $
data/lib/ldclip.rb CHANGED
@@ -2,7 +2,7 @@
2
2
  #
3
3
  # ruby interface of LivedoorClipAPI
4
4
  #
5
- # $Id: ldclip.rb 9 2008-02-11 04:44:09Z utadaq $
5
+ # $Id: ldclip.rb 13 2008-02-17 02:31:40Z utadaq $
6
6
 
7
7
  require 'net/https'
8
8
  require 'cgi'
@@ -16,9 +16,10 @@ class Ldclip
16
16
  # user,apikey
17
17
  # get apikey at this url
18
18
  # http://clip.livedoor.com/config/api
19
- def initialize(user, apikey)
19
+ def initialize(user, apikey, debug = nil)
20
20
  @user = user
21
21
  @apikey = apikey
22
+ @debug = debug
22
23
  end
23
24
 
24
25
  # return last update date
@@ -34,7 +35,7 @@ class Ldclip
34
35
  params = []
35
36
  params << "tag=#{CGI.escape(NKF.nkf('-w',options[:tag]))}" if options[:tag]
36
37
  params << "dt=#{options[:dt]}" if options[:dt]
37
- params << "url=#{options[:url]}" if options[:url]
38
+ params << "url=#{CGI.escape(options[:url])}" if options[:url]
38
39
  connect("posts/get?#{params.join('&')}")
39
40
  end
40
41
 
@@ -67,7 +68,7 @@ class Ldclip
67
68
  # r18
68
69
  def add(url, description, options = {})
69
70
  params = []
70
- params << "url=#{url}"
71
+ params << "url=#{CGI.escape(url)}"
71
72
  params << "description=#{CGI.escape(NKF.nkf('-w',description))}"
72
73
 
73
74
  options.each do |t,e|
@@ -78,7 +79,7 @@ class Ldclip
78
79
  end
79
80
 
80
81
  def delete(url)
81
- params = "url=#{url}"
82
+ params = "url=#{CGI.escape(url)}"
82
83
 
83
84
  connect("posts/delete?#{params}")
84
85
  end
@@ -95,6 +96,8 @@ private
95
96
  res = http.request(req)
96
97
  end
97
98
 
99
+ print "#{url_part}\n" if @debug
100
+
98
101
  sleep 1
99
102
  res.body
100
103
  end
@@ -2,9 +2,9 @@ class Ldclip #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- TINY = 2
5
+ TINY = 3
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
9
9
  end
10
- # $Id: version.rb 9 2008-02-11 04:44:09Z utadaq $
10
+ # $Id: version.rb 14 2008-02-17 02:35:19Z utadaq $
data/test/test_ldclip.rb CHANGED
@@ -1,4 +1,4 @@
1
- # $Id: test_ldclip.rb 9 2008-02-11 04:44:09Z utadaq $
1
+ # $Id: test_ldclip.rb 12 2008-02-17 02:31:20Z utadaq $
2
2
  require File.dirname(__FILE__) + '/test_helper.rb'
3
3
  require 'cgi'
4
4
 
@@ -7,8 +7,7 @@ class TestLdclip < Test::Unit::TestCase
7
7
  def setup
8
8
  # get your apikey at ( need livedoor id )
9
9
  # http://clip.livedoor.com/config/api
10
-
11
- # @ldc = Ldclip.new(@id,@apikey)
10
+ # @ldc = Ldclip.new(@id,@apikey,true) # for debug
12
11
  @ldc = Ldclip.new('your account','your apikey')
13
12
  assert_nil('get your apikey at ( need livedoor id )')
14
13
  exit
@@ -49,18 +48,29 @@ class TestLdclip < Test::Unit::TestCase
49
48
  end
50
49
 
51
50
  def test_posts
52
- assert_not_nil(res = @ldc.add('http://www.lucky-ch.com/',"ラッキー☆ちゃんねる#{`date`}",
51
+ assert_match('done',@ldc.add('http://www.lucky-ch.com/weekly/070827.html',"ラッキー☆ちゃんねる#{`date`}",
53
52
  {
54
53
  :extended => 'かがみんは俺の嫁',
55
54
  :tags => 'lucky-star kagamin 京アニ next',
56
- :dt => Time.now.xmlschema,
55
+ # :dt => Time.now.xmlschema,
57
56
  :replace => :no,
58
- :shared => :no,
57
+ :shared => :yes,
59
58
  :rate => 3,
60
59
  :r18 => :no
61
60
  }
62
61
  ))
63
- assert_match('done' ,res)
62
+ end
63
+
64
+ def test_posts_url_has_question_
65
+ assert_match('done' ,@ldc.add('http://search.yahoo.co.jp/search?ei=UTF-8&p=%3Fharuhi','test with ?'))
66
+ end
67
+
68
+ def test_posts_url_has_sharp # some probrem at 0.0.2
69
+ assert_match('done' ,@ldc.add('http://d.hatena.ne.jp/utadaq/20060919#c1158995677','test with #'))
70
+ end
71
+
72
+ def test_posts_url_has_plus # some probrem at 0.0.2
73
+ assert_match('done' ,@ldc.add('http://technoweenie.stikipad.com/plugins/show/User+Authentication','test with !'))
64
74
  end
65
75
 
66
76
  def test_delete
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: ldclip
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.0.2
7
- date: 2008-02-11 00:00:00 +09:00
6
+ version: 0.0.3
7
+ date: 2008-02-17 00:00:00 +09:00
8
8
  summary: livedoor clip api for ruby
9
9
  require_paths:
10
10
  - lib