wodify 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +20 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +6 -0
- data/lib/wodify/requester.rb +61 -0
- data/lib/wodify/resource.rb +90 -0
- data/lib/wodify/uri_builder.rb +16 -0
- data/lib/wodify/version.rb +3 -0
- data/lib/wodify/wods.rb +11 -0
- data/lib/wodify.rb +7 -0
- data/spec/spec_helper.rb +2 -0
- data/spec/wodify/wods_spec.rb +21 -0
- data/spec/wodify_spec.rb +0 -0
- data/wodify.gemspec +29 -0
- metadata +160 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3df8a4fc63f24872cf8a11ddd183e6eceaf30b63
|
4
|
+
data.tar.gz: 8901145d1b0e6e1806d2b6663d120f8965787a9e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 682c72374bd4567110c2b9fa323da0c97f8f977217a877a652f6fe5ccdc2a5f7c8acf4cf1af5b9ff3e18d83101616bb6c33e915e592c7c988499d953e281cfda
|
7
|
+
data.tar.gz: 83e92e28bd457cefbaf161051f333ceab2321833833ebcfcfd1305cb0f967e2591af1846952fc95d1ff1ac75057bf53c0fe8e712d61ec8675d12bb298e474220
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Adam Ervans
|
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,31 @@
|
|
1
|
+
# Wodify
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'wodify'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install wodify
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it ( https://github.com/[my-github-username]/wodify/fork )
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require 'wodify/uri_builder'
|
3
|
+
|
4
|
+
module Wodify
|
5
|
+
|
6
|
+
class Requester
|
7
|
+
include HTTParty
|
8
|
+
|
9
|
+
class << self
|
10
|
+
|
11
|
+
def setup(api_key, env="production", format='json', encoding='utf-8')
|
12
|
+
@api_key = api_key
|
13
|
+
@env = env
|
14
|
+
@format = format
|
15
|
+
@encoding = encoding
|
16
|
+
end
|
17
|
+
|
18
|
+
def request(verb, resource, opts={})
|
19
|
+
opts[:query] ||= {}
|
20
|
+
uri = URIBuilder.build_uri verb, resource, @env, opts
|
21
|
+
authorize! opts
|
22
|
+
set_request_opts! opts
|
23
|
+
@request_data = { verb: verb, resource: resource, uri: uri, opts: opts }
|
24
|
+
@response_data = self.send verb, uri, opts
|
25
|
+
symbolize_keys(JSON.parse(@response_data.body))[:recordlist]
|
26
|
+
end
|
27
|
+
|
28
|
+
def authorize!(opts={})
|
29
|
+
opts[:query].reverse_merge!({ apikey: @api_key })
|
30
|
+
end
|
31
|
+
|
32
|
+
def set_request_opts!(opts={})
|
33
|
+
opts[:query].reverse_merge!({ type: @format, encoding: @encoding })
|
34
|
+
end
|
35
|
+
|
36
|
+
def request_data
|
37
|
+
@request_data
|
38
|
+
end
|
39
|
+
|
40
|
+
def response_data
|
41
|
+
@response_data
|
42
|
+
end
|
43
|
+
|
44
|
+
# recursively symbolize hash keys
|
45
|
+
def symbolize_keys(hash)
|
46
|
+
hash.inject({}){|result, (key, value)|
|
47
|
+
new_key = case key
|
48
|
+
when String then key.downcase.to_sym
|
49
|
+
else key
|
50
|
+
end
|
51
|
+
new_value = case value
|
52
|
+
when Hash then symbolize_keys(value)
|
53
|
+
else value
|
54
|
+
end
|
55
|
+
result[new_key] = new_value
|
56
|
+
result
|
57
|
+
}
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
require 'active_model'
|
2
|
+
require 'active_support/core_ext/hash'
|
3
|
+
|
4
|
+
module Wodify
|
5
|
+
|
6
|
+
class Resource
|
7
|
+
include ActiveModel::Model
|
8
|
+
|
9
|
+
# attributes should be a list of attributes that can be set on the
|
10
|
+
# remote object.
|
11
|
+
# h will be assigned to self when passed. for safety it is assumed
|
12
|
+
# that the remote object already exists if an id is set in h
|
13
|
+
#
|
14
|
+
# RemoteObject.new(:resource, { some: 'attribute' }
|
15
|
+
#
|
16
|
+
# Note: attributes are only assigned per those defeind in @attributes
|
17
|
+
def initialize(attributes, h)
|
18
|
+
super()
|
19
|
+
@attributes = attributes
|
20
|
+
@resource = self.class.resource
|
21
|
+
@requester = ArthrexPaymentGateway::Requester
|
22
|
+
@created = h[:id].present?
|
23
|
+
|
24
|
+
assign_attributes h if h
|
25
|
+
end
|
26
|
+
|
27
|
+
# returns accessible attributes as defined by @attributes
|
28
|
+
#
|
29
|
+
# object.attributes
|
30
|
+
def attributes
|
31
|
+
@attributes
|
32
|
+
end
|
33
|
+
|
34
|
+
# assings the passed hash's attributes to self. only keys
|
35
|
+
# listed in @attributes will be assigned.
|
36
|
+
#
|
37
|
+
# object.assign_attributes({remote_id: 1})
|
38
|
+
def assign_attributes(h)
|
39
|
+
|
40
|
+
@attributes.each do |key|
|
41
|
+
self.send("#{key}=", h[key]) if h.has_key? key
|
42
|
+
end
|
43
|
+
|
44
|
+
self.to_h
|
45
|
+
end
|
46
|
+
|
47
|
+
# returns all keys listed in @attributes and their values
|
48
|
+
# as a hash
|
49
|
+
#
|
50
|
+
# object.to_h
|
51
|
+
def to_h
|
52
|
+
h = {}
|
53
|
+
|
54
|
+
@attributes.each do |key|
|
55
|
+
h[key] = self.send key
|
56
|
+
end
|
57
|
+
|
58
|
+
h
|
59
|
+
end
|
60
|
+
|
61
|
+
def inspect
|
62
|
+
to_h.to_s
|
63
|
+
end
|
64
|
+
|
65
|
+
class << self
|
66
|
+
|
67
|
+
attr_accessor :response
|
68
|
+
|
69
|
+
# name of the rest resource. created by convention using
|
70
|
+
# the class's name
|
71
|
+
#
|
72
|
+
# RemoteObject.resource # => :remoteobject
|
73
|
+
#
|
74
|
+
# if the resource can't be created by convention, it can be passed
|
75
|
+
#
|
76
|
+
# resource('customer/gettransactions')
|
77
|
+
def resource(custom_resource=nil)
|
78
|
+
@resource ||= custom_resource || name.demodulize.downcase.to_sym
|
79
|
+
end
|
80
|
+
|
81
|
+
# returns a collection of all remote objects for a resource
|
82
|
+
#
|
83
|
+
# RemoteObject.all
|
84
|
+
def all(query={})
|
85
|
+
opts = { query: query }
|
86
|
+
response = Requester.request :get, resource, opts
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Wodify
|
2
|
+
|
3
|
+
class URIBuilder
|
4
|
+
|
5
|
+
class << self
|
6
|
+
URIs = {
|
7
|
+
production: "https://app.wodify.com/API",
|
8
|
+
}
|
9
|
+
|
10
|
+
def build_uri(verb, resource, env, opts={})
|
11
|
+
env = URIs.has_key?(env.to_sym) ? env : "production"
|
12
|
+
uri = "#{URIs[env.to_sym]}/#{resource}.aspx"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/wodify/wods.rb
ADDED
data/lib/wodify.rb
ADDED
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Wodify::Wods do
|
4
|
+
|
5
|
+
before(:all) do
|
6
|
+
Wodify::Requester.setup('1e6sobzytnzk0bz88bjlczyea')
|
7
|
+
end
|
8
|
+
|
9
|
+
describe '#all' do
|
10
|
+
|
11
|
+
context 'with valid arguments' do
|
12
|
+
|
13
|
+
it 'retrieves wods' do
|
14
|
+
asset = Wodify::Wods.all location: ENV["WODIFY_LOCATION"],
|
15
|
+
date: ENV["WODIFY_DATE"], program: ENV["WODIFY_PROGRAM"]
|
16
|
+
binding.pry
|
17
|
+
expect(asset).to include(:apiwod)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/spec/wodify_spec.rb
ADDED
File without changes
|
data/wodify.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'wodify/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "wodify"
|
8
|
+
spec.version = Wodify::VERSION
|
9
|
+
spec.authors = ["Adam Ervans"]
|
10
|
+
spec.email = ["aervans@arthrex.com"]
|
11
|
+
spec.summary = %q{Lightweight gem for consuming the Wodify API.}
|
12
|
+
spec.description = %q{Check the GitHub page for a detailed description.}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
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_development_dependency "bundler", "~> 1.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "rspec"
|
24
|
+
spec.add_development_dependency "pry"
|
25
|
+
|
26
|
+
spec.add_dependency "httparty"
|
27
|
+
spec.add_dependency "activemodel"
|
28
|
+
spec.add_dependency "activesupport"
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,160 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: wodify
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Adam Ervans
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
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: httparty
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
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: activemodel
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: activesupport
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: Check the GitHub page for a detailed description.
|
112
|
+
email:
|
113
|
+
- aervans@arthrex.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- ".gitignore"
|
119
|
+
- Gemfile
|
120
|
+
- LICENSE.txt
|
121
|
+
- README.md
|
122
|
+
- Rakefile
|
123
|
+
- lib/wodify.rb
|
124
|
+
- lib/wodify/requester.rb
|
125
|
+
- lib/wodify/resource.rb
|
126
|
+
- lib/wodify/uri_builder.rb
|
127
|
+
- lib/wodify/version.rb
|
128
|
+
- lib/wodify/wods.rb
|
129
|
+
- spec/spec_helper.rb
|
130
|
+
- spec/wodify/wods_spec.rb
|
131
|
+
- spec/wodify_spec.rb
|
132
|
+
- wodify.gemspec
|
133
|
+
homepage: ''
|
134
|
+
licenses:
|
135
|
+
- MIT
|
136
|
+
metadata: {}
|
137
|
+
post_install_message:
|
138
|
+
rdoc_options: []
|
139
|
+
require_paths:
|
140
|
+
- lib
|
141
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
|
+
requirements:
|
148
|
+
- - ">="
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: '0'
|
151
|
+
requirements: []
|
152
|
+
rubyforge_project:
|
153
|
+
rubygems_version: 2.2.0
|
154
|
+
signing_key:
|
155
|
+
specification_version: 4
|
156
|
+
summary: Lightweight gem for consuming the Wodify API.
|
157
|
+
test_files:
|
158
|
+
- spec/spec_helper.rb
|
159
|
+
- spec/wodify/wods_spec.rb
|
160
|
+
- spec/wodify_spec.rb
|