osm 0.0.6 → 0.0.7
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 +6 -0
- data/lib/osm/activity.rb +9 -9
- data/lib/osm/api.rb +7 -21
- data/lib/osm/{programme_item.rb → evening.rb} +47 -7
- data/lib/osm/event.rb +1 -1
- data/lib/osm/member.rb +3 -3
- data/lib/osm/role.rb +1 -7
- data/lib/osm/section.rb +1 -10
- data/spec/osm/api_spec.rb +7 -7
- data/spec/osm/evening_spec.rb +103 -0
- data/spec/osm/section_spec.rb +0 -6
- data/version.rb +1 -1
- metadata +16 -18
- data/lib/osm/programme_activity.rb +0 -26
- data/spec/osm/programme_activity_spec.rb +0 -21
- data/spec/osm/programme_item_spec.rb +0 -64
data/CHANGELOG.md
CHANGED
data/lib/osm/activity.rb
CHANGED
@@ -22,27 +22,27 @@ module Osm
|
|
22
22
|
# @!attribute [r] running_time
|
23
23
|
# @return [FixNum] duration of the activity in minutes
|
24
24
|
# @!attribute [r] location
|
25
|
-
# @return [Symbol] :indoors or :
|
25
|
+
# @return [Symbol] :indoors, :outdoors or :both
|
26
26
|
# @!attribute [r] shared
|
27
|
-
# @return [FixNum]
|
27
|
+
# @return [FixNum] 2 - Public, 0 - Private
|
28
28
|
# @!attribute [r] rating
|
29
29
|
# @return [FixNum] ?
|
30
30
|
# @!attribute [r] editable
|
31
|
-
# @return [Boolean]
|
31
|
+
# @return [Boolean] Wether the current API user can edit this activity
|
32
32
|
# @!attribute [r] deletable
|
33
|
-
# @return [Boolean]
|
33
|
+
# @return [Boolean] Wether the current API user can delete this activity
|
34
34
|
# @!attribute [r] used
|
35
|
-
# @return [FixNum]
|
35
|
+
# @return [FixNum] How many times this activity has been used (total accross all of OSM)
|
36
36
|
# @!attribute [r] versions
|
37
|
-
# @return [Hash] ?
|
37
|
+
# @return [Array<Hash>] ? (:value - version, :firstname - created by, :label - label, :user_id - OSM user ID of creator)
|
38
38
|
# @!attribute [r] sections
|
39
39
|
# @return [Array<Symbol>] the sections the activity is appropriate for
|
40
40
|
# @!attribute [r] tags
|
41
41
|
# @return [Array<String>] the tags attached to the activity
|
42
42
|
# @!attribute [r] files
|
43
|
-
# @return [Array
|
43
|
+
# @return [Array<Hash> ? ('fileid', 'filename', 'name')
|
44
44
|
# @!attribute [r] badges
|
45
|
-
# @return [Array
|
45
|
+
# @return [Array<Hash> ? ('section', 'badgetype', 'badge', 'columnname', 'label')
|
46
46
|
|
47
47
|
|
48
48
|
# Initialize a new Activity using the hash returned by the API call
|
@@ -61,7 +61,7 @@ module Osm
|
|
61
61
|
@shared = data['details']['shared'].to_i
|
62
62
|
@rating = data['details']['rating'].to_i
|
63
63
|
@editable = data['editable']
|
64
|
-
@deletable = data['deletable']
|
64
|
+
@deletable = data['deletable'] ? true : false
|
65
65
|
@used = data['used'].to_i
|
66
66
|
@versions = data['versions']
|
67
67
|
@sections = Osm::make_array_of_symbols(data['sections'] || [])
|
data/lib/osm/api.rb
CHANGED
@@ -252,7 +252,7 @@ module Osm
|
|
252
252
|
# @param [FixNum] term_id the term to get the programme for
|
253
253
|
# @!macro options_get
|
254
254
|
# @!macro options_api_data
|
255
|
-
# @return [Array<Osm::
|
255
|
+
# @return [Array<Osm::Evening>]
|
256
256
|
def get_programme(section_id, term_id, options={}, api_data={})
|
257
257
|
if !options[:no_cache] && Rails.cache.exist?("OSMAPI-programme-#{section_id}-#{term_id}") && self.user_can_access?(:programme, section_id, api_data)
|
258
258
|
return Rails.cache.read("OSMAPI-programme-#{section_id}-#{term_id}")
|
@@ -267,9 +267,9 @@ module Osm
|
|
267
267
|
activities = data['activities'] || {}
|
268
268
|
|
269
269
|
items.each do |item|
|
270
|
-
|
271
|
-
result.push
|
272
|
-
|
270
|
+
evening = Osm::Evening.new(item, activities[item['eveningid']])
|
271
|
+
result.push evening
|
272
|
+
evening.activities.each do |activity|
|
273
273
|
self.user_can_access :activity, activity.activity_id, api_data
|
274
274
|
end
|
275
275
|
end
|
@@ -495,25 +495,11 @@ module Osm
|
|
495
495
|
end
|
496
496
|
|
497
497
|
# Update an evening in OSM
|
498
|
-
# @param [Osm::
|
498
|
+
# @param [Osm::Evening] evening the evening to update
|
499
499
|
# @!macro options_api_data
|
500
500
|
# @return [Boolean] if the operation suceeded or not
|
501
|
-
def update_evening(
|
502
|
-
response = perform_query("programme.php?action=editEvening", api_data.merge(
|
503
|
-
'eveningid' => programme_item.evening_id,
|
504
|
-
'sectionid' => programme_item.section_id,
|
505
|
-
'meetingdate' => programme_item.meeting_date.try(:strftime, '%Y-%m-%d'),
|
506
|
-
'starttime' => programme_item.start_time,
|
507
|
-
'endtime' => programme_item.end_time,
|
508
|
-
'title' => programme_item.title,
|
509
|
-
'notesforparents' => programme_item.notes_for_parents,
|
510
|
-
'prenotes' => programme_item.pre_notes,
|
511
|
-
'postnotes' => programme_item.post_notes,
|
512
|
-
'games' => programme_item.games,
|
513
|
-
'leaders' => programme_item.leaders,
|
514
|
-
'activity' => programme_item.activities_for_saving,
|
515
|
-
'googlecalendar' => programme_item.google_calendar || '',
|
516
|
-
}))
|
501
|
+
def update_evening(evening, api_data={})
|
502
|
+
response = perform_query("programme.php?action=editEvening", api_data.merge(evening.data_for_saving))
|
517
503
|
|
518
504
|
# The cached programmes for the section will be out of date - remove them
|
519
505
|
get_terms(api_data).each do |term|
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module Osm
|
2
2
|
|
3
|
-
class
|
3
|
+
class Evening
|
4
4
|
|
5
|
-
attr_accessor :evening_id, :section_id, :title, :notes_for_parents, :games, :pre_notes, :post_notes, :leaders, :meeting_date, :activities
|
5
|
+
attr_accessor :evening_id, :section_id, :title, :notes_for_parents, :games, :pre_notes, :post_notes, :leaders, :meeting_date, :activities
|
6
6
|
attr_reader :start_time, :end_time
|
7
7
|
# @!attribute [rw] evening_id
|
8
8
|
# @return [FixNum] the id of the evening
|
@@ -23,9 +23,7 @@ module Osm
|
|
23
23
|
# @!attribute [rw] meeting_date
|
24
24
|
# @return [Date] the date of the evening
|
25
25
|
# @!attribute [rw] activities
|
26
|
-
# @return [Array<
|
27
|
-
# @!attribute [rw] google_calendar
|
28
|
-
# @return [String] ?
|
26
|
+
# @return [Array<EveningActivity>] list of activities being done during the evening
|
29
27
|
# @!attribute [rw] start_time
|
30
28
|
# @return [String] the start time (hh:mm)
|
31
29
|
# @!attribute [rw] end_time
|
@@ -46,14 +44,14 @@ module Osm
|
|
46
44
|
@start_time = data['starttime'].nil? ? nil : data['starttime'][0..4]
|
47
45
|
@end_time = data['endtime'].nil? ? nil : data['endtime'][0..4]
|
48
46
|
@meeting_date = Osm::parse_date(data['meetingdate'])
|
49
|
-
@google_calendar = data['googlecalendar']
|
50
47
|
|
51
48
|
@activities = Array.new
|
52
49
|
unless activities.nil?
|
53
50
|
activities.each do |item|
|
54
|
-
@activities.push
|
51
|
+
@activities.push EveningActivity.new(item)
|
55
52
|
end
|
56
53
|
end
|
54
|
+
@activities.freeze
|
57
55
|
end
|
58
56
|
|
59
57
|
# Custom setters for times
|
@@ -67,7 +65,27 @@ module Osm
|
|
67
65
|
end
|
68
66
|
end
|
69
67
|
|
68
|
+
# Get the evening's data for use with the API
|
69
|
+
# @return [Hash]
|
70
|
+
def data_for_saving
|
71
|
+
{
|
72
|
+
'eveningid' => evening_id,
|
73
|
+
'sectionid' => section_id,
|
74
|
+
'meetingdate' => meeting_date.try(:strftime, '%Y-%m-%d'),
|
75
|
+
'starttime' => start_time,
|
76
|
+
'endtime' => end_time,
|
77
|
+
'title' => title,
|
78
|
+
'notesforparents' => notes_for_parents,
|
79
|
+
'prenotes' => pre_notes,
|
80
|
+
'postnotes' => post_notes,
|
81
|
+
'games' => games,
|
82
|
+
'leaders' => leaders,
|
83
|
+
'activity' => activities_for_saving,
|
84
|
+
}
|
85
|
+
end
|
86
|
+
|
70
87
|
|
88
|
+
private
|
71
89
|
# Get the JSON for the activitied to pass to the OSM API
|
72
90
|
# @return [String]
|
73
91
|
def activities_for_saving
|
@@ -82,6 +100,28 @@ module Osm
|
|
82
100
|
return ActiveSupport::JSON.encode(to_save)
|
83
101
|
end
|
84
102
|
|
103
|
+
|
104
|
+
class EveningActivity
|
105
|
+
|
106
|
+
attr_reader :activity_id, :title, :notes
|
107
|
+
# @!attribute [r] activity_id
|
108
|
+
# @return [FixNum] the activity being done
|
109
|
+
# @!attribute [r] title
|
110
|
+
# @return [String] the activity's title
|
111
|
+
# @!attribute [r] notes
|
112
|
+
# @return [String] notes relevant to doing this activity on this evening
|
113
|
+
|
114
|
+
# Initialize a new EveningActivity using the hash returned by the API call
|
115
|
+
# @param data the hash of data for the object returned by the API
|
116
|
+
def initialize(data)
|
117
|
+
@activity_id = Osm::to_i_or_nil(data['activityid'])
|
118
|
+
@title = data['title']
|
119
|
+
@notes = data['notes']
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
123
|
+
|
124
|
+
|
85
125
|
end
|
86
126
|
|
87
127
|
end
|
data/lib/osm/event.rb
CHANGED
@@ -14,7 +14,7 @@ module Osm
|
|
14
14
|
# @!attribute [r] end
|
15
15
|
# @return [DateTime] when the event ends
|
16
16
|
# @!attribute [r] cost
|
17
|
-
# @return [
|
17
|
+
# @return [String] the cost of the event
|
18
18
|
# @!attribute [r] location
|
19
19
|
# @return [String] where the event is
|
20
20
|
# @!attribute [r] notes
|
data/lib/osm/member.rb
CHANGED
@@ -12,7 +12,7 @@ module Osm
|
|
12
12
|
# @!attribute [r] first_name
|
13
13
|
# @return [String] the member's first name
|
14
14
|
# @!attribute [r] last_name
|
15
|
-
# @return [String] the
|
15
|
+
# @return [String] the member's last name
|
16
16
|
# @!attribute [r] email1
|
17
17
|
# @return [String] the 1st email address for the member
|
18
18
|
# @!attribute [r] email2
|
@@ -38,7 +38,7 @@ module Osm
|
|
38
38
|
# @!attribute [r] started
|
39
39
|
# @return [Date] when the member started Scouting
|
40
40
|
# @!attribute [r] joined_in_years
|
41
|
-
# @return [FixNum]
|
41
|
+
# @return [FixNum] ?
|
42
42
|
# @!attribute [r] parents
|
43
43
|
# @return [String] the member's parent's names
|
44
44
|
# @!attribute [r] notes
|
@@ -62,7 +62,7 @@ module Osm
|
|
62
62
|
# @!attribute [r] age
|
63
63
|
# @return [String] the member's current age (yy/mm)
|
64
64
|
# @!attribute [r] joined_years
|
65
|
-
# @return [FixNum]
|
65
|
+
# @return [FixNum] how many years the member has been in Scouting
|
66
66
|
|
67
67
|
|
68
68
|
# Initialize a new Member using the hash returned by the API call
|
data/lib/osm/role.rb
CHANGED
@@ -2,17 +2,13 @@ module Osm
|
|
2
2
|
|
3
3
|
class Role
|
4
4
|
|
5
|
-
attr_reader :section, :group_name, :group_id, :
|
5
|
+
attr_reader :section, :group_name, :group_id, :permissions
|
6
6
|
# @!attribute [r] section
|
7
7
|
# @return [Osm::Section] the section this role related to
|
8
8
|
# @!attribute [r] group_name
|
9
9
|
# @return [String] the name of the group the section is in
|
10
10
|
# @!attribute [r] group_id
|
11
11
|
# @return [FixNum] the group the section is in
|
12
|
-
# @!attribute [r] group_normalized
|
13
|
-
# @return [FixNum] ?
|
14
|
-
# @!attribute [r] default
|
15
|
-
# @return [Boolean] was this the last section this user used in OSM
|
16
12
|
# @!attribute [r] permissions
|
17
13
|
# @return [Hash] the permissions the user has in this role
|
18
14
|
|
@@ -22,8 +18,6 @@ module Osm
|
|
22
18
|
@section = Osm::Section.new(data['sectionid'], data['sectionname'], ActiveSupport::JSON.decode(data['sectionConfig']), self)
|
23
19
|
@group_name = data['groupname']
|
24
20
|
@group_id = Osm::to_i_or_nil(data['groupid'])
|
25
|
-
@group_normalized = Osm::to_i_or_nil(data['groupNormalised'])
|
26
|
-
@default = data['isDefault'].eql?('1') ? true : false
|
27
21
|
@permissions = Osm::symbolize_hash(data['permissions'] || {})
|
28
22
|
|
29
23
|
# Convert permission values to a number
|
data/lib/osm/section.rb
CHANGED
@@ -2,7 +2,7 @@ module Osm
|
|
2
2
|
|
3
3
|
class Section
|
4
4
|
|
5
|
-
attr_reader :id, :name, :subscription_level, :subscription_expires, :type, :num_scouts, :
|
5
|
+
attr_reader :id, :name, :subscription_level, :subscription_expires, :type, :num_scouts, :column_names, :fields, :intouch_fields, :mobile_fields, :extra_records, :role
|
6
6
|
# @!attribute [r] id
|
7
7
|
# @return [FixNum] the id for the section
|
8
8
|
# @!attribute [r] name
|
@@ -15,12 +15,6 @@ module Osm
|
|
15
15
|
# @return [Symbol] the section type (:beavers, :cubs, :scouts, :exporers, :adults, :waiting, :unknown)
|
16
16
|
# @!attribute [r] num_scouts
|
17
17
|
# @return [FixNum] how many members the section has
|
18
|
-
# @!attribute [r] has_badge_records
|
19
|
-
# @return [Boolean] ?
|
20
|
-
# @!attribute [r] has_programme
|
21
|
-
# @return [Boolean] ?
|
22
|
-
# @!attribute [r] wizard
|
23
|
-
# @return [Boolean] ?
|
24
18
|
# @!attribute [r] column_names
|
25
19
|
# @return [Hash] custom names to use for the data columns
|
26
20
|
# @!attribute [r] fields
|
@@ -48,9 +42,6 @@ module Osm
|
|
48
42
|
@subscription_expires = data['subscription_expires'] ? Date.parse(data['subscription_expires'], 'yyyy-mm-dd') : nil
|
49
43
|
@type = !data['sectionType'].nil? ? data['sectionType'].to_sym : :unknown
|
50
44
|
@num_scouts = data['numscouts']
|
51
|
-
@has_badge_records = data['hasUsedBadgeRecords'].eql?('1') ? true : false
|
52
|
-
@has_programme = data['hasProgramme']
|
53
|
-
@wizard = (data['wizard'] || '').downcase.eql?('true') ? true : false
|
54
45
|
@column_names = Osm::symbolize_hash(data['columnNames'] || {})
|
55
46
|
@fields = Osm::symbolize_hash(data['fields'] || {})
|
56
47
|
@intouch_fields = Osm::symbolize_hash(data['intouch'] || {})
|
data/spec/osm/api_spec.rb
CHANGED
@@ -188,7 +188,7 @@ describe "API" do
|
|
188
188
|
|
189
189
|
programme = Osm::Api.new('1', '2').get_programme(3, 4)
|
190
190
|
programme.size.should == 1
|
191
|
-
programme[0].is_a?(Osm::
|
191
|
+
programme[0].is_a?(Osm::Evening).should be_true
|
192
192
|
programme[0].activities.size.should == 2
|
193
193
|
end
|
194
194
|
|
@@ -410,14 +410,14 @@ describe "API" do
|
|
410
410
|
'secret' => 'secret',
|
411
411
|
'eveningid' => nil, 'sectionid' => nil, 'meetingdate' => nil, 'starttime' => nil,
|
412
412
|
'endtime' => nil, 'title' => 'Unnamed meeting', 'notesforparents' =>'', 'prenotes' => '',
|
413
|
-
'postnotes' => '', 'games' => '', 'leaders' => '', 'activity' => '[]',
|
413
|
+
'postnotes' => '', 'games' => '', 'leaders' => '', 'activity' => '[]',
|
414
414
|
}
|
415
415
|
api = Osm::Api.new('user', 'secret')
|
416
416
|
api.stub(:get_terms) { [] }
|
417
417
|
HTTParty.should_receive(:post).with(url, {:body => post_data}) { DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"result":0}'}) }
|
418
418
|
|
419
|
-
|
420
|
-
api.update_evening(
|
419
|
+
evening = Osm::Evening.new({}, [])
|
420
|
+
api.update_evening(evening).should be_true
|
421
421
|
end
|
422
422
|
|
423
423
|
it "Update an evening (failed)" do
|
@@ -429,14 +429,14 @@ describe "API" do
|
|
429
429
|
'secret' => 'secret',
|
430
430
|
'eveningid' => nil, 'sectionid' => nil, 'meetingdate' => nil, 'starttime' => nil,
|
431
431
|
'endtime' => nil, 'title' => 'Unnamed meeting', 'notesforparents' =>'', 'prenotes' => '',
|
432
|
-
'postnotes' => '', 'games' => '', 'leaders' => '', 'activity' => '[]',
|
432
|
+
'postnotes' => '', 'games' => '', 'leaders' => '', 'activity' => '[]',
|
433
433
|
}
|
434
434
|
api = Osm::Api.new('user', 'secret')
|
435
435
|
api.stub(:get_terms) { [] }
|
436
436
|
HTTParty.should_receive(:post).with(url, {:body => post_data}) { DummyHttpResult.new(:response=>{:code=>'200', :body=>'{"result":1}'}) }
|
437
437
|
|
438
|
-
|
439
|
-
api.update_evening(
|
438
|
+
evening = Osm::Evening.new({}, [])
|
439
|
+
api.update_evening(evening).should be_false
|
440
440
|
end
|
441
441
|
end
|
442
442
|
|
@@ -0,0 +1,103 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'date'
|
4
|
+
|
5
|
+
describe "Evening" do
|
6
|
+
|
7
|
+
it "Create" do
|
8
|
+
data = {
|
9
|
+
'eveningid' => 1,
|
10
|
+
'sectionid' => 2,
|
11
|
+
'title' => 'Evening Name',
|
12
|
+
'notesforparents' => 'Notes for parents',
|
13
|
+
'games' => 'Games',
|
14
|
+
'prenotes' => 'Before',
|
15
|
+
'postnotes' => 'After',
|
16
|
+
'leaders' => 'Leaders',
|
17
|
+
'starttime' => '19:00',
|
18
|
+
'endtime' => '21:00',
|
19
|
+
'meetingdate' => '2000-01-02',
|
20
|
+
}
|
21
|
+
activities = [{
|
22
|
+
'eveningid' => 1,
|
23
|
+
'activityid' => 2,
|
24
|
+
'title' => 'Activity Name',
|
25
|
+
'notes' => 'Notes',
|
26
|
+
}]
|
27
|
+
e = Osm::Evening.new(data, activities)
|
28
|
+
|
29
|
+
e.evening_id.should == 1
|
30
|
+
e.section_id.should == 2
|
31
|
+
e.title.should == 'Evening Name'
|
32
|
+
e.notes_for_parents.should == 'Notes for parents'
|
33
|
+
e.games.should == 'Games'
|
34
|
+
e.pre_notes.should == 'Before'
|
35
|
+
e.post_notes.should == 'After'
|
36
|
+
e.leaders.should == 'Leaders'
|
37
|
+
e.start_time.should == '19:00'
|
38
|
+
e.end_time.should == '21:00'
|
39
|
+
e.meeting_date.should == Date.new(2000, 1, 2)
|
40
|
+
|
41
|
+
e.activities.frozen?.should be_true
|
42
|
+
ea = e.activities[0]
|
43
|
+
ea.activity_id.should == 2
|
44
|
+
ea.title.should == 'Activity Name'
|
45
|
+
ea.notes.should == 'Notes'
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
it "Raises exceptions when trying to set invalid times" do
|
50
|
+
e = Osm::Evening.new({}, [])
|
51
|
+
|
52
|
+
expect{ e.start_time = 'abcde' }.to raise_error(ArgumentError)
|
53
|
+
expect{ e.start_time = '24:00' }.to raise_error(ArgumentError)
|
54
|
+
expect{ e.start_time = '10:61' }.to raise_error(ArgumentError)
|
55
|
+
e.start_time = '12:34'
|
56
|
+
e.start_time.should == '12:34'
|
57
|
+
|
58
|
+
expect{ e.end_time = 'abcde' }.to raise_error(ArgumentError)
|
59
|
+
expect{ e.end_time = '24:00' }.to raise_error(ArgumentError)
|
60
|
+
expect{ e.end_time = '10:61' }.to raise_error(ArgumentError)
|
61
|
+
e.end_time = '23:45'
|
62
|
+
e.end_time.should == '23:45'
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
it "Creates the data for saving through the API" do
|
67
|
+
data = {
|
68
|
+
'eveningid' => 1,
|
69
|
+
'sectionid' => 2,
|
70
|
+
'title' => 'Evening Name',
|
71
|
+
'notesforparents' => 'Notes for parents',
|
72
|
+
'games' => 'Games',
|
73
|
+
'prenotes' => 'Before',
|
74
|
+
'postnotes' => 'After',
|
75
|
+
'leaders' => 'Leaders',
|
76
|
+
'starttime' => '19:00',
|
77
|
+
'endtime' => '21:00',
|
78
|
+
'meetingdate' => '2000-01-02',
|
79
|
+
}
|
80
|
+
activities = [{
|
81
|
+
'eveningid' => 3,
|
82
|
+
'activityid' => 4,
|
83
|
+
'title' => 'Activity Name',
|
84
|
+
'notes' => 'Notes',
|
85
|
+
}]
|
86
|
+
e = Osm::Evening.new(data, activities)
|
87
|
+
e.data_for_saving.should == {
|
88
|
+
'eveningid' => 1,
|
89
|
+
'sectionid' => 2,
|
90
|
+
'meetingdate' => '2000-01-02',
|
91
|
+
'starttime' => '19:00',
|
92
|
+
'endtime' => '21:00',
|
93
|
+
'title' => 'Evening Name',
|
94
|
+
'notesforparents' => 'Notes for parents',
|
95
|
+
'prenotes' => 'Before',
|
96
|
+
'postnotes' => 'After',
|
97
|
+
'games' => 'Games',
|
98
|
+
'leaders' => 'Leaders',
|
99
|
+
'activity' => '[{"activityid":4,"notes":"Notes"}]',
|
100
|
+
}
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
data/spec/osm/section_spec.rb
CHANGED
@@ -23,9 +23,6 @@ describe "Section" do
|
|
23
23
|
'subscription_expires' => (Date.today + 60).strftime('%Y-%m-%d'),
|
24
24
|
'sectionType' => 'cubs',
|
25
25
|
'numscouts' => 10,
|
26
|
-
'hasUsedBadgeRecords' => '1',
|
27
|
-
'hasProgramme' => true,
|
28
|
-
'wizard' => 'False',
|
29
26
|
'columnNames' => {},
|
30
27
|
'fields' => {},
|
31
28
|
'intouch' => {},
|
@@ -41,9 +38,6 @@ describe "Section" do
|
|
41
38
|
section.subscription_expires.should == Date.today + 60
|
42
39
|
section.type.should == :cubs
|
43
40
|
section.num_scouts.should == 10
|
44
|
-
section.has_badge_records.should == true
|
45
|
-
section.has_programme.should == true
|
46
|
-
section.wizard.should == false
|
47
41
|
section.column_names.should == {}
|
48
42
|
section.fields.should == {}
|
49
43
|
section.intouch_fields.should == {}
|
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.0.7
|
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-08-
|
12
|
+
date: 2012-08-08 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
|
-
requirement: &
|
16
|
+
requirement: &76902620 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 3.2.5
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *76902620
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: activesupport
|
27
|
-
requirement: &
|
27
|
+
requirement: &76892140 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '3.2'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *76892140
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: httparty
|
38
|
-
requirement: &
|
38
|
+
requirement: &76890970 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *76890970
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rake
|
49
|
-
requirement: &
|
49
|
+
requirement: &76889000 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *76889000
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rspec
|
60
|
-
requirement: &
|
60
|
+
requirement: &76886900 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *76886900
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: fakeweb
|
71
|
-
requirement: &
|
71
|
+
requirement: &76883060 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,7 +76,7 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *76883060
|
80
80
|
description: Use the Online Scout Manager API (https://www.onlinescoutmanager.co.uk)
|
81
81
|
to retrieve and save data.
|
82
82
|
email:
|
@@ -98,11 +98,10 @@ files:
|
|
98
98
|
- lib/osm/api.rb
|
99
99
|
- lib/osm/api_access.rb
|
100
100
|
- lib/osm/due_badges.rb
|
101
|
+
- lib/osm/evening.rb
|
101
102
|
- lib/osm/event.rb
|
102
103
|
- lib/osm/grouping.rb
|
103
104
|
- lib/osm/member.rb
|
104
|
-
- lib/osm/programme_activity.rb
|
105
|
-
- lib/osm/programme_item.rb
|
106
105
|
- lib/osm/role.rb
|
107
106
|
- lib/osm/section.rb
|
108
107
|
- lib/osm/term.rb
|
@@ -112,12 +111,11 @@ files:
|
|
112
111
|
- spec/osm/api_spec.rb
|
113
112
|
- spec/osm/api_strangeness_spec.rb
|
114
113
|
- spec/osm/due_badges_spec.rb
|
114
|
+
- spec/osm/evening_spec.rb
|
115
115
|
- spec/osm/event_spec.rb
|
116
116
|
- spec/osm/grouping_spec.rb
|
117
117
|
- spec/osm/member_spec.rb
|
118
118
|
- spec/osm/osm_spec.rb
|
119
|
-
- spec/osm/programme_activity_spec.rb
|
120
|
-
- spec/osm/programme_item_spec.rb
|
121
119
|
- spec/osm/role_spec.rb
|
122
120
|
- spec/osm/section_spec.rb
|
123
121
|
- spec/osm/term_spec.rb
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module Osm
|
2
|
-
|
3
|
-
class ProgrammeActivity
|
4
|
-
|
5
|
-
attr_reader :evening_id, :activity_id, :title, :notes
|
6
|
-
# @!attribute [r] eveing_id
|
7
|
-
# @return [FixNum] the evening the activity is being done
|
8
|
-
# @!attribute [r] activity_id
|
9
|
-
# @return [FixNum] the activity being done
|
10
|
-
# @!attribute [r] title
|
11
|
-
# @return [String] the activity's title
|
12
|
-
# @!attribute [r] notes
|
13
|
-
# @return [String] tnotes relevant to doing this activity on this evening
|
14
|
-
|
15
|
-
# Initialize a new EveningActivity using the hash returned by the API call
|
16
|
-
# @param data the hash of data for the object returned by the API
|
17
|
-
def initialize(data)
|
18
|
-
@evening_id = Osm::to_i_or_nil(data['eveningid'])
|
19
|
-
@activity_id = Osm::to_i_or_nil(data['activityid'])
|
20
|
-
@title = data['title']
|
21
|
-
@notes = data['notes']
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe "Programme Activity" do
|
5
|
-
|
6
|
-
it "Create" do
|
7
|
-
data = {
|
8
|
-
'eveningid' => 1,
|
9
|
-
'activityid' => 2,
|
10
|
-
'title' => 'Activity Name',
|
11
|
-
'notes' => 'Notes',
|
12
|
-
}
|
13
|
-
pa = Osm::ProgrammeActivity.new(data)
|
14
|
-
|
15
|
-
pa.evening_id.should == 1
|
16
|
-
pa.activity_id.should == 2
|
17
|
-
pa.title.should == 'Activity Name'
|
18
|
-
pa.notes.should == 'Notes'
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
@@ -1,64 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'spec_helper'
|
3
|
-
require 'date'
|
4
|
-
|
5
|
-
describe "Programme Item" do
|
6
|
-
|
7
|
-
it "Create" do
|
8
|
-
data = {
|
9
|
-
'eveningid' => 1,
|
10
|
-
'sectionid' => 2,
|
11
|
-
'title' => 'Evening Name',
|
12
|
-
'notesforparents' => 'Notes for parents',
|
13
|
-
'games' => 'Games',
|
14
|
-
'prenotes' => 'Before',
|
15
|
-
'postnotes' => 'After',
|
16
|
-
'leaders' => 'Leaders',
|
17
|
-
'starttime' => '19:00',
|
18
|
-
'endtime' => '21:00',
|
19
|
-
'meetingdate' => '2000-01-02',
|
20
|
-
}
|
21
|
-
pi = Osm::ProgrammeItem.new(data, [])
|
22
|
-
|
23
|
-
pi.evening_id.should == 1
|
24
|
-
pi.section_id.should == 2
|
25
|
-
pi.title.should == 'Evening Name'
|
26
|
-
pi.notes_for_parents.should == 'Notes for parents'
|
27
|
-
pi.games.should == 'Games'
|
28
|
-
pi.pre_notes.should == 'Before'
|
29
|
-
pi.post_notes.should == 'After'
|
30
|
-
pi.leaders.should == 'Leaders'
|
31
|
-
pi.start_time.should == '19:00'
|
32
|
-
pi.end_time.should == '21:00'
|
33
|
-
pi.meeting_date.should == Date.new(2000, 1, 2)
|
34
|
-
end
|
35
|
-
|
36
|
-
|
37
|
-
it "Raises exceptions when trying to set invalid times" do
|
38
|
-
pi = Osm::ProgrammeItem.new({}, [])
|
39
|
-
|
40
|
-
expect{ pi.start_time = 'abcde' }.to raise_error(ArgumentError)
|
41
|
-
expect{ pi.start_time = '24:00' }.to raise_error(ArgumentError)
|
42
|
-
expect{ pi.start_time = '10:61' }.to raise_error(ArgumentError)
|
43
|
-
pi.start_time = '12:34'
|
44
|
-
pi.start_time.should == '12:34'
|
45
|
-
|
46
|
-
expect{ pi.end_time = 'abcde' }.to raise_error(ArgumentError)
|
47
|
-
expect{ pi.end_time = '24:00' }.to raise_error(ArgumentError)
|
48
|
-
expect{ pi.end_time = '10:61' }.to raise_error(ArgumentError)
|
49
|
-
pi.end_time = '23:45'
|
50
|
-
pi.end_time.should == '23:45'
|
51
|
-
end
|
52
|
-
|
53
|
-
|
54
|
-
it "Makes a list of activities to save for OSM's API" do
|
55
|
-
pi = Osm::ProgrammeItem.new({}, [{
|
56
|
-
'eveningid' => 1,
|
57
|
-
'activityid' => 2,
|
58
|
-
'title' => 'Activity Name',
|
59
|
-
'notes' => 'Notes',
|
60
|
-
}])
|
61
|
-
pi.activities_for_saving.should == '[{"activityid":2,"notes":"Notes"}]'
|
62
|
-
end
|
63
|
-
|
64
|
-
end
|