lodging 0.0.2 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,12 +1,32 @@
1
1
  Feature: Lodging Committee Calculations
2
2
  The lodging model should generate correct committee calculations
3
3
 
4
- Scenario: Magnitude committee from default
4
+ Scenario: Rooms committee from default
5
5
  Given a lodging emitter
6
- When the "magnitude" committee is calculated
6
+ When the "rooms" committee is calculated
7
7
  Then the committee should have used quorum "default"
8
8
  And the conclusion of the committee should be "1"
9
9
 
10
+ Scenario: Nights committee from default
11
+ Given a lodging emitter
12
+ When the "nights" committee is calculated
13
+ Then the committee should have used quorum "default"
14
+ And the conclusion of the committee should be "1"
15
+
16
+ Scenario: State committee from zip code
17
+ Given a lodging emitter
18
+ And a characteristic "zip_code.name" of "94122"
19
+ When the "state" committee is calculated
20
+ Then the committee should have used quorum "from zip code"
21
+ And the conclusion of the committee should have "postal_abbreviation" of "CA"
22
+
23
+ Scenario: Census division committee from state
24
+ Given a lodging emitter
25
+ And a characteristic "state.postal_abbreviation" of "CA"
26
+ When the "census_division" committee is calculated
27
+ Then the committee should have used quorum "from state"
28
+ And the conclusion of the committee should have "number" of "9"
29
+
10
30
  Scenario: Lodging class committee from nothing
11
31
  Given a lodging emitter
12
32
  When the "lodging_class" committee is calculated
@@ -27,6 +47,13 @@ Feature: Lodging Committee Calculations
27
47
  Then the committee should have used quorum "from lodging class"
28
48
  And the conclusion of the committee should be "20000000"
29
49
 
50
+ Scenario: District heat intensity committee from census division
51
+ Given a lodging emitter
52
+ And a characteristic "census_division.number" of "9"
53
+ When the "district_heat_intensity" committee is calculated
54
+ Then the committee should have used quorum "from census division"
55
+ And the conclusion of the committee should be "1000"
56
+
30
57
  Scenario: Electricity intensity committee from nothing
31
58
  Given a lodging emitter
32
59
  When the "lodging_class" committee is calculated
@@ -41,6 +68,13 @@ Feature: Lodging Committee Calculations
41
68
  Then the committee should have used quorum "from lodging class"
42
69
  And the conclusion of the committee should be "10"
43
70
 
71
+ Scenario: Electricity intensity committee from census division
72
+ Given a lodging emitter
73
+ And a characteristic "census_division.number" of "9"
74
+ When the "electricity_intensity" committee is calculated
75
+ Then the committee should have used quorum "from census division"
76
+ And the conclusion of the committee should be "3"
77
+
44
78
  Scenario: Fuel oil intensity committee from nothing
45
79
  Given a lodging emitter
46
80
  When the "lodging_class" committee is calculated
@@ -55,6 +89,13 @@ Feature: Lodging Committee Calculations
55
89
  Then the committee should have used quorum "from lodging class"
56
90
  And the conclusion of the committee should be "1"
57
91
 
92
+ Scenario: Fuel oil intensity committee from census division
93
+ Given a lodging emitter
94
+ And a characteristic "census_division.number" of "9"
95
+ When the "fuel_oil_intensity" committee is calculated
96
+ Then the committee should have used quorum "from census division"
97
+ And the conclusion of the committee should be "2"
98
+
58
99
  Scenario: Natural gas intensity committee from nothing
59
100
  Given a lodging emitter
60
101
  When the "lodging_class" committee is calculated
@@ -69,6 +110,13 @@ Feature: Lodging Committee Calculations
69
110
  Then the committee should have used quorum "from lodging class"
70
111
  And the conclusion of the committee should be "2"
71
112
 
113
+ Scenario: Natural gas intensity committee from census division
114
+ Given a lodging emitter
115
+ And a characteristic "census_division.number" of "9"
116
+ When the "natural_gas_intensity" committee is calculated
117
+ Then the committee should have used quorum "from census division"
118
+ And the conclusion of the committee should be "1"
119
+
72
120
  Scenario: Emission factor committee from nothing
73
121
  Given a lodging emitter
74
122
  When the "lodging_class" committee is calculated
@@ -88,6 +136,16 @@ Feature: Lodging Committee Calculations
88
136
  And the "fuel_oil_intensity" committee is calculated
89
137
  And the "natural_gas_intensity" committee is calculated
90
138
  And the "emission_factor" committee is calculated
91
- And the "emission_factor" committee is calculated
92
139
  Then the committee should have used quorum "from fuel intensities"
93
140
  And the conclusion of the committee should be "22.48991"
