readit 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -2,10 +2,11 @@ source 'http://rubygems.org'
2
2
  gem 'multi_json'
3
3
 
4
4
  group :development, :test do
5
- gem 'rspec'
5
+ gem 'rspec'
6
6
  # Testing infrastructure
7
7
  gem 'guard'
8
8
  gem 'guard-rspec'
9
+ gem 'cucumber'
9
10
 
10
11
  if RUBY_PLATFORM =~ /darwin/
11
12
  # OS X integration
data/Readme.md CHANGED
@@ -1,5 +1,4 @@
1
1
  ## Simple api client of [readability](http://www.readability.com)
2
- not ready to use
3
2
 
4
3
  ### Installation
5
4
  ```ruby
@@ -22,8 +21,8 @@ config/readability.yml
22
21
  ``` ruby
23
22
 
24
23
  development:
25
- consumer_key: some_key
26
- consumer_secret: some_secret
24
+ consumer_key: some_key
25
+ consumer_secret: some_secret
27
26
  ```
28
27
 
29
28
  or in your code
@@ -34,7 +33,7 @@ Readit::Config.consumer_key = some_key
34
33
  Readit::Config.consumer_secret = some_value
35
34
  ```
36
35
 
37
- ### API use
36
+ ### API usage
38
37
  ``` ruby
39
38
 
40
39
  @api = Readit::API.new 'access_token','access_token_secret'
@@ -0,0 +1,24 @@
1
+ Feature: Readability api access
2
+ In order to fetch all informations of users' readability
3
+ As a api user
4
+ I want full access information of readability
5
+
6
+ Scenario: create api client
7
+ Given the user's access_token and the access_secret
8
+ And set consumer_key and consumer_secret to Readit::Config
9
+ When call new of Readit
10
+ Then get the api client
11
+
12
+ Scenario: config the Readit api
13
+ Given set test_consumer_key and test_consumer_secret to Readit::Config
14
+ When get consumer_key and consumer_secret from Readit::Config
15
+ Then get config values of test_consumer_key and test_consumer_secret
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+
24
+
@@ -0,0 +1,9 @@
1
+ Feature: Get article contents
2
+
3
+ Background:
4
+ Given the readit api client
5
+
6
+ Scenario: get article infos
7
+ Given fetch the latest bookmark
8
+ When get article info of the latest bookmark
9
+ Then get article's except and content info
@@ -0,0 +1,56 @@
1
+ Feature: Get bookmarks infos
2
+ In order to get bookmarks infos
3
+ As a api user
4
+ I want get and change bookmarks information
5
+
6
+ Background:
7
+ Given the readit api client
8
+
9
+ Scenario: get top 20 bookmarks
10
+ When call bookmarks
11
+ Then got 20 bookmarks back
12
+
13
+ Scenario: get any number bookmarks with option
14
+ When call bookmarks with option per_page 42
15
+ Then got 42 bookmarks back
16
+
17
+ Scenario: get 20 bookmarks before date added on sometime
18
+ When call bookmarks with option added_until 2011-12-12
19
+ Then got the first bookmark's date should less than 2011-12-12
20
+
21
+ Scenario: get only favorite bookmarks
22
+ When call bookmarks with option favorite 1
23
+ Then got any number of bookmarks which marked favorite
24
+
25
+ Scenario: get one bookmark by providing bookmark_id
26
+ Given get latest bookmarks
27
+ When call bookmarks with bookmark_id of the lastest one
28
+ Then got one right bookmark with the same id
29
+
30
+ Scenario: update bookmark info
31
+ Given the readit api client
32
+ And call bookmarks
33
+ When call update_bookmark latest bookmark_id with options favorite 1
34
+ Then got bookmark's favorite set to true
35
+
36
+ Scenario: archive bookmark by id
37
+ Given the readit api client
38
+ When call archive with bookmark_id
39
+ Then got bookmark's archive set to true
40
+
41
+ Scenario: user can add and delete bookmark
42
+ Given the readit api client
43
+ When add bookmark with url http://google.com
44
+ Then got status ok
45
+ When fetch the latest bookmark
46
+ Then got the bookmark with url http://google.com
47
+ When delete this new added bookmark
48
+ And fetch the latest bookmark
49
+ Then the latesed bookmark which url is not http://google.com
50
+
51
+
52
+
53
+
54
+
55
+
56
+
@@ -0,0 +1,40 @@
1
+ require_relative '../../lib/readit'
2
+
3
+ Given /^the user's (\w+) and the (\w+)$/ do |access_token, access_secret|
4
+ @access_token = access_token
5
+ @access_secret = access_secret
6
+ end
7
+
8
+ Given /^set (\w+) and (\w+) to Readit::Config$/ do |consumer_key,consumer_secret|
9
+ Readit::Config.consumer_key = consumer_key
10
+ Readit::Config.consumer_secret = consumer_secret
11
+ end
12
+
13
+ When /^call new of Readit$/ do
14
+ @client = Readit::API.new @access_token,@access_secret
15
+ end
16
+
17
+ Then /^get the api client$/ do
18
+ @client.should_not == nil
19
+ end
20
+
21
+ Given /^the readit api client$/ do
22
+ consumer_info = YAML.load_file(File.join(File.dirname(__FILE__),'../../readability.yml'))["development"]
23
+ Readit::Config.consumer_key = consumer_info['consumer_key']
24
+ Readit::Config.consumer_secret = consumer_info['consumer_secret']
25
+ @client = Readit::API.new "zQuzAzVW4Ark7VZvm2","5VEnMNPr7Q4393wxAYdnTWnpWwn7bHm4"
26
+ end
27
+
28
+
29
+ When /^get consumer_key and consumer_secret from Readit::Config$/ do
30
+ @consumer_key = Readit::Config.consumer_key
31
+ @consumer_secret = Readit::Config.consumer_secret
32
+ end
33
+
34
+ Then /^get config values of (\w+) and (\w+)$/ do |test_consumer_key,test_consumer_secret|
35
+ @consumer_key.should == test_consumer_key
36
+ @consumer_secret.should == test_consumer_secret
37
+ end
38
+
39
+
40
+
@@ -0,0 +1,10 @@
1
+ require_relative '../../lib/readit'
2
+
3
+ When /^get article info of the latest bookmark$/ do
4
+ @article = @client.article(@last_bookmark.article.id)
5
+ end
6
+
7
+ Then /^get article's except and content info$/ do
8
+ @article.content.length.should > 10
9
+ end
10
+
@@ -0,0 +1,86 @@
1
+ require_relative '../../lib/readit'
2
+ require 'time'
3
+
4
+ Given /^get latest bookmarks$/ do
5
+ @l_bookmarks = @client.bookmarks
6
+ end
7
+
8
+ When /^call bookmarks with option (\w+) ((\w|-)+)$/ do |option_name,option_value,not_use|
9
+ @bookmarks = @client.bookmarks option_name.to_sym => option_value
10
+ end
11
+
12
+ When /^call bookmarks$/ do
13
+ @bookmarks = @client.bookmarks
14
+ end
15
+
16
+ Then /^got (\d+) bookmarks back$/ do |bookmarks_count|
17
+ @bookmarks.count.should == bookmarks_count.to_i
18
+ end
19
+
20
+ Then /^got the first bookmark's date should less than ((\w+|-)+)/ do |date,not_use|
21
+ Time.parse(@bookmarks.first.date_added).should <= Time.parse(date)
22
+ end
23
+
24
+
25
+ Then /^got any number of bookmarks which marked favorite$/ do
26
+ @bookmarks.select{|b| !b.favorite }.count.should == 0
27
+ end
28
+
29
+ When /^call bookmarks with bookmark_id of the lastest one$/ do
30
+ b_id = @l_bookmarks.first.id
31
+ @bookmark = @client.bookmarks :bookmark_id => b_id
32
+ @bookmark.id.should == b_id
33
+ end
34
+
35
+ Then /^got one right bookmark with the same id$/ do
36
+ @bookmark.should_not == nil
37
+ end
38
+
39
+ When /^call update_bookmark latest bookmark_id with options favorite (\d+)$/ do |favorite|
40
+ @client.update_bookmark @bookmarks.first.id,:favorite=>1
41
+ end
42
+
43
+ Then /^got bookmark's favorite set to true$/ do
44
+ @client.bookmarks.first.favorite.should == true
45
+ end
46
+
47
+ When /^call archive with bookmark_id$/ do
48
+ @bookmark = @client.bookmarks.first
49
+ @client.archive @bookmark.id
50
+ end
51
+
52
+ Then /^got bookmark's archive set to true$/ do
53
+ @client.bookmarks.first.archive.should == true
54
+ end
55
+
56
+ When /^add bookmark with url (https?:\/\/[\S]+)$/ do |url|
57
+ @add_bookmark_result = @client.bookmark :url=>url
58
+ end
59
+
60
+ Then /^got status ok$/ do
61
+ @add_bookmark_result.status.should == '202'
62
+ end
63
+
64
+ When /^fetch the latest bookmark$/ do
65
+ @last_bookmark = @client.bookmarks.first
66
+ end
67
+
68
+ Then /^got the bookmark with url (https?:\/\/[\S]+)$/ do |url|
69
+ @last_bookmark.article.url.chop.should == url
70
+ end
71
+
72
+ When /^delete this new added bookmark$/ do
73
+ @client.delete_bookmark @last_bookmark.id
74
+ end
75
+
76
+ Then /^the latesed bookmark which url is not (https?:\/\/[\S]+)$/ do |url|
77
+ @last_bookmark.article.url.should_not == url
78
+ end
79
+
80
+
81
+ def plog
82
+ puts "============================"
83
+ yield
84
+ puts "============================"
85
+ end
86
+
@@ -0,0 +1,10 @@
1
+ require_relative '../../lib/readit'
2
+
3
+ When /^call me on api client$/ do
4
+ @me = @client.me
5
+ end
6
+
7
+ Then /^get use infos$/ do
8
+ @me.username.should == 'lidongbin'
9
+ end
10
+
@@ -0,0 +1,9 @@
1
+ Feature: Get user info
2
+
3
+ Background:
4
+ Given the readit api client
5
+
6
+ Scenario: get use infos
7
+ When call me on api client
8
+ Then get use infos
9
+
data/lib/readit.rb CHANGED
@@ -8,159 +8,159 @@ require 'readit/railtie' if defined?(Rails)
8
8
 
9
9
  module Readit
10
10
 
11
- class ReaditError < StandardError;end
12
-
13
- module Config
14
-
15
- def self.consumer_key
16
- @@consumer_key
17
- end
18
-
19
- def self.consumer_key=(val)
20
- @@consumer_key = val
21
- end
22
-
23
- def self.consumer_secret
24
- @@consumer_secret
25
- end
26
-
27
- def self.consumer_secret=(val)
28
- @@consumer_secret = val
29
- end
30
-
31
- end
32
-
33
- class API
34
- # initializer if creating a new Readit API client
35
- # @param access_token access_token of user
36
- # @param access_token_secret access_token_secret of user
37
- def initialize(access_token='',access_token_secret='')
38
- if access_token == '' or access_token_secret == ''
39
- raise ReaditError.new('have to provide access_token and access_token_secret')
40
- end
41
- if Readit::Config.consumer_key=='' or Readit::Config.consumer_secret==''
42
- raise ReaditError.new('please set Readit::Config.consumer_key or Readit::Config.consumer_secret first')
43
- end
44
- @access_token = access_token
45
- @access_token_secret = access_token_secret
46
- end
47
-
48
- attr_reader :access_token
49
-
50
- SITE_URL = 'https://www.readability.com/'
51
-
52
- # Retrieve the base API URI - information about subresources.
53
- def resource_info
54
- request(:get,'/')
55
- end
56
-
57
- # Retrieve a single Article, including its content.
58
- # api rest address: /articles/{article_id}
59
- # @param article_id the article_id
60
- def article(article_id)
61
- request(:get,"/articles/#{article_id}")
62
- end
63
-
64
- # Retrieve the bookmarks collection. Automatically filtered to the current user.
65
- # api rest address : /bookmarks? or /bookmarks/{bookmark_id}
66
- # @args support
67
- # bookmark_id (at most return one record)
68
- # archive
69
- # favorite
70
- # domain
71
- # added_since
72
- # added_until
73
- # opened_since
74
- # opened_until
75
- # archived_since
76
- # archived_until
77
- # favorited_since
78
- # favorited_until
79
- # updated_since
80
- # updated_until
81
- # order
82
- # page
83
- # per_page default 20,max 50
84
- # exclude_accessibility
85
- # only_deleted
86
- def bookmarks(args={})
87
- if args[:bookmark_id] and args[:bookmark_id]!=''
88
- request(:get,"/bookmarks/#{args[:bookmark_id]}")
89
- else
90
- params = args.map{|k,v| "#{k}=#{v}"}.join('&')
91
- request(:get,"/bookmarks?#{URI.escape(params)}").bookmarks
92
- end
93
- end
94
-
95
- # Add a bookmark. Returns 202 Accepted, meaning that the bookmark has been added but no guarantees are made as
96
- # to whether the article proper has yet been parsed.
97
- # @param args args to bookmark a url
98
- # url the address to bookmark
99
- # favorite 0 or 1
100
- # archive 0 or 1
101
- def bookmark(args={})
102
- request(:post,'/bookmarks',args)
103
- end
104
-
105
- # Update a bookmark. Returns 200 on successful update.
106
- # api rest address : /bookmarks/{bookmark_id}
107
- # @param bookmark_id bookmark to update
108
- # @param args args to update the bookmark
109
- # favorite 0 or 1
110
- # archive 0 or 1
111
- def update_bookmark(bookmark_id,args={})
112
- request(:post,"/bookmarks/#{bookmark_id}",args)
113
- end
114
-
115
- # archive a bookmark by id
116
- # @param bookmark_id bookmark to archive
117
- def archive(bookmark_id)
118
- update_bookmark(bookmark_id,:archive=>1)
119
- end
120
-
121
- # favorite a bookmark by id
122
- # @param bookmark_id bookmark_id to favorite
123
- def favorite(bookmark_id)
124
- update_bookmark(bookmark_id,:favorite=>1)
125
- end
126
-
127
- # Remove a single bookmark from this user's history.
128
- # NOTE: THIS IS PROBABLY NOT WHAT YOU WANT. This is particularly for the case where a user accidentally bookmarks
129
- # something they have no intention of reading or supporting.
130
- # In almost all cases, you'll probably want to use archive by POSTing archive=1 to this bookmark.
131
- # If you use DELETE and this months bookmarks have not yet been tallied,
132
- # the site associated with this bookmark will not receive any contributions for this bookmark.
133
- # Use archive! It's better.
134
- # Returns a 204 on successful remove.
135
- # @param bookmark_id bookmark to delete
136
- def delete_bookmark(bookmark_id)
137
- request(:delete,"/bookmarks/#{bookmark_id}")
138
- end
139
-
140
- # Retrieve the contributions collection, which is a set of payments by a user to a specific domain. Automatically filtered to the current user.
141
- # api rest address : /contributions?since&until&domain&page&per_page
142
- def contributions(args={})
143
- request(:get,"/contributions",args)
144
- end
145
-
146
- # Retrieve the current user's information.
147
- # api rest address :/users/_current
148
- def me
149
- request(:get,"/users/_current")
150
- end
151
-
152
- private
153
- def request(method,url,args={})
154
- consumer = ::OAuth::Consumer.new(Readit::Config.consumer_key,Readit::Config.consumer_secret,:site=>SITE_URL)
155
- atoken = ::OAuth::AccessToken.new(consumer, @access_token, @access_token_secret)
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'))
157
- response = atoken.send(method,"/api/rest/v1#{url}",args)
158
- if response.body==nil or response.body==''
159
- Hashie::Mash.new({:status => response.code})
160
- else
161
- Hashie::Mash.new MultiJson.decode(response.body)
162
- end
163
- end
164
-
165
- end
11
+ class ReaditError < StandardError;end
12
+
13
+ module Config
14
+
15
+ def self.consumer_key
16
+ @@consumer_key
17
+ end
18
+
19
+ def self.consumer_key=(val)
20
+ @@consumer_key = val
21
+ end
22
+
23
+ def self.consumer_secret
24
+ @@consumer_secret
25
+ end
26
+
27
+ def self.consumer_secret=(val)
28
+ @@consumer_secret = val
29
+ end
30
+
31
+ end
32
+
33
+ class API
34
+ # initializer if creating a new Readit API client
35
+ # @param access_token access_token of user
36
+ # @param access_token_secret access_token_secret of user
37
+ def initialize(access_token='',access_token_secret='')
38
+ if access_token == '' or access_token_secret == ''
39
+ raise ReaditError.new('have to provide access_token and access_token_secret')
40
+ end
41
+ if Readit::Config.consumer_key=='' or Readit::Config.consumer_secret==''
42
+ raise ReaditError.new('please set Readit::Config.consumer_key or Readit::Config.consumer_secret first')
43
+ end
44
+ @access_token = access_token
45
+ @access_token_secret = access_token_secret
46
+ end
47
+
48
+ attr_reader :access_token
49
+
50
+ SITE_URL = 'https://www.readability.com/'
51
+
52
+ # Retrieve the base API URI - information about subresources.
53
+ def resource_info
54
+ request(:get,'/')
55
+ end
56
+
57
+ # Retrieve a single Article, including its content.
58
+ # api rest address: /articles/{article_id}
59
+ # @param article_id the article_id
60
+ def article(article_id)
61
+ request(:get,"/articles/#{article_id}")
62
+ end
63
+
64
+ # Retrieve the bookmarks collection. Automatically filtered to the current user.
65
+ # api rest address : /bookmarks? or /bookmarks/{bookmark_id}
66
+ # @args support
67
+ # bookmark_id (at most return one record)
68
+ # archive
69
+ # favorite
70
+ # domain
71
+ # added_since
72
+ # added_until
73
+ # opened_since
74
+ # opened_until
75
+ # archived_since
76
+ # archived_until
77
+ # favorited_since
78
+ # favorited_until
79
+ # updated_since
80
+ # updated_until
81
+ # order
82
+ # page
83
+ # per_page default 20,max 50
84
+ # exclude_accessibility
85
+ # only_deleted
86
+ def bookmarks(args={})
87
+ if args[:bookmark_id] and args[:bookmark_id]!=''
88
+ request(:get,"/bookmarks/#{args[:bookmark_id]}")
89
+ else
90
+ params = args.map{|k,v| "#{k}=#{v}"}.join('&')
91
+ request(:get,"/bookmarks?#{URI.escape(params)}").bookmarks
92
+ end
93
+ end
94
+
95
+ # Add a bookmark. Returns 202 Accepted, meaning that the bookmark has been added but no guarantees are made as
96
+ # to whether the article proper has yet been parsed.
97
+ # @param args args to bookmark a url
98
+ # url the address to bookmark
99
+ # favorite 0 or 1
100
+ # archive 0 or 1
101
+ def bookmark(args={})
102
+ request(:post,'/bookmarks',args)
103
+ end
104
+
105
+ # Update a bookmark. Returns 200 on successful update.
106
+ # api rest address : /bookmarks/{bookmark_id}
107
+ # @param bookmark_id bookmark to update
108
+ # @param args args to update the bookmark
109
+ # favorite 0 or 1
110
+ # archive 0 or 1
111
+ def update_bookmark(bookmark_id,args={})
112
+ request(:post,"/bookmarks/#{bookmark_id}",args)
113
+ end
114
+
115
+ # archive a bookmark by id
116
+ # @param bookmark_id bookmark to archive
117
+ def archive(bookmark_id)
118
+ update_bookmark(bookmark_id,:archive=>1)
119
+ end
120
+
121
+ # favorite a bookmark by id
122
+ # @param bookmark_id bookmark_id to favorite
123
+ def favorite(bookmark_id)
124
+ update_bookmark(bookmark_id,:favorite=>1)
125
+ end
126
+
127
+ # Remove a single bookmark from this user's history.
128
+ # NOTE: THIS IS PROBABLY NOT WHAT YOU WANT. This is particularly for the case where a user accidentally bookmarks
129
+ # something they have no intention of reading or supporting.
130
+ # In almost all cases, you'll probably want to use archive by POSTing archive=1 to this bookmark.
131
+ # If you use DELETE and this months bookmarks have not yet been tallied,
132
+ # the site associated with this bookmark will not receive any contributions for this bookmark.
133
+ # Use archive! It's better.
134
+ # Returns a 204 on successful remove.
135
+ # @param bookmark_id bookmark to delete
136
+ def delete_bookmark(bookmark_id)
137
+ request(:delete,"/bookmarks/#{bookmark_id}")
138
+ end
139
+
140
+ # Retrieve the contributions collection, which is a set of payments by a user to a specific domain. Automatically filtered to the current user.
141
+ # api rest address : /contributions?since&until&domain&page&per_page
142
+ def contributions(args={})
143
+ request(:get,"/contributions",args)
144
+ end
145
+
146
+ # Retrieve the current user's information.
147
+ # api rest address :/users/_current
148
+ def me
149
+ request(:get,"/users/_current")
150
+ end
151
+
152
+ private
153
+ def request(method,url,args={})
154
+ consumer = ::OAuth::Consumer.new(Readit::Config.consumer_key,Readit::Config.consumer_secret,:site=>SITE_URL)
155
+ atoken = ::OAuth::AccessToken.new(consumer, @access_token, @access_token_secret)
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'))
157
+ response = atoken.send(method,"/api/rest/v1#{url}",args)
158
+ if response.body==nil or response.body==''
159
+ Hashie::Mash.new({:status => response.code})
160
+ else
161
+ Hashie::Mash.new MultiJson.decode(response.body)
162
+ end
163
+ end
164
+
165
+ end
166
166
  end
@@ -3,15 +3,15 @@ module Readit
3
3
  config.after_initialize do
4
4
  if File.exists?('config/readability.yml')
5
5
  consumer_info = YAML.load_file(File.join(Rails.root.to_s, 'config', 'readability.yml'))[Rails.env || "development"]
6
- if consumer_info
7
- Readit::Config.consumer_key = consumer_info["consumer_key"]
8
- Readit::Config.consumer_secret = consumer_info["consumer_secret"]
9
- else
10
- Rails.logger.warn "Please check your config/readability.yml file, no consumer_key and consumer_sercret under #{Rails.env} found"
11
- end
12
- else
13
- Rails.logger.warn "Please provide consumer_key and consumer_sercret on config/readability.yml file"
14
- end
6
+ if consumer_info
7
+ Readit::Config.consumer_key = consumer_info["consumer_key"]
8
+ Readit::Config.consumer_secret = consumer_info["consumer_secret"]
9
+ else
10
+ Rails.logger.warn "Please check your config/readability.yml file, no consumer_key and consumer_sercret under #{Rails.env} found"
11
+ end
12
+ else
13
+ Rails.logger.warn "Please provide consumer_key and consumer_sercret on config/readability.yml file"
14
+ end
15
15
  end
16
16
  end
17
17
  end
@@ -1,3 +1,3 @@
1
1
  module Readit
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
@@ -2,67 +2,67 @@ require 'spec_helper'
2
2
  require 'time'
3
3
 
4
4
  describe "Readit::API" do
5
- before do
6
- # load consumer infos
7
- consumer_info = YAML.load_file(File.join(File.dirname(__FILE__),'../readability.yml'))["development"]
8
- Readit::Config.consumer_key = consumer_info['consumer_key']
9
- Readit::Config.consumer_secret = consumer_info['consumer_secret']
10
- @api = Readit::API.new 'zQuzAzVW4Ark7VZvm2','5VEnMNPr7Q4393wxAYdnTWnpWwn7bHm4'
11
- end
5
+ before do
6
+ # load consumer infos
7
+ consumer_info = YAML.load_file(File.join(File.dirname(__FILE__),'../../readability.yml'))["development"]
8
+ Readit::Config.consumer_key = consumer_info['consumer_key']
9
+ Readit::Config.consumer_secret = consumer_info['consumer_secret']
10
+ @api = Readit::API.new 'zQuzAzVW4Ark7VZvm2','5VEnMNPr7Q4393wxAYdnTWnpWwn7bHm4'
11
+ end
12
12
 
13
- let :bookmarks do
14
- @bms ||= @api.bookmarks
15
- end
13
+ let :bookmarks do
14
+ @bms ||= @api.bookmarks
15
+ end
16
16
 
17
- let :bookmark_ids do
18
- bookmarks.map{|a| a['id']}
19
- end
17
+ let :bookmark_ids do
18
+ bookmarks.map{|a| a['id']}
19
+ end
20
20
 
21
21
  it "should get user infos" do
22
- @api.me.should_not == nil
22
+ @api.me.should_not == nil
23
23
  end
24
24
 
25
- it "should get user's bookmarks" do
26
- bookmarks.should_not == nil
27
- bookmarks.count.should > 0
28
- end
25
+ it "should get user's bookmarks" do
26
+ bookmarks.should_not == nil
27
+ bookmarks.count.should > 0
28
+ end
29
29
 
30
- it "should add bookmark" do
31
- url = 'http://www.tripadvisor.com/Restaurant_Review-g297701-d1182615-Reviews-Cafe_Lotus-Ubud_Bali.html'
32
- resp = @api.bookmark :url=>url
33
- resp.should_not == nil
34
- end
30
+ it "should add bookmark" do
31
+ url = 'http://www.tripadvisor.com/Restaurant_Review-g297701-d1182615-Reviews-Cafe_Lotus-Ubud_Bali.html'
32
+ resp = @api.bookmark :url=>url
33
+ resp.should_not == nil
34
+ end
35
35
 
36
- it "should get the article content" do
37
- article = @api.article 'eg60dxbv'
38
- #puts article
39
- article.should_not == nil
40
- end
36
+ it "should get the article content" do
37
+ article = @api.article 'eg60dxbv'
38
+ #puts article
39
+ article.should_not == nil
40
+ end
41
41
 
42
- it "should get the bookmark info by bookmark id" do
43
- bookmark = @api.bookmarks :bookmark_id=>bookmark_ids.first
44
- bookmark.should_not == nil
45
- end
42
+ it "should get the bookmark info by bookmark id" do
43
+ bookmark = @api.bookmarks :bookmark_id=>bookmark_ids.first
44
+ bookmark.should_not == nil
45
+ end
46
46
 
47
- it "should get bookmarks according to added since" do
48
- bookmarks = @api.bookmarks({:added_until=>'2012-1-1',:per_page=>2})
49
- bookmarks.count.should > 0
50
- bookmarks.select{|b| Time.parse(b.date_added) > Time.parse('2012-1-1')}.count.should == 0
51
- end
47
+ it "should get bookmarks according to added since" do
48
+ bookmarks = @api.bookmarks(:added_until=>'2012-1-1',:per_page=>2)
49
+ bookmarks.count.should > 0
50
+ bookmarks.select{|b| Time.parse(b.date_added) > Time.parse('2012-1-1')}.count.should == 0
51
+ end
52
52
 
53
- it "should update bookmark to favarite" do
54
- bm_id = bookmark_ids.first
55
- @api.favorite bm_id
56
- bookmark = @api.bookmarks :bookmark_id=>bm_id
57
- bookmark.should be_favorite
58
- end
53
+ it "should update bookmark to favarite" do
54
+ bm_id = bookmark_ids.first
55
+ @api.favorite bm_id
56
+ bookmark = @api.bookmarks :bookmark_id=>bm_id
57
+ bookmark.should be_favorite
58
+ end
59
59
 
60
- it "should update bookmark to archive" do
61
- bm_id = bookmark_ids.first
62
- @api.archive bm_id
63
- bookmark = @api.bookmarks :bookmark_id=>bm_id
64
- bookmark.should be_archive
65
- end
60
+ it "should update bookmark to archive" do
61
+ bm_id = bookmark_ids.first
62
+ @api.archive bm_id
63
+ bookmark = @api.bookmarks :bookmark_id=>bm_id
64
+ bookmark.should be_archive
65
+ end
66
66
 
67
67
 
68
68
  end
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.6
4
+ version: 0.0.7
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-20 00:00:00.000000000Z
12
+ date: 2012-02-23 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json
16
- requirement: &2154753320 !ruby/object:Gem::Requirement
16
+ requirement: &2164830820 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2154753320
24
+ version_requirements: *2164830820
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: hashie
27
- requirement: &2154752900 !ruby/object:Gem::Requirement
27
+ requirement: &2164830180 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2154752900
35
+ version_requirements: *2164830180
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: oauth
38
- requirement: &2154752460 !ruby/object:Gem::Requirement
38
+ requirement: &2164829320 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *2154752460
46
+ version_requirements: *2164829320
47
47
  description: a simple readability api client
48
48
  email:
49
49
  - mike.d.1984@gmail.com
@@ -56,6 +56,14 @@ files:
56
56
  - Guardfile
57
57
  - Rakefile
58
58
  - Readme.md
59
+ - features/api.feature
60
+ - features/articles.feature
61
+ - features/bookmarks.feature
62
+ - features/step_definitions/api_steps.rb
63
+ - features/step_definitions/articles_steps.rb
64
+ - features/step_definitions/bookmarks_steps.rb
65
+ - features/step_definitions/user_info_steps.rb
66
+ - features/user_info.feature
59
67
  - lib/readit.rb
60
68
  - lib/readit/railtie.rb
61
69
  - lib/readit/version.rb
@@ -88,5 +96,14 @@ signing_key:
88
96
  specification_version: 3
89
97
  summary: a simple readability api client
90
98
  test_files:
99
+ - features/api.feature
100
+ - features/articles.feature
101
+ - features/bookmarks.feature
102
+ - features/step_definitions/api_steps.rb
103
+ - features/step_definitions/articles_steps.rb
104
+ - features/step_definitions/bookmarks_steps.rb
105
+ - features/step_definitions/user_info_steps.rb
106
+ - features/user_info.feature
91
107
  - spec/cases/api_spec.rb
92
108
  - spec/spec_helper.rb
109
+ has_rdoc: