diet 0.0.14 → 0.0.15

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.
@@ -1,7 +1,7 @@
1
1
  Feature: Diet Committee Calculations
2
2
  The diet model should generate correct committee calculations
3
3
 
4
- Scenario Outline: Standard Calculations for diet classes
4
+ Scenario Outline: Intensity committee from diet class
5
5
  Given a diet emitter
6
6
  And a characteristic "diet_class.name" of "<diet_class>"
7
7
  When the "intensity" committee is calculated
@@ -11,3 +11,22 @@
11
11
  | standard | 3.78 |
12
12
  | vegan | 2.57 |
13
13
  | vegetarian | 3.01 |
14
+
15
+ Scenario Outline: Intensity committee from food groups
16
+ Given a diet emitter
17
+ And a characteristic "red_meat_share" of "<meat>"
18
+ And a characteristic "poultry_share" of "<poultry>"
19
+ And a characteristic "fish_share" of "<fish>"
20
+ And a characteristic "eggs_share" of "<eggs>"
21
+ And a characteristic "nuts_share" of "<nuts>"
22
+ And a characteristic "dairy_share" of "<dairy>"
23
+ And a characteristic "cereals_and_grains_share" of "<cereals>"
24
+ And a characteristic "fruit_share" of "<fruit>"
25
+ And a characteristic "vegetables_share" of "<veg>"
26
+ And a characteristic "oils_and_sugars_share" of "<oil>"
27
+ When the "intensity" committee is calculated
28
+ Then the committee should have used quorum "from food groups"
29
+ And the conclusion of the committee should be "<intensity>"
30
+ Examples:
31
+ | meat | poultry | fish | eggs | nuts | dairy | cereals | fruit | veg | oil | intensity |
32
+ | 0.1 | 0.1 | 0.1 | 0.1 | 0.1 | 0.1 | 0.1 | 0.1 | 0.1 | 0.1 | 5 |
@@ -3,15 +3,5 @@ require 'emitter'
3
3
  module BrighterPlanet
4
4
  module Diet
5
5
  extend BrighterPlanet::Emitter
6
-
7
- def self.diet_model
8
- if Object.const_defined? 'Diet'
9
- ::Diet
10
- elsif Object.const_defined? 'DietRecord'
11
- DietRecord
12
- else
13
- raise 'There is no diet model'
14
- end
15
- end
16
6
  end
17
7
  end
@@ -15,8 +15,8 @@ module BrighterPlanet
15
15
 
16
16
  committee :intensity do # returns grams CO2 / kcal food
17
17
  quorum 'from food groups', :needs => [:red_meat_share, :poultry_share, :fish_share, :eggs_share, :nuts_share, :dairy_share, :cereals_and_grains_share, :fruit_share, :vegetables_share, :oils_and_sugars_share] do |characteristics|
18
- [:red_meat_share, :poultry_share, :fish_share, :eggs_share, :nuts_share, :dairy_share, :cereals_and_grains_share, :fruit_share, :vegetables_share, :oils_and_sugars_share].sum do |group|
19
- characteristics[group] * FoodGroup[group].intensity
18
+ [:red_meat, :poultry, :fish, :eggs, :nuts, :dairy, :cereals_and_grains, :fruit, :vegetables, :oils_and_sugars].sum do |group|
19
+ characteristics["#{group}_share".to_sym].to_f * FoodGroup[group].intensity.to_f
20
20
  end
21
21
  end
22
22
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: diet
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 1
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 14
10
- version: 0.0.14
9
+ - 15
10
+ version: 0.0.15
11
11
  platform: ruby
12
12
  authors:
13
13
  - Andy Rossmeissl
@@ -19,7 +19,7 @@ autorequire:
19
19
  bindir: bin
20
20
  cert_chain: []
21
21
 
22
- date: 2010-09-22 00:00:00 -04:00
22
+ date: 2010-09-27 00:00:00 -04:00
23
23
  default_executable:
24
24
  dependencies:
25
25
  - !ruby/object:Gem::Dependency
@@ -141,12 +141,12 @@ dependencies:
141
141
  requirements:
142
142
  - - ~>
143
143
  - !ruby/object:Gem::Version
144
- hash: 3
144
+ hash: 23
145
145
  segments:
146
146
  - 0
147
- - 1
148
- - 12
149
- version: 0.1.12
147
+ - 2
148
+ - 0
149
+ version: 0.2.0
150
150
  requirement: *id008
151
151
  - !ruby/object:Gem::Dependency
152
152
  type: :runtime
@@ -181,7 +181,6 @@ files:
181
181
  - lib/diet/characterization.rb
182
182
  - lib/diet/data.rb
183
183
  - lib/diet/summarization.rb
184
- - lib/test_support/db/schema.rb
185
184
  - lib/test_support/diet_record.rb
186
185
  - features/support/env.rb
187
186
  - features/diet_committees.feature
@@ -224,5 +223,4 @@ test_files:
224
223
  - features/support/env.rb
225
224
  - features/diet_committees.feature
226
225
  - features/diet_emissions.feature
227
- - lib/test_support/db/schema.rb
228
226
  - lib/test_support/diet_record.rb
@@ -1,27 +0,0 @@
1
- require 'sniff/database'
2
-
3
- Sniff::Database.define_schema do
4
- create_table "diet_records", :force => true do |t|
5
- t.string "name"
6
- t.integer "profile_id"
7
- t.integer "diet_class_id"
8
- t.float "proximity"
9
- t.float "conventionality"
10
- t.integer "size"
11
- t.float "intensity"
12
- t.datetime "created_at"
13
- t.datetime "updated_at"
14
- t.float "red_meat_share"
15
- t.float "poultry_share"
16
- t.float "fish_share"
17
- t.float "eggs_share"
18
- t.float "nuts_share"
19
- t.float "dairy_share"
20
- t.float "cereals_and_grains_share"
21
- t.float "fruit_share"
22
- t.float "vegetables_share"
23
- t.float "oils_and_sugars_share"
24
- t.date "start_date"
25
- t.date "end_date"
26
- end
27
- end