osm 1.0.0 → 1.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/CHANGELOG.md +6 -0
- data/README.md +1 -1
- data/lib/osm/api.rb +13 -0
- data/lib/osm/event.rb +1 -1
- data/lib/osm/term.rb +8 -0
- data/spec/osm/api_spec.rb +8 -0
- data/spec/osm/event_spec.rb +13 -1
- data/spec/osm/term_spec.rb +10 -0
- data/version.rb +1 -1
- metadata +2 -2
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
## Version 1.0.1
|
|
2
|
+
|
|
3
|
+
* Fix Osm::Term date helping methods when term contains nil dates
|
|
4
|
+
* Fix fetching event attendance when no attendance has been set for any members
|
|
5
|
+
* Osm::Api exposes the debug option as a psudo class attribute
|
|
6
|
+
|
|
1
7
|
## Version 1.0.0
|
|
2
8
|
|
|
3
9
|
* SMS text messages:
|
data/README.md
CHANGED
|
@@ -32,7 +32,7 @@ Use the [Online Scout Manager](https://www.onlinescoutmanager.co.uk) API.
|
|
|
32
32
|
Add to your Gemfile and run the `bundle` command to install it.
|
|
33
33
|
|
|
34
34
|
```ruby
|
|
35
|
-
gem 'osm', '~> 1.0
|
|
35
|
+
gem 'osm', '~> 1.0'
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
Configure the gem during the initalization of the app (e.g. if using rails then config/initializers/osm.rb would look like):
|
data/lib/osm/api.rb
CHANGED
|
@@ -50,6 +50,19 @@ module Osm
|
|
|
50
50
|
nil
|
|
51
51
|
end
|
|
52
52
|
|
|
53
|
+
# Configure the debug option
|
|
54
|
+
# @param [Boolean] debug whether to display debugging information
|
|
55
|
+
# @return nil
|
|
56
|
+
def self.debug=(debug)
|
|
57
|
+
@@debug = !!debug
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# The debug option
|
|
61
|
+
# @return Boolean whether debugging output is enabled
|
|
62
|
+
def self.debug
|
|
63
|
+
@@debug
|
|
64
|
+
end
|
|
65
|
+
|
|
53
66
|
# Initialize a new API connection
|
|
54
67
|
# @param [String] user_id OSM userid of the user to act as (get this by using the authorize method)
|
|
55
68
|
# @param [String] secret OSM secret of the user to act as (get this by using the authorize method)
|
data/lib/osm/event.rb
CHANGED
|
@@ -256,7 +256,7 @@ module Osm
|
|
|
256
256
|
end
|
|
257
257
|
|
|
258
258
|
data = api.perform_query("events.php?action=getEventAttendance&eventid=#{id}§ionid=#{section_id}&termid=#{term_id}")
|
|
259
|
-
data = data['items']
|
|
259
|
+
data = data['items'] || []
|
|
260
260
|
|
|
261
261
|
payment_values = {
|
|
262
262
|
'Manual' => :manual,
|
data/lib/osm/term.rb
CHANGED
|
@@ -187,6 +187,7 @@ module Osm
|
|
|
187
187
|
# @param [Date] date
|
|
188
188
|
# @return [Boolean] if the term is completly before the passed date
|
|
189
189
|
def before?(date)
|
|
190
|
+
return false if finish.nil?
|
|
190
191
|
return finish < date.to_date
|
|
191
192
|
end
|
|
192
193
|
|
|
@@ -194,24 +195,29 @@ module Osm
|
|
|
194
195
|
# @param [Date] date
|
|
195
196
|
# @return [Boolean] if the term is completly after the passed date
|
|
196
197
|
def after?(date)
|
|
198
|
+
return false if start.nil?
|
|
197
199
|
return start > date.to_date
|
|
198
200
|
end
|
|
199
201
|
|
|
200
202
|
# Determine if the term is in the future
|
|
201
203
|
# @return [Boolean] if the term starts after today
|
|
202
204
|
def future?
|
|
205
|
+
return false if start.nil?
|
|
203
206
|
return start > Date.today
|
|
204
207
|
end
|
|
205
208
|
|
|
206
209
|
# Determine if the term is in the past
|
|
207
210
|
# @return [Boolean] if the term finished before today
|
|
208
211
|
def past?
|
|
212
|
+
return false if finish.nil?
|
|
209
213
|
return finish < Date.today
|
|
210
214
|
end
|
|
211
215
|
|
|
212
216
|
# Determine if the term is current
|
|
213
217
|
# @return [Boolean] if the term started before today and finishes after today
|
|
214
218
|
def current?
|
|
219
|
+
return false if start.nil?
|
|
220
|
+
return false if finish.nil?
|
|
215
221
|
return (start <= Date.today) && (finish >= Date.today)
|
|
216
222
|
end
|
|
217
223
|
|
|
@@ -219,6 +225,8 @@ module Osm
|
|
|
219
225
|
# @param [Date] date The date to test
|
|
220
226
|
# @return [Boolean] if the term started before the date and finishes after the date
|
|
221
227
|
def contains_date?(date)
|
|
228
|
+
return false if start.nil?
|
|
229
|
+
return false if finish.nil?
|
|
222
230
|
return (start <= date) && (finish >= date)
|
|
223
231
|
end
|
|
224
232
|
|
data/spec/osm/api_spec.rb
CHANGED
|
@@ -25,6 +25,14 @@ describe "API" do
|
|
|
25
25
|
expect{ Osm::Api.configure(@CONFIGURATION[:api].merge(:ogm => @CONFIGURATION[:api][:ogm].select{ |k,v| (k != :name)})) }.to raise_error(ArgumentError, ':ogm must contain a key :name')
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
+
it "Exposes the debug option seperatly too" do
|
|
29
|
+
Osm::Api.debug.should be_false
|
|
30
|
+
Osm::Api.debug = true
|
|
31
|
+
Osm::Api.debug.should be_true
|
|
32
|
+
Osm::Api.debug = false
|
|
33
|
+
Osm::Api.debug.should be_false
|
|
34
|
+
end
|
|
35
|
+
|
|
28
36
|
|
|
29
37
|
it "Raises errors on bad arguments to create" do
|
|
30
38
|
# Both userid and secret must be passed
|
data/spec/osm/event_spec.rb
CHANGED
|
@@ -680,7 +680,6 @@ describe "Event" do
|
|
|
680
680
|
FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/events.php?action=getEventAttendance&eventid=2§ionid=1&termid=3", :body => attendance_body.to_json)
|
|
681
681
|
|
|
682
682
|
event = Osm::Event.new(:id => 2, :section_id => 1)
|
|
683
|
-
event.should_not be_nil
|
|
684
683
|
attendance = event.get_attendance(@api, 3)
|
|
685
684
|
attendance.is_a?(Array).should be_true
|
|
686
685
|
ea = attendance[0]
|
|
@@ -699,6 +698,19 @@ describe "Event" do
|
|
|
699
698
|
ea.row.should == 0
|
|
700
699
|
end
|
|
701
700
|
|
|
701
|
+
it "Get attendance (no items)" do
|
|
702
|
+
attendance_body = {
|
|
703
|
+
'identifier' => 'scoutid',
|
|
704
|
+
'eventid' => '2',
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
FakeWeb.register_uri(:post, "https://www.onlinescoutmanager.co.uk/events.php?action=getEventAttendance&eventid=2§ionid=1&termid=3", :body => attendance_body.to_json)
|
|
708
|
+
|
|
709
|
+
event = Osm::Event.new(:id => 2, :section_id => 1)
|
|
710
|
+
attendance = event.get_attendance(@api, 3)
|
|
711
|
+
attendance.should == []
|
|
712
|
+
end
|
|
713
|
+
|
|
702
714
|
it "Update attendance (succeded)" do
|
|
703
715
|
ea = Osm::Event::Attendance.new(:row => 0, :member_id => 4, :fields => {1 => 'old value', 2 => 'another old value'}, :event => Osm::Event.new(:id => 2, :section_id => 1))
|
|
704
716
|
|
data/spec/osm/term_spec.rb
CHANGED
|
@@ -108,6 +108,16 @@ describe "Term" do
|
|
|
108
108
|
term3.contains_date?(Date.today).should == false
|
|
109
109
|
end
|
|
110
110
|
|
|
111
|
+
it "Date helpers return false for nil dates" do
|
|
112
|
+
term = Osm::Term.new
|
|
113
|
+
term.before?(Date.today).should be_false
|
|
114
|
+
term.after?(Date.today).should be_false
|
|
115
|
+
term.past?.should be_false
|
|
116
|
+
term.future?.should be_false
|
|
117
|
+
term.current?.should be_false
|
|
118
|
+
term.contains_date?(Date.today).should be_false
|
|
119
|
+
end
|
|
120
|
+
|
|
111
121
|
|
|
112
122
|
describe "Using the API" do
|
|
113
123
|
|
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: 1.0.
|
|
4
|
+
version: 1.0.1
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2013-04-
|
|
12
|
+
date: 2013-04-14 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: activesupport
|