Skip to content

Commit

Permalink
Merge 087f7c3 into 9b79ec7
Browse files Browse the repository at this point in the history
  • Loading branch information
rhymes committed Jul 8, 2016
2 parents 9b79ec7 + 087f7c3 commit 4cb5abb
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 14 deletions.
12 changes: 6 additions & 6 deletions .rubocop_todo.yml
@@ -1,14 +1,14 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2016-03-27 14:54:37 +0200 using RuboCop version 0.37.2.
# on 2016-07-08 10:52:47 +0200 using RuboCop version 0.37.2.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 27
# Offense count: 28
Metrics/AbcSize:
Max: 35
Max: 36

# Offense count: 10
# Configuration parameters: CountComments.
Expand All @@ -17,7 +17,7 @@ Metrics/ClassLength:

# Offense count: 8
Metrics/CyclomaticComplexity:
Max: 12
Max: 13

# Offense count: 57
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
Expand All @@ -28,11 +28,11 @@ Metrics/LineLength:
# Offense count: 58
# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 31
Max: 32

# Offense count: 7
Metrics/PerceivedComplexity:
Max: 12
Max: 13

# Offense count: 3
Style/ClassVars:
Expand Down
13 changes: 7 additions & 6 deletions README.md
Expand Up @@ -32,12 +32,13 @@ parse-ruby-client lets you interact with Parse using Ruby. There are many uses.
```ruby
require 'parse-ruby-client'

Parse.create :application_id => "<your_app_id>", # required
:api_key => "<your_api_key>", # optional, defaults to nil
:master_key => "<your_master_key>", # optional, defaults to nil
:quiet => true | false, # optional, defaults to false
:host => 'http://localhost:1337', # optional, defaults to 'https://api.parse.com'
:path => '/parse', # optional, defaults to '/1'
Parse.create :application_id => "<your_app_id>", # required
:api_key => "<your_api_key>", # optional, defaults to nil
:master_key => "<your_master_key>", # optional, defaults to nil
:quiet => true | false, # optional, defaults to false
:host => 'http://localhost:1337', # optional, defaults to 'https://api.parse.com'
:path => '/parse', # optional, defaults to '/1'
:get_method_override => true | false, # optional, defaults to true
```

[![Gem Version](https://img.shields.io/gem/v/parse-ruby-client.svg)](http://badge.fury.io/rb/parse-ruby-client)
Expand Down
10 changes: 8 additions & 2 deletions lib/parse/client.rb
Expand Up @@ -30,6 +30,7 @@ class Client
attr_accessor :interval
attr_accessor :backoff_factor
attr_accessor :retried_exceptions
attr_reader :get_method_override

def initialize(data = {}, &_blk)
@host = data[:host] || Protocol::HOST
Expand All @@ -52,12 +53,15 @@ def initialize(data = {}, &_blk)
@retried_exceptions += data[:retried_exceptions] if data[
:retried_exceptions]

@get_method_override = data[:get_method_override]

options = { request: { timeout: @timeout, open_timeout: @timeout } }

@session = Faraday.new(host, options) do |c|
c.request :json

c.use Faraday::GetMethodOverride
c.use Faraday::GetMethodOverride if @get_method_override

c.use Faraday::BetterRetry,
max: @max_retries,
logger: @logger,
Expand Down Expand Up @@ -167,7 +171,9 @@ class << self
def create(data = {}, &blk)
defaults = {
application_id: ENV['PARSE_APPLICATION_ID'],
api_key: ENV['PARSE_REST_API_KEY'] }
api_key: ENV['PARSE_REST_API_KEY'],
get_method_override: true
}
defaults.merge!(data)

# use less permissive key if both are specified
Expand Down
1 change: 1 addition & 0 deletions parse-ruby-client.gemspec
Expand Up @@ -25,6 +25,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'bundler'
spec.add_development_dependency 'coveralls'
spec.add_development_dependency 'fasterer'
spec.add_development_dependency 'json', '~> 1.8.3'
spec.add_development_dependency 'minitest'
spec.add_development_dependency 'minitest-focus'
spec.add_development_dependency 'mocha'
Expand Down
10 changes: 10 additions & 0 deletions test/test_client_create.rb
Expand Up @@ -244,4 +244,14 @@ def test_get_missing
assert_equal '101: object not found for get: SomeClass:someIdThatDoesNotExist', e.message
end
end

def test_get_method_override
client = Parse.create
assert client.get_method_override
assert client.session.builder.handlers.include? Faraday::GetMethodOverride

client = Parse.create(get_method_override: false)
refute client.get_method_override
refute client.session.builder.handlers.include? Faraday::GetMethodOverride
end
end

0 comments on commit 4cb5abb

Please sign in to comment.