kekeewin 0.0.1
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.
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +37 -0
- data/Rakefile +1 -0
- data/kekeewin.gemspec +24 -0
- data/lib/kekeewin/version.rb +3 -0
- data/lib/kekeewin.rb +122 -0
- data/spec/kekeewin_spec.rb +9 -0
- data/spec/spec_helper.rb +2 -0
- metadata +98 -0
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Christopher Jones
|
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,37 @@
|
|
1
|
+
# Kekeewin
|
2
|
+
|
3
|
+
API wrapper for Kekeewin on Scouting.io.
|
4
|
+
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add to your Gemfile and run the `bundle` command to install it.
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem "kekeewin"
|
12
|
+
```
|
13
|
+
|
14
|
+
**Requires Ruby 1.9.2 or later.**
|
15
|
+
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
Once configured with host, username, and password from Scouting.io, you can call any of the resources through the API.
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
Kekeewin::RestAPI.configure do |config|
|
23
|
+
config.host = "http://api.scouting.io"
|
24
|
+
config.username = "45w45gwe4w4w56"
|
25
|
+
config.password = "g4e56e456h56e5ht6"
|
26
|
+
end
|
27
|
+
|
28
|
+
Kekeewin::RestAPI.lodges
|
29
|
+
Kekeewin::RestAPI.councils
|
30
|
+
```
|
31
|
+
|
32
|
+
|
33
|
+
## Development
|
34
|
+
|
35
|
+
Questions or problems? Please post them on the [issue tracker](https://github.com/scoutingio/kekeewin-gem/issues). You can contribute changes by forking the project and submitting a pull request. You can ensure the tests passing by running `bundle` and `rake`.
|
36
|
+
|
37
|
+
This gem is created by Scouting.io and is under the MIT License.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/kekeewin.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'kekeewin/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "kekeewin"
|
8
|
+
gem.version = Kekeewin::VERSION
|
9
|
+
gem.authors = ["Christopher Jones"]
|
10
|
+
gem.email = ["crjones@gmail.com"]
|
11
|
+
gem.description = "API wrapper for Kekeewin on Scouting.io."
|
12
|
+
gem.summary = "API wrapper for Kekeewin on Scouting.io."
|
13
|
+
gem.homepage = "http://scouting.io"
|
14
|
+
gem.license = "MIT"
|
15
|
+
|
16
|
+
gem.files = `git ls-files`.split($/)
|
17
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
18
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
|
+
gem.require_paths = ["lib"]
|
20
|
+
|
21
|
+
gem.add_development_dependency "rake"
|
22
|
+
gem.add_runtime_dependency "oauth2"
|
23
|
+
gem.add_runtime_dependency "httparty"
|
24
|
+
end
|
data/lib/kekeewin.rb
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
require "kekeewin/version"
|
2
|
+
|
3
|
+
require 'oauth2'
|
4
|
+
require 'httparty'
|
5
|
+
require 'active_support/core_ext/object/blank'
|
6
|
+
require 'active_support/core_ext/class/attribute'
|
7
|
+
require 'active_support/concern'
|
8
|
+
|
9
|
+
module Kekeewin
|
10
|
+
|
11
|
+
class Auth
|
12
|
+
attr :access_token
|
13
|
+
attr :oauth_client
|
14
|
+
|
15
|
+
def initialize(oauth_id = "ccd5cf853a2b5ddbb523da179376ef65467b6affc7b68b7fab647211c002a337", oauth_secret = "ed2a8299d31fb35d3a4f07f46eb0f1e1460ee49e98621a5b9dccfa6b56157ce3", host = "http://kekeewin.dev")
|
16
|
+
@oauth_client ||= OAuth2::Client.new(oauth_id, oauth_secret, site: host)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.access
|
20
|
+
@access_token ||= OAuth2::AccessToken.new(@oauth_client, @access_token)
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.hello
|
24
|
+
return "Hello, World!"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class Lodge
|
29
|
+
def self.all
|
30
|
+
@lodges ||= Auth.access.get("/api/lodges").parsed
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.test
|
34
|
+
return Auth.hello
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
module RestAPI
|
39
|
+
|
40
|
+
class << self
|
41
|
+
def configure(&block)
|
42
|
+
Kekeewin::RestAPI::Base.configure(&block)
|
43
|
+
end
|
44
|
+
|
45
|
+
def councils(options={})
|
46
|
+
options.merge!({:basic_auth => {:username => Base.username, :password => Base.password}})
|
47
|
+
HTTParty.get(Base.host + "/rest_api/councils.json", options)
|
48
|
+
end
|
49
|
+
|
50
|
+
def lodges(options={})
|
51
|
+
options.merge!({:basic_auth => {:username => Base.username, :password => Base.password}})
|
52
|
+
HTTParty.get(Base.host + "/rest_api/lodges.json", options)
|
53
|
+
end
|
54
|
+
|
55
|
+
def positions(options={})
|
56
|
+
options.merge!({:basic_auth => {:username => Base.username, :password => Base.password}})
|
57
|
+
HTTParty.get(Base.host + "/rest_api/positions.json", options)
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
end
|
62
|
+
module Configuration
|
63
|
+
extend ActiveSupport::Concern
|
64
|
+
|
65
|
+
included do
|
66
|
+
add_config :host
|
67
|
+
add_config :username
|
68
|
+
add_config :password
|
69
|
+
|
70
|
+
# set default values
|
71
|
+
reset_config
|
72
|
+
end
|
73
|
+
|
74
|
+
module ClassMethods
|
75
|
+
def add_config(name)
|
76
|
+
class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
77
|
+
|
78
|
+
def self.#{name}(value=nil)
|
79
|
+
@#{name} = value if value
|
80
|
+
return @#{name} if self.object_id == #{self.object_id} || defined?(@#{name})
|
81
|
+
name = superclass.#{name}
|
82
|
+
return nil if name.nil? && !instance_variable_defined?("@#{name}")
|
83
|
+
@#{name} = name && !name.is_a?(Module) && !name.is_a?(Symbol) && !name.is_a?(Numeric) && !name.is_a?(TrueClass) && !name.is_a?(FalseClass) ? name.dup : name
|
84
|
+
end
|
85
|
+
|
86
|
+
def self.#{name}=(value)
|
87
|
+
@#{name} = value
|
88
|
+
end
|
89
|
+
|
90
|
+
def #{name}=(value)
|
91
|
+
@#{name} = value
|
92
|
+
end
|
93
|
+
|
94
|
+
def #{name}
|
95
|
+
value = @#{name} if instance_variable_defined?(:@#{name})
|
96
|
+
value = self.class.#{name} unless instance_variable_defined?(:@#{name})
|
97
|
+
if value.instance_of?(Proc)
|
98
|
+
value.arity >= 1 ? value.call(self) : value.call
|
99
|
+
else
|
100
|
+
value
|
101
|
+
end
|
102
|
+
end
|
103
|
+
RUBY
|
104
|
+
end
|
105
|
+
|
106
|
+
def configure
|
107
|
+
yield self
|
108
|
+
end
|
109
|
+
|
110
|
+
def reset_config
|
111
|
+
configure do |config|
|
112
|
+
config.host = "http://kekeewin.dev"
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
class Base
|
119
|
+
include Kekeewin::RestAPI::Configuration
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kekeewin
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Christopher Jones
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-10-07 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: &70174486086940 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70174486086940
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: oauth2
|
27
|
+
requirement: &70174486086280 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70174486086280
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: httparty
|
38
|
+
requirement: &70174486085700 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70174486085700
|
47
|
+
description: API wrapper for Kekeewin on Scouting.io.
|
48
|
+
email:
|
49
|
+
- crjones@gmail.com
|
50
|
+
executables: []
|
51
|
+
extensions: []
|
52
|
+
extra_rdoc_files: []
|
53
|
+
files:
|
54
|
+
- .gitignore
|
55
|
+
- .rspec
|
56
|
+
- Gemfile
|
57
|
+
- LICENSE.txt
|
58
|
+
- README.md
|
59
|
+
- Rakefile
|
60
|
+
- kekeewin.gemspec
|
61
|
+
- lib/kekeewin.rb
|
62
|
+
- lib/kekeewin/version.rb
|
63
|
+
- spec/kekeewin_spec.rb
|
64
|
+
- spec/spec_helper.rb
|
65
|
+
homepage: http://scouting.io
|
66
|
+
licenses:
|
67
|
+
- MIT
|
68
|
+
post_install_message:
|
69
|
+
rdoc_options: []
|
70
|
+
require_paths:
|
71
|
+
- lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
segments:
|
79
|
+
- 0
|
80
|
+
hash: -792729284599569794
|
81
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
83
|
+
requirements:
|
84
|
+
- - ! '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
segments:
|
88
|
+
- 0
|
89
|
+
hash: -792729284599569794
|
90
|
+
requirements: []
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 1.8.17
|
93
|
+
signing_key:
|
94
|
+
specification_version: 3
|
95
|
+
summary: API wrapper for Kekeewin on Scouting.io.
|
96
|
+
test_files:
|
97
|
+
- spec/kekeewin_spec.rb
|
98
|
+
- spec/spec_helper.rb
|