feedly_api 0.5.1 → 0.6.0

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: 43a7715f0add0564eacbedfd563c66f1756b46c7
4
- data.tar.gz: 61c1853e5aa7cddfb0514a39a05996650cbb7781
3
+ metadata.gz: 6b7519c1e6112dda9cd35da6fd2951dda5c047ba
4
+ data.tar.gz: e3c7d15e7057f90ed01186acb927a8e8d3f40da0
5
5
  SHA512:
6
- metadata.gz: 9d695edda17f345ad9c2f99c36bf3e78f77a12873ba9745ad7557228ef0b75121ce9ba4d4ae438f868c946dd4c65b1d931f29de76c39243b0b72ae9fa45f19d1
7
- data.tar.gz: 5aa2b7af45b8a65b8bff4ce0369f6225b11edc36a73998acfc30b4c783b8796c7970a7034b9e8a640aeacb7279d8a6718980af1a63e541515ac8e1fb95e78bf3
6
+ metadata.gz: 57e4764514164564323c3b53f75d26debf5fb921485c678860c2832d48cd657fcc5c4d66cc074216b90384c9914be1e5a5a20c03d438a9b6773aaa520a073a64
7
+ data.tar.gz: b21d6794aa1ae065de8d2c10dc472dbdafe24181c916b792ad23b39990c287a1b8efdf58d96056c265951839509b22146f92b3193503b55d0af58a275ac7ae87
data/LICENSE CHANGED
@@ -1,13 +1,21 @@
1
- Copyright 2013 Myuzu
1
+ The MIT License (MIT)
2
2
 
3
- Licensed under the Apache License, Version 2.0 (the "License");
4
- you may not use this file except in compliance with the License.
5
- You may obtain a copy of the License at
3
+ Copyright (c) 2014 Myuzu
6
4
 
7
- http://www.apache.org/licenses/LICENSE-2.0
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
8
11
 
9
- Unless required by applicable law or agreed to in writing, software
10
- distributed under the License is distributed on an "AS IS" BASIS,
11
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- See the License for the specific language governing permissions and
13
- limitations under the License.
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -12,27 +12,14 @@ Early unofficial Feedly API with no external dependencies
12
12
  ## Usage
13
13
 
14
14
  ```ruby
15
- feedly = FeedlyApi::Client.new
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=>
33
- # ...
34
- client.get_feed_contents('feed/https://www.eff.org/rss/updates.xml', count: 1).size
35
- => 1
15
+ # Create client for API requests; OAuth token optional
16
+ @client = FeedlyApi::Client.new
17
+ # Create Feed object for specific feed id
18
+ @feed = @client.feed('feed/https://www.eff.org/rss/updates.xml')
19
+ # Get array of feed items hashes
20
+ @feed.items
21
+ # Pass params to get more or less items
22
+ @feed.items(count: 50)
36
23
  ```
37
24
 
38
25
  ## Supported Ruby Versions
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
9
9
  s.homepage = 'https://github.com/Myuzu/feedly_api'
10
10
  s.summary = %q{Ruby wrapper for Feedly API}
11
11
  s.description = %q{Simpe unofficial Feedly API wrapper. No auth yet.}
12
- s.license = 'Apache License, Version 2.0'
12
+ s.license = 'MIT License'
13
13
 
14
14
  s.files = `git ls-files`.split("\n")
15
15
  s.require_paths = ['lib']
@@ -13,7 +13,7 @@ module FeedlyApi
13
13
  class << self
14
14
  def get(url, token)
15
15
  uri = URI(url)
16
- req = Net::HTTP::Get.new(uri)
16
+ req = Net::HTTP::Get.new(uri.request_uri)
17
17
 
18
18
  unless token.nil?
19
19
  req['$Authorization.feedly'] = '$FeedlyAuth'
@@ -15,8 +15,7 @@ module FeedlyApi
15
15
  end
16
16
 
17
17
  def feed(feed_id)
