feedly_api 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 405308a3fdd8fa2af2f1e876fe90818920269ffb
4
- data.tar.gz: a573029f11f75f6384b09603e5904f3912bec219
3
+ metadata.gz: 43a7715f0add0564eacbedfd563c66f1756b46c7
4
+ data.tar.gz: 61c1853e5aa7cddfb0514a39a05996650cbb7781
5
5
  SHA512:
6
- metadata.gz: d3d47994b7708357079bb72eaac8106a83f4b41f2bdc4f7c431ed35e89bfc6c68d301ca862a964d77afa9984866b4b441a92fae97374fd1c9eba1f1afd68eaba
7
- data.tar.gz: 1776e3b5b6e5f9e94f2a5ae7f7e506470084e7522ead049f50c7fdaf9584ffe31a5f5ddb5f8b295a1a3dbf934d8e93aebcdd7f0c117221f81824dfd4670a85d9
6
+ metadata.gz: 9d695edda17f345ad9c2f99c36bf3e78f77a12873ba9745ad7557228ef0b75121ce9ba4d4ae438f868c946dd4c65b1d931f29de76c39243b0b72ae9fa45f19d1
7
+ data.tar.gz: 5aa2b7af45b8a65b8bff4ce0369f6225b11edc36a73998acfc30b4c783b8796c7970a7034b9e8a640aeacb7279d8a6718980af1a63e541515ac8e1fb95e78bf3
@@ -0,0 +1,2 @@
1
+ # 2013-07-16
2
+ * Change API, add requests with auth token
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:0xb91fed0c @auth_token=nil>
17
- feed = feedly.feed 'https://www.eff.org/rss/updates.xml'
18
- => #<FeedlyApi::Feed:0xb90aef38
19
- @subscribers=2348,
20
- @title="Deeplinks",
21
- @url="https://www.eff.org/rss/updates.xml",
22
- @velocity=15.2>
23
- feed.items
24
- => [{:id=>
25
- "55jQyVFBayOwBJQ5qCX8DsgTPumTnzjw6LozTAKPiWA=_13fa6b1134b:1a10f:eacbe387",
26
- :originId=>"74790 at https://www.eff.org",
27
- :fingerprint=>"2a5c0169",
28
- :title=>"Weev's Case Flawed From Beginning to End",
29
- :published=>1372888846000,
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.items(ranked: 'oldest')
32
- => [{:id=>
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
@@ -2,8 +2,8 @@
2
2
 
3
3
  require 'rspec/core/rake_task'
4
4
 
5
- RSpec::Core::RakeTask.new do |t|
6
- t.rspec_opts = '--color --format doc'
5
+ RSpec::Core::RakeTask.new(:spec) do |t|
6
+ t.rspec_opts = '--color --format doc'
7
7
  end
8
8
 
9
9
  task default: :spec
@@ -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
@@ -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
@@ -1,22 +1,21 @@
1
1
  module FeedlyApi
2
2
  class Feed
3
- attr_reader :url, :subscribers, :title, :velocity, :id
3
+ attr_reader :website,
4
+ :subscribers,
5
+ :title,
6
+ :velocity,
7
+ :id
4
8
 
5
- def initialize(url)
6
- @url = url
7
- @id = "feed%2F#{CGI.escape(@url)}"
8
- get_info
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 get_info
12
- json = Api.fetch(:feeds, @id)
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
@@ -0,0 +1,5 @@
1
+ module FeedlyApi
2
+ class FeedItem
3
+
4
+ end
5
+ end
@@ -1,3 +1,3 @@
1
1
  module FeedlyApi
2
- VERSION = '0.5.0'
2
+ VERSION = '0.5.1'
3
3
  end
@@ -0,0 +1,4 @@
1
+ require 'spec_helper'
2
+
3
+ describe FeedlyApi::Client do
4
+ end
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
@@ -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.0
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