purchase 1.0.8 → 1.0.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,33 @@
1
+ Feature: Purchase Characterizations
2
+ The purchase model should be characterized
3
+
4
+ Scenario: Merchant category characteristic
5
+ Given a purchase has "merchant_category.mcc" of "2222"
6
+ And it has "cost" of "100"
7
+ When emissions are calculated
8
+ Then the "merchant_category" characteristic should be displayed as "Fantasy creature product shops"
9
+
10
+ Scenario: Merchant category industries characteristic
11
+ Given a purchase has "merchant_category.mcc" of "2222"
12
+ And it has "cost" of "100"
13
+ When emissions are calculated
14
+ Then the "merchant_category_industries" characteristic should be displayed as "2 merchant categories"
15
+
16
+ Scenario: Trade industry ratios characteristic
17
+ Given a purchase has "merchant_category.mcc" of "2222"
18
+ And it has "cost" of "100"
19
+ When emissions are calculated
20
+ Then the "trade_industry_ratios" characteristic should be displayed as "1 trade industry ratio"
21
+
22
+ Scenario: Non-trade industry ratios characteristic
23
+ Given a purchase has "merchant_category.mcc" of "2222"
24
+ And it has "cost" of "100"
25
+ When emissions are calculated
26
+ Then the "non_trade_industry_ratios" characteristic should be displayed as "1 non-trade industry ratio"
27
+
28
+ Scenario: Sector direct requirements characteristic
29
+ Given a purchase has "merchant_category.mcc" of "2222"
30
+ And it has "cost" of "100"
31
+ When emissions are calculated
32
+ Then the "sector_direct_requirements" characteristic should be displayed as "6x6 sector direct requirements matrix"
33
+
@@ -0,0 +1,5 @@
1
+ Then /^the "(.*)" characteristic should be displayed as "(.*)"$/ do |name, value|
2
+ name = name.to_sym
3
+ all_chars = @activity.characteristics.merge @activity.deliberations[:emission].characteristics
4
+ @activity.class.characteristics[name].display(all_chars).should == value
5
+ end
@@ -1,8 +1,11 @@
1
1
  require 'characterizable'
2
+ require 'action_view'
2
3
 
3
4
  module BrighterPlanet
4
5
  module Purchase
5
6
  module Characterization
7
+ extend ActionView::Helpers::TextHelper
8
+
6
9
  def self.included(base)
7
10
  base.send :include, Characterizable
8
11
  base.characterize do
@@ -11,8 +14,53 @@ module BrighterPlanet
11
14
  has :tax # tax portion of purchase
12
15
  has :date
13
16
  has :merchant
14
- has :merchant_category
15
17
  has :industry
18
+
19
+ has :merchant_category do
20
+ displays { |mc| mc.name }
21
+ end
22
+ has :merchant_category_industries do
23
+ displays { |mci| pluralize(mci.count, 'merchant category') }
24
+ end
25
+ has :trade_industry_ratios do
26
+ displays { |tir| pluralize(tir.count, 'trade industry ratio') }
27
+ end
28
+ has :non_trade_industry_ratios do
29
+ displays { |ntir| pluralize(ntir.count, 'non-trade industry ratio') }
30
+ end
31
+ has :product_line_ratios do
32
+ displays { |plr| pluralize(plr.count, 'product line ratio') }
33
+ end
34
+ has :product_line_industry_product_ratios do
35
+ displays { |plipr| pluralize(plipr.count, 'product line industry product ratio') }
36
+ end
37
+ has :industry_product_ratios do
38
+ displays { |ipr| pluralize(ipr.count, 'industry product ratio') }
39
+ end
40
+ has :industry_ratios do
41
+ displays { |ir| pluralize(ir.count, 'industry ratio') }
42
+ end
43
+ has :industry_sector_ratios do
44
+ displays { |isr| pluralize(isr.count, 'industry sector ratio') }
45
+ end
46
+ has :industry_sector_shares do
47
+ displays { |isr| pluralize(isr.count, 'industry sector share') }
48
+ end
49
+ has :sector_shares do
50
+ displays { |isr| "#{isr.size}-element sector shares vector" }
51
+ end
52
+ has :sector_direct_requirements do
53
+ displays { |sdr| "#{sdr.row_size}x#{sdr.column_size} sector direct requirements matrix" }
54
+ end
55
+ has :economic_flows do
56
+ displays { |ef| "#{ef.size}-element economic flows vector" }
57
+ end
58
+ has :impact_vectors do
59
+ displays { |iv| "#{iv.row_size}x#{iv.column_size} impact vector" }
60
+ end
61
+ has :impacts do
62
+ displays { |i| "#{i.size}-element impacts vector" }
63
+ end
16
64
  end
17
65
  base.add_implicit_characteristics
18
66
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 0
8
- - 8
9
- version: 1.0.8
8
+ - 9
9
+ version: 1.0.9
10
10
  platform: ruby
11
11
  authors:
12
12
  - Andy Rossmeissl
@@ -18,7 +18,7 @@ autorequire:
18
18
  bindir: bin
19
19
  cert_chain: []
20
20
 
21
- date: 2010-10-19 00:00:00 -04:00
21
+ date: 2010-11-03 00:00:00 -04:00
22
22
  default_executable:
23
23
  dependencies:
24
24
  - !ruby/object:Gem::Dependency
@@ -131,15 +131,30 @@ dependencies:
131
131
  - !ruby/object:Gem::Version
132
132
  segments:
133
133
  - 0
134
- - 1
135
- - 16
136
- version: 0.1.16
134
+ - 2
135
+ - 3
136
+ version: 0.2.3
137
137
  type: :development
138
138
  prerelease: false
139
139
  version_requirements: *id008
140
140
  - !ruby/object:Gem::Dependency
141
- name: earth
141
+ name: actionpack
142
142
  requirement: &id009 !ruby/object:Gem::Requirement
143
+ none: false
144
+ requirements:
145
+ - - ~>
146
+ - !ruby/object:Gem::Version
147
+ segments:
148
+ - 3
149
+ - 0
150
+ - 1
151
+ version: 3.0.1
152
+ type: :runtime
153
+ prerelease: false
154
+ version_requirements: *id009
155
+ - !ruby/object:Gem::Dependency
156
+ name: earth
157
+ requirement: &id010 !ruby/object:Gem::Requirement
143
158
  none: false
144
159
  requirements:
145
160
  - - ~>
@@ -151,10 +166,10 @@ dependencies:
151
166
  version: 0.2.4
152
167
  type: :runtime
153
168
  prerelease: false
154
- version_requirements: *id009
169
+ version_requirements: *id010
155
170
  - !ruby/object:Gem::Dependency
156
171
  name: emitter
157
- requirement: &id010 !ruby/object:Gem::Requirement
172
+ requirement: &id011 !ruby/object:Gem::Requirement
158
173
  none: false
159
174
  requirements:
160
175
  - - ~>
@@ -162,14 +177,14 @@ dependencies:
162
177
  segments:
163
178
  - 0
164
179
  - 1
165
- - 4
166
- version: 0.1.4
180
+ - 9
181
+ version: 0.1.9
167
182
  type: :runtime
168
183
  prerelease: false
169
- version_requirements: *id010
184
+ version_requirements: *id011
170
185
  - !ruby/object:Gem::Dependency
171
186
  name: fastercsv
172
- requirement: &id011 !ruby/object:Gem::Requirement
187
+ requirement: &id012 !ruby/object:Gem::Requirement
173
188
  none: false
174
189
  requirements:
175
190
  - - ~>
@@ -181,10 +196,10 @@ dependencies:
181
196
  version: 1.5.3
182
197
  type: :runtime
183
198
  prerelease: false
184
- version_requirements: *id011
199
+ version_requirements: *id012
185
200
  - !ruby/object:Gem::Dependency
186
201
  name: slither
187
- requirement: &id012 !ruby/object:Gem::Requirement
202
+ requirement: &id013 !ruby/object:Gem::Requirement
188
203
  none: false
189
204
  requirements:
190
205
  - - ~>
@@ -196,7 +211,7 @@ dependencies:
196
211
  version: 0.99.3
197
212
  type: :runtime
198
213
  prerelease: false
199
- version_requirements: *id012
214
+ version_requirements: *id013
200
215
  description: A software model in Ruby for the greenhouse gas emissions of a purchase
201
216
  email: seamus@brighterplanet.com
202
217
  executables: []
@@ -219,10 +234,12 @@ files:
219
234
  - lib/test_support/purchase_record.rb
220
235
  - lib/test_support/test_impact_vectors_adapter.rb
221
236
  - lib/test_support/test_sector_direct_requirements_adapter.rb
237
+ - features/support/matrix_ext.rb
238
+ - features/support/env.rb
222
239
  - features/step_definitions/matrix_steps.rb
223
240
  - features/step_definitions/purchase_steps.rb
224
- - features/support/env.rb
225
- - features/support/matrix_ext.rb
241
+ - features/step_definitions/characteristic_steps.rb
242
+ - features/purchase_characterization.feature
226
243
  - features/purchase_committees.feature
227
244
  - features/purchase_emissions.feature
228
245
  has_rdoc: true
@@ -239,7 +256,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
239
256
  requirements:
240
257
  - - ">="
241
258
  - !ruby/object:Gem::Version
242
- hash: 4259412542954819564
259
+ hash: -1011847695
243
260
  segments:
244
261
  - 0
245
262
  version: "0"
@@ -259,13 +276,15 @@ signing_key:
259
276
  specification_version: 3
260
277
  summary: A carbon model
261
278
  test_files:
279
+ - features/support/matrix_ext.rb
280
+ - features/support/env.rb
262
281
  - features/step_definitions/matrix_steps.rb
263
282
  - features/step_definitions/purchase_steps.rb
264
- - features/support/env.rb
265
- - features/support/matrix_ext.rb
283
+ - features/step_definitions/characteristic_steps.rb
284
+ - features/purchase_characterization.feature
266
285
  - features/purchase_committees.feature
267
286
  - features/purchase_emissions.feature
287
+ - lib/test_support/test_sector_direct_requirements_adapter.rb
268
288
  - lib/test_support/db/schema.rb
269
289
  - lib/test_support/purchase_record.rb
270
290
  - lib/test_support/test_impact_vectors_adapter.rb
271
- - lib/test_support/test_sector_direct_requirements_adapter.rb