readit 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -14,6 +14,7 @@ group :development, :test do
14
14
  end
15
15
  end
16
16
  gem 'oauth'
17
+ gem 'hashie'
17
18
 
18
19
 
19
20
  # Specify your gem's dependencies in readit.gemspec
@@ -2,6 +2,7 @@ require "readit/version"
2
2
  require 'multi_json'
3
3
  require 'oauth'
4
4
  require 'uri'
5
+ require 'hashie'
5
6
  # plugin railtie hook when using rails
6
7
  require 'readit/railtie' if defined?(Rails)
7
8
 
@@ -87,7 +88,7 @@ module Readit
87
88
  request(:get,"/bookmarks/#{args[:bookmark_id]}")
88
89
  else
89
90
  params = args.map{|k,v| "#{k}=#{v}"}.join('&')
90
- request(:get,"/bookmarks?#{URI.escape(params)}")['bookmarks']
91
+ request(:get,"/bookmarks?#{URI.escape(params)}").bookmarks
91
92
  end
92
93
  end
93
94
 
@@ -155,9 +156,9 @@ module Readit
155
156
  #response = client.send(method,"/api/rest/v1#{url}",args.merge!('oauth_token'=>@access_token,'oauth_token_secret'=>'5VEnMNPr7Q4393wxAYdnTWnpWwn7bHm4','oauth_consumer_key'=>'lidongbin','oauth_consumer_secret'=>'gvjSYqH4PLWQtQG8Ywk7wKZnEgd4xf2C'))
156
157
  response = atoken.send(method,"/api/rest/v1#{url}",args)
157
158
  if response.body==nil or response.body==''
158
- {:status => response.code}
159
+ Hashie::Mash.new({:status => response.code})
159
160
  else
160
- MultiJson.decode response.body
161
+ Hashie::Mash.new MultiJson.decode(response.body)
161
162
  end
162
163
  end
163
164
 
@@ -1,3 +1,3 @@
1
1
  module Readit
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -10,6 +10,7 @@ Gem::Specification.new do |gem|
10
10
 
11
11
  gem.rubyforge_project = "readit"
12
12
  gem.add_dependency 'multi_json'
13
+ gem.add_dependency 'hashie'
13
14
  gem.add_dependency 'oauth'
14
15
 
15
16
  gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
@@ -1,4 +1,5 @@
1
1
  require 'spec_helper'
2
+ require 'time'
2
3
 
3
4
  describe "Readit::API" do
4
5
  before do
@@ -29,7 +30,6 @@ describe "Readit::API" do
29
30
  it "should add bookmark" do
30
31
  url = 'http://www.tripadvisor.com/Restaurant_Review-g297701-d1182615-Reviews-Cafe_Lotus-Ubud_Bali.html'
31
32
  resp = @api.bookmark :url=>url
32
- puts resp.inspect
33
33
  resp.should_not == nil
34
34
  end
35
35
 
@@ -42,27 +42,26 @@ describe "Readit::API" do
42
42
  it "should get the bookmark info by bookmark id" do
43
43
  bookmark = @api.bookmarks :bookmark_id=>bookmark_ids.first
44
44
  bookmark.should_not == nil
45
- puts bookmark
46
45
  end
47
46
 
48
47
  it "should get bookmarks according to added since" do
49
48
  bookmarks = @api.bookmarks({:added_until=>'2012-1-1',:per_page=>2})
50
- puts bookmarks
51
49
  bookmarks.count.should > 0
50
+ bookmarks.select{|b| Time.parse(b.date_added) > Time.parse('2012-1-1')}.count.should == 0
52
51
  end
53
52
 
54
53
  it "should update bookmark to favarite" do
55
54
  bm_id = bookmark_ids.first
56
55
  @api.favorite bm_id
57
56
  bookmark = @api.bookmarks :bookmark_id=>bm_id
58
- bookmark['favorite'].should == true
57
+ bookmark.should be_favorite
59
58
  end
60
59
 
61
60
  it "should update bookmark to archive" do
62
61
  bm_id = bookmark_ids.first
63
62
  @api.archive bm_id
64
63
  bookmark = @api.bookmarks :bookmark_id=>bm_id
65
- bookmark['archive'].should == true
64
+ bookmark.should be_archive
66
65
  end
67
66
 
68
67
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: readit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-11 00:00:00.000000000Z
12
+ date: 2012-02-20 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json
16
- requirement: &2155484380 !ruby/object:Gem::Requirement
16
+ requirement: &2154753320 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,21 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2155484380
24
+ version_requirements: *2154753320
25
+ - !ruby/object:Gem::Dependency
26
+ name: hashie
27
+ requirement: &2154752900 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *2154752900
25
36
  - !ruby/object:Gem::Dependency
26
37
  name: oauth
27
- requirement: &2155483960 !ruby/object:Gem::Requirement
38
+ requirement: &2154752460 !ruby/object:Gem::Requirement
28
39
  none: false
29
40
  requirements:
30
41
  - - ! '>='
@@ -32,7 +43,7 @@ dependencies:
32
43
  version: '0'
33
44
  type: :runtime
34
45
  prerelease: false
35
- version_requirements: *2155483960
46
+ version_requirements: *2154752460
36
47
  description: a simple readability api client
37
48
  email:
38
49
  - mike.d.1984@gmail.com