lodging 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,2 +1,93 @@
1
1
  Feature: Lodging Committee Calculations
2
2
  The lodging model should generate correct committee calculations
3
+
4
+ Scenario: Magnitude committee from default
5
+ Given a lodging emitter
6
+ When the "magnitude" committee is calculated
7
+ Then the committee should have used quorum "default"
8
+ And the conclusion of the committee should be "1"
9
+
10
+ Scenario: Lodging class committee from nothing
11
+ Given a lodging emitter
12
+ When the "lodging_class" committee is calculated
13
+ Then the committee should have used quorum "default"
14
+ And the conclusion of the committee should have "name" of "Average"
15
+
16
+ Scenario: District heat intensity committee from nothing
17
+ Given a lodging emitter
18
+ When the "lodging_class" committee is calculated
19
+ And the "district_heat_intensity" committee is calculated
20
+ Then the committee should have used quorum "from lodging class"
21
+ And the conclusion of the committee should be "10000000"
22
+
23
+ Scenario: District heat intensity committee from lodging class
24
+ Given a lodging emitter
25
+ And a characteristic "lodging_class.name" of "Luxury Hotel"
26
+ When the "district_heat_intensity" committee is calculated
27
+ Then the committee should have used quorum "from lodging class"
28
+ And the conclusion of the committee should be "20000000"
29
+
30
+ Scenario: Electricity intensity committee from nothing
31
+ Given a lodging emitter
32
+ When the "lodging_class" committee is calculated
33
+ And the "electricity_intensity" committee is calculated
34
+ Then the committee should have used quorum "from lodging class"
35
+ And the conclusion of the committee should be "5"
36
+
37
+ Scenario: Electricity intensity committee from lodging class
38
+ Given a lodging emitter
39
+ And a characteristic "lodging_class.name" of "Luxury Hotel"
40
+ When the "electricity_intensity" committee is calculated
41
+ Then the committee should have used quorum "from lodging class"
42
+ And the conclusion of the committee should be "10"
43
+
44
+ Scenario: Fuel oil intensity committee from nothing
45
+ Given a lodging emitter
46
+ When the "lodging_class" committee is calculated
47
+ And the "fuel_oil_intensity" committee is calculated
48
+ Then the committee should have used quorum "from lodging class"
49
+ And the conclusion of the committee should be "0.5"
50
+
51
+ Scenario: Fuel oil intensity committee from lodging class
52
+ Given a lodging emitter
53
+ And a characteristic "lodging_class.name" of "Luxury Hotel"
54
+ When the "fuel_oil_intensity" committee is calculated
55
+ Then the committee should have used quorum "from lodging class"
56
+ And the conclusion of the committee should be "1"
57
+
58
+ Scenario: Natural gas intensity committee from nothing
59
+ Given a lodging emitter
60
+ When the "lodging_class" committee is calculated
61
+ And the "natural_gas_intensity" committee is calculated
62
+ Then the committee should have used quorum "from lodging class"
63
+ And the conclusion of the committee should be "1"
64
+
65
+ Scenario: Natural gas intensity committee from lodging class
66
+ Given a lodging emitter
67
+ And a characteristic "lodging_class.name" of "Luxury Hotel"
68
+ When the "natural_gas_intensity" committee is calculated
69
+ Then the committee should have used quorum "from lodging class"
70
+ And the conclusion of the committee should be "2"
71
+
72
+ Scenario: Emission factor committee from nothing
73
+ Given a lodging emitter
74
+ When the "lodging_class" committee is calculated
75
+ And the "district_heat_intensity" committee is calculated
76
+ And the "electricity_intensity" committee is calculated
77
+ And the "fuel_oil_intensity" committee is calculated
78
+ And the "natural_gas_intensity" committee is calculated
79
+ And the "emission_factor" committee is calculated
80
+ Then the committee should have used quorum "from fuel intensities"
81
+ And the conclusion of the committee should be "11.24496"
82
+
83
+ Scenario: Emission factor committee from lodging class
84
+ Given a lodging emitter
85
+ And a characteristic "lodging_class.name" of "Luxury Hotel"
86
+ When the "district_heat_intensity" committee is calculated
87
+ And the "electricity_intensity" committee is calculated
88
+ And the "fuel_oil_intensity" committee is calculated
89
+ And the "natural_gas_intensity" committee is calculated
90
+ And the "emission_factor" committee is calculated
91
+ And the "emission_factor" committee is calculated
92
+ Then the committee should have used quorum "from fuel intensities"
93
+ And the conclusion of the committee should be "22.48991"
@@ -1,7 +1,23 @@
1
1
  Feature: Lodging Emissions Calculations
