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.
Files changed (46) hide show
  1. data/CHANGELOG.md +57 -0
  2. data/README.md +13 -7
  3. data/lib/osm.rb +47 -22
  4. data/lib/osm/activity.rb +52 -57
  5. data/lib/osm/api.rb +115 -1031
  6. data/lib/osm/api_access.rb +73 -36
  7. data/lib/osm/due_badges.rb +27 -12
  8. data/lib/osm/evening.rb +118 -55
  9. data/lib/osm/event.rb +275 -17
  10. data/lib/osm/flexi_record.rb +131 -0
  11. data/lib/osm/grouping.rb +37 -15
  12. data/lib/osm/member.rb +100 -41
  13. data/lib/osm/model.rb +95 -0
  14. data/lib/osm/register.rb +177 -0
  15. data/lib/osm/section.rb +163 -71
  16. data/lib/osm/term.rb +135 -21
  17. data/spec/osm/activity_spec.rb +7 -4
  18. data/spec/osm/api_access_spec.rb +44 -36
  19. data/spec/osm/api_spec.rb +32 -1147
  20. data/spec/osm/due_badges_spec.rb +8 -1
  21. data/spec/osm/evening_spec.rb +119 -54
  22. data/spec/osm/event_spec.rb +363 -13
  23. data/spec/osm/flexi_record_spec.rb +128 -0
  24. data/spec/osm/grouping_spec.rb +9 -5
  25. data/spec/osm/member_spec.rb +111 -36
  26. data/spec/osm/model_spec.rb +140 -0
  27. data/spec/osm/osm_spec.rb +7 -31
  28. data/spec/osm/register_spec.rb +103 -0
  29. data/spec/osm/section_spec.rb +208 -92
  30. data/spec/osm/term_spec.rb +164 -28
  31. data/spec/spec_helper.rb +22 -0
  32. data/version.rb +1 -1
  33. metadata +22 -29
  34. data/lib/osm/event_attendance.rb +0 -55
  35. data/lib/osm/flexi_record_data.rb +0 -51
  36. data/lib/osm/flexi_record_field.rb +0 -42
  37. data/lib/osm/register_data.rb +0 -64
  38. data/lib/osm/register_field.rb +0 -42
  39. data/lib/osm/role.rb +0 -133
  40. data/spec/osm/api_strangeness_spec.rb +0 -83
  41. data/spec/osm/event_attendance_spec.rb +0 -34
  42. data/spec/osm/flexi_record_data_spec.rb +0 -40
  43. data/spec/osm/flexi_record_field_spec.rb +0 -23
  44. data/spec/osm/register_data_spec.rb +0 -35
  45. data/spec/osm/register_field_spec.rb +0 -24
  46. data/spec/osm/role_spec.rb +0 -118