18
- data = get_feed_info(feed_id)
19
- FeedlyApi::Feed.new data
18
+ Feed.new(self, feed_id)
20
19
  end
21
20
 
22
21
  private
@@ -4,18 +4,29 @@ module FeedlyApi
4
4
  :subscribers,
5
5
  :title,
6
6
  :velocity,
7
- :id
7
+ :id,
8
+ :client
8
9
 
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)
10
+ def initialize(client = Client.new, feed_id)
11
+ @client = client
12
+ @id = feed_id
13
+
14
+ fetch_feed_info
15
+ end
16
+
17
+ def items(args = {})
18
+ @client.get_feed_contents(@id, args).fetch(:items) {[]}
15
19
  end
16
20
 
17
- def items
18
- []
21
+ private
22
+
23
+ def fetch_feed_info
24
+ data = @client.get_feed_info(@id)
25
+
26
+ @website = data.fetch(:website) { nil }
27
+ @subscribers = data.fetch(:subscribers) { nil }
28
+ @title = data.fetch(:title) { nil }
29
+ @velocity = data.fetch(:velocity) { nil }
19
30
  end
20
31
  end
21
32
  end
@@ -1,3 +1,3 @@
1
1
  module FeedlyApi
2
- VERSION = '0.5.1'
2
+ VERSION = '0.6.0'
3
3
  end
@@ -1,4 +1,18 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe FeedlyApi::Client do
4
+ let(:auth_token) { ENV['FEEDLY_TOKEN'] || 'GREATE_AUTH_TOKEN' }
5
+ let(:user_id) { ENV['FEEDLY_USER_ID'] || '00000000-000-NOT-VALID-a29b6679bb3c' }
6
+ let(:client) { FeedlyApi::Client.new(auth_token) }
7
+ let(:feed_data) { {website: 'https://www.eff.org/rss/updates.xml', subscribers: 2443,
8
+ title: 'Deeplinks', velocity: 15.2,
9
+ id: 'feed/https://www.eff.org/rss/updates.xml' }
10
+ }
11
+
12
+ describe '#feed' do
13
+ it 'returns Feed object with given feed_id' do
14
+ feed = client.feed(feed_data[:id])
15
+ expect(feed.id).to eq feed_data[:id]
16
+ end
17
+ end
4
18
  end
@@ -1,41 +1,23 @@
1
1
  require 'spec_helper'
2
2
 
3
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) }
4
+ DEFAULT_ITEMS_SIZE = 20
9
5
 
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
6
+ let(:auth_token) { ENV['FEEDLY_TOKEN'] || 'GREATE_AUTH_TOKEN' }
7
+ let(:user_id) { ENV['FEEDLY_USER_ID'] || '00000000-000-NOT-VALID-a29b6679bb3c' }
8
+ let(:feed_id) { 'feed/https://www.eff.org/rss/updates.xml' }
9
+ let(:feed) { FeedlyApi::Client.new(auth_token).feed(feed_id) }
22
10
 
23
- it 'stores velocity' do
24
- expect(feed.velocity).to eq 15.2
11
+ describe '#items' do
12
+ it 'returns feed items' do
13
+ expect(feed.items.size).to eq DEFAULT_ITEMS_SIZE
25
14
  end
26
15
 
27
- it 'stores id' do
28
- expect(feed.id).to eq 'feed/https://www.eff.org/rss/updates.xml'
16
+ it 'returns certain amount of feed items' do
17
+ items = feed.items(count: 2)
18
+ expect(items.size).to eq 2
29
19
  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
20
 
38
- it 'returns certain amount of feed items'
39
21
  it 'returns feed items in certain order'
40
22
  end
41
23
  end
@@ -1,14 +1,13 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe FeedlyApi::Client do
4
- do_stub = ENV['FEEDLY_API_BYPASS_STUBS'].nil?
5
- let(:auth_token) { ENV['FEEDLY_TOKEN'] || 'GREATE_AUTH_TOKEN' }
4
+ let(:auth_token) { ENV['FEEDLY_TOKEN'] || 'GREATE_AUTH_TOKEN' }
6
5
  let(:user_id) { ENV['FEEDLY_USER_ID'] || '00000000-000-NOT-VALID-a29b6679bb3c' }
