osm 0.0.26 → 0.1.0
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/CHANGELOG.md +57 -0
- data/README.md +13 -7
- data/lib/osm.rb +47 -22
- data/lib/osm/activity.rb +52 -57
- data/lib/osm/api.rb +115 -1031
- data/lib/osm/api_access.rb +73 -36
- data/lib/osm/due_badges.rb +27 -12
- data/lib/osm/evening.rb +118 -55
- data/lib/osm/event.rb +275 -17
- data/lib/osm/flexi_record.rb +131 -0
- data/lib/osm/grouping.rb +37 -15
- data/lib/osm/member.rb +100 -41
- data/lib/osm/model.rb +95 -0
- data/lib/osm/register.rb +177 -0
- data/lib/osm/section.rb +163 -71
- data/lib/osm/term.rb +135 -21
- data/spec/osm/activity_spec.rb +7 -4
- data/spec/osm/api_access_spec.rb +44 -36
- data/spec/osm/api_spec.rb +32 -1147
- data/spec/osm/due_badges_spec.rb +8 -1
- data/spec/osm/evening_spec.rb +119 -54
- data/spec/osm/event_spec.rb +363 -13
- data/spec/osm/flexi_record_spec.rb +128 -0
- data/spec/osm/grouping_spec.rb +9 -5
- data/spec/osm/member_spec.rb +111 -36
- data/spec/osm/model_spec.rb +140 -0
- data/spec/osm/osm_spec.rb +7 -31
- data/spec/osm/register_spec.rb +103 -0
- data/spec/osm/section_spec.rb +208 -92
- data/spec/osm/term_spec.rb +164 -28
- data/spec/spec_helper.rb +22 -0
- data/version.rb +1 -1
- metadata +22 -29
- data/lib/osm/event_attendance.rb +0 -55
- data/lib/osm/flexi_record_data.rb +0 -51
- data/lib/osm/flexi_record_field.rb +0 -42
- data/lib/osm/register_data.rb +0 -64
- data/lib/osm/register_field.rb +0 -42
- data/lib/osm/role.rb +0 -133
- data/spec/osm/api_strangeness_spec.rb +0 -83
- data/spec/osm/event_attendance_spec.rb +0 -34
- data/spec/osm/flexi_record_data_spec.rb +0 -40
- data/spec/osm/flexi_record_field_spec.rb +0 -23
- data/spec/osm/register_data_spec.rb +0 -35
- data/spec/osm/register_field_spec.rb +0 -24
- data/spec/osm/role_spec.rb +0 -118
data/spec/osm/term_spec.rb
CHANGED
@@ -14,15 +14,8 @@ describe "Term" do
|
|
14
14
|
}
|
15
15
|
end
|
16
16
|
|
17
|
-
it "Create
|
18
|
-
|
19
|
-
'termid' => '1',
|
20
|
-
'sectionid' => '2',
|
21
|
-
'name' => 'Term name',
|
22
|
-
'startdate' => '2001-01-01',
|
23
|
-
'enddate' => '2001-03-31'
|
24
|
-
}
|
25
|
-
term = Osm::Term.from_api(data)
|
17
|
+
it "Create" do
|
18
|
+
term = Osm::Term.new(@attributes)
|
26
19
|
|
27
20
|
term.id.should == 1
|
28
21
|
term.section_id.should == 2
|
@@ -32,18 +25,6 @@ describe "Term" do
|
|
32
25
|
term.valid?.should be_true
|
33
26
|
end
|
34
27
|
|
35
|
-
|
36
|
-
it "Creates the data for saving through the API" do
|
37
|
-
term = Osm::Term.new(@attributes)
|
38
|
-
term.to_api.should == {
|
39
|
-
'term' => @attributes[:name],
|
40
|
-
'start' => @attributes[:start].strftime(Osm::OSM_DATE_FORMAT),
|
41
|
-
'end' => @attributes[:finish].strftime(Osm::OSM_DATE_FORMAT),
|
42
|
-
'termid' => @attributes[:id]
|
43
|
-
}
|
44
|
-
end
|
45
|
-
|
46
|
-
|
47
28
|
it "Compares two matching terms" do
|
48
29
|
term1 = Osm::Term.new(@attributes)
|
49
30
|
term2 = Osm::Term.new(@attributes)
|
@@ -56,7 +37,6 @@ describe "Term" do
|
|
56
37
|
term.should_not == Osm::Term.new(@attributes.merge(:id => 3))
|
57
38
|
end
|
58
39
|
|
59
|
-
|
60
40
|
it "Sorts by Section ID, Start date and then Term ID" do
|
61
41
|
term1 = Osm::Term.new(@attributes.merge(:section_id => 1, :term => 11, :start => (Date.today - 60), :finish => (Date.today - 1)))
|
62
42
|
term2 = Osm::Term.new(@attributes.merge(:section_id => 1, :term => 12, :start => (Date.today - 0), :finish => (Date.today + 0)))
|
@@ -68,7 +48,6 @@ describe "Term" do
|
|
68
48
|
data.sort.should == [term1, term2, term3, term4, term5]
|
69
49
|
end
|
70
50
|
|
71
|
-
|
72
51
|
it "Works out if it is completly before a date" do
|
73
52
|
term1 = Osm::Term.new(@attributes.merge(:start => (Date.today - 60), :finish => (Date.today - 1)))
|
74
53
|
term2 = Osm::Term.new(@attributes.merge(:start => (Date.today - 0), :finish => (Date.today + 0)))
|
@@ -79,7 +58,6 @@ describe "Term" do
|
|
79
58
|
term3.before?(Date.today).should == false
|
80
59
|
end
|
81
60
|
|
82
|
-
|
83
61
|
it "Works out if it is completly after a date" do
|
84
62
|
term1 = Osm::Term.new(@attributes.merge(:start => (Date.today - 60), :finish => (Date.today - 1)))
|
85
63
|
term2 = Osm::Term.new(@attributes.merge(:start => (Date.today - 0), :finish => (Date.today + 0)))
|
@@ -90,7 +68,6 @@ describe "Term" do
|
|
90
68
|
term3.after?(Date.today).should == true
|
91
69
|
end
|
92
70
|
|
93
|
-
|
94
71
|
it "Works out if it has passed" do
|
95
72
|
term1 = Osm::Term.new(@attributes.merge(:start => (Date.today - 60), :finish => (Date.today - 1)))
|
96
73
|
term2 = Osm::Term.new(@attributes.merge(:start => (Date.today - 0), :finish => (Date.today + 0)))
|
@@ -101,7 +78,6 @@ describe "Term" do
|
|
101
78
|
term3.past?().should == false
|
102
79
|
end
|
103
80
|
|
104
|
-
|
105
81
|
it "Works out if it is in the future" do
|
106
82
|
term1 = Osm::Term.new(@attributes.merge(:start => (Date.today - 60), :finish => (Date.today - 1)))
|
107
83
|
term2 = Osm::Term.new(@attributes.merge(:start => (Date.today - 0), :finish => (Date.today + 0)))
|
@@ -112,7 +88,6 @@ describe "Term" do
|
|
112
88
|
term3.future?().should == true
|
113
89
|
end
|
114
90
|
|
115
|
-
|
116
91
|
it "Works out if it is the current term" do
|
117
92
|
term1 = Osm::Term.new(@attributes.merge(:start => (Date.today - 60), :finish => (Date.today - 1)))
|
118
93
|
term2 = Osm::Term.new(@attributes.merge(:start=> (Date.today - 0), :finish => (Date.today + 0)))
|
@@ -123,7 +98,6 @@ describe "Term" do
|
|
123
98
|
term3.current?().should == false
|
124
99
|
end
|
125
100
|
|
126
|
-
|
127
101
|
it "Works out if it contains a date" do
|
128
102
|
term1 = Osm::Term.new(@attributes.merge(:start => (Date.today - 60), :finish => (Date.today - 1)))
|
129
103
|
term2 = Osm::Term.new(@attributes.merge(:start => (Date.today - 0), :finish => (Date.today + 0)))
|
@@ -134,4 +108,166 @@ describe "Term" do
|
|
134
108
|
term3.contains_date?(Date.today).should == false
|
135
109
|
end
|
136
110
|
|
111
|
+
|
112
|
+
describe "Using the API" do
|
113
|
+
|
114
|
+
before :each do
|
115
|
+
body = [
|
116
|
+
{"sectionConfig"=>"{\"subscription_level\":1,\"subscription_expires\":\"2013-01-05\",\"sectionType\":\"beavers\",\"columnNames\":{\"column_names\":\"names\"},\"numscouts\":10,\"hasUsedBadgeRecords\":true,\"hasProgramme\":true,\"extraRecords\":[{\"name\":\"Flexi Record 1\",\"extraid\":\"111\"}],\"wizard\":\"false\",\"fields\":{\"fields\":true},\"intouch\":{\"intouch_fields\":true},\"mobFields\":{\"mobile_fields\":true}}", "groupname"=>"3rd Somewhere", "groupid"=>"3", "groupNormalised"=>"1", "sectionid"=>"9", "sectionname"=>"Section 1", "section"=>"beavers", "isDefault"=>"1", "permissions"=>{"badge"=>10, "member"=>20, "user"=>100, "register"=>100, "contact"=>100, "programme"=>100, "originator"=>1, "events"=>100, "finance"=>100, "flexi"=>100}},
|
117
|
+
{"sectionConfig"=>"{\"subscription_level\":3,\"subscription_expires\":\"2013-01-05\",\"sectionType\":\"cubs\",\"columnNames\":{\"phone1\":\"Home Phone\",\"phone2\":\"Parent 1 Phone\",\"address\":\"Member's Address\",\"phone3\":\"Parent 2 Phone\",\"address2\":\"Address 2\",\"phone4\":\"Alternate Contact Phone\",\"subs\":\"Gender\",\"email1\":\"Parent 1 Email\",\"medical\":\"Medical / Dietary\",\"email2\":\"Parent 2 Email\",\"ethnicity\":\"Gift Aid\",\"email3\":\"Member's Email\",\"religion\":\"Religion\",\"email4\":\"Email 4\",\"school\":\"School\"},\"numscouts\":10,\"hasUsedBadgeRecords\":true,\"hasProgramme\":true,\"extraRecords\":[],\"wizard\":\"false\",\"fields\":{\"email1\":true,\"email2\":true,\"email3\":true,\"email4\":false,\"address\":true,\"address2\":false,\"phone1\":true,\"phone2\":true,\"phone3\":true,\"phone4\":true,\"school\":false,\"religion\":true,\"ethnicity\":true,\"medical\":true,\"patrol\":true,\"subs\":true,\"saved\":true},\"intouch\":{\"address\":true,\"address2\":false,\"email1\":false,\"email2\":false,\"email3\":false,\"email4\":false,\"phone1\":true,\"phone2\":true,\"phone3\":true,\"phone4\":true,\"medical\":false},\"mobFields\":{\"email1\":false,\"email2\":false,\"email3\":false,\"email4\":false,\"address\":true,\"address2\":false,\"phone1\":true,\"phone2\":true,\"phone3\":true,\"phone4\":true,\"school\":false,\"religion\":false,\"ethnicity\":true,\"medical\":true,\"patrol\":true,\"subs\":false}}", "groupname"=>"1st Somewhere", "groupid"=>"1", "groupNormalised"=>"1", "sectionid"=>"10", "sectionname"=>"Section 2", "section"=>"cubs", "isDefault"=>"0", "permissions"=>{"badge"=>100, "member"=>100, "user"=>100, "register"=>100, "contact"=>100, "programme"=>100, "originator"=>1, "events"=>100, "finance"=>100, "flexi"=>100}}
|
118
|
+
]
|
119
|
+
FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/api.php?action=getUserRoles", :body => body.to_json)
|
120
|
+
|
121
|
+
body = {
|
122
|
+
"9" => [
|
123
|
+
{"termid" => "1", "name" => "Term 1", "sectionid" => "9", "startdate" => (Date.today + 31).strftime('%Y-%m-%d'), "enddate" => (Date.today + 90).strftime('%Y-%m-%d')}
|
124
|
+
],
|
125
|
+
"10" => [
|
126
|
+
{"termid" => "2", "name" => "Term 2", "sectionid" => "10", "startdate" => (Date.today + 31).strftime('%Y-%m-%d'), "enddate" => (Date.today + 90).strftime('%Y-%m-%d')},
|
127
|
+
{"termid" => "3", "name" => "Term 3", "sectionid" => "10", "startdate" => (Date.today + 91).strftime('%Y-%m-%d'), "enddate" => (Date.today + 180).strftime('%Y-%m-%d')}
|
128
|
+
]
|
129
|
+
}
|
130
|
+
FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/api.php?action=getTerms", :body => body.to_json)
|
131
|
+
end
|
132
|
+
|
133
|
+
|
134
|
+
it "Gets all terms" do
|
135
|
+
terms = Osm::Term.get_all(@api)
|
136
|
+
terms.size.should == 3
|
137
|
+
terms.map{ |i| i.id }.should == [1, 2, 3]
|
138
|
+
term = terms[0]
|
139
|
+
term.is_a?(Osm::Term).should be_true
|
140
|
+
term.id.should == 1
|
141
|
+
term.name.should == 'Term 1'
|
142
|
+
term.start.should == (Date.today + 31)
|
143
|
+
term.finish.should == (Date.today + 90)
|
144
|
+
end
|
145
|
+
|
146
|
+
it "Gets all terms for a section" do
|
147
|
+
terms = Osm::Term.get_for_section(@api, 10)
|
148
|
+
terms.size.should == 2
|
149
|
+
terms.map{ |i| i.id }.should == [2, 3]
|
150
|
+
end
|
151
|
+
|
152
|
+
it "Gets a term" do
|
153
|
+
term = Osm::Term.get(@api, 2)
|
154
|
+
term.is_a?(Osm::Term).should be_true
|
155
|
+
term.id.should == 2
|
156
|
+
end
|
157
|
+
|
158
|
+
describe "find current term" do
|
159
|
+
it "Returns the current term for the section from all terms returned by OSM" do
|
160
|
+
body = '{"9":['
|
161
|
+
body += '{"termid":"1","name":"Term 1","sectionid":"9","startdate":"' + (Date.today - 90).strftime('%Y-%m-%d') + '","enddate":"' + (Date.today - 31).strftime('%Y-%m-%d') + '"},'
|
162
|
+
body += '{"termid":"2","name":"Term 2","sectionid":"9","startdate":"' + (Date.today - 30).strftime('%Y-%m-%d') + '","enddate":"' + (Date.today + 30).strftime('%Y-%m-%d') + '"},'
|
163
|
+
body += '{"termid":"3","name":"Term 3","sectionid":"9","startdate":"' + (Date.today + 31).strftime('%Y-%m-%d') + '","enddate":"' + (Date.today + 90).strftime('%Y-%m-%d') + '"}'
|
164
|
+
body += ']}'
|
165
|
+
FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/api.php?action=getTerms", :body => body)
|
166
|
+
|
167
|
+
Osm::Term.get_current_term_for_section(@api, 9).id.should == 2
|
168
|
+
end
|
169
|
+
|
170
|
+
it "Raises an error if there is no current term" do
|
171
|
+
body = '{"9":['
|
172
|
+
body += '{"termid":"1","name":"Term 1","sectionid":"9","startdate":"' + (Date.today + 31).strftime('%Y-%m-%d') + '","enddate":"' + (Date.today + 90).strftime('%Y-%m-%d') + '"}'
|
173
|
+
body += ']}'
|
174
|
+
FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/api.php?action=getTerms", :body => body)
|
175
|
+
|
176
|
+
expect{ Osm::Term.get_current_term_for_section(@api, 9) }.to raise_error(Osm::Error, 'There is no current term for the section.')
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
it "Create a term" do
|
181
|
+
url = 'https://www.onlinescoutmanager.co.uk/users.php?action=addTerm§ionid=1'
|
182
|
+
post_data = {
|
183
|
+
'apiid' => @CONFIGURATION[:api][:osm][:id],
|
184
|
+
'token' => @CONFIGURATION[:api][:osm][:token],
|
185
|
+
'userid' => 'user_id',
|
186
|
+
'secret' => 'secret',
|
187
|
+
'term' => 'A Term',
|
188
|
+
'start' => '2010-01-01',
|
189
|
+
'end' => '2010-12-31',
|
190
|
+
'termid' => '0'
|
191
|
+
}
|
192
|
+
|
193
|
+
Osm::Term.stub(:get_all) { [] }
|
194
|
+
HTTParty.should_receive(:post).with(url, {:body => post_data}) { DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"terms":{}}'}) }
|
195
|
+
|
196
|
+
Osm::Term.create(@api, {
|
197
|
+
:section => 1,
|
198
|
+
:name => 'A Term',
|
199
|
+
:start => Date.new(2010, 01, 01),
|
200
|
+
:finish => Date.new(2010, 12, 31),
|
201
|
+
}).should be_true
|
202
|
+
end
|
203
|
+
|
204
|
+
it "Create a term (failed)" do
|
205
|
+
url = 'https://www.onlinescoutmanager.co.uk/users.php?action=addTerm§ionid=1'
|
206
|
+
post_data = {
|
207
|
+
'apiid' => @CONFIGURATION[:api][:osm][:id],
|
208
|
+
'token' => @CONFIGURATION[:api][:osm][:token],
|
209
|
+
'userid' => 'user_id',
|
210
|
+
'secret' => 'secret',
|
211
|
+
'term' => 'A Term',
|
212
|
+
'start' => '2010-01-01',
|
213
|
+
'end' => '2010-12-31',
|
214
|
+
'termid' => '0'
|
215
|
+
}
|
216
|
+
|
217
|
+
Osm::Term.stub(:get_all) { [] }
|
218
|
+
HTTParty.should_receive(:post).with(url, {:body => post_data}) { DummyHttpResult.new(:response=>{:code=>'200', :body=>'{}'}) }
|
219
|
+
|
220
|
+
Osm::Term.create(@api, {
|
221
|
+
:section => 1,
|
222
|
+
:name => 'A Term',
|
223
|
+
:start => Date.new(2010, 01, 01),
|
224
|
+
:finish => Date.new(2010, 12, 31),
|
225
|
+
}).should be_false
|
226
|
+
end
|
227
|
+
|
228
|
+
it "Update a term" do
|
229
|
+
url = 'https://www.onlinescoutmanager.co.uk/users.php?action=addTerm§ionid=1'
|
230
|
+
post_data = {
|
231
|
+
'apiid' => @CONFIGURATION[:api][:osm][:id],
|
232
|
+
'token' => @CONFIGURATION[:api][:osm][:token],
|
233
|
+
'userid' => 'user_id',
|
234
|
+
'secret' => 'secret',
|
235
|
+
'term' => 'A Term',
|
236
|
+
'start' => '2010-01-01',
|
237
|
+
'end' => '2010-12-31',
|
238
|
+
'termid' => 2
|
239
|
+
}
|
240
|
+
Osm::Term.stub(:get_all) { [] }
|
241
|
+
HTTParty.should_receive(:post).with(url, {:body => post_data}) { DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"terms":{}}'}) }
|
242
|
+
|
243
|
+
term = Osm::Term.new(:id=>2, :section_id=>1, :name=>'A Term', :start=>Date.new(2010, 01, 01), :finish=>Date.new(2010, 12, 31))
|
244
|
+
term.update(@api).should be_true
|
245
|
+
end
|
246
|
+
|
247
|
+
it "Update a term (failed)" do
|
248
|
+
url = 'https://www.onlinescoutmanager.co.uk/users.php?action=addTerm§ionid=1'
|
249
|
+
post_data = {
|
250
|
+
'apiid' => @CONFIGURATION[:api][:osm][:id],
|
251
|
+
'token' => @CONFIGURATION[:api][:osm][:token],
|
252
|
+
'userid' => 'user_id',
|
253
|
+
'secret' => 'secret',
|
254
|
+
'term' => 'A Term',
|
255
|
+
'start' => '2010-01-01',
|
256
|
+
'end' => '2010-12-31',
|
257
|
+
'termid' => 2
|
258
|
+
}
|
259
|
+
Osm::Term.stub(:get_all) { [] }
|
260
|
+
HTTParty.should_receive(:post).with(url, {:body => post_data}) { DummyHttpResult.new(:response=>{:code=>'200', :body=>'{}'}) }
|
261
|
+
|
262
|
+
term = Osm::Term.new(:id=>2, :section_id=>1, :name=>'A Term', :start=>Date.new(2010, 01, 01), :finish=>Date.new(2010, 12, 31))
|
263
|
+
term.update(@api).should be_false
|
264
|
+
end
|
265
|
+
|
266
|
+
it "Update a term (invalid term)" do
|
267
|
+
term = Osm::Term.new
|
268
|
+
expect{ term.update(@api) }.to raise_error(Osm::ObjectIsInvalid)
|
269
|
+
end
|
270
|
+
|
271
|
+
end
|
272
|
+
|
137
273
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -22,6 +22,28 @@ RSpec.configure do |config|
|
|
22
22
|
config.before(:each) do
|
23
23
|
FakeWeb.clean_registry
|
24
24
|
OsmTest::Cache.clear
|
25
|
+
|
26
|
+
@CONFIGURATION = {
|
27
|
+
:api => {
|
28
|
+
:default_site => :osm,
|
29
|
+
:osm => {
|
30
|
+
:id => '1',
|
31
|
+
:token => 'API TOKEN',
|
32
|
+
:name => 'API NAME',
|
33
|
+
},
|
34
|
+
:ogm => {
|
35
|
+
:id => '2',
|
36
|
+
:token => 'API TOKEN 2',
|
37
|
+
:name => 'API NAME 2',
|
38
|
+
},
|
39
|
+
},
|
40
|
+
:cache => {
|
41
|
+
:cache => OsmTest::Cache,
|
42
|
+
},
|
43
|
+
}
|
44
|
+
Osm::configure(@CONFIGURATION)
|
45
|
+
|
46
|
+
@api = Osm::Api.new('user_id', 'secret')
|
25
47
|
end
|
26
48
|
end
|
27
49
|
|
data/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: osm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
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: 2012-10-
|
12
|
+
date: 2012-10-21 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
16
|
-
requirement: &
|
16
|
+
requirement: &77741230 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '3.2'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *77741230
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: httparty
|
27
|
-
requirement: &
|
27
|
+
requirement: &77740810 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0.9'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *77740810
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: active_attr
|
38
|
-
requirement: &
|
38
|
+
requirement: &77740380 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0.6'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *77740380
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: activemodel
|
49
|
-
requirement: &
|
49
|
+
requirement: &77740070 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '3.2'
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *77740070
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rake
|
60
|
-
requirement: &
|
60
|
+
requirement: &77739770 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0.9'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *77739770
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
|
-
requirement: &
|
71
|
+
requirement: &77739280 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '2.11'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *77739280
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: fakeweb
|
82
|
-
requirement: &
|
82
|
+
requirement: &77738950 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ~>
|
@@ -87,7 +87,7 @@ dependencies:
|
|
87
87
|
version: '1.3'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *77738950
|
91
91
|
description: Use the Online Scout Manager API (https://www.onlinescoutmanager.co.uk)
|
92
92
|
to retrieve and save data.
|
93
93
|
email:
|
@@ -113,33 +113,26 @@ files:
|
|
113
113
|
- lib/osm/due_badges.rb
|
114
114
|
- lib/osm/evening.rb
|
115
115
|
- lib/osm/event.rb
|
116
|
-
- lib/osm/
|
117
|
-
- lib/osm/flexi_record_data.rb
|
118
|
-
- lib/osm/flexi_record_field.rb
|
116
|
+
- lib/osm/flexi_record.rb
|
119
117
|
- lib/osm/grouping.rb
|
120
118
|
- lib/osm/member.rb
|
121
|
-
- lib/osm/
|
122
|
-
- lib/osm/
|
123
|
-
- lib/osm/role.rb
|
119
|
+
- lib/osm/model.rb
|
120
|
+
- lib/osm/register.rb
|
124
121
|
- lib/osm/section.rb
|
125
122
|
- lib/osm/term.rb
|
126
123
|
- osm.gemspec
|
127
124
|
- spec/osm/activity_spec.rb
|
128
125
|
- spec/osm/api_access_spec.rb
|
129
126
|
- spec/osm/api_spec.rb
|
130
|
-
- spec/osm/api_strangeness_spec.rb
|
131
127
|
- spec/osm/due_badges_spec.rb
|
132
128
|
- spec/osm/evening_spec.rb
|
133
|
-
- spec/osm/event_attendance_spec.rb
|
134
129
|
- spec/osm/event_spec.rb
|
135
|
-
- spec/osm/
|
136
|
-
- spec/osm/flexi_record_field_spec.rb
|
130
|
+
- spec/osm/flexi_record_spec.rb
|
137
131
|
- spec/osm/grouping_spec.rb
|
138
132
|
- spec/osm/member_spec.rb
|
133
|
+
- spec/osm/model_spec.rb
|
139
134
|
- spec/osm/osm_spec.rb
|
140
|
-
- spec/osm/
|
141
|
-
- spec/osm/register_field_spec.rb
|
142
|
-
- spec/osm/role_spec.rb
|
135
|
+
- spec/osm/register_spec.rb
|
143
136
|
- spec/osm/section_spec.rb
|
144
137
|
- spec/osm/term_spec.rb
|
145
138
|
- spec/spec_helper.rb
|
data/lib/osm/event_attendance.rb
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
module Osm
|
2
|
-
|
3
|
-
class EventAttendance
|
4
|
-
include ::ActiveAttr::MassAssignmentSecurity
|
5
|
-
include ::ActiveAttr::Model
|
6
|
-
|
7
|
-
# @!attribute [rw] member_id
|
8
|
-
# @return [Fixnum] OSM id for the member
|
9
|
-
# @!attribute [rw] grouping__id
|
10
|
-
# @return [Fixnum] OSM id for the grouping the member is in
|
11
|
-
# @!attribute [rw] fields
|
12
|
-
# @return [Hash] Keys are the field's id, values are the field values
|
13
|
-
# @!attribute [rw] row
|
14
|
-
# @return [Fixnum] part of the OSM API
|
15
|
-
|
16
|
-
attribute :row, :type => Integer
|
17
|
-
attribute :member_id, :type => Integer
|
18
|
-
attribute :grouping_id, :type => Integer
|
19
|
-
attribute :fields, :default => {}
|
20
|
-
|
21
|
-
attr_accessible :member_id, :grouping_id, :fields, :row
|
22
|
-
|
23
|
-
validates_numericality_of :row, :only_integer=>true, :greater_than_or_equal_to=>0
|
24
|
-
validates_numericality_of :member_id, :only_integer=>true, :greater_than=>0
|
25
|
-
validates_numericality_of :grouping_id, :only_integer=>true, :greater_than_or_equal_to=>-2
|
26
|
-
validates :fields, :hash => {:key_type => String}
|
27
|
-
|
28
|
-
|
29
|
-
# @!method initialize
|
30
|
-
# Initialize a new FlexiRecordData
|
31
|
-
# @param [Hash] attributes the hash of attributes (see attributes for descriptions, use Symbol of attribute name as the key)
|
32
|
-
|
33
|
-
|
34
|
-
# Initialize a new FlexiRecordData from api data
|
35
|
-
# @param [Hash] data the hash of data provided by the API
|
36
|
-
# @param [Fixnum] row part of the OSM API
|
37
|
-
def self.from_api(data, row)
|
38
|
-
data.merge!({
|
39
|
-
'dob' => data['dob'].nil? ? nil : Osm::parse_date(data['dob'], :ignore_epoch => true),
|
40
|
-
'attending' => data['attending'].eql?('Yes'),
|
41
|
-
})
|
42
|
-
|
43
|
-
new({
|
44
|
-
:member_id => Osm::to_i_or_nil(data['scoutid']),
|
45
|
-
:grouping_id => Osm::to_i_or_nil(data['patrolid'].eql?('') ? nil : data['patrolid']),
|
46
|
-
:fields => data.select { |key, value|
|
47
|
-
['firstname', 'lastname', 'dob', 'attending'].include?(key) || key.to_s.match(/\Af_\d+\Z/)
|
48
|
-
},
|
49
|
-
:row => row,
|
50
|
-
})
|
51
|
-
end
|
52
|
-
|
53
|
-
end # Class EventAttendance
|
54
|
-
|
55
|
-
end # Module
|