osm 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +4 -0
- data/lib/osm.rb +10 -0
- data/lib/osm/api.rb +5 -5
- data/lib/osm/due_badges.rb +5 -5
- data/lib/osm/role.rb +1 -1
- data/lib/osm/section.rb +6 -6
- data/version.rb +1 -1
- metadata +13 -14
data/CHANGELOG.md
CHANGED
data/lib/osm.rb
CHANGED
@@ -68,4 +68,14 @@ module Osm
|
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
71
|
+
def self.symbolize_hash(hash_in)
|
72
|
+
raise ArgumentError.new('You did not pass in a hash') unless hash_in.is_a?(Hash)
|
73
|
+
|
74
|
+
hash_out = {}
|
75
|
+
hash_in.each do |key, value|
|
76
|
+
hash_out[key.to_sym] = value
|
77
|
+
end
|
78
|
+
hash_out
|
79
|
+
end
|
80
|
+
|
71
81
|
end
|
data/lib/osm/api.rb
CHANGED
@@ -489,10 +489,10 @@ module Osm
|
|
489
489
|
|
490
490
|
data = perform_query("users.php?action=registerStructure§ionid=#{section_id}&termid=#{term_id}", api_data)
|
491
491
|
|
492
|
-
data.
|
493
|
-
item
|
494
|
-
item[:rows].
|
495
|
-
row
|
492
|
+
data.each_with_index do |item, item_index|
|
493
|
+
data[item_index] = item = Osm::symbolize_hash(item)
|
494
|
+
item[:rows].each_with_index do |row, row_index|
|
495
|
+
item[:rows][row_index] = row = Osm::symbolize_hash(row)
|
496
496
|
end
|
497
497
|
end
|
498
498
|
self.user_can_access :register, section_id, api_data
|
@@ -521,7 +521,7 @@ module Osm
|
|
521
521
|
|
522
522
|
data = data['items']
|
523
523
|
data.each do |item|
|
524
|
-
item
|
524
|
+
item = Osm::symbolize_hash(item)
|
525
525
|
item[:scoutid] = item[:scoutid].to_i
|
526
526
|
item[:sectionid] = item[:sectionid].to_i
|
527
527
|
item[:patrolid] = item[:patrolid].to_i
|
data/lib/osm/due_badges.rb
CHANGED
@@ -9,18 +9,18 @@ module Osm
|
|
9
9
|
def initialize(data)
|
10
10
|
data = {} unless data.is_a?(Hash)
|
11
11
|
|
12
|
-
@pending = (data['pending'] || {})
|
13
|
-
@descriptions = (data['description'] || {})
|
12
|
+
@pending = Osm::symbolize_hash(data['pending'] || {})
|
13
|
+
@descriptions = Osm::symbolize_hash(data['description'] || {})
|
14
14
|
|
15
15
|
@pending.each_key do |key|
|
16
|
-
@pending[key].
|
17
|
-
item
|
16
|
+
@pending[key].each_with_index do |item, index|
|
17
|
+
@pending[key][index] = item = Osm::symbolize_hash(item)
|
18
18
|
item[:sid] = item[:sid].to_i
|
19
19
|
item[:completed] = item[:completed].to_i
|
20
20
|
end
|
21
21
|
end
|
22
22
|
@descriptions.each_key do |key|
|
23
|
-
@descriptions[key]
|
23
|
+
@descriptions[key] = Osm::symbolize_hash(@descriptions[key])
|
24
24
|
@descriptions[key][:section] = @descriptions[key][:section].to_sym
|
25
25
|
@descriptions[key][:type] = @descriptions[key][:type].to_sym
|
26
26
|
end
|
data/lib/osm/role.rb
CHANGED
@@ -12,7 +12,7 @@ module Osm
|
|
12
12
|
@group_id = Osm::to_i_or_nil(data['groupid'])
|
13
13
|
@group_normalized = Osm::to_i_or_nil(data['groupNormalised'])
|
14
14
|
@default = data['isDefault'].eql?('1') ? true : false
|
15
|
-
@permissions = (data['permissions'] || {})
|
15
|
+
@permissions = Osm::symbolize_hash(data['permissions'] || {})
|
16
16
|
|
17
17
|
# Convert permission values to a number
|
18
18
|
@permissions.each_key do |key|
|
data/lib/osm/section.rb
CHANGED
@@ -20,10 +20,10 @@ module Osm
|
|
20
20
|
@has_badge_records = data['hasUsedBadgeRecords'].eql?('1') ? true : false
|
21
21
|
@has_programme = data['hasProgramme']
|
22
22
|
@wizard = (data['wizard'] || '').downcase.eql?('true') ? true : false
|
23
|
-
@column_names = (data['columnNames'] || {})
|
24
|
-
@fields = (data['fields'] || {})
|
25
|
-
@intouch_fields = (data['intouch'] || {})
|
26
|
-
@mobile_fields = (data['mobFields'] || {})
|
23
|
+
@column_names = Osm::symbolize_hash(data['columnNames'] || {})
|
24
|
+
@fields = Osm::symbolize_hash(data['fields'] || {})
|
25
|
+
@intouch_fields = Osm::symbolize_hash(data['intouch'] || {})
|
26
|
+
@mobile_fields = Osm::symbolize_hash(data['mobFields'] || {})
|
27
27
|
@extra_records = data['extraRecords'] || []
|
28
28
|
@role = role
|
29
29
|
|
@@ -32,9 +32,9 @@ module Osm
|
|
32
32
|
# Expect item to be: {:name=>String, :extraid=>FixNum}
|
33
33
|
# Sometimes get item as: [String, {"name"=>String, "extraid"=>FixNum}]
|
34
34
|
if item.is_a?(Array)
|
35
|
-
item = item[1]
|
35
|
+
item = Osm::symbolize_hash(item[1])
|
36
36
|
else
|
37
|
-
item
|
37
|
+
item = Osm::symbolize_hash(item)
|
38
38
|
end
|
39
39
|
end
|
40
40
|
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.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-07-31 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
|
-
requirement: &
|
16
|
+
requirement: &74085370 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 3.2.5
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *74085370
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: activesupport
|
27
|
-
requirement: &
|
27
|
+
requirement: &74084650 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '3.2'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *74084650
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: httparty
|
38
|
-
requirement: &
|
38
|
+
requirement: &74084280 !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: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *74084280
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rake
|
49
|
-
requirement: &
|
49
|
+
requirement: &74083800 !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: *
|
57
|
+
version_requirements: *74083800
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rspec
|
60
|
-
requirement: &
|
60
|
+
requirement: &74083320 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *74083320
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: fakeweb
|
71
|
-
requirement: &
|
71
|
+
requirement: &74061350 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,7 +76,7 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *74061350
|
80
80
|
description: Use the Online Scout Manager API (https://www.onlinescoutmanager.co.uk)
|
81
81
|
to retrieve and save data.
|
82
82
|
email:
|
@@ -90,7 +90,6 @@ files:
|
|
90
90
|
- .travis.yml
|
91
91
|
- CHANGELOG.md
|
92
92
|
- Gemfile
|
93
|
-
- Gemfile.lock
|
94
93
|
- LICENSE.rdoc
|
95
94
|
- README.md
|
96
95
|
- Rakefile
|