7
6
  let(:client) { FeedlyApi::Client.new auth_token }
8
7
 
9
8
  describe '#new' do
10
9
  before :each do
11
- FeedlyApi.stub(:get).and_return(File.read(File.join('spec', 'fixtures', 'profile.json'))) if do_stub
10
+ FeedlyApi.stub(:get).and_return(File.read(File.join('spec', 'fixtures', 'profile.json')))
12
11
  end
13
12
 
14
13
  it 'creates Client object with given token' do
@@ -17,21 +16,21 @@ describe FeedlyApi::Client do
17
16
  end
18
17
 
19
18
  it 'saves user_id' do
20
- expect(client.user_id).to eq '00000000-000-NOT-VALID-a29b6679bb3c' #user_id
19
+ expect(client.user_id).to eq user_id
21
20
  end
22
21
  end
23
22
 
24
23
  describe '#get_user_profile' do
25
24
  # rewrite for more accurancy
26
25
  it 'returns user info' do
27
- FeedlyApi.stub(:get).and_return(File.read(File.join('spec', 'fixtures', 'profile.json'))) if do_stub
26
+ FeedlyApi.stub(:get).and_return(File.read(File.join('spec', 'fixtures', 'profile.json')))
28
27
  expect(client.get_user_profile[:client]).to eq 'feedly'
29
28
  end
30
29
  end
31
30
 
32
31
  describe '#get_feed_info' do
33
32
  it 'retrievs basic feed info' do
34
- FeedlyApi.stub(:get).and_return(File.read(File.join('spec', 'fixtures', 'feed_info.json'))) if do_stub
33
+ FeedlyApi.stub(:get).and_return(File.read(File.join('spec', 'fixtures', 'feed_info.json')))
35
34
  feed_info = client.get_feed_info('feed/https://www.eff.org/rss/updates.xml')
36
35
  expect(feed_info[:website]).to eq 'https://www.eff.org/rss/updates.xml'
37
36
  end
@@ -39,20 +38,20 @@ describe FeedlyApi::Client do
39
38
 
40
39
  describe '#get_subscriptions' do
41
40
  it 'retrievs user subscriptions' do
42
- FeedlyApi.stub(:get).and_return(File.read(File.join('spec', 'fixtures', 'subscriptions.json'))) if do_stub
41
+ FeedlyApi.stub(:get).and_return(File.read(File.join('spec', 'fixtures', 'subscriptions.json')))
43
42
  expect(client.get_subscriptions.size).to eq 3
44
43
  end
45
44
  end
46
45
 
47
46
  describe '#get_feed_contents' do
48
47
  it 'retrievs feed contents' do
49
- FeedlyApi.stub(:get).and_return(File.read(File.join('spec', 'fixtures', 'feed_contents_20.json'))) if do_stub
48
+ FeedlyApi.stub(:get).and_return(File.read(File.join('spec', 'fixtures', 'feed_contents_20.json')))
50
49
  feed_contents = client.get_feed_contents('feed/https://www.eff.org/rss/updates.xml')
51
50
  expect(feed_contents[:items].size).to eq 20
52
51
  end
53
52
 
54
53
  it 'retrievs custom number of feed items' do
55
- FeedlyApi.stub(:get).and_return(File.read(File.join('spec', 'fixtures', 'feed_contents_10.json'))) if do_stub
54
+ FeedlyApi.stub(:get).and_return(File.read(File.join('spec', 'fixtures', 'feed_contents_10.json')))
56
55
  feed_contents = client.get_feed_contents('feed/https://www.eff.org/rss/updates.xml', {count: 10})
57
56
  expect(feed_contents[:items].size).to eq 10
58
57
  end
@@ -64,7 +63,7 @@ describe FeedlyApi::Client do
64
63
 
65
64
  describe '#get_tag_contents' do
