feedly_api 0.3b → 0.4b

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aa7b9a5e1ff711b239e67177e6ba857d219bbda6
4
- data.tar.gz: 0428afa39ef088f27ad2f2f9f68d6414a80c21b7
3
+ metadata.gz: e10ba937ee8365a176d401cb4a4d0d19e7ed04d9
4
+ data.tar.gz: c227bf1ad3674a71b969cf21f3df017134c830c0
5
5
  SHA512:
6
- metadata.gz: cd76d9b7bee053885031f4c5a480b2e6b6e1bffa53af50676152f4c1def64448aaa405910c5d07be7d4d5f7f4a930f1825839a283b6db668edb79152f96dccf6
7
- data.tar.gz: 2c3be7a251a7b9519079463554570971ae88e952b23bf185eaf927f896e9dee651280a5b7bc6a16bf754902d6d80745af1824b16f11c84b649e4d616bb57fe52
6
+ metadata.gz: b9d1c14a4300efb6ee8c7ff6da7d1162b75ebfaaf23bb0f2ec0b319cc42f9b5bb5b804de8ce33058cf8d94ee3dc48ae054e205e00fb7e1f5182593d194b5a296
7
+ data.tar.gz: a5869186cbba6d7ce01fc979a53ad062c38579870b976530741c93f1f9cda04c48a51f36b901e7d869714f5614b8b70cad103a8b1f661a7a4c634da1a5756f4a
data/.travis.yml CHANGED
@@ -1,3 +1,5 @@
1
1
  rvm:
2
2
  - 1.9.3
3
3
  - 2.0.0
