fimmed_up 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/fimmed_up.gemspec +27 -0
- data/lib/fimmed_up/client.rb +35 -0
- data/lib/fimmed_up/configuration.rb +38 -0
- data/lib/fimmed_up/connection.rb +35 -0
- data/lib/fimmed_up/error.rb +20 -0
- data/lib/fimmed_up/helpers.rb +9 -0
- data/lib/fimmed_up/parameters.rb +53 -0
- data/lib/fimmed_up/request.rb +50 -0
- data/lib/fimmed_up/response/raise_client_error.rb +28 -0
- data/lib/fimmed_up/response/raise_server_error.rb +23 -0
- data/lib/fimmed_up/version.rb +3 -0
- data/lib/fimmed_up.rb +26 -0
- data/spec/fimmed_up/client_spec.rb +150 -0
- data/spec/fimmed_up/configuration_spec.rb +33 -0
- data/spec/fimmed_up/fimmed_up_spec.rb +7 -0
- data/spec/fimmed_up/request_spec.rb +0 -0
- data/spec/spec_helper.rb +14 -0
- data/spec/support/json_helpers.rb +5 -0
- metadata +157 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2f821bee7a0c16b2bcc9c1ff08aa46718639d455
|
4
|
+
data.tar.gz: 947bb89bfa4ff11e3f0d5119cef55f1de1e63f2f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2f862869f944710ab4a0d6aede796bc57ecbf4526fdd419e831585f747cd4de06136829e99fac609347c5e2e674eef209ad9d6f88b96ebf834808a1673ea4247
|
7
|
+
data.tar.gz: f799c8d1f073ba78cc11bc37f682dcaec0e62909a5cbd7b60b4b1a0cdae529cbc35b6e21c5c4a7499c9dc13e80c09a31bed3de09a5af01ba59b241c0ede174e2
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Jovon Packard
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# FimmedUp
|
2
|
+
|
3
|
+
Restful API Client for the Fimmed_up API
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'fimmed_up'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install fimmed_up
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/fimmed_up.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
|
+
require 'fimmed_up/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "fimmed_up"
|
8
|
+
spec.version = FimmedUp::VERSION
|
9
|
+
spec.authors = ["Jovon Packard"]
|
10
|
+
spec.email = ["jovonpackard@gmail.com"]
|
11
|
+
spec.description = %q{Client gem to connect to the fimmed_up API}
|
12
|
+
spec.summary = %q{Client for fimmed_up API}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency 'faraday'
|
22
|
+
spec.add_dependency 'json'
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "rspec"
|
26
|
+
spec.add_development_dependency "pry-remote"
|
27
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'fimmed_up/connection'
|
2
|
+
require 'fimmed_up/parameters'
|
3
|
+
require 'fimmed_up/helpers'
|
4
|
+
|
5
|
+
module FimmedUp
|
6
|
+
|
7
|
+
class Client
|
8
|
+
include FimmedUp::Connection
|
9
|
+
include FimmedUp::Parameters
|
10
|
+
|
11
|
+
# Define the same set of accessors as the FimmedUp module
|
12
|
+
attr_accessor *Configuration::VALID_CONFIG_KEYS
|
13
|
+
|
14
|
+
def initialize(options={})
|
15
|
+
# Merge the config values from the module and those passed
|
16
|
+
# to the client.
|
17
|
+
merged_options = FimmedUp.options.merge(options)
|
18
|
+
# Copy the merged values to this client and ignore those
|
19
|
+
# not part of our configuration
|
20
|
+
Configuration::VALID_CONFIG_KEYS.each do |key|
|
21
|
+
send("#{key}=", merged_options[key])
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def updated
|
26
|
+
self.get("#{resource}/updatedtoday/count", parameters, {}).to_i
|
27
|
+
end
|
28
|
+
|
29
|
+
def count
|
30
|
+
self.get("#{resource}/count", parameters, {}).to_i
|
31
|
+
end
|
32
|
+
|
33
|
+
end # Client
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module FimmedUp
|
2
|
+
module Configuration
|
3
|
+
VALID_CONNECTION_KEYS = [:endpoint, :method].freeze
|
4
|
+
VALID_OPTIONS_KEYS = [:username, :password, :resource].freeze
|
5
|
+
VALID_CONFIG_KEYS = VALID_CONNECTION_KEYS + VALID_OPTIONS_KEYS
|
6
|
+
|
7
|
+
|
8
|
+
DEFAULT_METHOD = :get
|
9
|
+
DEFAULT_ENDPOINT = 'http://10.0.0.140'
|
10
|
+
DEFAULT_USERNAME = ENV["API_USERNAME"].to_s
|
11
|
+
DEFAULT_PASSWORD = ENV["API_PASSWORD"].to_s
|
12
|
+
DEFAULT_RESOURCE = "profile"
|
13
|
+
|
14
|
+
|
15
|
+
attr_accessor *VALID_CONFIG_KEYS
|
16
|
+
|
17
|
+
# Make sure we have the default values set when we get 'extended'
|
18
|
+
def self.extended(base)
|
19
|
+
base.reset
|
20
|
+
end
|
21
|
+
|
22
|
+
def reset
|
23
|
+
self.endpoint = DEFAULT_ENDPOINT
|
24
|
+
self.method = DEFAULT_METHOD
|
25
|
+
self.username = DEFAULT_USERNAME
|
26
|
+
self.password = DEFAULT_PASSWORD
|
27
|
+
self.resource = DEFAULT_RESOURCE
|
28
|
+
end
|
29
|
+
|
30
|
+
def configure
|
31
|
+
yield self
|
32
|
+
end
|
33
|
+
|
34
|
+
def options
|
35
|
+
Hash[ * VALID_CONFIG_KEYS.map { |key| [key, send(key)] }.flatten ]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
require 'fimmed_up/response/raise_client_error'
|
3
|
+
require 'fimmed_up/response/raise_server_error'
|
4
|
+
|
5
|
+
module FimmedUp
|
6
|
+
module Connection
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def connection(options)
|
11
|
+
default_options = {
|
12
|
+
:url => options.fetch(:endpoint, endpoint),
|
13
|
+
:user => options.fetch(:username, username),
|
14
|
+
:password => options.fetch(:password, password)
|
15
|
+
|
16
|
+
}
|
17
|
+
|
18
|
+
@connection ||= Faraday.new(default_options) do |builder|
|
19
|
+
builder.use FimmedUp::Response::RaiseClientError
|
20
|
+
builder.use FimmedUp::Response::RaiseServerError
|
21
|
+
|
22
|
+
builder.basic_auth(default_options[:user], default_options[:password])
|
23
|
+
builder.headers["Http-Accept"] = "application/json"
|
24
|
+
builder.headers["Content-Type"] = "application/json"
|
25
|
+
|
26
|
+
# TODO: Make logging optional
|
27
|
+
# builder.response :logger
|
28
|
+
|
29
|
+
builder.adapter Faraday.default_adapter
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end # Connection
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module FimmedUp
|
2
|
+
|
3
|
+
class Error < StandardError
|
4
|
+
attr_reader :http_headers
|
5
|
+
|
6
|
+
def initialize(message, http_headers)
|
7
|
+
@http_headers = http_headers
|
8
|
+
super(message)
|
9
|
+
end
|
10
|
+
|
11
|
+
end # Error
|
12
|
+
|
13
|
+
class Error::ServerError < FimmedUp::Error; end
|
14
|
+
class Error::ServiceUnavailable < Error::ServerError; end
|
15
|
+
|
16
|
+
class Error::ClientError < FimmedUp::Error; end
|
17
|
+
class Error::Forbidden < Error::ClientError; end
|
18
|
+
class Error::BadRequest < Error::ClientError; end
|
19
|
+
class Error::RequestTooLarge < Error::ClientError; end
|
20
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'fimmed_up/request'
|
2
|
+
require 'fimmed_up/helpers'
|
3
|
+
|
4
|
+
module FimmedUp
|
5
|
+
module Parameters
|
6
|
+
include Enumerable
|
7
|
+
include FimmedUp::Request
|
8
|
+
include FimmedUp::Helpers
|
9
|
+
|
10
|
+
def parameters
|
11
|
+
@parameters ||= {}
|
12
|
+
end
|
13
|
+
|
14
|
+
def where(args)
|
15
|
+
parameters.merge!(args)
|
16
|
+
self
|
17
|
+
end
|
18
|
+
|
19
|
+
def like(args)
|
20
|
+
parameters.merge!(like_format(args))
|
21
|
+
self
|
22
|
+
end
|
23
|
+
|
24
|
+
def limit(limit)
|
25
|
+
parameters[:limit] = limit
|
26
|
+
self
|
27
|
+
end
|
28
|
+
|
29
|
+
def select(args)
|
30
|
+
parameters[:fields] = args
|
31
|
+
self
|
32
|
+
end
|
33
|
+
|
34
|
+
def find(id)
|
35
|
+
parameters.merge!(id: id)
|
36
|
+
self
|
37
|
+
end
|
38
|
+
|
39
|
+
def each(&block)
|
40
|
+
records = self.get(resource, parameters, {})
|
41
|
+
raise "Records not found" if records.empty?
|
42
|
+
json(records).each(&block)
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
def like_format(args)
|
47
|
+
return_args = args.map do | key, value |
|
48
|
+
hash = { "#{key.to_s}.like" => "%#{value}%" }
|
49
|
+
end
|
50
|
+
return_args[0]
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'uri'
|
3
|
+
require 'pry'
|
4
|
+
|
5
|
+
module FimmedUp
|
6
|
+
# Handless HTTP requests
|
7
|
+
module Request
|
8
|
+
def get(path, params={}, options={})
|
9
|
+
request(:get, path, params, options)
|
10
|
+
end
|
11
|
+
|
12
|
+
def post(path, params={}, options={})
|
13
|
+
request(:post, path, params, options)
|
14
|
+
end
|
15
|
+
|
16
|
+
def delete(path, params={}, options={})
|
17
|
+
request(:delete, path, params, options)
|
18
|
+
end
|
19
|
+
|
20
|
+
def patch(path, params={}, options={})
|
21
|
+
request(:patch, path, params, options)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def request(method, path, params, options)
|
27
|
+
|
28
|
+
response = connection(options).run_request(method, nil, nil, nil) do |request|
|
29
|
+
request.options[:raw] = true if options[:raw]
|
30
|
+
|
31
|
+
case method.to_sym
|
32
|
+
when :get
|
33
|
+
request.url(path, params)
|
34
|
+
when :post
|
35
|
+
request.path = path
|
36
|
+
request.body = params unless params.empty?
|
37
|
+
when :delete
|
38
|
+
request.path = path
|
39
|
+
request.body = params unless params.empty?
|
40
|
+
when :patch
|
41
|
+
request.path = path
|
42
|
+
request.body = params unless params.empty?
|
43
|
+
end
|
44
|
+
end
|
45
|
+
options[:raw] ? response : response.body
|
46
|
+
end
|
47
|
+
|
48
|
+
end # Request
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
|
3
|
+
module FimmedUp
|
4
|
+
|
5
|
+
module Response
|
6
|
+
|
7
|
+
class RaiseClientError < Faraday::Response::Middleware
|
8
|
+
|
9
|
+
def on_complete(env)
|
10
|
+
status = env[:status].to_i
|
11
|
+
body = env[:body]
|
12
|
+
headers = env[:response_headers]
|
13
|
+
|
14
|
+
case status
|
15
|
+
when 400
|
16
|
+
raise FimmedUp::Error::BadRequest.new body, headers
|
17
|
+
when 403
|
18
|
+
raise FimmedUp::Error::Forbidden.new body, headers
|
19
|
+
when 413
|
20
|
+
raise FimmedUp::Error::RequestTooLarge.new body, headers
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end # RaiseClientError
|
25
|
+
|
26
|
+
end # Response
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
require 'fimmed_up/error'
|
3
|
+
|
4
|
+
module FimmedUp
|
5
|
+
module Response
|
6
|
+
class RaiseServerError < Faraday::Response::Middleware
|
7
|
+
|
8
|
+
def on_complete(env)
|
9
|
+
status = env[:status].to_i
|
10
|
+
body = env[:body]
|
11
|
+
headers = env[:response_headers]
|
12
|
+
|
13
|
+
case status
|
14
|
+
when 503
|
15
|
+
raise FimmedUp::Error::ServiceUnavailable.new "503 No server is available to handle this request.", headers
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end # RaiseServerError
|
20
|
+
|
21
|
+
end # Response
|
22
|
+
|
23
|
+
end
|
data/lib/fimmed_up.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require "fimmed_up/version"
|
2
|
+
require "fimmed_up/configuration"
|
3
|
+
require "fimmed_up/client"
|
4
|
+
require "fimmed_up/parameters"
|
5
|
+
require "fimmed_up/helpers"
|
6
|
+
|
7
|
+
module FimmedUp
|
8
|
+
extend Configuration
|
9
|
+
include FimmedUp::Helpers
|
10
|
+
|
11
|
+
def new(options={})
|
12
|
+
Client.new(options)
|
13
|
+
end
|
14
|
+
|
15
|
+
# Delegate to FimmedUp::Client
|
16
|
+
|
17
|
+
def method_missing(method, *args, &block)
|
18
|
+
return super unless new.respond_to?(method)
|
19
|
+
new.send(method, *args, &block)
|
20
|
+
end
|
21
|
+
|
22
|
+
def respond_to?(method, include_private = false)
|
23
|
+
new.respond_to?(method, include_private) || super(method, include_private)
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,150 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe FimmedUp::Client do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@keys = FimmedUp::Configuration::VALID_CONFIG_KEYS
|
7
|
+
end
|
8
|
+
|
9
|
+
describe 'with module configuration' do
|
10
|
+
before do
|
11
|
+
FimmedUp.configure do |config|
|
12
|
+
@keys.each do |key|
|
13
|
+
config.send("#{key}=", key)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
after do
|
19
|
+
FimmedUp.reset
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should inherit module configuration" do
|
23
|
+
api = FimmedUp::Client.new
|
24
|
+
@keys.each do |key|
|
25
|
+
api.send(key).eql? key
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'with class configuration' do
|
30
|
+
before do
|
31
|
+
@config = {
|
32
|
+
:endpoint => 'ep',
|
33
|
+
:method => 'hm',
|
34
|
+
:username => 'ej',
|
35
|
+
:password => 'uo'
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should override module configuration' do
|
40
|
+
api = FimmedUp::Client.new(@config)
|
41
|
+
@keys.each do |key|
|
42
|
+
api.send(key).eql? @config[key]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should override module configuration after' do
|
47
|
+
api = FimmedUp::Client.new
|
48
|
+
|
49
|
+
@config.each do |key, value|
|
50
|
+
api.send("#{key}=", value)
|
51
|
+
end
|
52
|
+
|
53
|
+
@keys.each do |key|
|
54
|
+
api.send("#{key}").eql? @config[key]
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
describe 'access to api'do
|
63
|
+
context 'when logged in' do
|
64
|
+
it 'should not be blank' do
|
65
|
+
client = FimmedUp::Client.new(resource: "profile")
|
66
|
+
profile = client.find(5)
|
67
|
+
expect(profile.first["id"]).to eq("5".rjust(6))
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe '.where' do
|
73
|
+
before do
|
74
|
+
@profiles = FimmedUp::Client.new(resource: "profile")
|
75
|
+
end
|
76
|
+
it 'should return the correct records' do
|
77
|
+
profile = []
|
78
|
+
@profiles.where(orgname: "Active Heroes").each { |u| profile << u }
|
79
|
+
profile.each { |r| expect(r["orgname"]).to eq("Active Heroes") }
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe '.find' do
|
84
|
+
before do
|
85
|
+
@profiles = FimmedUp::Client.new(resource: "profile")
|
86
|
+
end
|
87
|
+
it 'should return id' do
|
88
|
+
profile = @profiles.find(5)
|
89
|
+
expect(profile.first["id"]).to eq('5'.rjust(6))
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
describe '.like' do
|
94
|
+
before do
|
95
|
+
@profiles = FimmedUp::Client.new(resource: "profile")
|
96
|
+
end
|
97
|
+
it 'returns orgname like' do
|
98
|
+
profile = []
|
99
|
+
@profiles.like(orgname: "Active").each {
|
100
|
+
|u| profile << u
|
101
|
+
}
|
102
|
+
expect(profile.first["orgname"].downcase).to include("active")
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
describe '.limit' do
|
107
|
+
before do
|
108
|
+
@profiles = FimmedUp::Client.new(resource: "profile")
|
109
|
+
end
|
110
|
+
it 'should return the correct records' do
|
111
|
+
profile = []
|
112
|
+
@profiles.limit(20).each { |u| profile << u }
|
113
|
+
expect(profile.count).to eq(20)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
describe '.updated' do
|
118
|
+
before do
|
119
|
+
@profiles = FimmedUp::Client.new(resource: "profile")
|
120
|
+
end
|
121
|
+
it 'should return the number of records updated today' do
|
122
|
+
updated = @profiles.updated
|
123
|
+
expect(updated).to eq(0)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
describe '.count' do
|
128
|
+
before do
|
129
|
+
@profiles = FimmedUp::Client.new(resource: "profile")
|
130
|
+
end
|
131
|
+
it 'should return the number of records' do
|
132
|
+
count = @profiles.count
|
133
|
+
expect(count).to eq(37397)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
describe '.select' do
|
138
|
+
before do
|
139
|
+
@profiles = FimmedUp::Client.new(resource: "profile")
|
140
|
+
end
|
141
|
+
it 'returns only fields' do
|
142
|
+
profile = []
|
143
|
+
@profiles.where(orgname: "Active Heroes").select(['id', 'orgname']).each { |u| profile << u }
|
144
|
+
expect(profile.first.keys).to include('id', 'orgname')
|
145
|
+
expect(profile.first.count).to eq(2)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
|
150
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe FimmedUp::Configuration do
|
4
|
+
after do
|
5
|
+
FimmedUp.reset
|
6
|
+
end
|
7
|
+
|
8
|
+
describe '.username' do
|
9
|
+
it 'should have correct username' do
|
10
|
+
FimmedUp.username.eql? FimmedUp::Configuration::DEFAULT_USERNAME
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '.password' do
|
15
|
+
it 'should have correct password' do
|
16
|
+
FimmedUp.password.eql? FimmedUp::Configuration::DEFAULT_PASSWORD
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '.endpoint' do
|
21
|
+
it 'should return the default endpoint' do
|
22
|
+
FimmedUp.endpoint.eql? FimmedUp::Configuration::DEFAULT_ENDPOINT
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
FimmedUp::Configuration::VALID_CONFIG_KEYS.each do |key|
|
27
|
+
describe ".#{key}" do
|
28
|
+
it 'should return the default value' do
|
29
|
+
FimmedUp.send(key).eql? FimmedUp::Configuration.const_get("DEFAULT_#{key.upcase}")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
File without changes
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "fimmed_up"
|
3
|
+
require "rspec"
|
4
|
+
require "json"
|
5
|
+
require "pry-remote"
|
6
|
+
|
7
|
+
Dir["./spec/support/*.rb"].sort.each {|file| require file}
|
8
|
+
|
9
|
+
RSpec.configure do |config|
|
10
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
11
|
+
config.run_all_when_everything_filtered = true
|
12
|
+
config.filter_run :focus
|
13
|
+
config.include JsonHelpers
|
14
|
+
end
|
metadata
ADDED
@@ -0,0 +1,157 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fimmed_up
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jovon Packard
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-10-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: json
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry-remote
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: Client gem to connect to the fimmed_up API
|
98
|
+
email:
|
99
|
+
- jovonpackard@gmail.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- .gitignore
|
105
|
+
- Gemfile
|
106
|
+
- LICENSE.txt
|
107
|
+
- README.md
|
108
|
+
- Rakefile
|
109
|
+
- fimmed_up.gemspec
|
110
|
+
- lib/fimmed_up.rb
|
111
|
+
- lib/fimmed_up/client.rb
|
112
|
+
- lib/fimmed_up/configuration.rb
|
113
|
+
- lib/fimmed_up/connection.rb
|
114
|
+
- lib/fimmed_up/error.rb
|
115
|
+
- lib/fimmed_up/helpers.rb
|
116
|
+
- lib/fimmed_up/parameters.rb
|
117
|
+
- lib/fimmed_up/request.rb
|
118
|
+
- lib/fimmed_up/response/raise_client_error.rb
|
119
|
+
- lib/fimmed_up/response/raise_server_error.rb
|
120
|
+
- lib/fimmed_up/version.rb
|
121
|
+
- spec/fimmed_up/client_spec.rb
|
122
|
+
- spec/fimmed_up/configuration_spec.rb
|
123
|
+
- spec/fimmed_up/fimmed_up_spec.rb
|
124
|
+
- spec/fimmed_up/request_spec.rb
|
125
|
+
- spec/spec_helper.rb
|
126
|
+
- spec/support/json_helpers.rb
|
127
|
+
homepage: ''
|
128
|
+
licenses:
|
129
|
+
- MIT
|
130
|
+
metadata: {}
|
131
|
+
post_install_message:
|
132
|
+
rdoc_options: []
|
133
|
+
require_paths:
|
134
|
+
- lib
|
135
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - '>='
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - '>='
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
requirements: []
|
146
|
+
rubyforge_project:
|
147
|
+
rubygems_version: 2.0.2
|
148
|
+
signing_key:
|
149
|
+
specification_version: 4
|
150
|
+
summary: Client for fimmed_up API
|
151
|
+
test_files:
|
152
|
+
- spec/fimmed_up/client_spec.rb
|
153
|
+
- spec/fimmed_up/configuration_spec.rb
|
154
|
+
- spec/fimmed_up/fimmed_up_spec.rb
|
155
|
+
- spec/fimmed_up/request_spec.rb
|
156
|
+
- spec/spec_helper.rb
|
157
|
+
- spec/support/json_helpers.rb
|