141
+
142
+ Scenario: Emission factor committee from census division
143
+ Given a lodging emitter
144
+ And a characteristic "census_division.number" of "9"
145
+ When the "district_heat_intensity" committee is calculated
146
+ And the "electricity_intensity" committee is calculated
147
+ And the "fuel_oil_intensity" committee is calculated
148
+ And the "natural_gas_intensity" committee is calculated
149
+ And the "emission_factor" committee is calculated
150
+ Then the committee should have used quorum "from fuel intensities"
151
+ And the conclusion of the committee should be "8.50002"
@@ -6,8 +6,13 @@ Feature: Lodging Emissions Calculations
6
6
  When emissions are calculated
7
7
  Then the emission value should be within "0.00001" kgs of "11.24496"
8
8
 
9
- Scenario: Calculations starting from magnitude
10
- Given a lodging has "magnitude" of "5"
9
+ Scenario: Calculations starting from rooms
10
+ Given a lodging has "rooms" of "5"
11
+ When emissions are calculated
12
+ Then the emission value should be within "0.00001" kgs of "56.22478"
13
+
14
+ Scenario: Calculations starting from nights
15
+ Given a lodging has "nights" of "5"
11
16
  When emissions are calculated
12
17
  Then the emission value should be within "0.00001" kgs of "56.22478"
13
18
 
@@ -16,8 +21,21 @@ Feature: Lodging Emissions Calculations
16
21
  When emissions are calculated
17
22
  Then the emission value should be within "0.00001" kgs of "22.48991"
18
23
 
19
- Scenario: Calculations starting from lodging class and magnitude
20
- Given a lodging has "lodging_class.name" of "Luxury Hotel"
21
- And it has "magnitude" of "5"
24
+ Scenario: Calculations starting from state
25
+ Given a lodging has "state.postal_abbreviation" of "CA"
26
+ When emissions are calculated
27
+ Then the emission value should be within "0.00001" kgs of "8.50002"
28
+
29
+ Scenario: Calculations starting from rooms, nights, and lodging class
30
+ Given a lodging has "rooms" of "2"
31
+ And it has "nights" of "2"
32
+ And it has "lodging_class.name" of "Luxury Hotel"
33
+ When emissions are calculated
34
+ Then the emission value should be within "0.00001" kgs of "89.95965"
35
+
36
+ Scenario: Calculations starting from rooms, nights, and state
37
+ Given a lodging has "rooms" of "2"
38
+ And it has "nights" of "2"
39
+ And it has "state.postal_abbreviation" of "CA"
22
40
  When emissions are calculated
23
- Then the emission value should be within "0.00001" kgs of "112.44957"
41
+ Then the emission value should be within "0.00001" kgs of "34.00010"
@@ -5,4 +5,4 @@ require 'cucumber'
5
5
  require 'cucumber/formatter/unicode'
6
6
 
7
7
  require 'sniff'
8
- Sniff.init File.join(File.dirname(__FILE__), '..', '..'), :earth => [:hospitality, :residence, :fuel], :cucumber => true
8
+ Sniff.init File.join(File.dirname(__FILE__), '..', '..'), :earth => [:hospitality, :residence, :fuel, :locality], :cucumber => true
@@ -8,8 +8,8 @@ module BrighterPlanet
8
8
  base.extend ::Leap::Subject
9
9
  base.decide :emission, :with => :characteristics do
10
10
  committee :emission do # returns kg CO2e
11
- quorum 'from magnitude and emission factor', :needs => [:magnitude, :emission_factor] do |characteristics|
12
- characteristics[:magnitude] * characteristics[:emission_factor]
11
+ quorum 'from rooms, nights, and emission factor', :needs => [:rooms, :nights, :emission_factor] do |characteristics|
12
+ characteristics[:rooms] * characteristics[:nights] * characteristics[:emission_factor]
13
13
  end
14
14
 
15
15
  quorum 'default' do
@@ -45,24 +45,40 @@ module BrighterPlanet
45
45
  end
46
46
 
47
47
  committee :natural_gas_intensity do # returns cubic metres per room-night
48
+ quorum 'from census division', :needs => :census_division do |characteristics|
49
+ characteristics[:census_division].lodging_building_natural_gas_intensity
50
+ end
51
+
48
52
  quorum 'from lodging class', :needs => :lodging_class do |characteristics|
49
53
  characteristics[:lodging_class].natural_gas_intensity
50
54
  end
51
55
  end
52
56
 
53
57
  committee :fuel_oil_intensity do # returns litres per room-night
58
+ quorum 'from census division', :needs => :census_division do |characteristics|
59
+ characteristics[:census_division].lodging_building_fuel_oil_intensity
60
+ end
61
+
54
62
  quorum 'from lodging class', :needs => :lodging_class do |characteristics|
55
63
  characteristics[:lodging_class].fuel_oil_intensity
56
64
  end
57
65
  end
58
66
 
59
67
  committee :electricity_intensity do # returns kilowatt hours per room-night
68
+ quorum 'from census division', :needs => :census_division do |characteristics|
69
+ characteristics[:census_division].lodging_building_electricity_intensity
70
+ end
71
+
60
72
  quorum 'from lodging class', :needs => :lodging_class do |characteristics|
61
73
  characteristics[:lodging_class].electricity_intensity
62
74
  end
63
75
  end
64
76
 
65
77
  committee :district_heat_intensity do # returns joules per room-night
78
+ quorum 'from census division', :needs => :census_division do |characteristics|
79
+ characteristics[:census_division].lodging_building_district_heat_intensity
80
+ end
81
+
66
82
  quorum 'from lodging class', :needs => :lodging_class do |characteristics|
67
83
  characteristics[:lodging_class].district_heat_intensity
68
84
  end
@@ -74,9 +90,27 @@ module BrighterPlanet
74
90
  end
75
91
  end
76
92
 
77
- committee :magnitude do # return room-nights - couldn't think of anything to call it except 'magnitude'
93
+ committee :census_division do # returns census division
94
+ quorum 'from state', :needs => :state do |characteristics|
95
+ characteristics[:state].census_division
96
+ end
97
+ end
98
+
99
+ committee :state do # returns state
100
+ quorum 'from zip code', :needs => :zip_code do |characteristics|
101
+ characteristics[:zip_code].state
102
+ end
103
+ end
104
+
105
+ committee :nights do # returns nights
106
+ quorum 'default' do
107
+ base.fallback.nights
108
+ end
109
+ end
110
+
111
+ committee :rooms do # return rooms
78
112
  quorum 'default' do
79
- base.fallback.magnitude
113
+ base.fallback.rooms
80
114
  end
81
115
  end
82
116
  end
@@ -6,8 +6,11 @@ module BrighterPlanet
6
6
  def self.included(base)
7
7
  base.send :include, Characterizable
8
8
  base.characterize do
9
- has :lodging_class # e.g. hotel / motel / other
10
- has :magnitude # room-nights
9
+ has :lodging_class
10
+ has :zip_code
11
+ has :state
12
+ has :rooms
13
+ has :nights
11
14
  end
12
15
  base.add_implicit_characteristics
13
16
  end
@@ -6,6 +6,11 @@ module BrighterPlanet
6
6
  def self.included(base)
7
7
  base.data_miner do
8
8
  schema do
9
+ string 'lodging_class_name'
10
+ string 'zip_code_name'
11
+ string 'state_postal_abbreviation'
12
+ integer 'rooms'
13
+ integer 'nights'
9
14
  end
10
15
 
11
16
  process :run_data_miner_on_belongs_to_associations
@@ -3,6 +3,9 @@ require 'sniff/database'
3
3
  Sniff::Database.define_schema do
4
4
  create_table "lodging_records", :force => true do |t|
5
5
  t.string 'lodging_class_name'
6
- t.integer 'magnitude'
6
+ t.string 'zip_code_name'
7
+ t.string 'state_postal_abbreviation'
8
+ t.integer 'rooms'
9
+ t.integer 'nights'
7
10
  end
8
11
  end
@@ -7,7 +7,10 @@ class LodgingRecord < ActiveRecord::Base
7
7
  include Sniff::Emitter
8
8
  include BrighterPlanet::Lodging
9
9
 
10
- belongs_to :lodging_class
10
+ belongs_to :lodging_class, :foreign_key => 'lodging_class_name'
11
+ belongs_to :zip_code, :foreign_key => 'zip_code_name'
12
+ belongs_to :state, :foreign_key => 'state_postal_abbreviation'
11
13
 
12
- falls_back_on :magnitude => 1
14
+ falls_back_on :rooms => 1,
15
+ :nights => 1
13
16
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lodging
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 5
10
+ version: 0.0.5
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-15 00:00:00 -04:00
22
+ date: 2010-09-20 00:00:00 -04:00
23
23
  default_executable:
24
24
  dependencies:
25
25
  - !ruby/object:Gem::Dependency
@@ -157,29 +157,13 @@ dependencies:
157
157
  requirements:
158
158
  - - ~>
159
159
  - !ruby/object:Gem::Version
160
- hash: 19
160
+ hash: 5
161
161
  segments:
162
162
  - 0
163
163
  - 0
164
- - 6
165
- version: 0.0.6
164
+ - 13
165
+ version: 0.0.13
166
166
  requirement: *id009
167
- - !ruby/object:Gem::Dependency
168
- type: :runtime
169
- prerelease: false
170
- name: earth
171
- version_requirements: &id010 !ruby/object:Gem::Requirement
172
- none: false
173
- requirements:
174
- - - ~>
175
- - !ruby/object:Gem::Version
176
- hash: 83
177
- segments:
178
- - 0
179
- - 0
180
- - 38
181
- version: 0.0.38
182
- requirement: *id010
183
167
  description: A software model in Ruby for the greenhouse gas emissions of a lodging
184
168
  email: andy@rossmeissl.net
185
169
  executables: []