purchase 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -50,10 +50,10 @@ Feature: Purchase Committee Calculations
50
50
  When the "merchant_category" committee is calculated
51
51
  Then the conclusion of the committee should have "mcc" of "5111"
52
52
 
53
- Scenario Outline: Merchant categories industries committee
53
+ Scenario Outline: Merchant category industries committee from merchant category
54
54
  Given a purchase emitter
55
55
  And a characteristic "merchant_category.mcc" of "<mcc>"
56
- When the "merchant_categories_industries" committee is calculated
56
+ When the "merchant_category_industries" committee is calculated
57
57
  Then the conclusion of the committee should have a record identified with "naics_code" of "<naics>" and having "ratio" of "<ratio>"
58
58
  Examples:
59
59
  | mcc | naics | ratio |
@@ -64,7 +64,7 @@ Feature: Purchase Committee Calculations
64
64
  Scenario Outline: Industry shares committee
65
65
  Given a purchase emitter
66
66
  And a characteristic "merchant_category.mcc" of "<mcc>"
67
- When the "merchant_categories_industries" committee is calculated
67
+ When the "merchant_category_industries" committee is calculated
68
68
  And the "industry_shares" committee is calculated
69
69
  Then the conclusion of the committee should have a record identified with "naics_code" of "<naics>" and having "ratio" of "<share>"
70
70
  Examples:
@@ -88,7 +88,7 @@ Feature: Purchase Committee Calculations
88
88
  Scenario Outline: Product line shares committee from merchant category
89
89
  Given a purchase emitter
90
90
  And a characteristic "merchant_category.mcc" of "<mcc>"
91
- When the "merchant_categories_industries" committee is calculated
91
+ When the "merchant_category_industries" committee is calculated
92
92
  And the "industry_shares" committee is calculated
93
93
  And the "product_line_shares" committee is calculated
94
94
  Then the conclusion of the committee should have a record identified with "ps_code" of "<ps_code>" and having "ratio" of "<share>"
@@ -101,7 +101,7 @@ Feature: Purchase Committee Calculations
101
101
  Scenario Outline: Industries sectors committee from industry
102
102
  Given a purchase emitter
103
103
  And a characteristic "naics_code" of "<naics>"
104
- When the "industries_sectors" committee is calculated
104
+ When the "industry_sectors" committee is calculated
105
105
  Then the committee should have used quorum "from industry"
106
106
  And the conclusion of the committee should have a record identified with "io_code" of "<io_code>" and having "ratio" of "<share>"
107
107
  Examples:
@@ -119,9 +119,9 @@ Feature: Purchase Committee Calculations
119
119
  And a characteristic "cost" of "100"
120
120
  And a characteristic "date" of "2010-08-01"
121
121
  When the "adjusted_cost" committee is calculated
122
- And the "merchant_categories_industries" committee is calculated
122
+ And the "merchant_category_industries" committee is calculated
123
123
  And the "industry_shares" committee is calculated
124
- And the "industries_sectors" committee is calculated
124
+ And the "industry_sectors" committee is calculated
125
125
  Then the committee should have used quorum "from industry shares"
126
126
  And the conclusion of the committee should have a record identified with "io_code" of "<io_code>" and having "ratio" of "<share>"
127
127
  Examples:
@@ -134,10 +134,10 @@ Feature: Purchase Committee Calculations
134
134
  Given a purchase emitter
135
135
  And a characteristic "merchant_category.mcc" of "<mcc>"
136
136
  And a characteristic "adjusted_cost" of "1"
137
- When the "merchant_categories_industries" committee is calculated
137
+ When the "merchant_category_industries" committee is calculated
138
138
  And the "industry_shares" committee is calculated
139
139
  And the "product_line_shares" committee is calculated
140
- And the "industries_sectors" committee is calculated
140
+ And the "industry_sectors" committee is calculated
141
141
  And the "sector_shares" committee is calculated
142
142
  Then the conclusion of the committee should be a vector with values "<1>,<10>,<11>,<12>,<13>,<14>,<15>,<16>,<17>,<18>,<19>,<2>,<20>,<21>,<22>,<23>,<24>,<25>,<26>,<3>,<4>,<44100>,<44102>,<44103>,<44104>,<44105>,<5>,<6>,<7>,<8>,<9>,<A>,<B>,<C>,<D>"