66
65
  it 'retrievs content for specific tag' do
67
- FeedlyApi.stub(:get).and_return(File.read(File.join('spec', 'fixtures', 'tagged.json'))) if do_stub
66
+ FeedlyApi.stub(:get).and_return(File.read(File.join('spec', 'fixtures', 'tagged.json')))
68
67
  feed_contents = client.get_tag_contents('global.saved')
69
68
  expect(feed_contents[:items].size).to eq 1
70
69
  end
@@ -78,13 +77,13 @@ describe FeedlyApi::Client do
78
77
 
79
78
  describe '#get_category_contents' do
80
79
  it 'retrievs content for custom category_id' do
81
- FeedlyApi.stub(:get).and_return(File.read(File.join('spec', 'fixtures', 'uncategoriezed.json'))) if do_stub
80
+ FeedlyApi.stub(:get).and_return(File.read(File.join('spec', 'fixtures', 'uncategoriezed.json')))
82
81
  feed_contents = client.get_category_contents('global.uncategorized')
83
82
  expect(feed_contents[:items].size).to eq 16
84
83
  end
85
84
 
86
85
  it 'retrievs custom number of feed items for specific category_id' do
87
- FeedlyApi.stub(:get).and_return(File.read(File.join('spec', 'fixtures', 'uncategoriezed_10.json'))) if do_stub
86
+ FeedlyApi.stub(:get).and_return(File.read(File.join('spec', 'fixtures', 'uncategoriezed_10.json')))
88
87
  feed_contents = client.get_category_contents('global.uncategorized', {count: 10})
89
88
  expect(feed_contents[:items].size).to eq 10
90
89
  end
@@ -92,15 +91,8 @@ describe FeedlyApi::Client do
92
91
 
93
92
  describe '#get_markers' do
94
93
  it 'returns unred counts for all feeds' do
95
- FeedlyApi.stub(:get).and_return(File.read(File.join('spec', 'fixtures', 'markers.json'))) if do_stub
94
+ FeedlyApi.stub(:get).and_return(File.read(File.join('spec', 'fixtures', 'markers.json')))
96
95
  expect(client.get_markers[:unreadcounts].last[:count]).to eq 16
97
96
  end
98
97
  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
106
98
  end
metadata CHANGED
@@ -1,69 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: feedly_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Myuzu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-16 00:00:00.000000000 Z
11
+ date: 2014-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: pry
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: coveralls
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  description: Simpe unofficial Feedly API wrapper. No auth yet.
@@ -72,9 +72,9 @@ executables: []
72
72
  extensions: []
73
73
  extra_rdoc_files: []
74
74
  files:
75
- - .gitignore
76
- - .rspec
77
- - .travis.yml
75
+ - ".gitignore"
76
+ - ".rspec"
77
+ - ".travis.yml"
78
78
  - CHANGELOG.md
79
79
  - Gemfile
80
80
  - LICENSE
@@ -104,7 +104,7 @@ files:
104
104
  - spec/spec_helper.rb
105
105
  homepage: https://github.com/Myuzu/feedly_api
106
106
  licenses:
107
- - Apache License, Version 2.0
107
+ - MIT License
108
108
  metadata: {}
109
109
  post_install_message:
110
110
  rdoc_options: []
@@ -112,17 +112,17 @@ require_paths:
112
112
  - lib
113
113
  required_ruby_version: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - '>='
115
+ - - ">="
116
116
  - !ruby/object:Gem::Version
117
117
  version: 1.9.3
118
118
  required_rubygems_version: !ruby/object:Gem::Requirement
119
119
  requirements:
120
- - - '>='
120
+ - - ">="
121
121
  - !ruby/object:Gem::Version
122
122
  version: '0'
123
123
  requirements: []
124
124
  rubyforge_project:
125
- rubygems_version: 2.0.5
125
+ rubygems_version: 2.3.0
126
126
  signing_key:
127
127
  specification_version: 4
128
128
  summary: Ruby wrapper for Feedly API