osm 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +21 -0
- data/README.md +2 -0
- data/lib/osm.rb +10 -0
- data/lib/osm/badge.rb +8 -0
- data/lib/osm/event.rb +149 -34
- data/lib/osm/flexi_record.rb +8 -0
- data/lib/osm/section.rb +6 -3
- data/spec/osm/event_spec.rb +59 -9
- data/spec/osm/osm_spec.rb +28 -0
- data/spec/osm/section_spec.rb +5 -3
- data/version.rb +1 -1
- metadata +22 -22
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,24 @@
|
|
1
|
+
## Version 0.4.0
|
2
|
+
|
3
|
+
* Event::Attendance
|
4
|
+
* Move fields['firstname'] to first\_name attribute
|
5
|
+
* Move fields['lastname'] to last\_name attribute
|
6
|
+
* Move fields['dob'] to date\_of\_birth attribute
|
7
|
+
* Move fields['attending'] to attending attribute
|
8
|
+
* The keys for fields are now Fixnums not Strings
|
9
|
+
* Addition of payment\_control and payments attributes
|
10
|
+
* Addition of automatic\_payments? and manual\_payments? methods
|
11
|
+
* Addition of is\_attending?, is\_not\_attending?, is\_invited? and is\_shown? methods
|
12
|
+
* update(api, field\_id) method now updates only changed fields, becoming update(api)
|
13
|
+
* Add :network Section type
|
14
|
+
* Add custom inspect methods for:
|
15
|
+
* Event::Attendance (replace event with event.id if present)
|
16
|
+
* Event::Column (replace event with event.id if present)
|
17
|
+
* FlexiRecord::Column (replace flexi\_record with flexi\_record.id)
|
18
|
+
* FlexiRecord::Data (replace flexi\_record with flexi\_record.id)
|
19
|
+
* Badge::Requirement (replace badge with badge.osm\_key)
|
20
|
+
* Badge::Data (replace badge with badge.osm\_key)
|
21
|
+
|
1
22
|
## Version 0.3.0
|
2
23
|
|
3
24
|
* Removal of DueBadges
|
data/README.md
CHANGED
@@ -137,6 +137,8 @@ however it should be noted that when the OSM API adds a feature it can be diffic
|
|
137
137
|
|
138
138
|
## Parts of the OSM API currently NOT supported (may not be an exhaustive list):
|
139
139
|
|
140
|
+
See the [Roadmap page in the wiki](https://github.com/robertgauld/osm/wiki/Roadmap) for more details.
|
141
|
+
|
140
142
|
* SMS:
|
141
143
|
* Retrieval of delivery reports [issue 54]
|
142
144
|
* Sending a message [issue 54]
|
data/lib/osm.rb
CHANGED
@@ -142,4 +142,14 @@ module Osm
|
|
142
142
|
[OSM_EPOCH, OSM_EPOCH_HUMAN].include?(date)
|
143
143
|
end
|
144
144
|
|
145
|
+
def self.inspect_instance(instance, options={})
|
146
|
+
replace_with = options[:replace_with] || {}
|
147
|
+
|
148
|
+
values = instance.attributes.sort.map{ |(k,v)|
|
149
|
+
(replace_with.keys.include?(k) && !v.nil?) ? "#{k}.#{replace_with[k]}: #{v.try(replace_with[k])}" : "#{k}: #{v.inspect}"
|
150
|
+
}
|
151
|
+
|
152
|
+
return "#<#{instance.class.name} #{values.join(', ')} >"
|
153
|
+
end
|
154
|
+
|
145
155
|
end # Module
|
data/lib/osm/badge.rb
CHANGED
@@ -189,6 +189,10 @@ module Osm
|
|
189
189
|
return result
|
190
190
|
end
|
191
191
|
|
192
|
+
def inspect
|
193
|
+
Osm.inspect_instance(self, options={:replace_with => {'badge' => :osm_key}})
|
194
|
+
end
|
195
|
+
|
192
196
|
end # Class Requirement
|
193
197
|
|
194
198
|
|
@@ -318,6 +322,10 @@ module Osm
|
|
318
322
|
return result
|
319
323
|
end
|
320
324
|
|
325
|
+
def inspect
|
326
|
+
Osm.inspect_instance(self, options={:replace_with => {'badge' => :osm_key}})
|
327
|
+
end
|
328
|
+
|
321
329
|
end # Class Data
|
322
330
|
|
323
331
|
end # Class Badge
|
data/lib/osm/event.rb
CHANGED
@@ -251,20 +251,32 @@ module Osm
|
|
251
251
|
data = api.perform_query("events.php?action=getEventAttendance&eventid=#{id}§ionid=#{section_id}&termid=#{term_id}")
|
252
252
|
data = data['items']
|
253
253
|
|
254
|
+
payment_values = {
|
255
|
+
'Manual' => :manual,
|
256
|
+
'Automatic' => :automatic,
|
257
|
+
}
|
258
|
+
attending_values = {
|
259
|
+
'Yes' => :yes,
|
260
|
+
'No' => :no,
|
261
|
+
'Invited' => :invited,
|
262
|
+
'Show in My.SCOUT' => :shown,
|
263
|
+
}
|
264
|
+
|
254
265
|
attendance = []
|
255
266
|
data.each_with_index do |item, index|
|
256
|
-
item.merge!({
|
257
|
-
'dob' => item['dob'].nil? ? nil : Osm::parse_date(item['dob'], :ignore_epoch => true),
|
258
|
-
'attending' => item['attending'].eql?('Yes'),
|
259
|
-
})
|
260
|
-
|
261
267
|
attendance.push Osm::Event::Attendance.new(
|
262
268
|
:event => self,
|
263
269
|
:member_id => Osm::to_i_or_nil(item['scoutid']),
|
264
270
|
:grouping_id => Osm::to_i_or_nil(item['patrolid'].eql?('') ? nil : item['patrolid']),
|
265
|
-
:
|
266
|
-
|
267
|
-
|
271
|
+
:first_name => item['firstname'],
|
272
|
+
:last_name => item['lastname'],
|
273
|
+
:date_of_birth => item['dob'].nil? ? nil : Osm::parse_date(item['dob'], :ignore_epoch => true),
|
274
|
+
:attending => attending_values[item['attending']],
|
275
|
+
:payment_control => payment_values[item['payment']],
|
276
|
+
:fields => item.select { |key, value| key.to_s.match(/\Af_\d+\Z/) }
|
277
|
+
.inject({}){ |h,(k,v)| h[k[2..-1].to_i] = v; h },
|
278
|
+
:payments => item.select { |key, value| key.to_s.match(/\Ap\d+\Z/) }
|
279
|
+
.inject({}){ |h,(k,v)| h[k[1..-1].to_i] = v; h },
|
268
280
|
:row => index,
|
269
281
|
)
|
270
282
|
end
|
@@ -454,10 +466,14 @@ module Osm
|
|
454
466
|
return result
|
455
467
|
end
|
456
468
|
|
469
|
+
def inspect
|
470
|
+
Osm.inspect_instance(self, options={:replace_with => {'event' => :id}})
|
471
|
+
end
|
472
|
+
|
457
473
|
end # class Column
|
458
474
|
|
459
475
|
|
460
|
-
class Attendance < Osm::Model
|
476
|
+
class Attendance < Osm::Model
|
461
477
|
# @!attribute [rw] member_id
|
462
478
|
# @return [Fixnum] OSM id for the member
|
463
479
|
# @!attribute [rw] grouping__id
|
@@ -468,64 +484,163 @@ module Osm
|
|
468
484
|
# @return [Fixnum] part of the OSM API
|
469
485
|
# @!attriute [rw] event
|
470
486
|
# @return [Osm::Event] the event that this attendance applies to
|
487
|
+
# @!attribute [rw] first_name
|
488
|
+
# @return [String] the member's first name
|
489
|
+
# @!attribute [rw] last_name
|
490
|
+
# @return [String] the member's last name
|
491
|
+
# @!attribute [rw] date_of_birth
|
492
|
+
# @return [Date] the member's date of birth
|
493
|
+
# @!attribute [rw] attending
|
494
|
+
# @return [Symbol] whether the member is attending (either :yes, :no, :invited, :shown or nil)
|
495
|
+
# @!attribute [rw] payments
|
496
|
+
# @return [Hash] keys are the payment's id, values are the payment state
|
497
|
+
# @!attribute [rw] payment_control
|
498
|
+
# @return [Symbol] whether payments are done manually or automatically (either :manual, :automatic or nil)
|
471
499
|
|
472
500
|
attribute :row, :type => Integer
|
473
501
|
attribute :member_id, :type => Integer
|
474
502
|
attribute :grouping_id, :type => Integer
|
475
503
|
attribute :fields, :default => {}
|
476
504
|
attribute :event
|
477
|
-
|
478
|
-
|
479
|
-
|
505
|
+
attribute :first_name, :type => String
|
506
|
+
attribute :last_name, :type => String
|
507
|
+
attribute :date_of_birth, :type => Date
|
508
|
+
attribute :attending
|
509
|
+
attribute :payments, :default => {}
|
510
|
+
attribute :payment_control
|
511
|
+
|
512
|
+
attr_accessible :member_id, :grouping_id, :fields, :row, :event, :first_name, :last_name, :date_of_birth, :attending, :payments, :payment_control
|
513
|
+
|
480
514
|
validates_numericality_of :row, :only_integer=>true, :greater_than_or_equal_to=>0
|
481
515
|
validates_numericality_of :member_id, :only_integer=>true, :greater_than=>0
|
482
516
|
validates_numericality_of :grouping_id, :only_integer=>true, :greater_than_or_equal_to=>-2
|
483
|
-
validates :fields, :hash => {:key_type => String}
|
517
|
+
validates :fields, :hash => { :key_type => Fixnum, :value_type => String }
|
518
|
+
validates :payments, :hash => { :key_type => Fixnum, :value_type => String }
|
484
519
|
validates_each :event do |record, attr, value|
|
485
520
|
record.event.valid?
|
486
521
|
end
|
522
|
+
validates_presence_of :first_name
|
523
|
+
validates_presence_of :last_name
|
524
|
+
validates_presence_of :date_of_birth
|
525
|
+
validates_inclusion_of :payment_control, :in => [:manual, :automatic, nil]
|
526
|
+
validates_inclusion_of :attending, :in => [:yes, :no, :invited, :shown, nil]
|
527
|
+
|
487
528
|
|
488
|
-
|
489
529
|
# @!method initialize
|
490
530
|
# Initialize a new Attendance
|
491
531
|
# @param [Hash] attributes The hash of attributes (see attributes for descriptions, use Symbol of attribute name as the key)
|
532
|
+
old_initialize = instance_method(:initialize)
|
533
|
+
define_method :initialize do |*args|
|
534
|
+
ret_val = old_initialize.bind(self).call(*args)
|
535
|
+
self.fields = DirtyHashy.new(self.fields)
|
536
|
+
self.fields.clean_up!
|
537
|
+
return ret_val
|
538
|
+
end
|
492
539
|
|
493
540
|
|
494
541
|
# Update event attendance
|
495
542
|
# @param [Osm::Api] api The api to use to make the request
|
496
|
-
# @param [String] field_id The id of the field to update (must be 'attending' or /\Af_\d+\Z/)
|
497
543
|
# @return [Boolean] if the operation suceeded or not
|
498
|
-
|
499
|
-
def update(api, field_id)
|
544
|
+
def update(api)
|
500
545
|
require_ability_to(api, :write, :events, event.section_id)
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
546
|
+
|
547
|
+
payment_values = {
|
548
|
+
:manual => 'Manual',
|
549
|
+
:automatic => 'Automatic',
|
550
|
+
}
|
551
|
+
attending_values = {
|
552
|
+
:yes => 'Yes',
|
553
|
+
:no => 'No',
|
554
|
+
:invited => 'Invited',
|
555
|
+
:shown => 'Show in My.SCOUT',
|
556
|
+
}
|
557
|
+
|
558
|
+
updated = true
|
559
|
+
fields.changes.each do |field, (was,now)|
|
560
|
+
data = api.perform_query("events.php?action=updateScout", {
|
561
|
+
'scoutid' => member_id,
|
562
|
+
'column' => "f_#{field}",
|
563
|
+
'value' => now,
|
564
|
+
'sectionid' => event.section_id,
|
565
|
+
'row' => row,
|
566
|
+
'eventid' => event.id,
|
567
|
+
})
|
568
|
+
updated = false unless data.is_a?(Hash)
|
569
|
+
end
|
570
|
+
|
571
|
+
if changed_attributes.include?('payment_control')
|
572
|
+
data = api.perform_query("events.php?action=updateScout", {
|
573
|
+
'scoutid' => member_id,
|
574
|
+
'column' => 'payment',
|
575
|
+
'value' => payment_values[payment_control],
|
576
|
+
'sectionid' => event.section_id,
|
577
|
+
'row' => row,
|
578
|
+
'eventid' => event.id,
|
579
|
+
})
|
580
|
+
updated = false unless data.is_a?(Hash)
|
581
|
+
end
|
582
|
+
if changed_attributes.include?('attending')
|
583
|
+
data = api.perform_query("events.php?action=updateScout", {
|
584
|
+
'scoutid' => member_id,
|
585
|
+
'column' => 'attending',
|
586
|
+
'value' => attending_values[attending],
|
587
|
+
'sectionid' => event.section_id,
|
588
|
+
'row' => row,
|
589
|
+
'eventid' => event.id,
|
590
|
+
})
|
591
|
+
updated = false unless data.is_a?(Hash)
|
592
|
+
end
|
593
|
+
|
594
|
+
if updated
|
513
595
|
reset_changed_attributes
|
596
|
+
fields.clean_up!
|
514
597
|
# The cached event attedance will be out of date
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
598
|
+
cache_delete(api, ['event_attendance', event.id])
|
599
|
+
end
|
600
|
+
return updated
|
601
|
+
end
|
602
|
+
|
603
|
+
# @! method automatic_payments?
|
604
|
+
# Check wether payments are made automatically for this member
|
605
|
+
# @return [Boolean]
|
606
|
+
# @! method manual_payments?
|
607
|
+
# Check wether payments are made manually for this member
|
608
|
+
# @return [Boolean]
|
609
|
+
[:automatic, :manual].each do |payment_control_type|
|
610
|
+
define_method "#{payment_control_type}_payments?" do
|
611
|
+
payments == payment_control_type
|
519
612
|
end
|
520
613
|
end
|
521
614
|
|
522
|
-
#
|
615
|
+
# @! method is_attending?
|
616
|
+
# Check wether the member has said they are attending the event
|
617
|
+
# @return [Boolean]
|
618
|
+
# @! method is_not_attending?
|
619
|
+
# Check wether the member has said they are not attending the event
|
620
|
+
# @return [Boolean]
|
621
|
+
# @! method is_invited?
|
622
|
+
# Check wether the member has been invited to the event
|
623
|
+
# @return [Boolean]
|
624
|
+
# @! method is_shown?
|
625
|
+
# Check wether the member can see the event in My.SCOUT
|
626
|
+
# @return [Boolean]
|
627
|
+
[:attending, :not_attending, :invited, :shown].each do |attending_type|
|
628
|
+
define_method "is_#{attending_type}?" do
|
629
|
+
attending == attending_type
|
630
|
+
end
|
631
|
+
end
|
632
|
+
|
633
|
+
# Compare Attendance based on event then row
|
523
634
|
def <=>(another)
|
524
635
|
result = self.event <=> another.try(:event)
|
525
636
|
result = self.row <=> another.try(:row) if result == 0
|
526
637
|
return result
|
527
638
|
end
|
528
639
|
|
640
|
+
def inspect
|
641
|
+
Osm.inspect_instance(self, options={:replace_with => {'event' => :id}})
|
642
|
+
end
|
643
|
+
|
529
644
|
end # Class Attendance
|
530
645
|
|
531
646
|
end # Class Event
|
data/lib/osm/flexi_record.rb
CHANGED
@@ -226,6 +226,10 @@ module Osm
|
|
226
226
|
return result
|
227
227
|
end
|
228
228
|
|
229
|
+
def inspect
|
230
|
+
Osm.inspect_instance(self, options={:replace_with => {'flexi_record' => :id}})
|
231
|
+
end
|
232
|
+
|
229
233
|
end # Class FlexiRecord::Column
|
230
234
|
|
231
235
|
|
@@ -316,6 +320,10 @@ module Osm
|
|
316
320
|
return result
|
317
321
|
end
|
318
322
|
|
323
|
+
def inspect
|
324
|
+
Osm.inspect_instance(self, options={:replace_with => {'flexi_record' => :id}})
|
325
|
+
end
|
326
|
+
|
319
327
|
end # Class FlexiRecord::Data
|
320
328
|
|
321
329
|
end # Class FlexiRecord
|
data/lib/osm/section.rb
CHANGED
@@ -14,7 +14,7 @@ module Osm
|
|
14
14
|
# @!attribute [rw] subscription_expires
|
15
15
|
# @return [Date] when the section's subscription to OSM expires
|
16
16
|
# @!attribute [rw] type
|
17
|
-
# @return [Symbol] the section type (:beavers, :cubs, :scouts, :exporers, :adults, :waiting, :unknown)
|
17
|
+
# @return [Symbol] the section type (:beavers, :cubs, :scouts, :exporers, :network, :adults, :waiting, :unknown)
|
18
18
|
# @!attribute [rw] column_names
|
19
19
|
# @return [Hash] custom names to use for the data columns
|
20
20
|
# @!attribute [rw] fields
|
@@ -310,13 +310,16 @@ module Osm
|
|
310
310
|
# @!method explorers?
|
311
311
|
# Check if this is an Explorers section
|
312
312
|
# @return (Boolean)
|
313
|
+
# @!method network?
|
314
|
+
# Check if this is a Network section
|
315
|
+
# @return (Boolean)
|
313
316
|
# @!method adults?
|
314
317
|
# Check if this is an Adults section
|
315
318
|
# @return (Boolean)
|
316
319
|
# @!method waiting?
|
317
320
|
# Check if this is a waiting list
|
318
321
|
# @return (Boolean)
|
319
|
-
[:beavers, :cubs, :scouts, :explorers, :adults, :waiting].each do |attribute|
|
322
|
+
[:beavers, :cubs, :scouts, :explorers, :network, :adults, :waiting].each do |attribute|
|
320
323
|
define_method "#{attribute}?" do
|
321
324
|
type == attribute
|
322
325
|
end
|
@@ -336,7 +339,7 @@ module Osm
|
|
336
339
|
def <=>(another)
|
337
340
|
result = self.group_name <=> another.try(:group_name)
|
338
341
|
result = 0 if self.type == another.try(:type) && result == 0
|
339
|
-
[:beavers, :cubs, :scouts, :explorers, :
|
342
|
+
[:beavers, :cubs, :scouts, :explorers, :network, :adults, :waiting].each do |type|
|
340
343
|
if result == 0
|
341
344
|
result = -1 if self.type == type
|
342
345
|
result = 1 if another.try(:type) == type
|
data/spec/osm/event_spec.rb
CHANGED
@@ -69,7 +69,12 @@ describe "Event" do
|
|
69
69
|
:member_id => 1,
|
70
70
|
:grouping_id => 2,
|
71
71
|
:row => 3,
|
72
|
-
:
|
72
|
+
:first_name => 'First',
|
73
|
+
:last_name => 'Last',
|
74
|
+
:attending => :yes,
|
75
|
+
:date_of_birth => Date.new(2000, 1, 2),
|
76
|
+
:fields => {},
|
77
|
+
:payments => {},
|
73
78
|
:event => Osm::Event.new(:id => 1, :section_id => 1, :name => 'Name', :columns => [])
|
74
79
|
}
|
75
80
|
|
@@ -77,7 +82,12 @@ describe "Event" do
|
|
77
82
|
ea.member_id.should == 1
|
78
83
|
ea.grouping_id.should == 2
|
79
84
|
ea.fields.should == {}
|
85
|
+
ea.payments.should == {}
|
80
86
|
ea.row.should == 3
|
87
|
+
ea.first_name.should == 'First'
|
88
|
+
ea.last_name.should == 'Last'
|
89
|
+
ea.date_of_birth.should == Date.new(2000, 1, 2)
|
90
|
+
ea.attending.should == :yes
|
81
91
|
ea.valid?.should be_true
|
82
92
|
end
|
83
93
|
|
@@ -528,6 +538,8 @@ describe "Event" do
|
|
528
538
|
'dob' => '1980-01-02',
|
529
539
|
'patrolid' => '2',
|
530
540
|
'f_1' => 'a',
|
541
|
+
'payment' => 'Manual',
|
542
|
+
'p1' => ''
|
531
543
|
}
|
532
544
|
]
|
533
545
|
}
|
@@ -541,25 +553,63 @@ describe "Event" do
|
|
541
553
|
ea = attendance[0]
|
542
554
|
ea.member_id.should == 1
|
543
555
|
ea.grouping_id.should == 2
|
556
|
+
ea.first_name.should == 'First'
|
557
|
+
ea.last_name.should == 'Last'
|
558
|
+
ea.date_of_birth.should == Date.new(1980, 1, 2)
|
559
|
+
ea.attending.should == :yes
|
544
560
|
ea.fields.should == {
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
'f_1' => 'a',
|
561
|
+
1 => 'a',
|
562
|
+
}
|
563
|
+
ea.payments.should == {
|
564
|
+
1 => '',
|
550
565
|
}
|
551
566
|
ea.row.should == 0
|
552
567
|
end
|
553
568
|
|
554
569
|
it "Update attendance (succeded)" do
|
555
|
-
ea = Osm::Event::Attendance.new(:row => 0, :member_id => 4, :fields => {'
|
570
|
+
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))
|
556
571
|
|
572
|
+
ea.fields[1] = 'value'
|
557
573
|
HTTParty.should_receive(:post).with(
|
558
574
|
"https://www.onlinescoutmanager.co.uk/events.php?action=updateScout",
|
559
575
|
{:body => {
|
560
576
|
'scoutid' => 4,
|
561
577
|
'column' => 'f_1',
|
562
|
-
'value' => '
|
578
|
+
'value' => 'value',
|
579
|
+
'sectionid' => 1,
|
580
|
+
'row' => 0,
|
581
|
+
'eventid' => 2,
|
582
|
+
'apiid' => @CONFIGURATION[:api][:osm][:id],
|
583
|
+
'token' => @CONFIGURATION[:api][:osm][:token],
|
584
|
+
'userid' => 'user_id',
|
585
|
+
'secret' => 'secret',
|
586
|
+
}}
|
587
|
+
) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>'{}'}) }
|
588
|
+
|
589
|
+
ea.attending = :yes
|
590
|
+
HTTParty.should_receive(:post).with(
|
591
|
+
"https://www.onlinescoutmanager.co.uk/events.php?action=updateScout",
|
592
|
+
{:body => {
|
593
|
+
'scoutid' => 4,
|
594
|
+
'column' => 'attending',
|
595
|
+
'value' => 'Yes',
|
596
|
+
'sectionid' => 1,
|
597
|
+
'row' => 0,
|
598
|
+
'eventid' => 2,
|
599
|
+
'apiid' => @CONFIGURATION[:api][:osm][:id],
|
600
|
+
'token' => @CONFIGURATION[:api][:osm][:token],
|
601
|
+
'userid' => 'user_id',
|
602
|
+
'secret' => 'secret',
|
603
|
+
}}
|
604
|
+
) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>'{}'}) }
|
605
|
+
|
606
|
+
ea.payment_control = :automatic
|
607
|
+
HTTParty.should_receive(:post).with(
|
608
|
+
"https://www.onlinescoutmanager.co.uk/events.php?action=updateScout",
|
609
|
+
{:body => {
|
610
|
+
'scoutid' => 4,
|
611
|
+
'column' => 'payment',
|
612
|
+
'value' => 'Automatic',
|
563
613
|
'sectionid' => 1,
|
564
614
|
'row' => 0,
|
565
615
|
'eventid' => 2,
|
@@ -570,7 +620,7 @@ describe "Event" do
|
|
570
620
|
}}
|
571
621
|
) { OsmTest::DummyHttpResult.new(:response=>{:code=>'200', :body=>'{}'}) }
|
572
622
|
|
573
|
-
ea.update(@api
|
623
|
+
ea.update(@api).should be_true
|
574
624
|
end
|
575
625
|
|
576
626
|
|
data/spec/osm/osm_spec.rb
CHANGED
@@ -55,4 +55,32 @@ describe "Online Scout Manager" do
|
|
55
55
|
|
56
56
|
end
|
57
57
|
|
58
|
+
|
59
|
+
describe "Inspect instance" do
|
60
|
+
|
61
|
+
class TestA < Osm::Model
|
62
|
+
attribute :id
|
63
|
+
attribute :b
|
64
|
+
attr_accessible :id, :b
|
65
|
+
end
|
66
|
+
class TestB < Osm::Model
|
67
|
+
attribute :id
|
68
|
+
attribute :a
|
69
|
+
attr_accessible :id, :a
|
70
|
+
end
|
71
|
+
|
72
|
+
it "Returns a string" do
|
73
|
+
this_one = TestA.new(:id => 1, :b => '1')
|
74
|
+
inspect = Osm.inspect_instance(this_one)
|
75
|
+
inspect.should == '#<TestA b: "1", id: 1 >'
|
76
|
+
end
|
77
|
+
|
78
|
+
it "Replaces items with their attribute" do
|
79
|
+
this_one = TestA.new(:id => 1, :b => TestB.new(:id => 2))
|
80
|
+
inspect = Osm.inspect_instance(this_one, options={:replace_with => {'b' => :id}})
|
81
|
+
inspect.should == '#<TestA b.id: 2, id: 1 >'
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
85
|
+
|
58
86
|
end
|
data/spec/osm/section_spec.rb
CHANGED
@@ -229,12 +229,13 @@ describe "Section" do
|
|
229
229
|
cubs = Osm::Section.new(:type => :cubs)
|
230
230
|
scouts = Osm::Section.new(:type => :scouts)
|
231
231
|
explorers = Osm::Section.new(:type => :explorers)
|
232
|
+
network = Osm::Section.new(:type => :network)
|
232
233
|
adults = Osm::Section.new(:type => :adults)
|
233
234
|
waiting = Osm::Section.new(:type => :waiting)
|
234
235
|
|
235
|
-
{:beavers => beavers, :cubs => cubs, :scouts => scouts, :explorers => explorers, :adults => adults, :waiting => waiting, :unknown => unknown}.each do |section_type, section|
|
236
|
+
{:beavers => beavers, :cubs => cubs, :scouts => scouts, :explorers => explorers, :network => network, :adults => adults, :waiting => waiting, :unknown => unknown}.each do |section_type, section|
|
236
237
|
it "For a #{section_type} section" do
|
237
|
-
[:beavers, :cubs, :scouts, :explorers, :adults, :waiting].each do |type|
|
238
|
+
[:beavers, :cubs, :scouts, :explorers, :network, :adults, :waiting].each do |type|
|
238
239
|
section.send("#{type.to_s}?").should == (section_type == type)
|
239
240
|
end
|
240
241
|
end
|
@@ -248,6 +249,7 @@ describe "Section" do
|
|
248
249
|
cubs = Osm::Section.new(:type => :cubs)
|
249
250
|
scouts = Osm::Section.new(:type => :scouts)
|
250
251
|
explorers = Osm::Section.new(:type => :explorers)
|
252
|
+
network = Osm::Section.new(:type => :network)
|
251
253
|
adults = Osm::Section.new(:type => :adults)
|
252
254
|
waiting = Osm::Section.new(:type => :waiting)
|
253
255
|
|
@@ -256,7 +258,7 @@ describe "Section" do
|
|
256
258
|
section.youth_section?.should be_true
|
257
259
|
end
|
258
260
|
end
|
259
|
-
[adults, waiting, unknown].each do |section|
|
261
|
+
[network, adults, waiting, unknown].each do |section|
|
260
262
|
it "For a #{section.type} section" do
|
261
263
|
section.youth_section?.should be_false
|
262
264
|
end
|
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.
|
4
|
+
version: 0.4.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: 2013-
|
12
|
+
date: 2013-03-10 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
16
|
-
requirement: &
|
16
|
+
requirement: &88838420 !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: *88838420
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: httparty
|
27
|
-
requirement: &
|
27
|
+
requirement: &88838170 !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: *88838170
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: active_attr
|
38
|
-
requirement: &
|
38
|
+
requirement: &88837940 !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: *88837940
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: activemodel
|
49
|
-
requirement: &
|
49
|
+
requirement: &88837710 !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: *88837710
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: dirty_hashy
|
60
|
-
requirement: &
|
60
|
+
requirement: &88837480 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 0.2.1
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *88837480
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rake
|
71
|
-
requirement: &
|
71
|
+
requirement: &88837250 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '10.0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *88837250
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: rspec
|
82
|
-
requirement: &
|
82
|
+
requirement: &88837020 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ~>
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '2.11'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *88837020
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: fakeweb
|
93
|
-
requirement: &
|
93
|
+
requirement: &88836790 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ~>
|
@@ -98,10 +98,10 @@ dependencies:
|
|
98
98
|
version: '1.3'
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *88836790
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: guard-rspec
|
104
|
-
requirement: &
|
104
|
+
requirement: &88836560 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ~>
|
@@ -109,10 +109,10 @@ dependencies:
|
|
109
109
|
version: '2.4'
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *88836560
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: rb-inotify
|
115
|
-
requirement: &
|
115
|
+
requirement: &88836330 !ruby/object:Gem::Requirement
|
116
116
|
none: false
|
117
117
|
requirements:
|
118
118
|
- - ~>
|
@@ -120,7 +120,7 @@ dependencies:
|
|
120
120
|
version: '0.9'
|
121
121
|
type: :development
|
122
122
|
prerelease: false
|
123
|
-
version_requirements: *
|
123
|
+
version_requirements: *88836330
|
124
124
|
description: Use the Online Scout Manager API (https://www.onlinescoutmanager.co.uk)
|
125
125
|
to retrieve and save data.
|
126
126
|
email:
|