143
143
  Examples:
@@ -156,10 +156,10 @@ Feature: Purchase Committee Calculations
156
156
  And a characteristic "date" of "2010-08-01"
157
157
  And a characteristic "cost" of "100"
158
158
  When the "adjusted_cost" committee is calculated
159
- And the "merchant_categories_industries" committee is calculated
159
+ And the "merchant_category_industries" committee is calculated
160
160
  And the "industry_shares" committee is calculated
161
161
  And the "product_line_shares" committee is calculated
162
- And the "industries_sectors" committee is calculated
162
+ And the "industry_sectors" committee is calculated
163
163
  And the "sector_shares" committee is calculated
164
164
  And the "sector_direct_requirements" committee is calculated
165
165
  And the "economic_flows" committee is calculated
@@ -171,10 +171,10 @@ Feature: Purchase Committee Calculations
171
171
  And a characteristic "date" of "2010-08-01"
172
172
  And a characteristic "cost" of "100"
173
173
  When the "adjusted_cost" committee is calculated
174
- And the "merchant_categories_industries" committee is calculated
174
+ And the "merchant_category_industries" committee is calculated
175
175
  And the "industry_shares" committee is calculated
176
176
  And the "product_line_shares" committee is calculated
177
- And the "industries_sectors" committee is calculated
177
+ And the "industry_sectors" committee is calculated
178
178
  And the "sector_shares" committee is calculated
179
179
  And the "sector_direct_requirements" committee is calculated
180
180
  And the "economic_flows" committee is calculated
@@ -46,9 +46,9 @@ module BrighterPlanet
46
46
  end
47
47
 
48
48
  committee :sector_shares do
49
- quorum 'from industries sectors and product line shares', :needs => [:industries_sectors, :product_line_shares, :adjusted_cost] do |characteristics|
49
+ quorum 'from industry sectors and product line shares', :needs => [:industry_sectors, :product_line_shares, :adjusted_cost] do |characteristics|
50
50
  industry_sector_shares = {}
51
- characteristics[:industries_sectors].each do |industry_sector|
51
+ characteristics[:industry_sectors].each do |industry_sector|
52
52
  unless ['420000','4A0000'].include?(industry_sector.io_code)
53
53
  industry_sector_shares[industry_sector.io_code] ||= 0
54
54
  industry_sector_shares[industry_sector.io_code] +=
@@ -58,7 +58,7 @@ module BrighterPlanet
58
58
 
59
59
  product_line_sector_shares = {}
60
60
  characteristics[:product_line_shares].each do |product_line_share|
61
- product_line_share.product_lines_sectors.each do |product_line_sector|
61
+ product_line_share.product_line_sectors.each do |product_line_sector|
62
62
  io_code = product_line_sector.io_code
63
63
  product_line_sector_shares[io_code] ||= 0
64
64
  product_line_sector_shares[io_code] +=
@@ -73,9 +73,9 @@ module BrighterPlanet
73
73
  Vector[*shares]
74
74
  end
75
75
 
76
- quorum 'from industries sectors', :needs => [:industries_sectors, :adjusted_cost] do |characteristics|
76
+ quorum 'from industry sectors', :needs => [:industry_sectors, :adjusted_cost] do |characteristics|
77
77
  industry_sector_shares = {}
78
- characteristics[:industries_sectors].each do |industry_sector|
78
+ characteristics[:industry_sectors].each do |industry_sector|
79
79
  unless ['420000','4A0000'].include?(industry_sector.io_code)
80
80
  industry_sector_shares[industry_sector.io_code] ||= 0
81
81
  industry_sector_shares[industry_sector.io_code] +=
@@ -90,18 +90,18 @@ module BrighterPlanet
90
90
  end
91
91
  end
92
92
 
93
- committee :industries_sectors do
93
+ committee :industry_sectors do
94
94
  quorum 'from industry', :needs => :naics_code do |characteristics|
95
- industries_sectors = IndustriesSectors.
95
+ industry_sectors = IndustrySector.
96
96
  find_all_by_naics_code characteristics[:naics_code]
97
- industries_sectors.map do |industry_sector|
97
+ industry_sectors.map do |industry_sector|
98
98
  IndustrySectorShare.new industry_sector.io_code, industry_sector.ratio
99
99
  end
100
100
  end
101
101
 
102
102
  quorum 'from industry shares', :needs => :industry_shares do |characteristics|
103
103
  characteristics[:industry_shares].inject([]) do |list, industry_share|
104
- sectors = IndustriesSectors.
104
+ sectors = IndustrySector.
105
105
  find_all_by_naics_code industry_share.naics_code
106
106
  sectors.each do |sector|
107
107
  ratio = industry_share.ratio * sector.ratio
@@ -117,7 +117,7 @@ module BrighterPlanet
117
117
  # ratios = the portion of the purchase amount that goes to each product line
118
118
  committee :product_line_shares do
119
119
  quorum 'from industry', :needs => :naics_code do |characteristics|
120
- IndustriesProductLines.
120
+ IndustryProductLine.
121
121
  find_all_by_naics_code(characteristics[:naics_code]).
122
122
  map do |industry_product_line|
123
123
  ProductLineShare.new industry_product_line.ps_code,
@@ -128,9 +128,9 @@ module BrighterPlanet
128
128
  quorum 'from industry shares', :needs => :industry_shares do |characteristics|
129
129
  industry_shares = characteristics[:industry_shares]
130
130
  industry_shares.inject([]) do |list, industry_share|
131
- industries_product_lines = IndustriesProductLines.
131
+ industry_product_lines = IndustryProductLine.
132
132
  find_all_by_naics_code industry_share.naics_code
133
- industries_product_lines.each do |industry_product_line|
133
+ industry_product_lines.each do |industry_product_line|
134
134
  ratio = industry_product_line.ratio * industry_share.ratio
135
135
  list << ProductLineShare.new(industry_product_line.ps_code,
136
136
  ratio)
@@ -143,20 +143,21 @@ module BrighterPlanet
143
143
  # industries = the industries needed to produce the purchased item
144
144
  # ratios = the portion of the purchase amount that goes to each industry
145
145
  committee :industry_shares do
146
- quorum 'from merchant categories industries', :needs => :merchant_categories_industries do |characteristics|
147
- characteristics[:merchant_categories_industries].map do |mci|
146
+ quorum 'from merchant category industries', :needs => :merchant_category_industries do |characteristics|
147
+ characteristics[:merchant_category_industries].map do |mci|
148
148
  IndustryShare.new mci.naics_code, mci.ratio
149
149
  end
150
150
  end
151
151
  end
152
152
 
153
153
  # a dictionary to go from merchant categories to industries
154
- committee :merchant_categories_industries do
154
+ committee :merchant_category_industries do
155
155
  quorum 'from merchant category', :needs => :merchant_category do |characteristics|
156
- characteristics[:merchant_category].merchant_categories_industries
156
+ puts 'here'
157
+ characteristics[:merchant_category].merchant_category_industries
157
158
  end
158
159
  quorum 'from industry', :needs => :naics_code do |characteristics|
159
- MerchantCategoriesIndustries.find_all_by_naics_code characteristics[:naics_code]
160
+ MerchantCategoryIndustry.find_all_by_naics_code characteristics[:naics_code]
160
161
  end
161
162
  end
162
163
 
@@ -221,8 +222,8 @@ module BrighterPlanet
221
222
  self.ratio = ratio
222
223
  end
223
224
 
224
- def product_lines_sectors
225
- ProductLinesSectors.find_all_by_ps_code ps_code
225
+ def product_line_sectors
226
+ ProductLineSector.find_all_by_ps_code ps_code
226
227
  end
227
228
  end
228
229
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: purchase
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 1
10
- version: 1.0.1
9
+ - 2
10
+ version: 1.0.2
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-20 00:00:00 -04:00
22
+ date: 2010-09-21 00:00:00 -04:00
23
23
  default_executable:
24
24
  dependencies:
25
25
  - !ruby/object:Gem::Dependency
@@ -157,12 +157,12 @@ dependencies:
157
157
  requirements:
158
158
  - - ~>
159
159
  - !ruby/object:Gem::Version
160
- hash: 5
160
+ hash: 19
161
161
  segments:
162
162
  - 0
163
- - 0
164
- - 13
165
- version: 0.0.13
163
+ - 1
164
+ - 4
165
+ version: 0.1.4
166
166
  requirement: *id009
167
167
  description: A software model in Ruby for the greenhouse gas emissions of a purchase
168
168
  email: seamus@brighterplanet.com