collegiatelink 0.1.0 → 0.1.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/lib/collegiatelink.rb +1 -0
- data/lib/collegiatelink/member.rb +73 -0
- data/lib/collegiatelink/organization.rb +1 -50
- metadata +2 -1
data/lib/collegiatelink.rb
CHANGED
@@ -13,6 +13,7 @@ require 'collegiatelink/response'
|
|
13
13
|
require 'collegiatelink/request'
|
14
14
|
require 'collegiatelink/client'
|
15
15
|
require 'collegiatelink/organization'
|
16
|
+
require 'collegiatelink/member'
|
16
17
|
|
17
18
|
##
|
18
19
|
# This gem provides a CollegiateLink API client in Ruby. It's still under
|
@@ -0,0 +1,73 @@
|
|
1
|
+
module CollegiateLink
|
2
|
+
##
|
3
|
+
# A position of someone in an organization
|
4
|
+
#
|
5
|
+
class Position < OpenStruct
|
6
|
+
include Representable::XML
|
7
|
+
|
8
|
+
property :name
|
9
|
+
property :enddate
|
10
|
+
property :startdate
|
11
|
+
property :userstartdate
|
12
|
+
property :userenddate
|
13
|
+
|
14
|
+
def current?
|
15
|
+
use_startdate = (userstartdate.to_i > 0) ? userstartdate.to_i : startdate.to_i
|
16
|
+
indefinite = (userenddate.to_i < 0) && (enddate.to_i < 0)
|
17
|
+
|
18
|
+
starts = Time.at(use_startdate / 1000, use_startdate % 1000)
|
19
|
+
|
20
|
+
if indefinite
|
21
|
+
return (starts < Time.now)
|
22
|
+
else
|
23
|
+
use_enddate = (userenddate.to_i > 0) ? userenddate.to_i : enddate.to_i
|
24
|
+
ends = Time.at(use_enddate / 1000, use_enddate % 1000)
|
25
|
+
return (starts < Time.now && Time.now < ends)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
module PositionRepresenter
|
31
|
+
include Representable::XML
|
32
|
+
|
33
|
+
property :name
|
34
|
+
property :enddate
|
35
|
+
property :startdate
|
36
|
+
property :userstartdate
|
37
|
+
property :userenddate
|
38
|
+
end
|
39
|
+
|
40
|
+
class PositionList < OpenStruct
|
41
|
+
include Representable::XML
|
42
|
+
|
43
|
+
collection :positions, :extend => PositionRepresenter, :class => Position, :as => :position
|
44
|
+
end
|
45
|
+
|
46
|
+
##
|
47
|
+
# A Member record returned by CollegiateLink
|
48
|
+
#
|
49
|
+
class Member < OpenStruct
|
50
|
+
include Representable::XML
|
51
|
+
|
52
|
+
#property :affiliation # Not sure the format of this...
|
53
|
+
property :campusemail
|
54
|
+
property :firstname
|
55
|
+
property :id
|
56
|
+
property :lastname
|
57
|
+
property :preferredemail
|
58
|
+
property :username
|
59
|
+
property :positionList, :class => PositionList, :as => :positions
|
60
|
+
|
61
|
+
def positions
|
62
|
+
positionList.positions
|
63
|
+
end
|
64
|
+
|
65
|
+
def active_positions
|
66
|
+
positions.keep_if { |p| p.current? }
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.parse(xml)
|
70
|
+
from_xml(xml.to_s)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -87,7 +87,7 @@ module CollegiateLink
|
|
87
87
|
# * <tt>:status </tt> - String
|
88
88
|
# * <tt>:urlLarge </tt> - String
|
89
89
|
# * <tt>:urlSmall </tt> - String
|
90
|
-
# * <tt>:organization</tt> - The hosting Organization
|
90
|
+
# * <tt>:organization</tt> - The hosting Organization (..todo?)
|
91
91
|
#
|
92
92
|
class Event < OpenStruct
|
93
93
|
include Representable::XML
|
@@ -141,53 +141,4 @@ module CollegiateLink
|
|
141
141
|
new(hash)
|
142
142
|
end
|
143
143
|
end
|
144
|
-
|
145
|
-
##
|
146
|
-
# A position of someone in an organization
|
147
|
-
#
|
148
|
-
class Position < OpenStruct
|
149
|
-
include Representable::XML
|
150
|
-
|
151
|
-
property :name
|
152
|
-
property :enddate
|
153
|
-
property :startdate
|
154
|
-
property :userstartdate
|
155
|
-
property :userenddate
|
156
|
-
|
157
|
-
def current?
|
158
|
-
use_startdate = (userstartdate > 0) ? userstartdate : startdate
|
159
|
-
indefinite = (userenddate < 0) && (enddate < 0)
|
160
|
-
|
161
|
-
starts = Time.at(use_startdate / 1000, use_startdate % 1000)
|
162
|
-
|
163
|
-
if indefinite
|
164
|
-
return (starts < Time.now)
|
165
|
-
else
|
166
|
-
use_enddate = (userenddate > 0) ? userenddate : enddate
|
167
|
-
ends = Time.at(use_enddate / 1000, use_enddate % 1000)
|
168
|
-
return (starts < Time.now && Time.now < ends)
|
169
|
-
end
|
170
|
-
end
|
171
|
-
end
|
172
|
-
|
173
|
-
##
|
174
|
-
# A Member record returned by CollegiateLink
|
175
|
-
#
|
176
|
-
class Member < OpenStruct
|
177
|
-
include Representable::XML
|
178
|
-
|
179
|
-
#property :affiliation # Not sure the format of this...
|
180
|
-
property :campusemail
|
181
|
-
property :firstname
|
182
|
-
property :id
|
183
|
-
property :lastname
|
184
|
-
property :preferredemail
|
185
|
-
property :username
|
186
|
-
|
187
|
-
collection :positions, :class => CollegiateLink::Position
|
188
|
-
|
189
|
-
def active_positions
|
190
|
-
positions.keep_if { |p| p.current? }
|
191
|
-
end
|
192
|
-
end
|
193
144
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: collegiatelink
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -118,6 +118,7 @@ files:
|
|
118
118
|
- lib/collegiatelink/response.rb
|
119
119
|
- lib/collegiatelink/client.rb
|
120
120
|
- lib/collegiatelink/organization.rb
|
121
|
+
- lib/collegiatelink/member.rb
|
121
122
|
homepage:
|
122
123
|
licenses: []
|
123
124
|
post_install_message:
|