feedlr 0.1.0
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 +7 -0
- data/.gitignore +17 -0
- data/.rspec +3 -0
- data/.travis.yml +22 -0
- data/.yardopts +5 -0
- data/Gemfile +32 -0
- data/Guardfile +7 -0
- data/LICENSE.md +16 -0
- data/README.md +85 -0
- data/Rakefile +10 -0
- data/feedlr.gemspec +27 -0
- data/lib/feedlr.rb +34 -0
- data/lib/feedlr/base.rb +4 -0
- data/lib/feedlr/client.rb +60 -0
- data/lib/feedlr/collection.rb +15 -0
- data/lib/feedlr/error.rb +79 -0
- data/lib/feedlr/gateway/categories.rb +36 -0
- data/lib/feedlr/gateway/entries.rb +40 -0
- data/lib/feedlr/gateway/evernote.rb +37 -0
- data/lib/feedlr/gateway/facebook.rb +28 -0
- data/lib/feedlr/gateway/feeds.rb +26 -0
- data/lib/feedlr/gateway/markers.rb +195 -0
- data/lib/feedlr/gateway/microsoft.rb +30 -0
- data/lib/feedlr/gateway/mixes.rb +29 -0
- data/lib/feedlr/gateway/opml.rb +26 -0
- data/lib/feedlr/gateway/preferences.rb +25 -0
- data/lib/feedlr/gateway/profile.rb +25 -0
- data/lib/feedlr/gateway/search.rb +41 -0
- data/lib/feedlr/gateway/shorten.rb +17 -0
- data/lib/feedlr/gateway/streams.rb +42 -0
- data/lib/feedlr/gateway/subscriptions.rb +43 -0
- data/lib/feedlr/gateway/tags.rb +88 -0
- data/lib/feedlr/gateway/topics.rb +43 -0
- data/lib/feedlr/gateway/twitter.rb +29 -0
- data/lib/feedlr/mapper.rb +25 -0
- data/lib/feedlr/rate_limit.rb +21 -0
- data/lib/feedlr/request.rb +148 -0
- data/lib/feedlr/success.rb +5 -0
- data/lib/feedlr/version.rb +15 -0
- data/spec/cassettes/Feedlr_Gateway_Categories/_change_category_label/resoponds_with_hashie_object.yml +50 -0
- data/spec/cassettes/Feedlr_Gateway_Categories/_delete_category/resoponds_with_hashie_object.yml +50 -0
- data/spec/cassettes/Feedlr_Gateway_Categories/_user_categories/resoponds_with_hashie_object.yml +52 -0
- data/spec/cassettes/Feedlr_Gateway_Entries/_add_entry/resoponds_with_hashie_object.yml +52 -0
- data/spec/cassettes/Feedlr_Gateway_Entries/_user_entries/resoponds_with_hashie_object.yml +337 -0
- data/spec/cassettes/Feedlr_Gateway_Evernote/_add_to_evernote/resoponds_with_hashie_object.yml +50 -0
- data/spec/cassettes/Feedlr_Gateway_Evernote/_evernote_notebooks/resoponds_with_hashie_object.yml +51 -0
- data/spec/cassettes/Feedlr_Gateway_Evernote/_unlink_evernote/resoponds_with_hashie_object.yml +50 -0
- data/spec/cassettes/Feedlr_Gateway_Facebook/_facebook_suggestions/resoponds_with_hashie_object.yml +52 -0
- data/spec/cassettes/Feedlr_Gateway_Facebook/_unlink_facebook/resoponds_with_hashie_object.yml +50 -0
- data/spec/cassettes/Feedlr_Gateway_Feeds/_feeds/resoponds_with_hashie_object.yml +51 -0
- data/spec/cassettes/Feedlr_Gateway_Markers/_lastest_tagged_entries/resoponds_with_hashie_object.yml +52 -0
- data/spec/cassettes/Feedlr_Gateway_Markers/_mark_articles_as_read/resoponds_with_hashie_object.yml +50 -0
- data/spec/cassettes/Feedlr_Gateway_Markers/_mark_articles_as_unread/resoponds_with_hashie_object.yml +50 -0
- data/spec/cassettes/Feedlr_Gateway_Markers/_mark_categories_as_read/with_asOf_param/resoponds_with_hashie_object.yml +50 -0
- data/spec/cassettes/Feedlr_Gateway_Markers/_mark_categories_as_read/with_lastReadEntryId_param/resoponds_with_hashie_object.yml +50 -0
- data/spec/cassettes/Feedlr_Gateway_Markers/_mark_feeds_as_read/with_asOf_param/resoponds_with_hashie_object.yml +50 -0
- data/spec/cassettes/Feedlr_Gateway_Markers/_mark_feeds_as_read/with_lastReadEntryId_param/resoponds_with_hashie_object.yml +50 -0
- data/spec/cassettes/Feedlr_Gateway_Markers/_sync_read_counts/resoponds_with_hashie_object.yml +52 -0
- data/spec/cassettes/Feedlr_Gateway_Markers/_undo_mark_categories_as_read/resoponds_with_hashie_object.yml +50 -0
- data/spec/cassettes/Feedlr_Gateway_Markers/_undo_mark_feeds_as_read/resoponds_with_hashie_object.yml +50 -0
- data/spec/cassettes/Feedlr_Gateway_Markers/_user_unread_counts/resoponds_with_hashie_object.yml +52 -0
- data/spec/cassettes/Feedlr_Gateway_Microsoft/_add_to_onenote/resoponds_with_hashie_object.yml +52 -0
- data/spec/cassettes/Feedlr_Gateway_Microsoft/_unlink_microsoft/resoponds_with_hashie_object.yml +50 -0
- data/spec/cassettes/Feedlr_Gateway_Mixes/_stream_most_engaging/resoponds_with_hashie_object.yml +102 -0
- data/spec/cassettes/Feedlr_Gateway_Opml/_import_opml/resoponds_with_hashie_object.yml +63 -0
- data/spec/cassettes/Feedlr_Gateway_Opml/_user_opml/resoponds_with_hashie_object.yml +80 -0
- data/spec/cassettes/Feedlr_Gateway_Preferences/_preferences/resoponds_with_hashie_object.yml +52 -0
- data/spec/cassettes/Feedlr_Gateway_Preferences/_update_preferences/resoponds_with_hashie_object.yml +50 -0
- data/spec/cassettes/Feedlr_Gateway_Profile/_get_profile/resoponds_with_hashie_object.yml +54 -0
- data/spec/cassettes/Feedlr_Gateway_Profile/_profile/resoponds_with_hashie_object.yml +54 -0
- data/spec/cassettes/Feedlr_Gateway_Profile/_update_profile/resoponds_with_hashie_object.yml +54 -0
- data/spec/cassettes/Feedlr_Gateway_Search/_search_feeds/resoponds_with_hashie_object.yml +303 -0
- data/spec/cassettes/Feedlr_Gateway_Search/_search_stream/resoponds_with_hashie_object.yml +1941 -0
- data/spec/cassettes/Feedlr_Gateway_Shorten/_shorten/resoponds_with_hashie_object.yml +51 -0
- data/spec/cassettes/Feedlr_Gateway_Streams/_stream_entries_contents/resoponds_with_hashie_object.yml +1150 -0
- data/spec/cassettes/Feedlr_Gateway_Streams/_stream_entries_ids/resoponds_with_hashie_object.yml +51 -0
- data/spec/cassettes/Feedlr_Gateway_Subscriptions/_add_subscription/resoponds_with_hashie_object.yml +53 -0
- data/spec/cassettes/Feedlr_Gateway_Subscriptions/_create_subscription/resoponds_with_hashie_object.yml +51 -0
- data/spec/cassettes/Feedlr_Gateway_Subscriptions/_delete_subscription/resoponds_with_hashie_object.yml +50 -0
- data/spec/cassettes/Feedlr_Gateway_Subscriptions/_update_subscription/resoponds_with_hashie_object.yml +51 -0
- data/spec/cassettes/Feedlr_Gateway_Subscriptions/_user_subscriptions/resoponds_with_hashie_object.yml +57 -0
- data/spec/cassettes/Feedlr_Gateway_Tags/_change_tag_label/resoponds_with_hashie_object.yml +50 -0
- data/spec/cassettes/Feedlr_Gateway_Tags/_delete_tags/resoponds_with_hashie_object.yml +50 -0
- data/spec/cassettes/Feedlr_Gateway_Tags/_get_tags/resoponds_with_hashie_object.yml +50 -0
- data/spec/cassettes/Feedlr_Gateway_Tags/_tag_entries/resoponds_with_hashie_object.yml +50 -0
- data/spec/cassettes/Feedlr_Gateway_Tags/_untag_entries/resoponds_with_hashie_object.yml +50 -0
- data/spec/cassettes/Feedlr_Gateway_Tags/_user_tags/resoponds_with_hashie_object.yml +50 -0
- data/spec/cassettes/Feedlr_Gateway_Topics/_add_topic/resoponds_with_hashie_object.yml +50 -0
- data/spec/cassettes/Feedlr_Gateway_Topics/_delete_topic/resoponds_with_hashie_object.yml +50 -0
- data/spec/cassettes/Feedlr_Gateway_Topics/_update_topic/resoponds_with_hashie_object.yml +50 -0
- data/spec/cassettes/Feedlr_Gateway_Topics/_user_topics/resoponds_with_hashie_object.yml +50 -0
- data/spec/cassettes/Feedlr_Gateway_Twitter/_twitter_suggestions/resoponds_with_hashie_object.yml +50 -0
- data/spec/cassettes/Feedlr_Gateway_Twitter/_unlink_twitter/resoponds_with_hashie_object.yml +50 -0
- data/spec/feedly/base_spec.rb +10 -0
- data/spec/feedly/client_spec.rb +49 -0
- data/spec/feedly/collection_spec.rb +21 -0
- data/spec/feedly/error_spec.rb +59 -0
- data/spec/feedly/feedly_spec.rb +54 -0
- data/spec/feedly/gateway/categories_spec.rb +59 -0
- data/spec/feedly/gateway/entries_spec.rb +67 -0
- data/spec/feedly/gateway/evernote_spec.rb +60 -0
- data/spec/feedly/gateway/facebook_spec.rb +36 -0
- data/spec/feedly/gateway/feeds_spec.rb +36 -0
- data/spec/feedly/gateway/markers_spec.rb +295 -0
- data/spec/feedly/gateway/microsoft_spec.rb +40 -0
- data/spec/feedly/gateway/mixes_spec.rb +27 -0
- data/spec/feedly/gateway/opml_spec.rb +57 -0
- data/spec/feedly/gateway/preferences_spec.rb +41 -0
- data/spec/feedly/gateway/profile_spec.rb +40 -0
- data/spec/feedly/gateway/search_spec.rb +43 -0
- data/spec/feedly/gateway/shorten_spec.rb +27 -0
- data/spec/feedly/gateway/streams_spec.rb +44 -0
- data/spec/feedly/gateway/subscriptions_spec.rb +87 -0
- data/spec/feedly/gateway/tags_spec.rb +129 -0
- data/spec/feedly/gateway/topics_spec.rb +77 -0
- data/spec/feedly/gateway/twitter_spec.rb +37 -0
- data/spec/feedly/mapper_spec.rb +25 -0
- data/spec/feedly/rate_limit_spec.rb +41 -0
- data/spec/feedly/request_spec.rb +74 -0
- data/spec/feedly/success_spec.rb +7 -0
- data/spec/feedly/version_spec.rb +9 -0
- data/spec/helper.rb +52 -0
- metadata +319 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 8f9c5f933f7d90ed296ad50e4483b6ff27223c49
|
|
4
|
+
data.tar.gz: fcab7c715235c6e2ecb9c4b3d1e225badc560c37
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: a7fac4759e1982913e43619c155ecbe1b05f5251348cfaf2f1d8f034b700cf8e8d1b27daa86352dd67a52ea160953c69840a94b856e340b126de4c230f666df2
|
|
7
|
+
data.tar.gz: 72e2b987f48703a02d2a2ec8e16c0b632f96d2e5fedcbaae4f2b1f71bc35b8d3e7ea03884e9a86c7e89d7975e7ccba55cac68d17a2cfa44196de29a7c3eea45d
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
bundler_args: --without development
|
|
2
|
+
language: ruby
|
|
3
|
+
rvm:
|
|
4
|
+
- 1.9.2
|
|
5
|
+
- 1.9.3
|
|
6
|
+
- 2.0.0
|
|
7
|
+
- 2.1
|
|
8
|
+
- rbx-2
|
|
9
|
+
- jruby-19mode
|
|
10
|
+
- ruby-head
|
|
11
|
+
- jruby-head
|
|
12
|
+
matrix:
|
|
13
|
+
include:
|
|
14
|
+
- rvm: jruby-19mode
|
|
15
|
+
env: JRUBY_OPTS="$JRUBY_OPTS --debug"
|
|
16
|
+
- rvm: jruby-head
|
|
17
|
+
env: JRUBY_OPTS="$JRUBY_OPTS --debug"
|
|
18
|
+
allow_failures:
|
|
19
|
+
- rvm: jruby-head
|
|
20
|
+
- rvm: rbx-2
|
|
21
|
+
- rvm: ruby-head
|
|
22
|
+
fast_finish: true
|
data/.yardopts
ADDED
data/Gemfile
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
|
+
|
|
3
|
+
gem 'jruby-openssl', :platforms => :jruby
|
|
4
|
+
gem 'rake'
|
|
5
|
+
gem 'yard'
|
|
6
|
+
|
|
7
|
+
group :development do
|
|
8
|
+
gem 'pry'
|
|
9
|
+
gem 'pry-remote'
|
|
10
|
+
gem 'pry-nav'
|
|
11
|
+
platforms :ruby_19, :ruby_20, :ruby_21 do
|
|
12
|
+
gem 'redcarpet'
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
group :test do
|
|
17
|
+
gem 'coveralls', '~> 0.7', :require => false
|
|
18
|
+
gem 'rspec', '>= 2.14'
|
|
19
|
+
gem 'rspec-nc'
|
|
20
|
+
gem 'rubocop', '>= 0.2', :platforms => [:ruby_19, :ruby_20, :ruby_21]
|
|
21
|
+
gem 'simplecov', '~> 0.7.1', :require => false
|
|
22
|
+
if RUBY_VERSION >= "1.9.3"
|
|
23
|
+
gem 'guard', '~> 2.6'
|
|
24
|
+
gem 'guard-rspec', '~> 4.2'
|
|
25
|
+
end
|
|
26
|
+
gem 'webmock', '~> 1.1'
|
|
27
|
+
gem 'vcr', '~> 2.5'
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
# Specify your gem's dependencies in feedlr.gemspec
|
|
32
|
+
gemspec
|
data/Guardfile
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
guard 'rspec' do
|
|
2
|
+
watch(%r{^spec/.+_spec\.rb$})
|
|
3
|
+
watch(%r{^spec/gateway/.+_spec\.rb$})
|
|
4
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/feedlr/#{m[1]}_spec.rb" }
|
|
5
|
+
watch(%r{^lib/gateway/(.+)\.rb$}) { |m| "spec/feedlr/gateway/#{m[1]}_spec.rb" }
|
|
6
|
+
watch('spec/helper.rb') { "spec" }
|
|
7
|
+
end
|
data/LICENSE.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Copyright (c) 2014 Khaled alHabache
|
|
2
|
+
|
|
3
|
+
LGPL-3.0 License
|
|
4
|
+
|
|
5
|
+
This library is free software; you can redistribute it and/or
|
|
6
|
+
modify it under the terms of the GNU Lesser General Public
|
|
7
|
+
License as published by the Free Software Foundation; either
|
|
8
|
+
version 3.0 of the License, or (at your option) any later version.
|
|
9
|
+
|
|
10
|
+
This library is distributed in the hope that it will be useful,
|
|
11
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
13
|
+
Lesser General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU Lesser General Public
|
|
16
|
+
License along with this library.
|
data/README.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# Feedlr
|
|
2
|
+
|
|
3
|
+
A Ruby interface to Feedly's [API](http://developer.feedly.com/).
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add this line to your application's Gemfile:
|
|
8
|
+
|
|
9
|
+
gem 'feedlr'
|
|
10
|
+
|
|
11
|
+
And then execute:
|
|
12
|
+
|
|
13
|
+
$ bundle
|
|
14
|
+
|
|
15
|
+
Or install it yourself as:
|
|
16
|
+
|
|
17
|
+
$ gem install feedlr
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
### Baisc usage
|
|
22
|
+
|
|
23
|
+
```ruby
|
|
24
|
+
require 'feedlr'
|
|
25
|
+
client = Feedlr::Client.new(oauth_access_token: 'oauth access token')
|
|
26
|
+
# Fetch user categories
|
|
27
|
+
p client.user_categories
|
|
28
|
+
# Fetch user subscriptions
|
|
29
|
+
p client.user_subscriptions
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Detailed API
|
|
33
|
+
|
|
34
|
+
You can easily inspect the available client methods:
|
|
35
|
+
|
|
36
|
+
```ruby
|
|
37
|
+
require 'feedlr'
|
|
38
|
+
client = Feedlr::Client.new
|
|
39
|
+
p client.methods.sort - Object.methods
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Also, the gem is fairly documented. Browse the YARD [documentaion](http://rubydoc.info/gems/feedlr/) for more information.
|
|
43
|
+
|
|
44
|
+
### Global configuration
|
|
45
|
+
|
|
46
|
+
You can have a global configuration that instances can use. For example, you can have the following in some initializer's code:
|
|
47
|
+
|
|
48
|
+
```ruby
|
|
49
|
+
Feedlr.configure do |config|
|
|
50
|
+
config.oauth_access_token = 'oauth access token'
|
|
51
|
+
config.sandbox = true
|
|
52
|
+
config.logger = SomeCustomLogger.new
|
|
53
|
+
end
|
|
54
|
+
```
|
|
55
|
+
And elsewhere you can do:
|
|
56
|
+
```ruby
|
|
57
|
+
client = Feedlr::Client.new
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Instance initialization
|
|
61
|
+
|
|
62
|
+
You can set the oauth access token, a custom logger(if needed) and whether or not to use the client on sandbox(develpment) mode:
|
|
63
|
+
|
|
64
|
+
```ruby
|
|
65
|
+
require 'feedlr'
|
|
66
|
+
require 'logger'
|
|
67
|
+
client = Feedlr::Client.new(
|
|
68
|
+
oauth_access_token: 'oauth access token',
|
|
69
|
+
sandbox: true,
|
|
70
|
+
logger: Logger.new(STDOUT)
|
|
71
|
+
)
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Rate limiting
|
|
75
|
+
|
|
76
|
+
The client deals with a variaty of [errors](http://rubydoc.info/gems/feedlr/Error). The errors have a corresponding [rate_limit]((http://rubydoc.info/gems/feedlr/RateLimit)) object that maps to the returned rate limiting [headers](http://developer.feedly.com/v3/#rate-limiting) if any.
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
## Contributing
|
|
80
|
+
|
|
81
|
+
1. Fork it
|
|
82
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
83
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
84
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
85
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
require 'rspec/core/rake_task'
|
|
2
|
+
require 'bundler/gem_tasks'
|
|
3
|
+
|
|
4
|
+
# Default directory to look in is `/specs`
|
|
5
|
+
# Run with `rake spec`
|
|
6
|
+
RSpec::Core::RakeTask.new(:spec) do |task|
|
|
7
|
+
task.rspec_opts = ['--color', '--format', 'doc']
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
task :default => :spec
|
data/feedlr.gemspec
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
|
|
5
|
+
require 'feedlr/version'
|
|
6
|
+
|
|
7
|
+
Gem::Specification.new do |gem|
|
|
8
|
+
gem.add_dependency 'hashie', '~> 2.0'
|
|
9
|
+
gem.add_dependency 'multi_xml', '~> 0.5'
|
|
10
|
+
gem.add_dependency 'multi_json', '~> 1.0'
|
|
11
|
+
gem.add_dependency 'faraday', '~> 0.9'
|
|
12
|
+
gem.add_dependency 'faraday_middleware', '~> 0.9'
|
|
13
|
+
|
|
14
|
+
gem.name = 'feedlr'
|
|
15
|
+
gem.version = Feedlr::Version
|
|
16
|
+
gem.authors = ['Khaled alHabache']
|
|
17
|
+
gem.email = ['khellls@gmail.com']
|
|
18
|
+
gem.description = %q(A Ruby interface to the Feedly API.)
|
|
19
|
+
gem.summary = %q(A Ruby interface to the Feedly API.)
|
|
20
|
+
gem.homepage = 'http://github.com/khelll/feedlr'
|
|
21
|
+
gem.license = 'LGPL-3'
|
|
22
|
+
gem.required_ruby_version = '>= 1.9.2'
|
|
23
|
+
gem.files = `git ls-files`.split($/)
|
|
24
|
+
gem.executables = gem.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
25
|
+
gem.test_files = Dir.glob('spec/**/*')
|
|
26
|
+
gem.require_paths = ['lib']
|
|
27
|
+
end
|
data/lib/feedlr.rb
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
require_relative 'feedlr/version'
|
|
2
|
+
require_relative 'feedlr/client'
|
|
3
|
+
# Feedlr top level module
|
|
4
|
+
module Feedlr
|
|
5
|
+
class << self
|
|
6
|
+
attr_accessor :oauth_access_token, :logger
|
|
7
|
+
attr_writer :sandbox
|
|
8
|
+
|
|
9
|
+
# config/initializers/Feedlr.rb (for instance)
|
|
10
|
+
#
|
|
11
|
+
# ```ruby
|
|
12
|
+
# Feedlr.configure do |config|
|
|
13
|
+
# config.oauth_access_token = 'oauth_access_token'
|
|
14
|
+
# config.sandbox = true
|
|
15
|
+
# config.logger = SomeCustomLogger.new
|
|
16
|
+
# end
|
|
17
|
+
# ```
|
|
18
|
+
# elsewhere
|
|
19
|
+
#
|
|
20
|
+
# ```ruby
|
|
21
|
+
# client = Feedlr::Client.new
|
|
22
|
+
# ```
|
|
23
|
+
|
|
24
|
+
def configure
|
|
25
|
+
yield self
|
|
26
|
+
true
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Returns the value of attribute sandbox
|
|
30
|
+
def sandbox
|
|
31
|
+
@sandbox ||= false
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
data/lib/feedlr/base.rb
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
require_relative 'request'
|
|
2
|
+
require_relative 'gateway/feeds'
|
|
3
|
+
require_relative 'gateway/categories'
|
|
4
|
+
require_relative 'gateway/entries'
|
|
5
|
+
require_relative 'gateway/markers'
|
|
6
|
+
require_relative 'gateway/subscriptions'
|
|
7
|
+
require_relative 'gateway/tags'
|
|
8
|
+
require_relative 'gateway/topics'
|
|
9
|
+
require_relative 'gateway/shorten'
|
|
10
|
+
require_relative 'gateway/profile'
|
|
11
|
+
require_relative 'gateway/preferences'
|
|
12
|
+
require_relative 'gateway/streams'
|
|
13
|
+
require_relative 'gateway/opml'
|
|
14
|
+
require_relative 'gateway/search'
|
|
15
|
+
require_relative 'gateway/mixes'
|
|
16
|
+
require_relative 'gateway/facebook'
|
|
17
|
+
require_relative 'gateway/twitter'
|
|
18
|
+
require_relative 'gateway/microsoft'
|
|
19
|
+
require_relative 'gateway/evernote'
|
|
20
|
+
|
|
21
|
+
module Feedlr
|
|
22
|
+
# Feedlr Client
|
|
23
|
+
class Client
|
|
24
|
+
include Request
|
|
25
|
+
include Gateway::Feeds
|
|
26
|
+
include Gateway::Categories
|
|
27
|
+
include Gateway::Entries
|
|
28
|
+
include Gateway::Streams
|
|
29
|
+
include Gateway::Markers
|
|
30
|
+
include Gateway::Subscriptions
|
|
31
|
+
include Gateway::Tags
|
|
32
|
+
include Gateway::Topics
|
|
33
|
+
include Gateway::Shorten
|
|
34
|
+
include Gateway::Profile
|
|
35
|
+
include Gateway::Preferences
|
|
36
|
+
include Gateway::Mixes
|
|
37
|
+
include Gateway::Opml
|
|
38
|
+
include Gateway::Search
|
|
39
|
+
include Gateway::Facebook
|
|
40
|
+
include Gateway::Twitter
|
|
41
|
+
include Gateway::Microsoft
|
|
42
|
+
include Gateway::Evernote
|
|
43
|
+
|
|
44
|
+
attr_reader :oauth_access_token, :sandbox, :logger
|
|
45
|
+
|
|
46
|
+
# Initializer
|
|
47
|
+
# @param [Hash] options client options
|
|
48
|
+
# @option options [String] :oauth_access_token
|
|
49
|
+
# @option options [Boolean] :sandbox
|
|
50
|
+
# @option options [#debug,#info] :logger
|
|
51
|
+
# @return [Feedlr::Client]
|
|
52
|
+
def initialize(options = {})
|
|
53
|
+
@oauth_access_token = options.fetch(:oauth_access_token) do
|
|
54
|
+
Feedlr.oauth_access_token
|
|
55
|
+
end
|
|
56
|
+
@sandbox = options.fetch(:sandbox) { Feedlr.sandbox }
|
|
57
|
+
@logger = options.fetch(:logger) { Feedlr.logger }
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module Feedlr
|
|
2
|
+
# When the response is of Array type,
|
|
3
|
+
# it creates an array of Feedlr::Base or plain types elements
|
|
4
|
+
class Collection < Array
|
|
5
|
+
# Initializer
|
|
6
|
+
# @param [Array] data
|
|
7
|
+
# @return [Feedlr::Collection]
|
|
8
|
+
def initialize(data)
|
|
9
|
+
super([])
|
|
10
|
+
data.each do |e|
|
|
11
|
+
self.<<(e.is_a?(Hash) ? Feedlr::Base.new(e) : e)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
data/lib/feedlr/error.rb
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
require_relative 'rate_limit'
|
|
2
|
+
|
|
3
|
+
module Feedlr
|
|
4
|
+
# Custom error class for rescuing from all Feedlr errors
|
|
5
|
+
class Error < StandardError
|
|
6
|
+
attr_reader :rate_limit
|
|
7
|
+
|
|
8
|
+
class << self
|
|
9
|
+
# Create a new error from an HTTP response
|
|
10
|
+
#
|
|
11
|
+
# @param response [Faraday::Response]
|
|
12
|
+
# @return [Feedlr::Error]
|
|
13
|
+
def from_response(response)
|
|
14
|
+
status_code = response.status.to_i
|
|
15
|
+
message = parse_error(status_code, response.body)
|
|
16
|
+
new(message, response.headers)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# @return [Hash]
|
|
20
|
+
def errors
|
|
21
|
+
@errors ||= {
|
|
22
|
+
400 => Feedlr::Error::BadRequest,
|
|
23
|
+
401 => Feedlr::Error::Unauthorized,
|
|
24
|
+
403 => Feedlr::Error::Forbidden,
|
|
25
|
+
404 => Feedlr::Error::NotFound,
|
|
26
|
+
500 => Feedlr::Error::InternalServerError
|
|
27
|
+
}
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
private
|
|
31
|
+
|
|
32
|
+
def parse_error(status, body)
|
|
33
|
+
if body.is_a?(Hash)
|
|
34
|
+
if body['errorMessage']
|
|
35
|
+
"Error #{status} - #{body['errorMessage']}"
|
|
36
|
+
else
|
|
37
|
+
"Error #{status}"
|
|
38
|
+
end
|
|
39
|
+
else
|
|
40
|
+
"Error #{status} - #{body}"
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Initializes a new Error object
|
|
46
|
+
#
|
|
47
|
+
# @param message [Exception, String]
|
|
48
|
+
# @param rate_limit [Hash]
|
|
49
|
+
# @return [Feedlr::Error]
|
|
50
|
+
def initialize(message = '', rate_limit = {})
|
|
51
|
+
super(message)
|
|
52
|
+
@rate_limit = Feedlr::RateLimit.new(rate_limit)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Raised when Feedlr returns a 4xx HTTP status status_code
|
|
56
|
+
class ClientError < self; end
|
|
57
|
+
|
|
58
|
+
# Raised when Feedlr returns the HTTP status status_code 400
|
|
59
|
+
class BadRequest < ClientError; end
|
|
60
|
+
|
|
61
|
+
# Raised when Feedlr returns the HTTP status status_code 401
|
|
62
|
+
class Unauthorized < ClientError; end
|
|
63
|
+
|
|
64
|
+
# Raised when Feedlr returns the HTTP status status_code 403
|
|
65
|
+
class Forbidden < ClientError; end
|
|
66
|
+
|
|
67
|
+
# Raised when Feedlr returns the HTTP status status_code 404
|
|
68
|
+
class NotFound < ClientError; end
|
|
69
|
+
|
|
70
|
+
# Raised when Twitter returns a 5xx HTTP status code
|
|
71
|
+
class ServerError < self; end
|
|
72
|
+
|
|
73
|
+
# Raised when Feedlr returns the HTTP status status_code 500
|
|
74
|
+
class InternalServerError < ServerError; end
|
|
75
|
+
|
|
76
|
+
# Raised when the request times out
|
|
77
|
+
class RequestTimeout < self; end
|
|
78
|
+
end
|
|
79
|
+
end
|