2
2
  The lodging model should generate correct emission calculations
3
3
 
4
- Scenario: Standard Calculations for lodgings
5
- Given a lodging
4
+ Scenario: Calculations starting from nothing
5
+ Given a lodging has nothing
6
6
  When emissions are calculated
7
- Then the emission value should be 1
7
+ Then the emission value should be within "0.00001" kgs of "11.24496"
8
+
9
+ Scenario: Calculations starting from magnitude
10
+ Given a lodging has "magnitude" 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 lodging class
15
+ Given a lodging has "lodging_class.name" of "Luxury Hotel"
16
+ When emissions are calculated
17
+ Then the emission value should be within "0.00001" kgs of "22.48991"
18
+
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"
22
+ When emissions are calculated
23
+ Then the emission value should be within "0.00001" kgs of "112.44957"
@@ -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 => :automobile
8
+ Sniff.init File.join(File.dirname(__FILE__), '..', '..'), :earth => [:hospitality, :residence, :fuel], :cucumber => true
@@ -7,9 +7,76 @@ module BrighterPlanet
7
7
  def self.included(base)
8
8
  base.extend ::Leap::Subject
9
9
  base.decide :emission, :with => :characteristics do
10
- committee :emission do # returns kg CO2
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]
13
+ end
14
+
15
+ quorum 'default' do
16
+ raise "The emission committee's default quorum should never be called."
17
+ end
18
+ end
19
+
20
+ committee :emission_factor do # returns kg CO2e per room night
21
+ quorum 'from fuel intensities', :needs => [:natural_gas_intensity, :fuel_oil_intensity, :electricity_intensity, :district_heat_intensity] do |characteristics|
22
+ natural_gas = FuelType.find_by_name "Commercial Natural Gas"
23
+ fuel_oil = FuelType.find_by_name "Distillate Fuel Oil 2"
24
+ electricity = ResidenceFuelType.find_by_name "electricity"
25
+
26
+ # FIXME TODO won't need this once we convert emission factors to co2 / unit energy
27
+ # kg / J kg / cubic m J / cubic m
28
+ natural_gas_energy_ef = natural_gas.emission_factor / 38_339_000
29
+
30
+ # FIXME TODO won't need this once we convert emission factors to co2 / unit energy
31
+ # kg / J kg / l J / l
32
+ fuel_oil_energy_ef = fuel_oil.emission_factor / 38_655_000
33
+
34
+ # based on CA-CP calculator
35
+ # assume district heat is 50% natural gas 50% distillate fuel
36
+ # assume natural gas boilers 81.7% efficient; fuel oil boilers 84.6% efficient
37
+ # assume 5% transmission loss
38
+ district_heat_emission_factor = (((natural_gas_energy_ef / 0.817) / 2) + ((fuel_oil_energy_ef / 0.846) / 2)) / 0.95
39
+
40
+ (characteristics[:natural_gas_intensity] * natural_gas.emission_factor) +
41
+ (characteristics[:fuel_oil_intensity] * fuel_oil.emission_factor) +
42
+ (characteristics[:electricity_intensity] * electricity.emission_factor) +
43
+ (characteristics[:district_heat_intensity] * district_heat_emission_factor)
44
+ end
45
+ end
46
+
47
+ committee :natural_gas_intensity do # returns cubic metres per room-night
48
+ quorum 'from lodging class', :needs => :lodging_class do |characteristics|
49
+ characteristics[:lodging_class].natural_gas_intensity
50
+ end
51
+ end
52
+
53
+ committee :fuel_oil_intensity do # returns litres per room-night
54
+ quorum 'from lodging class', :needs => :lodging_class do |characteristics|
55
+ characteristics[:lodging_class].fuel_oil_intensity
56
+ end
57
+ end
58
+
59
+ committee :electricity_intensity do # returns kilowatt hours per room-night
60
+ quorum 'from lodging class', :needs => :lodging_class do |characteristics|
61
+ characteristics[:lodging_class].electricity_intensity
62
+ end
63
+ end
64
+
65
+ committee :district_heat_intensity do # returns joules per room-night
66
+ quorum 'from lodging class', :needs => :lodging_class do |characteristics|
67
+ characteristics[:lodging_class].district_heat_intensity
68
+ end
69
+ end
70
+
71
+ committee :lodging_class do # returns the type of lodging
72
+ quorum 'default' do
73
+ LodgingClass.find_by_name 'Average'
74
+ end
75
+ end
76
+
77
+ committee :magnitude do # return room-nights - couldn't think of anything to call it except 'magnitude'
11
78
  quorum 'default' do
12
- 1.0
79
+ base.fallback.magnitude
13
80
  end
14
81
  end
15
82
  end
@@ -6,6 +6,8 @@ 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
11
  end
10
12
  base.add_implicit_characteristics
11
13
  end
@@ -0,0 +1,8 @@
1
+ require 'sniff/database'
2
+
3
+ Sniff::Database.define_schema do
4
+ create_table "lodging_records", :force => true do |t|
5
+ t.string 'lodging_class_name'
6
+ t.integer 'magnitude'
7
+ end
8
+ end
@@ -0,0 +1,13 @@
1
+ require 'active_record'
2
+ require 'falls_back_on'
3
+ require 'lodging'
4
+ require 'sniff'
5
+
6
+ class LodgingRecord < ActiveRecord::Base
7
+ include Sniff::Emitter
8
+ include BrighterPlanet::Lodging
9
+
10
+ belongs_to :lodging_class
11
+
12
+ falls_back_on :magnitude => 1
13
+ end
metadata CHANGED
@@ -1,27 +1,96 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lodging
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Andy Rossmeissl
14
+ - Seamus Abshere
15
+ - Ian Hough
16
+ - Matt Kling
17
+ - Derek Kastner
14
18
  autorequire:
15
19
  bindir: bin
16
20
  cert_chain: []
17
21
 
18
- date: 2010-09-09 00:00:00 -04:00
22
+ date: 2010-09-15 00:00:00 -04:00
19
23
  default_executable:
20
24
  dependencies:
21
25
  - !ruby/object:Gem::Dependency
22
- name: thoughtbot-shoulda
26
+ type: :development
27
+ prerelease: false
28
+ name: activerecord
29
+ version_requirements: &id001 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ~>
33
+ - !ruby/object:Gem::Version
34
+ hash: 7
35
+ segments:
36
+ - 3
37
+ - 0
38
+ - 0
39
+ version: 3.0.0
40
+ requirement: *id001
41
+ - !ruby/object:Gem::Dependency
42
+ type: :development
23
43
  prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
44
+ name: bundler
45
+ version_requirements: &id002 !ruby/object:Gem::Requirement
46
+ none: false
47
+ requirements:
48
+ - - ~>
49
+ - !ruby/object:Gem::Version
50
+ hash: 23
51
+ segments:
52
+ - 1
53
+ - 0
54
+ - 0
55
+ version: 1.0.0
56
+ requirement: *id002
57
+ - !ruby/object:Gem::Dependency
58
+ type: :development
59
+ prerelease: false
60
+ name: cucumber
61
+ version_requirements: &id003 !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ~>
65
+ - !ruby/object:Gem::Version
66
+ hash: 57
67
+ segments:
68
+ - 0
69
+ - 8
70
+ - 3
71
+ version: 0.8.3
72
+ requirement: *id003
73
+ - !ruby/object:Gem::Dependency
74
+ type: :development
75
+ prerelease: false
76
+ name: jeweler
77
+ version_requirements: &id004 !ruby/object:Gem::Requirement
78
+ none: false
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ hash: 7
83
+ segments:
84
+ - 1
85
+ - 4
86
+ - 0
87
+ version: 1.4.0
88
+ requirement: *id004
89
+ - !ruby/object:Gem::Dependency
90
+ type: :development
91
+ prerelease: false
92
+ name: rake
93
+ version_requirements: &id005 !ruby/object:Gem::Requirement
25
94
  none: false
26
95
  requirements:
27
96
  - - ">="
@@ -30,8 +99,87 @@ dependencies:
30
99
  segments:
31
100
  - 0
32
101
  version: "0"
102
+ requirement: *id005
103
+ - !ruby/object:Gem::Dependency
33
104
  type: :development
34
- version_requirements: *id001
105
+ prerelease: false
106
+ name: rdoc
107
+ version_requirements: &id006 !ruby/object:Gem::Requirement
108
+ none: false
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ hash: 3
113
+ segments:
114
+ - 0
115
+ version: "0"
116
+ requirement: *id006
117
+ - !ruby/object:Gem::Dependency
118
+ type: :development
119
+ prerelease: false
120
+ name: rspec
121
+ version_requirements: &id007 !ruby/object:Gem::Requirement
122
+ none: false
123
+ requirements:
124
+ - - ~>
125
+ - !ruby/object:Gem::Version
126
+ hash: 62196417
127
+ segments:
128
+ - 2
129
+ - 0
130
+ - 0
131
+ - beta
132
+ - 17
133
+ version: 2.0.0.beta.17
134
+ requirement: *id007
135
+ - !ruby/object:Gem::Dependency
136
+ type: :development
137
+ prerelease: false
138
+ name: sniff
139
+ version_requirements: &id008 !ruby/object:Gem::Requirement
140
+ none: false
141
+ requirements:
142
+ - - ~>
143
+ - !ruby/object:Gem::Version
144
+ hash: 3
145
+ segments:
146
+ - 0
147
+ - 1
148
+ - 12
149
+ version: 0.1.12
150
+ requirement: *id008
151
+ - !ruby/object:Gem::Dependency
152
+ type: :runtime
153
+ prerelease: false
154
+ name: emitter
155
+ version_requirements: &id009 !ruby/object:Gem::Requirement
156
+ none: false
157
+ requirements:
158
+ - - ~>
159
+ - !ruby/object:Gem::Version
160
+ hash: 19
161
+ segments:
162
+ - 0
163
+ - 0
164
+ - 6
165
+ version: 0.0.6
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
35
183
  description: A software model in Ruby for the greenhouse gas emissions of a lodging
36
184
  email: andy@rossmeissl.net
37
185
  executables: []
@@ -42,24 +190,18 @@ extra_rdoc_files:
42
190
  - LICENSE
43
191
  - README.rdoc
44
192
  files:
45
- - .document
46
- - .gitignore
47
- - Gemfile
48
- - Gemfile.lock
49
193
  - LICENSE
50
194
  - README.rdoc
51
- - Rakefile
52
- - VERSION
53
- - dot.rvmrc
54
- - features/lodging_committees.feature
55
- - features/lodging_emissions.feature
56
- - features/support/env.rb
57
195
  - lib/lodging.rb
58
196
  - lib/lodging/carbon_model.rb
59
197
  - lib/lodging/characterization.rb
60
198
  - lib/lodging/data.rb
61
199
  - lib/lodging/summarization.rb
62
- - lodging.gemspec
200
+ - lib/test_support/db/schema.rb
201
+ - lib/test_support/lodging_record.rb
202
+ - features/support/env.rb
203
+ - features/lodging_committees.feature
204
+ - features/lodging_emissions.feature
63
205
  has_rdoc: true
64
206
  homepage: http://github.com/brighterplanet/lodging
65
207
  licenses: []
@@ -94,5 +236,9 @@ rubygems_version: 1.3.7
94
236
  signing_key:
95
237
  specification_version: 3
96
238
  summary: A carbon model
97
- test_files: []
98
-
239
+ test_files:
240
+ - features/support/env.rb
241
+ - features/lodging_committees.feature
242
+ - features/lodging_emissions.feature
243
+ - lib/test_support/db/schema.rb
244
+ - lib/test_support/lodging_record.rb
data/.document DELETED
@@ -1,5 +0,0 @@
1
- README.rdoc
2
- lib/**/*.rb
3
- bin/*
4
- features/**/*.feature
5
- LICENSE
data/.gitignore DELETED
@@ -1,21 +0,0 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## PROJECT::GENERAL
17
- coverage
18
- rdoc
19
- pkg
20
-
21
- ## PROJECT::SPECIFIC
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- gem 'emitter', :path => ENV['LOCAL_EMITTER'] if ENV['LOCAL_EMITTER']
2
- source :rubygems
3
-
4
- gemspec :path => '.'
data/Gemfile.lock DELETED
@@ -1,16 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- lodging (0.0.0)
5
-
6
- GEM
7
- remote: http://rubygems.org/
8
- specs:
9
- thoughtbot-shoulda (2.11.1)
10
-
11
- PLATFORMS
12
- ruby
13
-
14
- DEPENDENCIES
15
- lodging!
16
- thoughtbot-shoulda
data/Rakefile DELETED
@@ -1,53 +0,0 @@
1
- require 'rubygems'
2
- require 'rake'
3
-
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "lodging"
8
- gem.summary = %Q{A carbon model}
9
- gem.description = %Q{A software model in Ruby for the greenhouse gas emissions of a lodging}
10
- gem.email = "andy@rossmeissl.net"
11
- gem.homepage = "http://github.com/brighterplanet/lodging"
12
- gem.authors = ["Andy Rossmeissl"]
13
- gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
14
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
- end
16
- Jeweler::GemcutterTasks.new
17
- rescue LoadError
18
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
19
- end
20
-
21
- require 'rake/testtask'
22
- Rake::TestTask.new(:test) do |test|
23
- test.libs << 'lib' << 'test'
24
- test.pattern = 'test/**/test_*.rb'
25
- test.verbose = true
26
- end
27
-
28
- begin
29
- require 'rcov/rcovtask'
30
- Rcov::RcovTask.new do |test|
31
- test.libs << 'test'
32
- test.pattern = 'test/**/test_*.rb'
33
- test.verbose = true
34
- end
35
- rescue LoadError
36
- task :rcov do
37
- abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
38
- end
39
- end
40
-
41
- task :test => :check_dependencies
42
-
43
- task :default => :test
44
-
45
- require 'rake/rdoctask'
46
- Rake::RDocTask.new do |rdoc|
47
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
48
-
49
- rdoc.rdoc_dir = 'rdoc'
50
- rdoc.title = "lodging #{version}"
51
- rdoc.rdoc_files.include('README*')
52
- rdoc.rdoc_files.include('lib/**/*.rb')
53
- end
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.0.1
data/dot.rvmrc DELETED
@@ -1,9 +0,0 @@
1
- rvm 1.8.7
2
- project=`basename \`pwd\``
3
- if rvm gemset list | grep $project
4
- then
5
- rvm 1.8.7@$project
6
- else
7
- rvm gemset create $project
8
- rvm gemset use $project
9
- fi
data/lodging.gemspec DELETED
@@ -1,58 +0,0 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
- # -*- encoding: utf-8 -*-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = %q{lodging}
8
- s.version = "0.0.1"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Andy Rossmeissl"]
12
- s.date = %q{2010-09-09}
13
- s.description = %q{A software model in Ruby for the greenhouse gas emissions of a lodging}
14
- s.email = %q{andy@rossmeissl.net}
15
- s.extra_rdoc_files = [
16
- "LICENSE",
17
- "README.rdoc"
18
- ]
19
- s.files = [
20
- ".document",
21
- ".gitignore",
22
- "Gemfile",
23
- "Gemfile.lock",
24
- "LICENSE",
25
- "README.rdoc",
26
- "Rakefile",
27
- "VERSION",
28
- "dot.rvmrc",
29
- "features/lodging_committees.feature",
30
- "features/lodging_emissions.feature",
31
- "features/support/env.rb",
32
- "lib/lodging.rb",
33
- "lib/lodging/carbon_model.rb",
34
- "lib/lodging/characterization.rb",
35
- "lib/lodging/data.rb",
36
- "lib/lodging/summarization.rb",
37
- "lodging.gemspec"
38
- ]
39
- s.homepage = %q{http://github.com/brighterplanet/lodging}
40
- s.rdoc_options = ["--charset=UTF-8"]
41
- s.require_paths = ["lib"]
42
- s.rubygems_version = %q{1.3.7}
43
- s.summary = %q{A carbon model}
44
-
45
- if s.respond_to? :specification_version then
46
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
47
- s.specification_version = 3
48
-
49
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
50
- s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
51
- else
52
- s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
53
- end
54
- else
55
- s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
56
- end
57
- end
58
-