feedly_api 0.5.0 → 0.5.1
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +2 -0
- data/README.md +19 -34
- data/Rakefile +2 -2
- data/lib/feedly_api.rb +7 -1
- data/lib/feedly_api/client.rb +6 -1
- data/lib/feedly_api/feed.rb +13 -14
- data/lib/feedly_api/feed_item.rb +5 -0
- data/lib/feedly_api/version.rb +1 -1
- data/spec/lib/feedly_api/client_spec.rb +4 -0
- data/spec/lib/feedly_api/feed_item_spec.rb +0 -0
- data/spec/lib/feedly_api/feed_spec.rb +41 -0
- data/spec/lib/feedly_api_spec.rb +18 -10
- metadata +6 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43a7715f0add0564eacbedfd563c66f1756b46c7
|
4
|
+
data.tar.gz: 61c1853e5aa7cddfb0514a39a05996650cbb7781
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d695edda17f345ad9c2f99c36bf3e78f77a12873ba9745ad7557228ef0b75121ce9ba4d4ae438f868c946dd4c65b1d931f29de76c39243b0b72ae9fa45f19d1
|
7
|
+
data.tar.gz: 5aa2b7af45b8a65b8bff4ce0369f6225b11edc36a73998acfc30b4c783b8796c7970a7034b9e8a640aeacb7279d8a6718980af1a63e541515ac8e1fb95e78bf3
|
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -13,43 +13,28 @@ Early unofficial Feedly API with no external dependencies
|
|
13
13
|
|
14
14
|
```ruby
|
15
15
|
feedly = FeedlyApi::Client.new
|
16
|
-
=> #<FeedlyApi::Client:
|
17
|
-
|
18
|
-
=>
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
feed.
|
24
|
-
=>
|
25
|
-
|
26
|
-
|
27
|
-
:
|
28
|
-
|
29
|
-
|
16
|
+
=> #<FeedlyApi::Client:0x007ff233308ae0 @auth_token=nil>
|
17
|
+
client.get_feed_info 'feed/https://www.eff.org/rss/updates.xml'
|
18
|
+
=> {:website=>"https://www.eff.org/rss/updates.xml",
|
19
|
+
:id=>"feed/https://www.eff.org/rss/updates.xml",
|
20
|
+
:subscribers=>2442,
|
21
|
+
:title=>"Deeplinks",
|
22
|
+
:velocity=>15.2}
|
23
|
+
client.get_feed_contents 'feed/https://www.eff.org/rss/updates.xml'
|
24
|
+
=> {:direction=>"ltr",
|
25
|
+
:continuation=>"13fa6b1134b:1a10f:eacbe387",
|
26
|
+
:alternate=>
|
27
|
+
[{:href=>"https://www.eff.org/rss/updates.xml", :type=>"text/html"}],
|
28
|
+
:id=>"feed/https://www.eff.org/rss/updates.xml",
|
29
|
+
:updated=>1373935361457,
|
30
|
+
:title=>"Deeplinks",
|
31
|
+
:items=>
|
32
|
+
[{:id=>
|
30
33
|
# ...
|
31
|
-
feed.
|
32
|
-
=>
|
33
|
-
"55jQyVFBayOwBJQ5qCX8DsgTPumTnzjw6LozTAKPiWA=_13f12b61e62:1a2a50:4b1c86ed",
|
34
|
-
:originId=>"74409 at https://www.eff.org",
|
35
|
-
:fingerprint=>"20f13975",
|
36
|
-
:title=>
|
37
|
-
"Taiwanese Users Thwart Government Plans to Introduce Internet
|
38
|
-
Blacklist Law",
|
39
|
-
:published=>1370282860000,
|
40
|
-
# ...
|
41
|
-
feed.items.length
|
42
|
-
=> 20
|
43
|
-
feed.items(count: 50, ranked: 'oldest').length
|
44
|
-
=> 50
|
34
|
+
client.get_feed_contents('feed/https://www.eff.org/rss/updates.xml', count: 1).size
|
35
|
+
=> 1
|
45
36
|
```
|
46
37
|
|
47
|
-
List of params you can pass to `items` method:
|
48
|
-
* `ranked`: 'oldest', 'newest'
|
49
|
-
* `count`: integer, number of feed items to return (1..1000)
|
50
|
-
* `continuation`: string
|
51
|
-
* maybe some other params...
|
52
|
-
|
53
38
|
## Supported Ruby Versions
|
54
39
|
|
55
40
|
feedly_api is tested under 1.9.3, 2.0.0, JRuby (1.9 mode), and Rubinius (1.9 mode).
|
data/Rakefile
CHANGED
data/lib/feedly_api.rb
CHANGED
@@ -6,6 +6,8 @@ require 'feedly_api/client'
|
|
6
6
|
require 'feedly_api/feed'
|
7
7
|
|
8
8
|
module FeedlyApi
|
9
|
+
# A Ruby client library for Feedly Reader
|
10
|
+
|
9
11
|
API_ENDPOINT = 'http://cloud.feedly.com/v3/'.freeze
|
10
12
|
|
11
13
|
class << self
|
@@ -22,6 +24,10 @@ module FeedlyApi
|
|
22
24
|
http.request(req)
|
23
25
|
end
|
24
26
|
|
27
|
+
handle_errors(response)
|
28
|
+
end
|
29
|
+
|
30
|
+
def handle_errors(response)
|
25
31
|
raise BadRequest if 'null' == response.body
|
26
32
|
|
27
33
|
case response.code.to_i
|
@@ -30,7 +36,7 @@ module FeedlyApi
|
|
30
36
|
when 403 then raise AuthError
|
31
37
|
when 404 then raise NotFound
|
32
38
|
when 500 then raise Error
|
33
|
-
else
|
39
|
+
else
|
34
40
|
raise Error
|
35
41
|
end
|
36
42
|
end
|
data/lib/feedly_api/client.rb
CHANGED
@@ -14,11 +14,16 @@ module FeedlyApi
|
|
14
14
|
get_user_profile[:id]
|
15
15
|
end
|
16
16
|
|
17
|
+
def feed(feed_id)
|
18
|
+
data = get_feed_info(feed_id)
|
19
|
+
FeedlyApi::Feed.new data
|
20
|
+
end
|
21
|
+
|
17
22
|
private
|
18
23
|
|
19
24
|
def make_request(path, argv = {})
|
20
25
|
url = FeedlyApi::API_ENDPOINT + path + '?'
|
21
|
-
argv.each do |k,v|
|
26
|
+
argv.each do |k, v|
|
22
27
|
url << "#{k}=#{v}&"
|
23
28
|
end
|
24
29
|
# p url
|
data/lib/feedly_api/feed.rb
CHANGED
@@ -1,22 +1,21 @@
|
|
1
1
|
module FeedlyApi
|
2
2
|
class Feed
|
3
|
-
attr_reader :
|
3
|
+
attr_reader :website,
|
4
|
+
:subscribers,
|
5
|
+
:title,
|
6
|
+
:velocity,
|
7
|
+
:id
|
4
8
|
|
5
|
-
def initialize(
|
6
|
-
@
|
7
|
-
@
|
8
|
-
|
9
|
+
def initialize(data)
|
10
|
+
@website = data.fetch(:website)
|
11
|
+
@subscribers = data.fetch(:subscribers)
|
12
|
+
@title = data.fetch(:title)
|
13
|
+
@velocity = data.fetch(:velocity)
|
14
|
+
@id = data.fetch(:id)
|
9
15
|
end
|
10
16
|
|
11
|
-
def
|
12
|
-
|
13
|
-
@subscribers = json.fetch(:subscribers) { nil }
|
14
|
-
@title = json.fetch(:title) { nil }
|
15
|
-
@velocity = json.fetch(:velocity) { nil }
|
16
|
-
end
|
17
|
-
|
18
|
-
def items(params = {})
|
19
|
-
Api.fetch(:streams, @id, params).fetch(:items)
|
17
|
+
def items
|
18
|
+
[]
|
20
19
|
end
|
21
20
|
end
|
22
21
|
end
|
data/lib/feedly_api/version.rb
CHANGED
File without changes
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe FeedlyApi::Feed do
|
4
|
+
let(:feed_data) { {website: 'https://www.eff.org/rss/updates.xml', subscribers: 2443,
|
5
|
+
title: 'Deeplinks', velocity: 15.2,
|
6
|
+
id: 'feed/https://www.eff.org/rss/updates.xml' }
|
7
|
+
}
|
8
|
+
let(:feed) { FeedlyApi::Feed.new(feed_data) }
|
9
|
+
|
10
|
+
describe '#new' do
|
11
|
+
it 'stores website' do
|
12
|
+
expect(feed.website).to eq 'https://www.eff.org/rss/updates.xml'
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'stores subscribers' do
|
16
|
+
expect(feed.subscribers).to eq 2443
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'stores title' do
|
20
|
+
expect(feed.title).to eq 'Deeplinks'
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'stores velocity' do
|
24
|
+
expect(feed.velocity).to eq 15.2
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'stores id' do
|
28
|
+
expect(feed.id).to eq 'feed/https://www.eff.org/rss/updates.xml'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#items' do
|
33
|
+
it 'returns feed items'
|
34
|
+
# it 'returns feed items' do
|
35
|
+
# expect(feed.items.size).to eq 20
|
36
|
+
# end
|
37
|
+
|
38
|
+
it 'returns certain amount of feed items'
|
39
|
+
it 'returns feed items in certain order'
|
40
|
+
end
|
41
|
+
end
|
data/spec/lib/feedly_api_spec.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe FeedlyApi::Client do
|
4
|
+
do_stub = ENV['FEEDLY_API_BYPASS_STUBS'].nil?
|
4
5
|
let(:auth_token) { ENV['FEEDLY_TOKEN'] || 'GREATE_AUTH_TOKEN' }
|
5
6
|
let(:user_id) { ENV['FEEDLY_USER_ID'] || '00000000-000-NOT-VALID-a29b6679bb3c' }
|
6
7
|
let(:client) { FeedlyApi::Client.new auth_token }
|
7
8
|
|
8
9
|
describe '#new' do
|
9
10
|
before :each do
|
10
|
-
FeedlyApi.stub(:get).and_return(File.read(File.join('spec', 'fixtures', 'profile.json')))
|
11
|
+
FeedlyApi.stub(:get).and_return(File.read(File.join('spec', 'fixtures', 'profile.json'))) if do_stub
|
11
12
|
end
|
12
13
|
|
13
14
|
it 'creates Client object with given token' do
|
@@ -23,14 +24,14 @@ describe FeedlyApi::Client do
|
|
23
24
|
describe '#get_user_profile' do
|
24
25
|
# rewrite for more accurancy
|
25
26
|
it 'returns user info' do
|
26
|
-
FeedlyApi.stub(:get).and_return(File.read(File.join('spec', 'fixtures', 'profile.json')))
|
27
|
+
FeedlyApi.stub(:get).and_return(File.read(File.join('spec', 'fixtures', 'profile.json'))) if do_stub
|
27
28
|
expect(client.get_user_profile[:client]).to eq 'feedly'
|
28
29
|
end
|
29
30
|
end
|
30
31
|
|
31
32
|
describe '#get_feed_info' do
|
32
33
|
it 'retrievs basic feed info' do
|
33
|
-
FeedlyApi.stub(:get).and_return(File.read(File.join('spec', 'fixtures', 'feed_info.json')))
|
34
|
+
FeedlyApi.stub(:get).and_return(File.read(File.join('spec', 'fixtures', 'feed_info.json'))) if do_stub
|
34
35
|
feed_info = client.get_feed_info('feed/https://www.eff.org/rss/updates.xml')
|
35
36
|
expect(feed_info[:website]).to eq 'https://www.eff.org/rss/updates.xml'
|
36
37
|
end
|
@@ -38,20 +39,20 @@ describe FeedlyApi::Client do
|
|
38
39
|
|
39
40
|
describe '#get_subscriptions' do
|
40
41
|
it 'retrievs user subscriptions' do
|
41
|
-
FeedlyApi.stub(:get).and_return(File.read(File.join('spec', 'fixtures', 'subscriptions.json')))
|
42
|
+
FeedlyApi.stub(:get).and_return(File.read(File.join('spec', 'fixtures', 'subscriptions.json'))) if do_stub
|
42
43
|
expect(client.get_subscriptions.size).to eq 3
|
43
44
|
end
|
44
45
|
end
|
45
46
|
|
46
47
|
describe '#get_feed_contents' do
|
47
48
|
it 'retrievs feed contents' do
|
48
|
-
FeedlyApi.stub(:get).and_return(File.read(File.join('spec', 'fixtures', 'feed_contents_20.json')))
|
49
|
+
FeedlyApi.stub(:get).and_return(File.read(File.join('spec', 'fixtures', 'feed_contents_20.json'))) if do_stub
|
49
50
|
feed_contents = client.get_feed_contents('feed/https://www.eff.org/rss/updates.xml')
|
50
51
|
expect(feed_contents[:items].size).to eq 20
|
51
52
|
end
|
52
53
|
|
53
54
|
it 'retrievs custom number of feed items' do
|
54
|
-
FeedlyApi.stub(:get).and_return(File.read(File.join('spec', 'fixtures', 'feed_contents_10.json')))
|
55
|
+
FeedlyApi.stub(:get).and_return(File.read(File.join('spec', 'fixtures', 'feed_contents_10.json'))) if do_stub
|
55
56
|
feed_contents = client.get_feed_contents('feed/https://www.eff.org/rss/updates.xml', {count: 10})
|
56
57
|
expect(feed_contents[:items].size).to eq 10
|
57
58
|
end
|
@@ -63,7 +64,7 @@ describe FeedlyApi::Client do
|
|
63
64
|
|
64
65
|
describe '#get_tag_contents' do
|
65
66
|
it 'retrievs content for specific tag' do
|
66
|
-
FeedlyApi.stub(:get).and_return(File.read(File.join('spec', 'fixtures', 'tagged.json')))
|
67
|
+
FeedlyApi.stub(:get).and_return(File.read(File.join('spec', 'fixtures', 'tagged.json'))) if do_stub
|
67
68
|
feed_contents = client.get_tag_contents('global.saved')
|
68
69
|
expect(feed_contents[:items].size).to eq 1
|
69
70
|
end
|
@@ -77,13 +78,13 @@ describe FeedlyApi::Client do
|
|
77
78
|
|
78
79
|
describe '#get_category_contents' do
|
79
80
|
it 'retrievs content for custom category_id' do
|
80
|
-
FeedlyApi.stub(:get).and_return(File.read(File.join('spec', 'fixtures', 'uncategoriezed.json')))
|
81
|
+
FeedlyApi.stub(:get).and_return(File.read(File.join('spec', 'fixtures', 'uncategoriezed.json'))) if do_stub
|
81
82
|
feed_contents = client.get_category_contents('global.uncategorized')
|
82
83
|
expect(feed_contents[:items].size).to eq 16
|
83
84
|
end
|
84
85
|
|
85
86
|
it 'retrievs custom number of feed items for specific category_id' do
|
86
|
-
FeedlyApi.stub(:get).and_return(File.read(File.join('spec', 'fixtures', 'uncategoriezed_10.json')))
|
87
|
+
FeedlyApi.stub(:get).and_return(File.read(File.join('spec', 'fixtures', 'uncategoriezed_10.json'))) if do_stub
|
87
88
|
feed_contents = client.get_category_contents('global.uncategorized', {count: 10})
|
88
89
|
expect(feed_contents[:items].size).to eq 10
|
89
90
|
end
|
@@ -91,8 +92,15 @@ describe FeedlyApi::Client do
|
|
91
92
|
|
92
93
|
describe '#get_markers' do
|
93
94
|
it 'returns unred counts for all feeds' do
|
94
|
-
FeedlyApi.stub(:get).and_return(File.read(File.join('spec', 'fixtures', 'markers.json')))
|
95
|
+
FeedlyApi.stub(:get).and_return(File.read(File.join('spec', 'fixtures', 'markers.json'))) if do_stub
|
95
96
|
expect(client.get_markers[:unreadcounts].last[:count]).to eq 16
|
96
97
|
end
|
97
98
|
end
|
99
|
+
|
100
|
+
describe '#feed' do
|
101
|
+
it 'returns Feed object for current feed id' do
|
102
|
+
feed = client.feed('feed/https://www.eff.org/rss/updates.xml')
|
103
|
+
expect(feed).to be_instance_of(FeedlyApi::Feed)
|
104
|
+
end
|
105
|
+
end
|
98
106
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: feedly_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Myuzu
|
@@ -75,6 +75,7 @@ files:
|
|
75
75
|
- .gitignore
|
76
76
|
- .rspec
|
77
77
|
- .travis.yml
|
78
|
+
- CHANGELOG.md
|
78
79
|
- Gemfile
|
79
80
|
- LICENSE
|
80
81
|
- README.md
|
@@ -85,6 +86,7 @@ files:
|
|
85
86
|
- lib/feedly_api/client.rb
|
86
87
|
- lib/feedly_api/errors.rb
|
87
88
|
- lib/feedly_api/feed.rb
|
89
|
+
- lib/feedly_api/feed_item.rb
|
88
90
|
- lib/feedly_api/version.rb
|
89
91
|
- spec/fixtures/feed_contents_10.json
|
90
92
|
- spec/fixtures/feed_contents_20.json
|
@@ -95,6 +97,9 @@ files:
|
|
95
97
|
- spec/fixtures/tagged.json
|
96
98
|
- spec/fixtures/uncategoriezed.json
|
97
99
|
- spec/fixtures/uncategoriezed_10.json
|
100
|
+
- spec/lib/feedly_api/client_spec.rb
|
101
|
+
- spec/lib/feedly_api/feed_item_spec.rb
|
102
|
+
- spec/lib/feedly_api/feed_spec.rb
|
98
103
|
- spec/lib/feedly_api_spec.rb
|
99
104
|
- spec/spec_helper.rb
|
100
105
|
homepage: https://github.com/Myuzu/feedly_api
|