@@ -1,40 +0,0 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
- require 'date'
4
-
5
-
6
- describe "Flexi Record Data" do
7
-
8
- it "Create from API data" do
9
- data = {
10
- "scoutid" => "1",
11
- "firstname" => "First",
12
- "lastname" => "Last",
13
- "dob" => "1899-11-30",
14
- "patrolid" => "2",
15
- "total" => "3",
16
- "completed" => "",
17
- "f_1" => "a",
18
- "f_2" => "b",
19
- "age" => "",
20
- "patrol" => "Green"
21
- }
22
-
23
- rd = Osm::FlexiRecordData.from_api(data)
24
-
25
- rd.member_id.should == 1
26
- rd.grouping_id.should == 2
27
- rd.fields.should == {
28
- 'firstname' => 'First',
29
- 'lastname' => 'Last',
30
- 'dob' => Date.new(1899, 11, 30),
31
- 'total' => 3,
32
- 'completed' => nil,
33
- 'age' => nil,
34
- 'f_1' => 'a',
35
- 'f_2' => 'b',
36
- }
37
- rd.valid?.should be_true
38
- end
39
-
40
- end
@@ -1,23 +0,0 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
-
4
-
5
- describe "Flexi Record Field" do
6
-
7
- it "Create from API data" do
8
- data = {
9
- "field" => "f_1",
10
- "name" => "Field Name",
11
- "width" => "150",
12
- "editable" => true
13
- }
14
-
15
- field = Osm::FlexiRecordField.from_api(data)
16
-
17
- field.id.should == 'f_1'
18
- field.name.should == 'Field Name'
19
- field.editable.should be_true
20
- field.valid?.should be_true
21
- end
22
-
23
- end
@@ -1,35 +0,0 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
- require 'date'
4
-
5
-
6
- describe "Register Data" do
7
-
8
- it "Create from API data" do
9
- data = {
10
- 'scoutid' => '1',
11
- 'firstname' => 'A',
12
- 'lastname' => 'B',
13
- 'sectionid' => '2',
14
- 'patrolid' => '3',
15
- 'total' => 4,
16
- '2012-01-10' => 'Yes',
17
- '2012-01-24' => 'No',
18
- }
19
-
20
- rd = Osm::RegisterData.from_api(data)
21
-
22
- rd.member_id.should == 1
23
- rd.section_id.should == 2
24
- rd.grouping_id.should == 3
25
- rd.first_name.should == 'A'
26
- rd.last_name.should == 'B'
27
- rd.total.should == 4
28
- rd.attendance.should == {
29
- Date.new(2012, 01, 10) => 'Yes',
30
- Date.new(2012, 01, 24) => 'No'
31
- }
32
- rd.valid?.should be_true
33
- end
34
-
35
- end
@@ -1,24 +0,0 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
-
4
-
5
- describe "Register Field" do
6
-
7
- it "Create" do
8
- data = {
9
- 'name' => 'Human name',
10
- 'field' => 'machine_name',
11
- 'formatter' => 'doneFormatter',
12
- 'width' => '110px',
13
- 'tooltip' => 'Tooltip'
14
- }
15
-
16
- field = Osm::RegisterField.from_api(data)
17
-
18
- field.id.should == 'machine_name'
19
- field.name.should == 'Human name'
20
- field.tooltip.should == 'Tooltip'
21
- field.valid?.should be_true
22
- end
23
-
24
- end
@@ -1,118 +0,0 @@
1
- # encoding: utf-8
2
- require 'spec_helper'
3
- require 'date'
4
-
5
-
6
- class DummySection
7
- attr_reader :name, :id
8
- def initialize(options={})
9
- options.each { |k,v| instance_variable_set("@#{k}", v) }
10
- end
11
- def valid?
12
- true
13
- end
14
- end
15
-
16
-
17
- describe "Role" do
18
-
19
- it "Create from API data" do
20
- data = {
21
- 'sectionid' => 1,
22
- 'sectionname' => 'A Section',
23
- 'sectionConfig' => '{"subscription_expires":"2000-01-02","numscouts":0}',
24
- 'groupname' => 'A Group',
25
- 'groupid' => '2',
26
- 'groupNormalised' => '3',
27
- 'isDefault' => '1',
28
- 'permissions' => {'something' => 100}
29
- }
30
- role = Osm::Role.from_api(data)
31
-
32
- role.section.id.should == 1
33
- role.section.name.should == 'A Section'
34
- role.group_id.should == 2
35
- role.group_name.should == 'A Group'
36
- role.valid?.should be_true
37
- end
38
-
39
-
40
- it "Compares two matching roles" do
41
- role1 = Osm::Role.new
42
- role2 = Osm::Role.new
43
- role1.should == role2
44
- end
45
-
46
- it "Compares two non-matching roles" do
47
- role1 = Osm::Role.new(:section => DummySection.new(:id => 1))
48
- role2 = Osm::Role.new(:section => DummySection.new(:id => 2))
49
-
50
- role1.should_not == role2
51
- end
52
-
53
-
54
- it "Sorts by Group Name then section type (age order)" do
55
- role1 = Osm::Role.from_api({'groupname' => 'Group A', 'sectionConfig' => '{}'})
56
- role2 = Osm::Role.from_api({'groupname' => 'Group B', 'sectionConfig' => '{"sectionType":"beavers"}'})
57
- role3 = Osm::Role.from_api({'groupname' => 'Group B', 'sectionConfig' => '{"sectionType":"cubs"}'})
58
- role4 = Osm::Role.from_api({'groupname' => 'Group B', 'sectionConfig' => '{"sectionType":"scouts"}'})
59
- role5 = Osm::Role.from_api({'groupname' => 'Group B', 'sectionConfig' => '{"sectionType":"explorers"}'})
60
- role6 = Osm::Role.from_api({'groupname' => 'Group B', 'sectionConfig' => '{"sectionType":"waiting"}'})
61
- role7 = Osm::Role.from_api({'groupname' => 'Group B', 'sectionConfig' => '{"sectionType":"adults"}'})
62
- role8 = Osm::Role.from_api({'groupname' => 'Group C', 'sectionConfig' => '{}'})
63
-
64
- data = [role8, role5, role3, role7, role2, role4, role1, role6]
65
- data.sort.should == [role1, role2, role3, role4, role5, role6, role7, role8]
66
- end
67
-
68
-
69
- it "Provides a long name for the role" do
70
- role = Osm::Role.new({
71
- :section => DummySection.new(:name => 'A Section'),
72
- :group_name => 'A Group',
73
- })
74
- role.long_name.should == 'A Section (A Group)'
75
-
76
- role = Osm::Role.new({
77
- :section => DummySection.new(:name => 'A Section'),
78
- })
79
- role.long_name.should == 'A Section'
80
- end
81
-
82
-
83
- it "Provides a full name for the role" do
84
- role = Osm::Role.new({
85
- :section => DummySection.new(:name => 'A Section'),
86
- :group_name => 'A Group',
87
- })
88
- role.full_name.should == 'A Group A Section'
89
-
90
- role = Osm::Role.new({
91
- :section => DummySection.new(:name => 'A Section'),
92
- })
93
- role.full_name.should == 'A Section'
94
- end
95
-
96
-
97
- it "Allows interegation of the permissions hash" do
98
- role = Osm::Role.new({
99
- :permissions => {
100
- :read_only => 10,
101
- :read_write => 20,
102
- :administer => 100
103
- }
104
- })
105
-
106
- role.can_read?(:read_only).should == true
107
- role.can_read?(:read_write).should == true
108
- role.can_read?(:administer).should == true
109
-
110
- role.can_write?(:read_only).should == false
111
- role.can_write?(:read_write).should == true
112
- role.can_write?(:administer).should == true
113
-
114
- role.can_read?(:non_existant).should == false
115
- role.can_write?(:non_existant).should == false
116
- end
117
-
118
- end