osm 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,7 @@
1
+ ## Version 0.6.1
2
+
3
+ * Fixes to adventure badges
4
+
1
5
  ## Version 0.6.0
2
6
 
3
7
  * Badge::Data
@@ -326,9 +326,14 @@ module Osm
326
326
  count = {}
327
327
  requirements.each do |field, data|
328
328
  field = field.split('_')[0]
329
- count[field] ||= 0
330
- next if data.blank? || data[0].downcase.eql?('x')
331
- count[field] += 1
329
+ unless field.eql?('y')
330
+ count[field] ||= 0
331
+ next if data.blank? || data[0].downcase.eql?('x')
332
+ count[field] += 1
333
+ else
334
+ # A total 'section'
335
+ count['a'] = data.to_i
336
+ end
332
337
  end
333
338
  return count
334
339
  end
@@ -344,8 +349,14 @@ module Osm
344
349
  def started?
345
350
  unless badge.type == :staged
346
351
  return false if completed?
347
- requirements.each do |key, value|
348
- return true unless value.blank? || value[0].downcase.eql?('x')
352
+ if badge.osm_key == 'adventure'
353
+ # Badge requires completing a number of activities
354
+ return (requirements['y_01'].to_i > 0)
355
+ else
356
+ # 'Normal' nonstaged badge
357
+ requirements.each do |key, value|
358
+ return true unless value.blank? || value[0].downcase.eql?('x')
359
+ end
349
360
  end
350
361
  else
351
362
  # Staged badge
@@ -373,6 +384,7 @@ module Osm
373
384
  end
374
385
  end
375
386
  else
387
+ # 'Normal' staged badge
376
388
  start_group = 'abcde'[completed] # Requirements use the group letter to denote stage
377
389
  started = 'z'
378
390
  requirements.each do |key, value|
@@ -146,6 +146,7 @@ describe "Badge" do
146
146
  Osm::Badge::Data.new(:badge => Osm::CoreBadge.new, :requirements => {'a_01' => 'Yes', 'a_02' => ''}, :completed => 1).started?.should be_false
147
147
  Osm::Badge::Data.new(:badge => Osm::CoreBadge.new, :requirements => {'a_01' => 'xNo', 'a_02' => ''}).started?.should be_false
148
148
  Osm::Badge::Data.new(:badge => Osm::CoreBadge.new, :requirements => {'a_01' => '', 'a_02' => ''}).started?.should be_false
149
+
149
150
  # Staged Badge
150
151
  Osm::Badge::Data.new(
151
152
  :badge => Osm::StagedBadge.new,
@@ -162,6 +163,30 @@ describe "Badge" do
162
163
  :requirements => {'a_01' => 2, 'y_01' => '2', 'custom_26695' => ''},
163
164
  :completed => 1,
164
165
  ).started?.should be_true
166
+
167
+ # Scout's adventure challenge
168
+ Osm::Badge::Data.new(
169
+ :badge => Osm::ChallengeBadge.new(:osm_key => 'adventure'),
170
+ :requirements => {'y_01' => 5, 'custom_26695' => 'Text'},
171
+ :completed => 0,
172
+ ).started?.should be_true
173
+ Osm::Badge::Data.new(
174
+ :badge => Osm::ChallengeBadge.new(:osm_key => 'adventure'),
175
+ :requirements => {'y_01' => '', 'custom_26695' => ''},
176
+ :completed => 0,
177
+ ).started?.should be_false
178
+
179
+ # Beaver's adventure activity
180
+ Osm::Badge::Data.new(
181
+ :badge => Osm::ActivityBadge.new(:osm_key => 'adventure'),
182
+ :requirements => {'y_01' => 5, 'custom_26695' => 'Text'},
183
+ :completed => 0,
184
+ ).started?.should be_true
185
+ Osm::Badge::Data.new(
186
+ :badge => Osm::ActivityBadge.new(:osm_key => 'adventure'),
187
+ :requirements => {'y_01' => '', 'custom_26695' => ''},
188
+ :completed => 0,
189
+ ).started?.should be_false
165
190
  end
166
191
 
167
192
  it "Works out what stage of the badge has been started" do
data/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Osm
2
- VERSION = "0.6.0"
2
+ VERSION = "0.6.1"
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.6.0
4
+ version: 0.6.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-05 00:00:00.000000000 Z
12
+ date: 2013-04-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport