osm 0.0.14 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,7 +1,12 @@
1
- ## Version 0.0.14
1
+ ## Version 0.0.15
2
2
 
3
3
  * Add :debug option to Api.configure
4
4
  * -2 is a valid grouping\_id value
5
+ * Fix check of :section\_id in Member.initalize (apparently 0 is allowd in the API return data)
6
+ * Fix role's section not being set from API data
7
+
8
+ ## Version 0.0.14
9
+
5
10
  * Fix Api.get_register\_data\ returning wrong object
6
11
  * Fix check of :num\_scouts in Section.initalize
7
12
 
data/lib/osm/member.rb CHANGED
@@ -68,13 +68,11 @@ module Osm
68
68
  # Initialize a new Member
69
69
  # @param [Hash] attributes the hash of attributes (see attributes for descriptions, use Symbol of attribute name as the key)
70
70
  def initialize(attributes={})
71
- [:id, :section_id].each do |attribute|
72
- raise ArgumentError, ":#{attribute} must be nil or a Fixnum > 0" unless attributes[attribute].nil? || (attributes[attribute].is_a?(Fixnum) && attributes[attribute] > 0)
71
+ [:id, :section_id, :grouping_leader].each do |attribute|
72
+ raise ArgumentError, ":#{attribute} must be nil or a Fixnum >= 0" unless attributes[attribute].nil? || (attributes[attribute].is_a?(Fixnum) && attributes[attribute] >= 0)
73
73
  end
74
74
  raise ArgumentError, ':grouping_id must be nil or a Fixnum >= -2' unless attributes[:grouping_id].nil? || (attributes[:grouping_id].is_a?(Fixnum) && attributes[:grouping_id] >= -2)
75
- [:joined_years, :grouping_leader].each do |attribute|
76
- raise ArgumentError, ":#{attribute} must be nil or a Fixnum >= -1" unless attributes[attribute].nil? || (attributes[attribute].is_a?(Fixnum) && attributes[attribute] >= -1)
77
- end
75
+ raise ArgumentError, ':joined_years must be nil or a Fixnum >= -1' unless attributes[:joined_years].nil? || (attributes[:joined_years].is_a?(Fixnum) && attributes[:joined_years] >= -1)
78
76
  raise ArgumentError, ':joining_in_years must be nil or a Fixnum' unless attributes[:joining_in_years].nil? || attributes[:joining_in_years].is_a?(Fixnum)
79
77
  [:type, :first_name, :last_name, :email1, :email2, :email3, :email4, :phone1, :phone2, :phone3, :phone4, :address, :address2, :parents, :notes, :medical, :religion, :school, :ethnicity, :subs, :age].each do |attribute|
80
78
  raise ArgumentError, ":#{attribute} must be nil or a String" unless attributes[attribute].nil? || attributes[attribute].is_a?(String)
@@ -117,7 +115,7 @@ module Osm
117
115
  :ethnicity => data['ethnicity'],
118
116
  :subs => data['subs'],
119
117
  :grouping_id => Osm::to_i_or_nil(data['patrolidO']),
120
- :grouping_leader => data['patrolleaderO'],
118
+ :grouping_leader => Osm::to_i_or_nil(data['patrolleaderO']),
121
119
  :joined => Osm::parse_date(data['joined']),
122
120
  :age => data['age'],
123
121
  :joined_years => data['yrs'].to_i,
data/lib/osm/role.rb CHANGED
@@ -3,7 +3,8 @@ module Osm
3
3
  class Role
4
4
 
5
5
  attr_reader :section, :group_name, :group_id, :permissions
6
- # @!attribute [r] section
6
+ # @!attribute [rw] section
7
+ # @param [Osm::Section] section the section this role is related to (can only be set once)
7
8
  # @return [Osm::Section] the section this role related to
8
9
  # @!attribute [r] group_name
9
10
  # @return [String] the name of the group the section is in
@@ -30,7 +31,6 @@ module Osm
30
31
  # @param [Hash] data the hash of data provided by the API