4
+ - jruby-19mode
5
+ - rbx-19mode
data/README.md CHANGED
@@ -1,8 +1,13 @@
1
- feedly_api
1
+ feedly_api [![Build Status](https://travis-ci.org/Myuzu/feedly_api.png?branch=master)](https://travis-ci.org/Myuzu/feedly_api) [![Code Climate](https://codeclimate.com/github/Myuzu/feedly_api.png)](https://codeclimate.com/github/Myuzu/feedly_api) [![Dependency Status](https://gemnasium.com/Myuzu/feedly_api.png)](https://gemnasium.com/Myuzu/feedly_api) [![Gem Version](https://badge.fury.io/rb/feedly_api.png)](http://badge.fury.io/rb/feedly_api)
2
2
  ==========
3
3
 
4
4
  Early unofficial Feedly API
5
5
 
6
+ ## Limitations
7
+ * no auth for now
8
+ * only feed stats and feed items
9
+ * continuation not implemented
10
+
6
11
  ## Usage
7
12
 
8
13
  ```ruby
data/lib/feedly_api.rb CHANGED
@@ -1,63 +1,34 @@
1
1
  # encoding: utf-8
2
2
 
3
- module FeedlyApi
4
- VERSION = '0.3b'
5
- API_ENDPOINT = 'http://cloud.feedly.com/v3/'
3
+ require 'feedly_api/version'
4
+ require 'feedly_api/errors'
5
+ require 'feedly_api/api'
6
+ require 'feedly_api/client'
6
7
 
8
+ module FeedlyApi
7
9
  class Feed
8
10
  attr_reader :url, :subscribers, :title, :velocity
9
11
 
10
12
  def initialize(url)
11
13
  @url = url
14
+ @id = "feed%2F#{CGI.escape(@url)}"
12
15
  get_info
13
16
  end
14
17
 
15
18
  def get_info
16
- url = API_ENDPOINT
17
- url += 'feeds/feed%2F'
18
- url += CGI.escape(@url)
19
- json = JSON.parse(get(url))
20
-
21
- @subscribers = json['subscribers']
22
- @title = json['title']
23
- @velocity = json['velocity']
19
+ json = Api.fetch(:feeds, @id)
20
+ @subscribers = json.fetch(:subscribers)
21
+ @title = json.fetch(:title)
22
+ @velocity = json.fetch(:velocity)
24
23
  end
25
24
 
26
25
  def items(params = {})
27
- json = JSON.parse(get(construct_url(params)), symbolize_names: true)
28
- json[:items]
29
- end
30
-
31
- private
32
-
33
- def construct_url(options)
34
- params = options.map { |k,v| "#{k.to_s}=#{v.to_s}&" }.join
35
- url = FeedlyApi::API_ENDPOINT
36
- url += 'streams/feed%2F'
37
- url += CGI.escape(@url)
38
- url += '/contents?'
39
- url += "ck=#{Time.now.to_i}000&"
40
- url += params
41
- end
42
-
43
- def get(url)
44
- response = Net::HTTP.get_response(URI(url))
45
- raise unless 200 == response.code.to_i
46
- response.body
47
- end
48
- end
49
-
50
- class Client
51
- def initialize(auth_token = nil)
52
- @auth_token = auth_token
53
- end
54
-
55
- def feed(feed_url)
56
- FeedlyApi::Feed.new feed_url
26
+ Api.fetch(:streams, @id, params).fetch(:items)
57
27
  end
58
28
  end
59
29
 
60
30
  require 'cgi'
61
31
  require 'net/http'
62
32
  require 'json'
33
+ require 'date'
63
34
  end
@@ -0,0 +1,30 @@
1
+ module FeedlyApi
2
+ module Api
3
+ API_ENDPOINT = 'http://cloud.feedly.com/v3/'
4
+
5
+ class << self
6
+ def fetch(resource, id, params = {})
7
+ params = params.map { |k,v| "#{k.to_s}=#{v.to_s}&" }.join
8
+
9
+ url = API_ENDPOINT
10
+ url += resource.to_s
11
+ url += '/'
12
+ url += id
13
+ url += '/contents' if :streams == resource
14
+ url += "?ck=#{Time.now.to_i}000&"
15
+ url += params
16
+
17
+ JSON.parse(get(url), symbolize_names: true)
18
+ end
19
+
20
+ private
21
+
22
+ def get(url)
23
+ response = Net::HTTP.get_response(URI(url))
24
+ raise Error unless 200 == response.code.to_i
25
+ raise BadRequest if 'null' == response.body
26
+ response.body
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,11 @@
1
+ module FeedlyApi
2
+ class Client
3
+ def initialize(auth_token = nil)
4
+ @auth_token = auth_token
5
+ end
6
+
7
+ def feed(feed_url)
8
+ FeedlyApi::Feed.new feed_url
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,4 @@
1
+ module FeedlyApi
2
+ class Error < StandardError; end
3
+ class BadRequest < StandardError; end
4
+ end
@@ -0,0 +1,3 @@
1
+ module FeedlyApi
2
+ VERSION = '0.4b'
3
+ end
@@ -2,8 +2,4 @@ require 'spec_helper'
2
2
 
3
3
  describe FeedlyApi do
4
4
 
5
- describe '#new' do
6
-
7
- end
8
-
9
5
  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.3b
4
+ version: 0.4b
5
5
  platform: ruby
6
6
  authors:
7
7
  - Myuzu
@@ -67,6 +67,10 @@ files:
67
67
  - Rakefile
68
68
  - feedly_api.gemspec
69
69
  - lib/feedly_api.rb
70
+ - lib/feedly_api/api.rb
71
+ - lib/feedly_api/client.rb
72
+ - lib/feedly_api/errors.rb
73
+ - lib/feedly_api/version.rb
70
74
  - spec/lib/feedly_api_spec.rb
71
75
  - spec/spec_helper.rb
72
76
  homepage: https://github.com/Myuzu/feedly_api
@@ -94,4 +98,3 @@ signing_key:
94
98
  specification_version: 4
95
99
  summary: Ruby wrapper for Feedly API
96
100
  test_files: []
97
- has_rdoc: