osm 0.0.24 → 0.0.25

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,13 @@
1
+ ## Version 0.0.25
2
+
3
+ * FlexiRecordData, move these attributes to the fields hash:
4
+ * first\_name => 'firstname'
5
+ * last\_name => 'lastname'
6
+ * age => 'age'
7
+ * date\_of\_birth => 'dob'
8
+ * completed => 'completed'
9
+ * total => 'total'
10
+
1
11
  ## Version 0.0.24
2
12
 
3
13
  * Make Section::FlexiRecord sortable
@@ -6,40 +6,20 @@ module Osm
6
6
 
7
7
  # @!attribute [rw] member_id
8
8
  # @return [Fixnum] OSM id for the member
9
- # @!attribute [rw] first_name
10
- # @return [String] Member's first name
11
- # @!attribute [rw] last_name
12
- # @return [String] Member's last name
13
9
  # @!attribute [rw] grouping__id
14
10
  # @return [Fixnum] OSM id for the grouping the member is in
15
11
  # @!attribute [rw] fields
16
12
  # @return [Hash] Keys are the field'd id, values are the field values
17
- # @!attribute [rw] total
18
- # @return [Fixnum, nil] The total of the field values, nil if the flexi record does not have this column type
19
- # @!attribute [rw] completed
20
- # @return [Fixnum, nil] The count of completed fields, nil if the flexi record does not have this column type
21
- # @!attribute [rw] date_of_birth
22
- # @return [Date, nil] The member's date of birth, nil if the flexi record does not have this column type
23
- # @!attribute [rw] age
24
- # @return [String, nil] The member's age (yy/mm), nil if the flexi record does not have this column type
25
13
 
26
14
  attribute :member_id, :type => Integer
27
- attribute :first_name, :type => String
28
- attribute :last_name, :type => String
29
15
  attribute :grouping_id, :type => Integer
30
- attribute :date_of_birth, :type => Date
31
- attribute :total, :type => Integer
32
- attribute :completed, :type => Integer
33
- attribute :age, :type => String
34
16
  attribute :fields, :default => {}
35
17
 
36
- attr_accessible :member_id, :first_name, :last_name, :date_of_birth, :grouping_id, :total, :completed, :age, :fields
18
+ attr_accessible :member_id, :grouping_id, :fields
37
19
 
38
- validates_presence_of :first_name
39
- validates_presence_of :last_name
20
+ validates_numericality_of :member_id, :only_integer=>true, :greater_than=>0
40
21
  validates_numericality_of :grouping_id, :only_integer=>true, :greater_than_or_equal_to=>-2
41
- validates_format_of :age, :with => /\A[0-9]{2}\/(0[0-9]|1[012])\Z/, :message => 'age is not in the correct format (yy/mm)', :allow_nil => true
42
- validates :fields, :hash => {:key_type => String, :value_type => String}
22
+ validates :fields, :hash => {:key_type => String}
43
23
 
44
24
 
45
25
  # @!method initialize
@@ -50,16 +30,19 @@ module Osm
50
30
  # Initialize a new FlexiRecordData from api data
51
31
  # @param [Hash] data the hash of data provided by the API
52
32
  def self.from_api(data)
33
+ data.merge!({
34
+ 'dob' => data['dob'].nil? ? nil : Osm::parse_date(data['dob'], :ignore_epoch => true),
35
+ 'total' => Osm::to_i_or_nil(data['total'].eql?('') ? nil : data['total']),
36
+ 'completed' => Osm::to_i_or_nil(data['completed'].eql?('') ? nil : data['completed']),
37
+ 'age' => data['age'].eql?('') ? nil : data['age'],
38
+ })
39
+
53
40
  new({
54
41
  :member_id => Osm::to_i_or_nil(data['scoutid']),
55
- :first_name => data['firstname'],
56
- :last_name => data['lastname'],
57
42
  :grouping_id => Osm::to_i_or_nil(data['patrolid'].eql?('') ? nil : data['patrolid']),
58
- :date_of_birth => data['dob'].nil? ? nil : Osm::parse_date(data['dob'], :ignore_epoch => true),
59
- :total => Osm::to_i_or_nil(data['total'].eql?('') ? nil : data['total']),
60
- :completed => Osm::to_i_or_nil(data['completed'].eql?('') ? nil : data['completed']),
61
- :age => data['age'].eql?('') ? nil : data['age'],
62
- :fields => data.select { |key, value| key.to_s.match(/^f_\d+/) }
43
+ :fields => data.select { |key, value|
44
+ ['firstname', 'lastname', 'dob', 'total', 'completed', 'age'].include?(key) || key.to_s.match(/^f_\d+/)
45
+ }
63
46
  })
64
47
  end
65
48
 
@@ -19,6 +19,7 @@ module Osm
19
19
 
20
20
  validates_presence_of :id
21
21
  validates_presence_of :name
22
+ validates_inclusion_of :editable, :in => [true, false]
22
23
 
23
24
 
24
25
  # @!method initialize
@@ -24,13 +24,13 @@ describe "Flexi Record Data" do
24
24
 
25
25
  rd.member_id.should == 1
26
26
  rd.grouping_id.should == 2
27
- rd.first_name.should == 'First'
28
- rd.last_name.should == 'Last'
29
- rd.total.should == 3
30
- rd.completed.nil?.should be_true
31
- rd.age.nil?.should be_true
32
- rd.date_of_birth.should == Date.new(1899, 11, 30)
33
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
34
  'f_1' => 'a',
35
35
  'f_2' => 'b',
36
36
  }
data/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Osm
2
- VERSION = "0.0.24"
2
+ VERSION = "0.0.25"
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.24
4
+ version: 0.0.25
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-09-26 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
16
- requirement: &71355080 !ruby/object:Gem::Requirement
16
+ requirement: &83764340 !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: *71355080
24
+ version_requirements: *83764340
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: httparty
27
- requirement: &71354100 !ruby/object:Gem::Requirement
27
+ requirement: &83763040 !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: *71354100
35
+ version_requirements: *83763040
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: active_attr
38
- requirement: &71353110 !ruby/object:Gem::Requirement
38
+ requirement: &83762650 !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: *71353110
46
+ version_requirements: *83762650
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: activemodel
49
- requirement: &71352230 !ruby/object:Gem::Requirement
49
+ requirement: &83761810 !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: *71352230
57
+ version_requirements: *83761810
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rake
60
- requirement: &71351620 !ruby/object:Gem::Requirement
60
+ requirement: &83759370 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0.9'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *71351620
68
+ version_requirements: *83759370
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
- requirement: &71350940 !ruby/object:Gem::Requirement
71
+ requirement: &83745000 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '2.11'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *71350940
79
+ version_requirements: *83745000
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: fakeweb
82
- requirement: &71350120 !ruby/object:Gem::Requirement
82
+ requirement: &83744610 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ~>
@@ -87,7 +87,7 @@ dependencies:
87
87
  version: '1.3'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *71350120
90
+ version_requirements: *83744610
91
91
  description: Use the Online Scout Manager API (https://www.onlinescoutmanager.co.uk)
92
92
  to retrieve and save data.
93
93
  email: