osm 0.0.17 → 0.0.18
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 +4 -0
- data/lib/array_of_validator.rb +15 -0
- data/lib/hash_validator.rb +24 -0
- data/lib/osm.rb +11 -14
- data/lib/osm/activity.rb +152 -103
- data/lib/osm/api.rb +3 -2
- data/lib/osm/api_access.rb +23 -16
- data/lib/osm/due_badges.rb +53 -24
- data/lib/osm/evening.rb +58 -56
- data/lib/osm/event.rb +23 -19
- data/lib/osm/grouping.rb +23 -16
- data/lib/osm/member.rb +86 -54
- data/lib/osm/register_data.rb +34 -25
- data/lib/osm/register_field.rb +19 -16
- data/lib/osm/role.rb +59 -30
- data/lib/osm/section.rb +93 -60
- data/lib/osm/term.rb +36 -28
- data/osm.gemspec +2 -0
- data/spec/osm/activity_spec.rb +2 -0
- data/spec/osm/api_access_spec.rb +3 -2
- data/spec/osm/api_spec.rb +10 -5
- data/spec/osm/due_badges_spec.rb +1 -0
- data/spec/osm/evening_spec.rb +5 -20
- data/spec/osm/event_spec.rb +2 -1
- data/spec/osm/grouping_spec.rb +1 -0
- data/spec/osm/member_spec.rb +1 -0
- data/spec/osm/register_data_spec.rb +1 -0
- data/spec/osm/register_field_spec.rb +1 -0
- data/spec/osm/role_spec.rb +6 -2
- data/spec/osm/section_spec.rb +2 -0
- data/spec/osm/term_spec.rb +26 -25
- data/spec/spec_helper.rb +2 -0
- data/version.rb +1 -1
- metadata +36 -12
data/spec/osm/event_spec.rb
CHANGED
@@ -23,10 +23,11 @@ describe "Event" do
|
|
23
23
|
event.section_id.should == 2
|
24
24
|
event.name.should == 'Event name'
|
25
25
|
event.start.should == DateTime.new(2001, 1, 2, 12, 0, 0)
|
26
|
-
event.
|
26
|
+
event.finish.should == nil
|
27
27
|
event.cost.should == 'Free'
|
28
28
|
event.location.should == 'Somewhere'
|
29
29
|
event.notes.should == 'None'
|
30
|
+
event.valid?.should be_true
|
30
31
|
end
|
31
32
|
|
32
33
|
end
|
data/spec/osm/grouping_spec.rb
CHANGED
data/spec/osm/member_spec.rb
CHANGED
data/spec/osm/role_spec.rb
CHANGED
@@ -8,6 +8,9 @@ class DummySection
|
|
8
8
|
def initialize(options={})
|
9
9
|
options.each { |k,v| instance_variable_set("@#{k}", v) }
|
10
10
|
end
|
11
|
+
def valid?
|
12
|
+
true
|
13
|
+
end
|
11
14
|
end
|
12
15
|
|
13
16
|
|
@@ -17,12 +20,12 @@ describe "Role" do
|
|
17
20
|
data = {
|
18
21
|
'sectionid' => 1,
|
19
22
|
'sectionname' => 'A Section',
|
20
|
-
'sectionConfig' => '{}',
|
23
|
+
'sectionConfig' => '{"subscription_expires":"2000-01-02","numscouts":0}',
|
21
24
|
'groupname' => 'A Group',
|
22
25
|
'groupid' => '2',
|
23
26
|
'groupNormalised' => '3',
|
24
27
|
'isDefault' => '1',
|
25
|
-
'permissions' => {}
|
28
|
+
'permissions' => {'something' => 100}
|
26
29
|
}
|
27
30
|
role = Osm::Role.from_api(data)
|
28
31
|
|
@@ -30,6 +33,7 @@ describe "Role" do
|
|
30
33
|
role.section.name.should == 'A Section'
|
31
34
|
role.group_id.should == 2
|
32
35
|
role.group_name.should == 'A Group'
|
36
|
+
role.valid?.should be_true
|
33
37
|
end
|
34
38
|
|
35
39
|
|
data/spec/osm/section_spec.rb
CHANGED
data/spec/osm/term_spec.rb
CHANGED
@@ -10,7 +10,7 @@ describe "Term" do
|
|
10
10
|
:section_id => 2,
|
11
11
|
:name => 'Term name',
|
12
12
|
:start => Date.new(2001, 01, 01),
|
13
|
-
:
|
13
|
+
:finish => Date.new(2001, 03, 31)
|
14
14
|
}
|
15
15
|
end
|
16
16
|
|
@@ -28,7 +28,8 @@ describe "Term" do
|
|
28
28
|
term.section_id.should == 2
|
29
29
|
term.name.should == 'Term name'
|
30
30
|
term.start.should == Date.new(2001, 1, 1)
|
31
|
-
term.
|
31
|
+
term.finish.should == Date.new(2001, 3, 31)
|
32
|
+
term.valid?.should be_true
|
32
33
|
end
|
33
34
|
|
34
35
|
|
@@ -46,11 +47,11 @@ describe "Term" do
|
|
46
47
|
|
47
48
|
|
48
49
|
it "Sorts by Section ID, Start date and then Term ID" do
|
49
|
-
term1 = Osm::Term.new(@attributes.merge(:section_id => 1, :term => 11, :start => (Date.today - 60), :
|
50
|
-
term2 = Osm::Term.new(@attributes.merge(:section_id => 1, :term => 12, :start => (Date.today - 0), :
|
51
|
-
term3 = Osm::Term.new(@attributes.merge(:section_id => 1, :term => 13, :start => (Date.today + 1), :
|
52
|
-
term4 = Osm::Term.new(@attributes.merge(:section_id => 2, :term => 1, :start => (Date.today + 1), :
|
53
|
-
term5 = Osm::Term.new(@attributes.merge(:section_id => 2, :term => 2, :start => (Date.today + 1), :
|
50
|
+
term1 = Osm::Term.new(@attributes.merge(:section_id => 1, :term => 11, :start => (Date.today - 60), :finish => (Date.today - 1)))
|
51
|
+
term2 = Osm::Term.new(@attributes.merge(:section_id => 1, :term => 12, :start => (Date.today - 0), :finish => (Date.today + 0)))
|
52
|
+
term3 = Osm::Term.new(@attributes.merge(:section_id => 1, :term => 13, :start => (Date.today + 1), :finish => (Date.today + 60)))
|
53
|
+
term4 = Osm::Term.new(@attributes.merge(:section_id => 2, :term => 1, :start => (Date.today + 1), :finish => (Date.today + 60)))
|
54
|
+
term5 = Osm::Term.new(@attributes.merge(:section_id => 2, :term => 2, :start => (Date.today + 1), :finish => (Date.today + 60)))
|
54
55
|
|
55
56
|
data = [term5, term3, term2, term4, term1]
|
56
57
|
data.sort.should == [term1, term2, term3, term4, term5]
|
@@ -58,9 +59,9 @@ describe "Term" do
|
|
58
59
|
|
59
60
|
|
60
61
|
it "Works out if it is completly before a date" do
|
61
|
-
term1 = Osm::Term.new(@attributes.merge(:start => (Date.today - 60), :
|
62
|
-
term2 = Osm::Term.new(@attributes.merge(:start => (Date.today - 0), :
|
63
|
-
term3 = Osm::Term.new(@attributes.merge(:start => (Date.today + 1), :
|
62
|
+
term1 = Osm::Term.new(@attributes.merge(:start => (Date.today - 60), :finish => (Date.today - 1)))
|
63
|
+
term2 = Osm::Term.new(@attributes.merge(:start => (Date.today - 0), :finish => (Date.today + 0)))
|
64
|
+
term3 = Osm::Term.new(@attributes.merge(:start => (Date.today + 1), :finish => (Date.today + 60)))
|
64
65
|
|
65
66
|
term1.before?(Date.today).should == true
|
66
67
|
term2.before?(Date.today).should == false
|
@@ -69,9 +70,9 @@ describe "Term" do
|
|
69
70
|
|
70
71
|
|
71
72
|
it "Works out if it is completly after a date" do
|
72
|
-
term1 = Osm::Term.new(@attributes.merge(:start => (Date.today - 60), :
|
73
|
-
term2 = Osm::Term.new(@attributes.merge(:start => (Date.today - 0), :
|
74
|
-
term3 = Osm::Term.new(@attributes.merge(:start => (Date.today + 1), :
|
73
|
+
term1 = Osm::Term.new(@attributes.merge(:start => (Date.today - 60), :finish => (Date.today - 1)))
|
74
|
+
term2 = Osm::Term.new(@attributes.merge(:start => (Date.today - 0), :finish => (Date.today + 0)))
|
75
|
+
term3 = Osm::Term.new(@attributes.merge(:start => (Date.today + 1), :finish => (Date.today + 60)))
|
75
76
|
|
76
77
|
term1.after?(Date.today).should == false
|
77
78
|
term2.after?(Date.today).should == false
|
@@ -80,9 +81,9 @@ describe "Term" do
|
|
80
81
|
|
81
82
|
|
82
83
|
it "Works out if it has passed" do
|
83
|
-
term1 = Osm::Term.new(@attributes.merge(:start => (Date.today - 60), :
|
84
|
-
term2 = Osm::Term.new(@attributes.merge(:start => (Date.today - 0), :
|
85
|
-
term3 = Osm::Term.new(@attributes.merge(:start => (Date.today + 1), :
|
84
|
+
term1 = Osm::Term.new(@attributes.merge(:start => (Date.today - 60), :finish => (Date.today - 1)))
|
85
|
+
term2 = Osm::Term.new(@attributes.merge(:start => (Date.today - 0), :finish => (Date.today + 0)))
|
86
|
+
term3 = Osm::Term.new(@attributes.merge(:start => (Date.today + 1), :finish => (Date.today + 60)))
|
86
87
|
|
87
88
|
term1.past?().should == true
|
88
89
|
term2.past?().should == false
|
@@ -91,9 +92,9 @@ describe "Term" do
|
|
91
92
|
|
92
93
|
|
93
94
|
it "Works out if it is in the future" do
|
94
|
-
term1 = Osm::Term.new(@attributes.merge(:start => (Date.today - 60), :
|
95
|
-
term2 = Osm::Term.new(@attributes.merge(:start => (Date.today - 0), :
|
96
|
-
term3 = Osm::Term.new(@attributes.merge(:start => (Date.today + 1), :
|
95
|
+
term1 = Osm::Term.new(@attributes.merge(:start => (Date.today - 60), :finish => (Date.today - 1)))
|
96
|
+
term2 = Osm::Term.new(@attributes.merge(:start => (Date.today - 0), :finish => (Date.today + 0)))
|
97
|
+
term3 = Osm::Term.new(@attributes.merge(:start => (Date.today + 1), :finish => (Date.today + 60)))
|
97
98
|
|
98
99
|
term1.future?().should == false
|
99
100
|
term2.future?().should == false
|
@@ -102,9 +103,9 @@ describe "Term" do
|
|
102
103
|
|
103
104
|
|
104
105
|
it "Works out if it is the current term" do
|
105
|
-
term1 = Osm::Term.new(@attributes.merge(:start => (Date.today - 60), :
|
106
|
-
term2 = Osm::Term.new(@attributes.merge(:start=> (Date.today - 0), :
|
107
|
-
term3 = Osm::Term.new(@attributes.merge(:start => (Date.today + 1), :
|
106
|
+
term1 = Osm::Term.new(@attributes.merge(:start => (Date.today - 60), :finish => (Date.today - 1)))
|
107
|
+
term2 = Osm::Term.new(@attributes.merge(:start=> (Date.today - 0), :finish => (Date.today + 0)))
|
108
|
+
term3 = Osm::Term.new(@attributes.merge(:start => (Date.today + 1), :finish => (Date.today + 60)))
|
108
109
|
|
109
110
|
term1.current?().should == false
|
110
111
|
term2.current?().should == true
|
@@ -113,9 +114,9 @@ describe "Term" do
|
|
113
114
|
|
114
115
|
|
115
116
|
it "Works out if it contains a date" do
|
116
|
-
term1 = Osm::Term.new(@attributes.merge(:start => (Date.today - 60), :
|
117
|
-
term2 = Osm::Term.new(@attributes.merge(:start => (Date.today - 0), :
|
118
|
-
term3 = Osm::Term.new(@attributes.merge(:start => (Date.today + 1), :
|
117
|
+
term1 = Osm::Term.new(@attributes.merge(:start => (Date.today - 60), :finish => (Date.today - 1)))
|
118
|
+
term2 = Osm::Term.new(@attributes.merge(:start => (Date.today - 0), :finish => (Date.today + 0)))
|
119
|
+
term3 = Osm::Term.new(@attributes.merge(:start => (Date.today + 1), :finish => (Date.today + 60)))
|
119
120
|
|
120
121
|
term1.contains_date?(Date.today).should == false
|
121
122
|
term2.contains_date?(Date.today).should == true
|
data/spec/spec_helper.rb
CHANGED
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.18
|
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-09-
|
12
|
+
date: 2012-09-12 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
16
|
-
requirement: &
|
16
|
+
requirement: &83140270 !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: *83140270
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: httparty
|
27
|
-
requirement: &
|
27
|
+
requirement: &83124630 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,32 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *83124630
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: active_attr
|
38
|
+
requirement: &83124090 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *83124090
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: activemodel
|
49
|
+
requirement: &83123540 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :runtime
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *83123540
|
36
58
|
- !ruby/object:Gem::Dependency
|
37
59
|
name: rake
|
38
|
-
requirement: &
|
60
|
+
requirement: &83123160 !ruby/object:Gem::Requirement
|
39
61
|
none: false
|
40
62
|
requirements:
|
41
63
|
- - ! '>='
|
@@ -43,10 +65,10 @@ dependencies:
|
|
43
65
|
version: '0'
|
44
66
|
type: :development
|
45
67
|
prerelease: false
|
46
|
-
version_requirements: *
|
68
|
+
version_requirements: *83123160
|
47
69
|
- !ruby/object:Gem::Dependency
|
48
70
|
name: rspec
|
49
|
-
requirement: &
|
71
|
+
requirement: &83122830 !ruby/object:Gem::Requirement
|
50
72
|
none: false
|
51
73
|
requirements:
|
52
74
|
- - ! '>='
|
@@ -54,10 +76,10 @@ dependencies:
|
|
54
76
|
version: '0'
|
55
77
|
type: :development
|
56
78
|
prerelease: false
|
57
|
-
version_requirements: *
|
79
|
+
version_requirements: *83122830
|
58
80
|
- !ruby/object:Gem::Dependency
|
59
81
|
name: fakeweb
|
60
|
-
requirement: &
|
82
|
+
requirement: &83122500 !ruby/object:Gem::Requirement
|
61
83
|
none: false
|
62
84
|
requirements:
|
63
85
|
- - ! '>='
|
@@ -65,7 +87,7 @@ dependencies:
|
|
65
87
|
version: '0'
|
66
88
|
type: :development
|
67
89
|
prerelease: false
|
68
|
-
version_requirements: *
|
90
|
+
version_requirements: *83122500
|
69
91
|
description: Use the Online Scout Manager API (https://www.onlinescoutmanager.co.uk)
|
70
92
|
to retrieve and save data.
|
71
93
|
email:
|
@@ -82,6 +104,8 @@ files:
|
|
82
104
|
- LICENSE.rdoc
|
83
105
|
- README.md
|
84
106
|
- Rakefile
|
107
|
+
- lib/array_of_validator.rb
|
108
|
+
- lib/hash_validator.rb
|
85
109
|
- lib/osm.rb
|
86
110
|
- lib/osm/activity.rb
|
87
111
|
- lib/osm/api.rb
|