kekeewin 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +7 -0
- data/README.md +15 -2
- data/lib/kekeewin.rb +102 -18
- data/lib/kekeewin/version.rb +1 -1
- metadata +11 -10
data/CHANGELOG
ADDED
data/README.md
CHANGED
@@ -1,7 +1,20 @@
|
|
1
1
|
# Kekeewin
|
2
2
|
|
3
|
-
API wrapper for Kekeewin on Scouting.io.
|
4
|
-
|
3
|
+
API wrapper for Kekeewin on Scouting.io. Kekeewin is a central database for all things Scouting related. Currently it contains the following resources:
|
4
|
+
|
5
|
+
- Regions
|
6
|
+
- Areas
|
7
|
+
- Councils
|
8
|
+
- Districts
|
9
|
+
- Lodges
|
10
|
+
- Chapters
|
11
|
+
- Merit Badges
|
12
|
+
- Positions
|
13
|
+
- Training Courses
|
14
|
+
|
15
|
+
```
|
16
|
+
Kekeewin - Such things as are generally understood by the tribe.
|
17
|
+
```
|
5
18
|
|
6
19
|
## Installation
|
7
20
|
|
data/lib/kekeewin.rb
CHANGED
@@ -8,32 +8,107 @@ require 'active_support/concern'
|
|
8
8
|
|
9
9
|
module Kekeewin
|
10
10
|
|
11
|
-
|
12
|
-
attr :access_token
|
13
|
-
attr :oauth_client
|
11
|
+
module OauthAPI
|
14
12
|
|
15
|
-
|
16
|
-
|
13
|
+
class << self
|
14
|
+
def configure(&block)
|
15
|
+
Kekeewin::OauthAPI::Base.configure(&block)
|
16
|
+
end
|
17
17
|
end
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
class Auth
|
20
|
+
attr :access_token
|
21
|
+
attr :oauth_client
|
22
|
+
|
23
|
+
def self.client(oauth_id = Base.oauth_id, oauth_secret = Base.oauth_secret, host = Base.host)
|
24
|
+
@oauth_client ||= OAuth2::Client.new(oauth_id, oauth_secret, site: host)
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.access
|
28
|
+
@access_token ||= OAuth2::AccessToken.new(self.client, Base.access_token)
|
29
|
+
end
|
22
30
|
|
23
|
-
|
24
|
-
|
31
|
+
def self.hello
|
32
|
+
return "Hello, World!"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
class Lodge
|
37
|
+
def self.all
|
38
|
+
@lodges ||= Auth.access.get("/api/lodges").parsed
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.test
|
42
|
+
return Auth.hello
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
class User
|
47
|
+
def self.profile
|
48
|
+
Auth.access.get("/api/me.json").parsed
|
49
|
+
end
|
25
50
|
end
|
26
|
-
end
|
27
51
|
|
28
|
-
|
29
|
-
|
30
|
-
|
52
|
+
module Configuration
|
53
|
+
extend ActiveSupport::Concern
|
54
|
+
|
55
|
+
included do
|
56
|
+
add_config :host
|
57
|
+
add_config :oauth_id
|
58
|
+
add_config :oauth_secret
|
59
|
+
add_config :access_token
|
60
|
+
# set default values
|
61
|
+
reset_config
|
62
|
+
end
|
63
|
+
|
64
|
+
module ClassMethods
|
65
|
+
def add_config(name)
|
66
|
+
class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
67
|
+
|
68
|
+
def self.#{name}(value=nil)
|
69
|
+
@#{name} = value if value
|
70
|
+
return @#{name} if self.object_id == #{self.object_id} || defined?(@#{name})
|
71
|
+
name = superclass.#{name}
|
72
|
+
return nil if name.nil? && !instance_variable_defined?("@#{name}")
|
73
|
+
@#{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
|
74
|
+
end
|
75
|
+
|
76
|
+
def self.#{name}=(value)
|
77
|
+
@#{name} = value
|
78
|
+
end
|
79
|
+
|
80
|
+
def #{name}=(value)
|
81
|
+
@#{name} = value
|
82
|
+
end
|
83
|
+
|
84
|
+
def #{name}
|
85
|
+
value = @#{name} if instance_variable_defined?(:@#{name})
|
86
|
+
value = self.class.#{name} unless instance_variable_defined?(:@#{name})
|
87
|
+
if value.instance_of?(Proc)
|
88
|
+
value.arity >= 1 ? value.call(self) : value.call
|
89
|
+
else
|
90
|
+
value
|
91
|
+
end
|
92
|
+
end
|
93
|
+
RUBY
|
94
|
+
end
|
95
|
+
|
96
|
+
def configure
|
97
|
+
yield self
|
98
|
+
end
|
99
|
+
|
100
|
+
def reset_config
|
101
|
+
configure do |config|
|
102
|
+
config.host = "http://kekeewin.dev"
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
31
106
|
end
|
32
107
|
|
33
|
-
|
34
|
-
|
108
|
+
class Base
|
109
|
+
include Kekeewin::OauthAPI::Configuration
|
35
110
|
end
|
36
|
-
|
111
|
+
end
|
37
112
|
|
38
113
|
module RestAPI
|
39
114
|
|
@@ -47,11 +122,21 @@ module Kekeewin
|
|
47
122
|
HTTParty.get(Base.host + "/rest_api/councils.json", options)
|
48
123
|
end
|
49
124
|
|
125
|
+
def districts(options={})
|
126
|
+
options.merge!({:basic_auth => {:username => Base.username, :password => Base.password}})
|
127
|
+
HTTParty.get(Base.host + "/rest_api/districts.json", options)
|
128
|
+
end
|
129
|
+
|
50
130
|
def lodges(options={})
|
51
131
|
options.merge!({:basic_auth => {:username => Base.username, :password => Base.password}})
|
52
132
|
HTTParty.get(Base.host + "/rest_api/lodges.json", options)
|
53
133
|
end
|
54
134
|
|
135
|
+
def chapters(options={})
|
136
|
+
options.merge!({:basic_auth => {:username => Base.username, :password => Base.password}})
|
137
|
+
HTTParty.get(Base.host + "/rest_api/chapters.json", options)
|
138
|
+
end
|
139
|
+
|
55
140
|
def positions(options={})
|
56
141
|
options.merge!({:basic_auth => {:username => Base.username, :password => Base.password}})
|
57
142
|
HTTParty.get(Base.host + "/rest_api/positions.json", options)
|
@@ -66,7 +151,6 @@ module Kekeewin
|
|
66
151
|
add_config :host
|
67
152
|
add_config :username
|
68
153
|
add_config :password
|
69
|
-
|
70
154
|
# set default values
|
71
155
|
reset_config
|
72
156
|
end
|
data/lib/kekeewin/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kekeewin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-10-
|
12
|
+
date: 2013-10-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
16
|
-
requirement: &
|
16
|
+
requirement: &70156718726200 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70156718726200
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: oauth2
|
27
|
-
requirement: &
|
27
|
+
requirement: &70156718725560 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70156718725560
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: httparty
|
38
|
-
requirement: &
|
38
|
+
requirement: &70156718724980 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70156718724980
|
47
47
|
description: API wrapper for Kekeewin on Scouting.io.
|
48
48
|
email:
|
49
49
|
- crjones@gmail.com
|
@@ -53,6 +53,7 @@ extra_rdoc_files: []
|
|
53
53
|
files:
|
54
54
|
- .gitignore
|
55
55
|
- .rspec
|
56
|
+
- CHANGELOG
|
56
57
|
- Gemfile
|
57
58
|
- LICENSE.txt
|
58
59
|
- README.md
|
@@ -77,7 +78,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
77
78
|
version: '0'
|
78
79
|
segments:
|
79
80
|
- 0
|
80
|
-
hash: -
|
81
|
+
hash: -1436102944154449281
|
81
82
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
83
|
none: false
|
83
84
|
requirements:
|
@@ -86,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
86
87
|
version: '0'
|
87
88
|
segments:
|
88
89
|
- 0
|
89
|
-
hash: -
|
90
|
+
hash: -1436102944154449281
|
90
91
|
requirements: []
|
91
92
|
rubyforge_project:
|
92
93
|
rubygems_version: 1.8.17
|