31
32
  def self.from_api(data)
32
33
  attributes = {}
33
- attributes[:section] = Osm::Section.from_api(data['sectionid'], data['sectionname'], ActiveSupport::JSON.decode(data['sectionConfig']), self)
34
34
  attributes[:group_name] = data['groupname']
35
35
  attributes[:group_id] = Osm::to_i_or_nil(data['groupid'])
36
36
 
@@ -40,7 +40,14 @@ module Osm
40
40
  permissions[key] = permissions[key].to_i
41
41
  end
42
42
 
43
- new(attributes.merge(:permissions => permissions))
43
+ role = new(attributes.merge(:permissions => permissions))
44
+ role.section = Osm::Section.from_api(data['sectionid'], data['sectionname'], ActiveSupport::JSON.decode(data['sectionConfig']), role)
45
+ return role
46
+ end
47
+
48
+ def section=(section)
49
+ raise ArgumentError, 'section must be an Osm::Section' unless section.is_a?(Osm::Section)
50
+ @section = section if @section.nil?
44
51
  end
45
52
 
46
53
  # Determine if this role has read access for the provided permission
data/lib/osm/section.rb CHANGED
@@ -32,7 +32,6 @@ module Osm
32
32
  # Initialize a new Section
33
33
  # @param [Hash] attributes the hash of attributes (see attributes for descriptions, use Symbol of attribute name as the key)
34
34
  def initialize(attributes={})
35
- puts ":num_scouts = #{attributes[:num_scouts].inspect}"
36
35
  raise ArgumentError, ':id must be nil or a Fixnum > 0' unless attributes[:id].nil? || (attributes[:id].is_a?(Fixnum) && attributes[:id] > 0)
37
36
  raise ArgumentError, ':section_name must be nil or a String' unless attributes[:section_name].nil? || attributes[:section_name].is_a?(String)
38
37
  raise ArgumentError, ':num_scouts must be nil or a Fixnum >= 0' unless attributes[:num_scouts].nil? || (attributes[:num_scouts].is_a?(Fixnum) && attributes[:num_scouts] >= 0)
@@ -61,7 +60,7 @@ puts ":num_scouts = #{attributes[:num_scouts].inspect}"
61
60
  # @param [Fixnum] id the section ID used by the API to refer to this section
62
61
  # @param [String] name the name given to the sction in OSM
63
62
  # @param [Hash] data the hash of data for the object returned by the API
64
- # @param {Osm::Role] role the Osm::Role linked with this section
63
+ # @param [Osm::Role] role the Osm::Role linked with this section
65
64
  def self.from_api(id, name, data, role)
66
65
  subscription_levels = [:bronze, :silver, :gold]
67
66
  subscription_level = data['subscription_level'].to_i - 1
data/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Osm
2
- VERSION = "0.0.14"
2
+ VERSION = "0.0.15"
3
3
  end
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.14
4
+ version: 0.0.15
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-08-30 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
16
- requirement: &87769510 !ruby/object:Gem::Requirement
16
+ requirement: &76203780 !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: *87769510
24
+ version_requirements: *76203780
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: httparty
27
- requirement: &87769250 !ruby/object:Gem::Requirement
27
+ requirement: &76203550 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *87769250
35
+ version_requirements: *76203550
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &87768850 !ruby/object:Gem::Requirement
38
+ requirement: &76203320 !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: :development
45
45
  prerelease: false
46
- version_requirements: *87768850
46
+ version_requirements: *76203320
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
- requirement: &87768490 !ruby/object:Gem::Requirement
49
+ requirement: &76203080 !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: *87768490
57
+ version_requirements: *76203080
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: fakeweb
60
- requirement: &87768140 !ruby/object:Gem::Requirement
60
+ requirement: &76202860 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *87768140
68
+ version_requirements: *76202860
69
69
  description: Use the Online Scout Manager API (https://www.onlinescoutmanager.co.uk)
70
70
  to retrieve and save data.
71
71
  email: