ski_binding_calculator 0.6.7 → 0.6.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/ski_binding_calculator/calculator.rb +10 -8
- data/ski_binding_calculator.gemspec +2 -1
- data/spec/lib/calculator_spec.rb +14 -0
- metadata +17 -1
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'ski_binding_calculator/config_loader'
|
2
|
+
require 'active_support/core_ext/hash/indifferent_access'
|
2
3
|
|
3
4
|
class SkiBinding::Calculator
|
4
5
|
extend SkiBinding::ConfigLoader
|
@@ -13,17 +14,18 @@ class SkiBinding::Calculator
|
|
13
14
|
|
14
15
|
private
|
15
16
|
def self.prep_attributes(attrs)
|
17
|
+
attrs = attrs.with_indifferent_access
|
16
18
|
hashy = {}
|
17
|
-
hashy[:weight] = attrs[:weight].to_f
|
18
|
-
if hashy[:weight] < 10
|
19
|
+
hashy[:weight] = attrs[:weight].to_f
|
20
|
+
if hashy[:weight] < 10.0
|
19
21
|
raise ArgumentError, "Weight must be at least 10kg"
|
20
22
|
end
|
21
|
-
hashy[:height] = attrs[:height].to_f
|
22
|
-
hashy[:sole_length] = attrs[:sole_length].to_f
|
23
|
-
hashy[:birthday_year] = attrs[:birthday_year].to_i
|
24
|
-
hashy[:birthday_month] = attrs[:birthday_month].to_i
|
25
|
-
hashy[:birthday_day] = attrs[:birthday_day].to_i
|
26
|
-
hashy[:type] = attrs[:type]
|
23
|
+
hashy[:height] = attrs[:height].to_f
|
24
|
+
hashy[:sole_length] = attrs[:sole_length].to_f
|
25
|
+
hashy[:birthday_year] = attrs[:birthday_year].to_i
|
26
|
+
hashy[:birthday_month] = attrs[:birthday_month].to_i
|
27
|
+
hashy[:birthday_day] = attrs[:birthday_day].to_i
|
28
|
+
hashy[:type] = attrs[:type]
|
27
29
|
hashy
|
28
30
|
end
|
29
31
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'ski_binding_calculator'
|
4
|
-
s.version = '0.6.
|
4
|
+
s.version = '0.6.8'
|
5
5
|
s.summary = "Ski Binding Calculator"
|
6
6
|
s.description = "Calculates the z-value according to ISO 11088."
|
7
7
|
s.authors = ["Jonas Ruef, Felix Langenegger"]
|
@@ -14,6 +14,7 @@ Gem::Specification.new do |s|
|
|
14
14
|
s.add_development_dependency "simplecov", "~> 0.7.1"
|
15
15
|
s.add_development_dependency "timecop", "~> 0.6.3"
|
16
16
|
s.add_development_dependency "fuubar", "~> 1.1.1"
|
17
|
+
s.add_development_dependency "activesupport", "~> 4.0.0"
|
17
18
|
|
18
19
|
s.files = Dir.glob("{config,lib,spec}/**/*")
|
19
20
|
s.files += %w(Rakefile ski_binding_calculator.gemspec)
|
data/spec/lib/calculator_spec.rb
CHANGED
@@ -15,6 +15,15 @@ describe SkiBinding::Calculator do
|
|
15
15
|
:birthday_month => "01",
|
16
16
|
:birthday_day => "01" }
|
17
17
|
end
|
18
|
+
subject(:skiers_parameters_string_keys) do
|
19
|
+
{ "type" => "Type2",
|
20
|
+
"weight" => "70",
|
21
|
+
"height" => "170",
|
22
|
+
"sole_length" => "315",
|
23
|
+
"birthday_year" => "1983",
|
24
|
+
"birthday_month" => "01",
|
25
|
+
"birthday_day" => "01" }
|
26
|
+
end
|
18
27
|
subject(:expected_preped) do
|
19
28
|
{ :type => "Type2",
|
20
29
|
:weight => 70.0,
|
@@ -58,6 +67,11 @@ describe SkiBinding::Calculator do
|
|
58
67
|
|
59
68
|
it { calculated_preped.should == expected_preped }
|
60
69
|
|
70
|
+
context "when hash keys are strings" do
|
71
|
+
let(:parameters) { skiers_parameters_string_keys}
|
72
|
+
it { calculated_preped.should == expected_preped }
|
73
|
+
end
|
74
|
+
|
61
75
|
context "when weight < 10kg" do
|
62
76
|
let(:parameters) do
|
63
77
|
skiers_parameters[:weight] = 9
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ski_binding_calculator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -91,6 +91,22 @@ dependencies:
|
|
91
91
|
- - ~>
|
92
92
|
- !ruby/object:Gem::Version
|
93
93
|
version: 1.1.1
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: activesupport
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ~>
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: 4.0.0
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 4.0.0
|
94
110
|
description: Calculates the z-value according to ISO 11088.
|
95
111
|
email: support@fadendaten.ch
|
96
112
|
executables: []
|