Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RateLimitException - catches 429 errors #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
source :rubygems
source 'https://rubygems.org'

gem 'rest-client'
gem 'json', '~> 1.6.5'
gem 'json', '~> 1.8', '>= 1.8.3'
gem 'rest-client', '~> 1.8'

group :test do
gem 'rr', '~> 1.0.4'
gem 'simplecov', '~> 0.6.1', :require => false
gem 'simplecov', '~> 0.6.1', require: false
end
25 changes: 18 additions & 7 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,24 +1,35 @@
GEM
remote: http://rubygems.org/
remote: https://rubygems.org/
specs:
json (1.6.8)
mime-types (2.3)
domain_name (0.5.20170404)
unf (>= 0.0.5, < 1.0.0)
http-cookie (1.0.3)
domain_name (~> 0.5)
json (1.8.6)
mime-types (2.99.3)
multi_json (1.10.1)
netrc (0.7.7)
rest-client (1.7.2)
netrc (0.11.0)
rest-client (1.8.0)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 3.0)
netrc (~> 0.7)
rr (1.0.5)
simplecov (0.6.4)
multi_json (~> 1.0)
simplecov-html (~> 0.5.3)
simplecov-html (0.5.3)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.4)

PLATFORMS
ruby

DEPENDENCIES
json (~> 1.6.5)
rest-client
json (~> 1.8, >= 1.8.3)
rest-client (~> 1.8)
rr (~> 1.0.4)
simplecov (~> 0.6.1)

BUNDLED WITH
1.16.0
27 changes: 10 additions & 17 deletions gem-ooyala-v2-api/Gemfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
source "http://rubygems.org"
# Add dependencies required to use your gem here.
# Example:
# gem "activesupport", ">= 2.3.5"
source 'http://rubygems.org'

# Add dependencies to develop your gem here.
# Include everything needed to run rake, tests, features, etc.

gem "rdoc"
gem "rake"
gem "rest-client", "~> 1.6.6"
gem "json"
gem 'json', '~> 1.8', '>= 1.8.3'
gem 'rake'
gem 'rdoc'
gem 'rest-client', '~> 1.8'

group :development do
gem "shoulda", ">= 0"
gem "rdoc"
gem "bundler"
gem "jeweler"
gem "simplecov", ">= 0"
gem "rr"
gem 'bundler'
gem 'jeweler'
gem 'rr'
gem 'shoulda', '>= 0'
gem 'simplecov', '>= 0'
end
104 changes: 104 additions & 0 deletions gem-ooyala-v2-api/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
GEM
remote: http://rubygems.org/
specs:
activesupport (5.1.4)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7)
minitest (~> 5.1)
tzinfo (~> 1.1)
addressable (2.4.0)
builder (3.2.3)
concurrent-ruby (1.0.5)
descendants_tracker (0.0.4)
thread_safe (~> 0.3, >= 0.3.1)
docile (1.1.5)
domain_name (0.5.20170404)
unf (>= 0.0.5, < 1.0.0)
faraday (0.9.2)
multipart-post (>= 1.2, < 3)
git (1.3.0)
github_api (0.16.0)
addressable (~> 2.4.0)
descendants_tracker (~> 0.0.4)
faraday (~> 0.8, < 0.10)
hashie (>= 3.4)
mime-types (>= 1.16, < 3.0)
oauth2 (~> 1.0)
hashie (3.5.7)
highline (1.7.10)
http-cookie (1.0.3)
domain_name (~> 0.5)
i18n (0.9.1)
concurrent-ruby (~> 1.0)
jeweler (2.3.9)
builder
bundler
git (>= 1.2.5)
github_api (~> 0.16.0)
highline (>= 1.6.15)
nokogiri (>= 1.5.10)
psych
rake
rdoc
semver2
json (1.8.6)
jwt (1.5.6)
mime-types (2.99.3)
mini_portile2 (2.3.0)
minitest (5.11.1)
multi_json (1.13.1)
multi_xml (0.6.0)
multipart-post (2.0.0)
netrc (0.11.0)
nokogiri (1.8.1)
mini_portile2 (~> 2.3.0)
oauth2 (1.4.0)
faraday (>= 0.8, < 0.13)
jwt (~> 1.0)
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (>= 1.2, < 3)
psych (3.0.2)
rack (2.0.3)
rake (12.3.0)
rdoc (6.0.1)
rest-client (1.8.0)
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 3.0)
netrc (~> 0.7)
rr (1.2.1)
semver2 (3.4.2)
shoulda (3.5.0)
shoulda-context (~> 1.0, >= 1.0.1)
shoulda-matchers (>= 1.4.1, < 3.0)
shoulda-context (1.2.2)
shoulda-matchers (2.8.0)
activesupport (>= 3.0.0)
simplecov (0.15.1)
docile (~> 1.1.0)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.2)
thread_safe (0.3.6)
tzinfo (1.2.4)
thread_safe (~> 0.1)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.4)

PLATFORMS
ruby

DEPENDENCIES
bundler
jeweler
json (~> 1.8, >= 1.8.3)
rake
rdoc
rest-client (~> 1.8)
rr
shoulda
simplecov

BUNDLED WITH
1.16.0
8 changes: 2 additions & 6 deletions gem-ooyala-v2-api/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,9 @@ Jeweler::Tasks.new do |gem|
gem.homepage = "https://github.com/ooyala/api-sdks"
gem.license = "MIT"
gem.summary = %Q{Ooyala's API SDK}
gem.description = %Q{Contains the necessary mehtods to communicate with the Ooyala's API.}
gem.description = %Q{Contains the necessary methods to communicate with the Ooyala API.}
gem.email = "[email protected]"
gem.authors = ["Ooyala"]
# dependencies defined in Gemfile
# dependencies defined in Gemfile
gem.add_dependency('json')
gem.add_dependency('rest-client', "~> 1.6.6")
gem.authors = ["Ooyala","DerikOlsson"]
end
Jeweler::RubygemsDotOrgTasks.new

Expand Down
2 changes: 1 addition & 1 deletion gem-ooyala-v2-api/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.3
0.0.5
11 changes: 10 additions & 1 deletion gem-ooyala-v2-api/lib/ooyala-v2-api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,13 @@ def send_request(http_method, request_path, query_params = {},
return [] if response.body.empty?
JSON.parse(response.body)
rescue RestClient::Exception => ex
raise Ooyala::RequestErrorException.new(ex.inspect)
if ex.http_code == 429
scan = ex.inspect.scan(/(\d+)\ssecond/)
delay = scan[0][0].to_i
raise Ooyala::RateLimitException.new((Time.now + delay))
else
raise Ooyala::RequestErrorException.new(ex.inspect)
end
end

# Builds the URL for a request. Adds the query parameters, the signature
Expand Down Expand Up @@ -302,4 +308,7 @@ class RequestErrorException < StandardError

class MethodNotSupportedException < StandardError
end

class RateLimitException < StandardError
end
end
Binary file removed gem-ooyala-v2-api/ooyala-v2-api-0.0.3.gem
Binary file not shown.
87 changes: 42 additions & 45 deletions gem-ooyala-v2-api/ooyala-v2-api.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,72 +2,69 @@
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
# -*- encoding: utf-8 -*-
# stub: ooyala-v2-api 0.0.5 ruby lib

Gem::Specification.new do |s|
s.name = "ooyala-v2-api"
s.version = "0.0.3"
s.name = "ooyala-v2-api".freeze
s.version = "0.0.5"

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Jose Gasca"]
s.date = "2013-05-21"
s.description = "This gem allows the interaction with the Ooyala's API v2."
s.email = "[email protected]"
s.extra_rdoc_files = [
"LICENSE.txt",
"README.rdoc"
]
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
s.require_paths = ["lib".freeze]
s.authors = ["Ooyala".freeze, "DerikOlsson".freeze]
s.date = "2018-01-19"
s.description = "Contains the necessary methods to communicate with the Ooyala API.".freeze
s.email = "[email protected]".freeze
s.files = [
".document",
"Gemfile",
"Gemfile.lock",
"LICENSE.txt",
"README.rdoc",
"Rakefile",
"VERSION",
"lib/ooyala-v2-api.rb",
"ooyala-v2-api.gemspec",
"test/helper.rb",
"test/test_ooyala-v2-api.rb"
]
s.homepage = "http://api.ooyala.com/docs/v2/api_libraries"
s.licenses = ["See license.txt"]
s.require_paths = ["lib"]
s.rubygems_version = "1.8.10"
s.summary = "Ooyala's API v2 Ruby SDK"
s.homepage = "https://github.com/ooyala/api-sdks".freeze
s.licenses = ["MIT".freeze]
s.rubygems_version = "2.6.13".freeze
s.summary = "Ooyala's API SDK".freeze

if s.respond_to? :specification_version then
s.specification_version = 3
s.specification_version = 4

if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
s.add_runtime_dependency(%q<rdoc>, [">= 0"])
s.add_runtime_dependency(%q<rake>, [">= 0"])
s.add_runtime_dependency(%q<rest-client>, ["~> 1.6.6"])
s.add_runtime_dependency(%q<json>, [">= 0"])
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
s.add_development_dependency(%q<tomdoc>, [">= 0"])
s.add_runtime_dependency(%q<json>, [">= 0"])
s.add_runtime_dependency(%q<rest-client>, ["~> 1.6.6"])
s.add_runtime_dependency(%q<json>.freeze, [">= 1.8.3", "~> 1.8"])
s.add_runtime_dependency(%q<rake>.freeze, [">= 0"])
s.add_runtime_dependency(%q<rdoc>.freeze, [">= 0"])
s.add_runtime_dependency(%q<rest-client>.freeze, ["~> 1.8"])
s.add_development_dependency(%q<bundler>.freeze, [">= 0"])
s.add_development_dependency(%q<jeweler>.freeze, [">= 0"])
s.add_development_dependency(%q<rr>.freeze, [">= 0"])
s.add_development_dependency(%q<shoulda>.freeze, [">= 0"])
s.add_development_dependency(%q<simplecov>.freeze, [">= 0"])
else
s.add_dependency(%q<rdoc>, [">= 0"])
s.add_dependency(%q<rake>, [">= 0"])
s.add_dependency(%q<rest-client>, ["~> 1.6.6"])
s.add_dependency(%q<json>, [">= 0"])
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
s.add_dependency(%q<tomdoc>, [">= 0"])
s.add_dependency(%q<json>, [">= 0"])
s.add_dependency(%q<rest-client>, ["~> 1.6.6"])
s.add_dependency(%q<json>.freeze, [">= 1.8.3", "~> 1.8"])
s.add_dependency(%q<rake>.freeze, [">= 0"])
s.add_dependency(%q<rdoc>.freeze, [">= 0"])
s.add_dependency(%q<rest-client>.freeze, ["~> 1.8"])
s.add_dependency(%q<bundler>.freeze, [">= 0"])
s.add_dependency(%q<jeweler>.freeze, [">= 0"])
s.add_dependency(%q<rr>.freeze, [">= 0"])
s.add_dependency(%q<shoulda>.freeze, [">= 0"])
s.add_dependency(%q<simplecov>.freeze, [">= 0"])
end
else
s.add_dependency(%q<rdoc>, [">= 0"])
s.add_dependency(%q<rake>, [">= 0"])
s.add_dependency(%q<rest-client>, ["~> 1.6.6"])
s.add_dependency(%q<json>, [">= 0"])
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
s.add_dependency(%q<tomdoc>, [">= 0"])
s.add_dependency(%q<json>, [">= 0"])
s.add_dependency(%q<rest-client>, ["~> 1.6.6"])
s.add_dependency(%q<json>.freeze, [">= 1.8.3", "~> 1.8"])
s.add_dependency(%q<rake>.freeze, [">= 0"])
s.add_dependency(%q<rdoc>.freeze, [">= 0"])
s.add_dependency(%q<rest-client>.freeze, ["~> 1.8"])
s.add_dependency(%q<bundler>.freeze, [">= 0"])
s.add_dependency(%q<jeweler>.freeze, [">= 0"])
s.add_dependency(%q<rr>.freeze, [">= 0"])
s.add_dependency(%q<shoulda>.freeze, [">= 0"])
s.add_dependency(%q<simplecov>.freeze, [">= 0"])
end
end