diet 0.0.17 → 0.0.18

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.
@@ -0,0 +1,20 @@
1
+ module BrighterPlanet
2
+ module Diet
3
+ module Fallback
4
+ def self.included(base)
5
+ base.falls_back_on :size => 2150, # kcal https://brighterplanet.sifterapp.com/projects/30/issues/456
6
+ :red_meat_share => 0.0958, # https://brighterplanet.sifterapp.com/projects/30/issues/654/comments
7
+ :poultry_share => 0.0416,
8
+ :fish_share => 0.0059,
9
+ :eggs_share => 0.0098,
10
+ :nuts_share => 0.0209,
11
+ :dairy_share => 0.1116,
12
+ :cereals_and_grains_share => 0.2453,
13
+ :fruit_share => 0.0367,
14
+ :vegetables_share => 0.0514,
15
+ :oils_and_sugars_share => 0.3811
16
+ end
17
+ end
18
+ end
19
+ end
20
+
@@ -0,0 +1,9 @@
1
+ module BrighterPlanet
2
+ module Diet
3
+ module Relationships
4
+ def self.included(target)
5
+ target.belongs_to :diet_class
6
+ end
7
+ end
8
+ end
9
+ end
@@ -3,37 +3,4 @@ require 'diet'
3
3
  class DietRecord < ActiveRecord::Base
4
4
  include Sniff::Emitter
5
5
  include BrighterPlanet::Diet
6
- belongs_to :diet_class
7
-
8
- falls_back_on :size => 2150, # kcal https://brighterplanet.sifterapp.com/projects/30/issues/456
9
- :red_meat_share => 0.0958, # https://brighterplanet.sifterapp.com/projects/30/issues/654/comments
10
- :poultry_share => 0.0416,
11
- :fish_share => 0.0059,
12
- :eggs_share => 0.0098,
13
- :nuts_share => 0.0209,
14
- :dairy_share => 0.1116,
15
- :cereals_and_grains_share => 0.2453,
16
- :fruit_share => 0.0367,
17
- :vegetables_share => 0.0514,
18
- :oils_and_sugars_share => 0.3811
19
-
20
- def active?
21
- end_date.nil? or end_date > Time.zone.today
22
- end
23
-
24
- def organic?
25
- conventionality and conventionality < 0.5
26
- end
27
-
28
- def local?
29
- proximity and proximity >= 0.5
30
- end
31
-
32
- def share_or_fallback(group)
33
- [ self, diet_class, self.class.fallback ].compact.grab { |i| i.send "#{group}_share" }
34
- end
35
-
36
- def size_or_fallback
37
- size || self.class.fallback.size
38
- end
39
6
  end
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: 61
4
+ hash: 59
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 17
10
- version: 0.0.17
9
+ - 18
10
+ version: 0.0.18
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-12-02 00:00:00 -05:00
22
+ date: 2010-12-07 00:00:00 -06:00
23
23
  default_executable:
24
24
  dependencies:
25
25
  - !ruby/object:Gem::Dependency
@@ -171,6 +171,8 @@ files:
171
171
  - lib/diet/carbon_model.rb
172
172
  - lib/diet/characterization.rb
173
173
  - lib/diet/data.rb
174
+ - lib/diet/fallback.rb
175
+ - lib/diet/relationships.rb
174
176
  - lib/diet/summarization.rb
175
177
  - lib/test_support/diet_record.rb
176
178
  - features/support/env.rb