carbon 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +1 -1
- data/bin/carbon +0 -0
- data/carbon.gemspec +1 -0
- data/lib/carbon.rb +11 -10
- data/lib/carbon/base.rb +1 -3
- data/lib/carbon/emission_estimate.rb +5 -4
- data/lib/carbon/registry.rb +6 -0
- data/lib/carbon/version.rb +1 -1
- metadata +134 -165
data/README.rdoc
CHANGED
@@ -240,7 +240,7 @@ This library includes a special console for performing calculations interactivel
|
|
240
240
|
=== Shell mode
|
241
241
|
|
242
242
|
[+help+] Displays a list of emitter types.
|
243
|
-
[+key+ _yourkey_] Set the {developer key}[http://keys.brighterplanet.com] that should be used for this session. Alternatively, put this key in <tt>~/.
|
243
|
+
[+key+ _yourkey_] Set the {developer key}[http://keys.brighterplanet.com] that should be used for this session. Alternatively, put this key in <tt>~/.brighter_planet</tt> and it will be auto-selected on console startup.
|
244
244
|
[+_emitter_type_+] (e.g. +flight+) Enters emitter mode using this emitter type.
|
245
245
|
[<tt><i>emitter_type num</i></tt>] (e.g. <tt>flight 0</tt>) Recalls a previous emitter from this session.
|
246
246
|
[+exit+] Quits.
|
data/bin/carbon
CHANGED
File without changes
|
data/carbon.gemspec
CHANGED
data/lib/carbon.rb
CHANGED
@@ -6,20 +6,14 @@ require 'rest' # provided by nap gem
|
|
6
6
|
require 'active_support'
|
7
7
|
require 'active_support/version'
|
8
8
|
%w{
|
9
|
-
active_support/core_ext
|
10
|
-
active_support/core_ext/class/attribute_accessors
|
11
|
-
active_support/core_ext/hash/keys
|
12
|
-
active_support/core_ext/hash/reverse_merge
|
13
|
-
active_support/core_ext/object/to_query
|
9
|
+
active_support/core_ext
|
14
10
|
active_support/inflector
|
15
11
|
active_support/inflector/inflections
|
16
12
|
active_support/json/decoding
|
17
13
|
}.each do |active_support_3_requirement|
|
18
14
|
require active_support_3_requirement
|
19
|
-
end if ActiveSupport::VERSION::MAJOR
|
15
|
+
end if ActiveSupport::VERSION::MAJOR >= 3
|
20
16
|
|
21
|
-
require 'carbon/base'
|
22
|
-
require 'carbon/emission_estimate'
|
23
17
|
require 'logger'
|
24
18
|
|
25
19
|
# A module (aka mixin) that lets you estimate carbon emissions by querying the {Brighter Planet carbon middleware emission estimate web service}[http://carbon.brighterplanet.com].
|
@@ -42,8 +36,11 @@ require 'logger'
|
|
42
36
|
#
|
43
37
|
# Once you've mixed in <tt>Carbon</tt>, you get the method <tt>emission_estimate</tt>, which you can call at any time to request an emission estimate.
|
44
38
|
module Carbon
|
39
|
+
autoload :Base, 'carbon/base'
|
40
|
+
autoload :EmissionEstimate, 'carbon/emission_estimate'
|
41
|
+
autoload :Registry, 'carbon/registry'
|
42
|
+
|
45
43
|
def self.included(klass) # :nodoc:
|
46
|
-
klass.cattr_accessor :carbon_base
|
47
44
|
klass.extend ClassMethods
|
48
45
|
end
|
49
46
|
|
@@ -82,11 +79,15 @@ module Carbon
|
|
82
79
|
# provide :make
|
83
80
|
# end
|
84
81
|
def emit_as(emitter_common_name, &block)
|
85
|
-
|
82
|
+
Registry.instance[name] = ::Carbon::Base.new emitter_common_name
|
86
83
|
::Blockenspiel.invoke block, carbon_base
|
87
84
|
end
|
88
85
|
# Third-person singular preferred.
|
89
86
|
alias :emits_as :emit_as
|
87
|
+
|
88
|
+
def carbon_base # :nodoc:
|
89
|
+
Registry.instance[name]
|
90
|
+
end
|
90
91
|
end
|
91
92
|
|
92
93
|
# Returns an emission estimate.
|
data/lib/carbon/base.rb
CHANGED
@@ -4,11 +4,9 @@ module Carbon
|
|
4
4
|
# An instance of this appears on any class that includes <tt>Carbon</tt>.
|
5
5
|
class Base
|
6
6
|
include Blockenspiel::DSL
|
7
|
-
attr_reader :klass
|
8
7
|
attr_reader :emitter_common_name
|
9
8
|
|
10
|
-
def initialize(
|
11
|
-
@klass = klass
|
9
|
+
def initialize(emitter_common_name)
|
12
10
|
@emitter_common_name = emitter_common_name.to_s
|
13
11
|
end
|
14
12
|
|
@@ -1,7 +1,3 @@
|
|
1
|
-
require 'carbon/emission_estimate/response'
|
2
|
-
require 'carbon/emission_estimate/request'
|
3
|
-
require 'carbon/emission_estimate/storage'
|
4
|
-
|
5
1
|
module Carbon
|
6
2
|
# Let's start off by saying that realtime <tt>EmissionEstimate</tt> objects quack like numbers.
|
7
3
|
#
|
@@ -11,8 +7,13 @@ module Carbon
|
|
11
7
|
#
|
12
8
|
# At the same time, they contain all the data you get back from the emission estimate web service. For example, you could say <tt>puts my_donut_factor.emission_estimate.oven_count</tt> (see the tests) and you'd get back the oven count used in the calculation, if any.
|
13
9
|
class EmissionEstimate
|
10
|
+
autoload :Response, 'carbon/emission_estimate/response'
|
11
|
+
autoload :Request, 'carbon/emission_estimate/request'
|
12
|
+
autoload :Storage, 'carbon/emission_estimate/storage'
|
13
|
+
|
14
14
|
def self.parse(str) #:nodoc:
|
15
15
|
data = ::ActiveSupport::JSON.decode str
|
16
|
+
# TODO rename to timeframe
|
16
17
|
data['active_subtimeframe'] = ::Timeframe.interval(data['active_subtimeframe']) if data.has_key? 'active_subtimeframe'
|
17
18
|
data['updated_at'] = ::Time.parse(data['updated_at']) if data.has_key?('updated_at') and data['updated_at'].is_a?(::String)
|
18
19
|
data
|
data/lib/carbon/version.rb
CHANGED
metadata
CHANGED
@@ -1,191 +1,161 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: carbon
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.2
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 1
|
9
|
-
- 1
|
10
|
-
version: 1.1.1
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Derek Kastner
|
14
9
|
- Seamus Abshere
|
15
10
|
- Andy Rossmeissl
|
16
11
|
autorequire:
|
17
12
|
bindir: bin
|
18
13
|
cert_chain: []
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
dependencies:
|
23
|
-
- !ruby/object:Gem::Dependency
|
14
|
+
date: 2011-07-15 00:00:00.000000000Z
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
24
17
|
name: activesupport
|
25
|
-
|
26
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
18
|
+
requirement: &2162440820 !ruby/object:Gem::Requirement
|
27
19
|
none: false
|
28
|
-
requirements:
|
29
|
-
- -
|
30
|
-
- !ruby/object:Gem::Version
|
31
|
-
hash: 9
|
32
|
-
segments:
|
33
|
-
- 2
|
34
|
-
- 3
|
35
|
-
- 5
|
20
|
+
requirements:
|
21
|
+
- - ! '>='
|
22
|
+
- !ruby/object:Gem::Version
|
36
23
|
version: 2.3.5
|
37
24
|
type: :runtime
|
38
|
-
version_requirements: *id001
|
39
|
-
- !ruby/object:Gem::Dependency
|
40
|
-
name: i18n
|
41
25
|
prerelease: false
|
42
|
-
|
26
|
+
version_requirements: *2162440820
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: i18n
|
29
|
+
requirement: &2162440400 !ruby/object:Gem::Requirement
|
43
30
|
none: false
|
44
|
-
requirements:
|
45
|
-
- -
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
|
48
|
-
segments:
|
49
|
-
- 0
|
50
|
-
version: "0"
|
31
|
+
requirements:
|
32
|
+
- - ! '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
51
35
|
type: :runtime
|
52
|
-
version_requirements: *id002
|
53
|
-
- !ruby/object:Gem::Dependency
|
54
|
-
name: nap
|
55
36
|
prerelease: false
|
56
|
-
|
37
|
+
version_requirements: *2162440400
|
38
|
+
- !ruby/object:Gem::Dependency
|
39
|
+
name: nap
|
40
|
+
requirement: &2162439940 !ruby/object:Gem::Requirement
|
57
41
|
none: false
|
58
|
-
requirements:
|
59
|
-
- -
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
|
62
|
-
segments:
|
63
|
-
- 0
|
64
|
-
version: "0"
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
65
46
|
type: :runtime
|
66
|
-
version_requirements: *id003
|
67
|
-
- !ruby/object:Gem::Dependency
|
68
|
-
name: timeframe
|
69
47
|
prerelease: false
|
70
|
-
|
48
|
+
version_requirements: *2162439940
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: timeframe
|
51
|
+
requirement: &2162439520 !ruby/object:Gem::Requirement
|
71
52
|
none: false
|
72
|
-
requirements:
|
73
|
-
- -
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
|
76
|
-
segments:
|
77
|
-
- 0
|
78
|
-
version: "0"
|
53
|
+
requirements:
|
54
|
+
- - ! '>='
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
79
57
|
type: :runtime
|
80
|
-
version_requirements: *id004
|
81
|
-
- !ruby/object:Gem::Dependency
|
82
|
-
name: blockenspiel
|
83
58
|
prerelease: false
|
84
|
-
|
59
|
+
version_requirements: *2162439520
|
60
|
+
- !ruby/object:Gem::Dependency
|
61
|
+
name: blockenspiel
|
62
|
+
requirement: &2162439100 !ruby/object:Gem::Requirement
|
85
63
|
none: false
|
86
|
-
requirements:
|
87
|
-
- -
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
|
90
|
-
segments:
|
91
|
-
- 0
|
92
|
-
version: "0"
|
64
|
+
requirements:
|
65
|
+
- - ! '>='
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
93
68
|
type: :runtime
|
94
|
-
version_requirements: *id005
|
95
|
-
- !ruby/object:Gem::Dependency
|
96
|
-
name: conversions
|
97
69
|
prerelease: false
|
98
|
-
|
70
|
+
version_requirements: *2162439100
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: conversions
|
73
|
+
requirement: &2162438680 !ruby/object:Gem::Requirement
|
99
74
|
none: false
|
100
|
-
requirements:
|
101
|
-
- -
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
|
104
|
-
segments:
|
105
|
-
- 0
|
106
|
-
version: "0"
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
107
79
|
type: :runtime
|
108
|
-
version_requirements: *id006
|
109
|
-
- !ruby/object:Gem::Dependency
|
110
|
-
name: brighter_planet_metadata
|
111
80
|
prerelease: false
|
112
|
-
|
81
|
+
version_requirements: *2162438680
|
82
|
+
- !ruby/object:Gem::Dependency
|
83
|
+
name: brighter_planet_metadata
|
84
|
+
requirement: &2162438260 !ruby/object:Gem::Requirement
|
113
85
|
none: false
|
114
|
-
requirements:
|
115
|
-
- -
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
|
118
|
-
segments:
|
119
|
-
- 0
|
120
|
-
version: "0"
|
86
|
+
requirements:
|
87
|
+
- - ! '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
121
90
|
type: :runtime
|
122
|
-
version_requirements: *id007
|
123
|
-
- !ruby/object:Gem::Dependency
|
124
|
-
name: bombshell
|
125
91
|
prerelease: false
|
126
|
-
|
92
|
+
version_requirements: *2162438260
|
93
|
+
- !ruby/object:Gem::Dependency
|
94
|
+
name: bombshell
|
95
|
+
requirement: &2162437840 !ruby/object:Gem::Requirement
|
127
96
|
none: false
|
128
|
-
requirements:
|
129
|
-
- -
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
|
132
|
-
segments:
|
133
|
-
- 0
|
134
|
-
version: "0"
|
97
|
+
requirements:
|
98
|
+
- - ! '>='
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
135
101
|
type: :runtime
|
136
|
-
version_requirements: *id008
|
137
|
-
- !ruby/object:Gem::Dependency
|
138
|
-
name: fakeweb
|
139
102
|
prerelease: false
|
140
|
-
|
103
|
+
version_requirements: *2162437840
|
104
|
+
- !ruby/object:Gem::Dependency
|
105
|
+
name: fakeweb
|
106
|
+
requirement: &2162437420 !ruby/object:Gem::Requirement
|
141
107
|
none: false
|
142
|
-
requirements:
|
143
|
-
- -
|
144
|
-
- !ruby/object:Gem::Version
|
145
|
-
|
146
|
-
segments:
|
147
|
-
- 0
|
148
|
-
version: "0"
|
108
|
+
requirements:
|
109
|
+
- - ! '>='
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
149
112
|
type: :development
|
150
|
-
version_requirements: *id009
|
151
|
-
- !ruby/object:Gem::Dependency
|
152
|
-
name: rspec
|
153
113
|
prerelease: false
|
154
|
-
|
114
|
+
version_requirements: *2162437420
|
115
|
+
- !ruby/object:Gem::Dependency
|
116
|
+
name: rspec
|
117
|
+
requirement: &2162437000 !ruby/object:Gem::Requirement
|
155
118
|
none: false
|
156
|
-
requirements:
|
157
|
-
- -
|
158
|
-
- !ruby/object:Gem::Version
|
159
|
-
|
160
|
-
segments:
|
161
|
-
- 0
|
162
|
-
version: "0"
|
119
|
+
requirements:
|
120
|
+
- - ! '>='
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
163
123
|
type: :development
|
164
|
-
|
165
|
-
|
124
|
+
prerelease: false
|
125
|
+
version_requirements: *2162437000
|
126
|
+
- !ruby/object:Gem::Dependency
|
166
127
|
name: aruba
|
128
|
+
requirement: &2152166340 !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
type: :development
|
167
135
|
prerelease: false
|
168
|
-
|
136
|
+
version_requirements: *2152166340
|
137
|
+
- !ruby/object:Gem::Dependency
|
138
|
+
name: rake
|
139
|
+
requirement: &2152165920 !ruby/object:Gem::Requirement
|
169
140
|
none: false
|
170
|
-
requirements:
|
171
|
-
- -
|
172
|
-
- !ruby/object:Gem::Version
|
173
|
-
|
174
|
-
segments:
|
175
|
-
- 0
|
176
|
-
version: "0"
|
141
|
+
requirements:
|
142
|
+
- - ! '>='
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
177
145
|
type: :development
|
178
|
-
|
179
|
-
|
180
|
-
|
146
|
+
prerelease: false
|
147
|
+
version_requirements: *2152165920
|
148
|
+
description: Carbon is a Ruby API wrapper for the Brighter Planet emission estimate
|
149
|
+
web service (http://carbon.brighterplanet.com). By querying the web service, it
|
150
|
+
can estimate the carbon emissions of many real-life objects, such as cars and houses,
|
151
|
+
based on particular attributes that they may have.
|
152
|
+
email:
|
181
153
|
- derek.kastner@brighterplanet.com
|
182
|
-
executables:
|
154
|
+
executables:
|
183
155
|
- carbon
|
184
156
|
extensions: []
|
185
|
-
|
186
157
|
extra_rdoc_files: []
|
187
|
-
|
188
|
-
files:
|
158
|
+
files:
|
189
159
|
- .gitignore
|
190
160
|
- Gemfile
|
191
161
|
- MIT-LICENSE.txt
|
@@ -207,6 +177,7 @@ files:
|
|
207
177
|
- lib/carbon/emission_estimate/request.rb
|
208
178
|
- lib/carbon/emission_estimate/response.rb
|
209
179
|
- lib/carbon/emission_estimate/storage.rb
|
180
|
+
- lib/carbon/registry.rb
|
210
181
|
- lib/carbon/shell.rb
|
211
182
|
- lib/carbon/shell/emitter.rb
|
212
183
|
- lib/carbon/version.rb
|
@@ -216,39 +187,37 @@ files:
|
|
216
187
|
- spec/lib/carbon_spec.rb
|
217
188
|
- spec/spec_helper.rb
|
218
189
|
- spec/specwatchr
|
219
|
-
has_rdoc: true
|
220
190
|
homepage: https://github.com/brighterplanet/carbon
|
221
191
|
licenses: []
|
222
|
-
|
223
192
|
post_install_message:
|
224
193
|
rdoc_options: []
|
225
|
-
|
226
|
-
require_paths:
|
194
|
+
require_paths:
|
227
195
|
- lib
|
228
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
196
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
229
197
|
none: false
|
230
|
-
requirements:
|
231
|
-
- -
|
232
|
-
- !ruby/object:Gem::Version
|
233
|
-
|
234
|
-
|
235
|
-
- 0
|
236
|
-
version: "0"
|
237
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - ! '>='
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '0'
|
202
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
238
203
|
none: false
|
239
|
-
requirements:
|
240
|
-
- -
|
241
|
-
- !ruby/object:Gem::Version
|
242
|
-
|
243
|
-
segments:
|
244
|
-
- 0
|
245
|
-
version: "0"
|
204
|
+
requirements:
|
205
|
+
- - ! '>='
|
206
|
+
- !ruby/object:Gem::Version
|
207
|
+
version: '0'
|
246
208
|
requirements: []
|
247
|
-
|
248
209
|
rubyforge_project: carbon
|
249
|
-
rubygems_version: 1.
|
210
|
+
rubygems_version: 1.8.5
|
250
211
|
signing_key:
|
251
212
|
specification_version: 3
|
252
|
-
summary: Carbon is a Ruby API wrapper for the Brighter Planet emission estimate web
|
253
|
-
|
254
|
-
|
213
|
+
summary: Carbon is a Ruby API wrapper for the Brighter Planet emission estimate web
|
214
|
+
service (http://carbon.brighterplanet.com).
|
215
|
+
test_files:
|
216
|
+
- features/shell.feature
|
217
|
+
- features/support/env.rb
|
218
|
+
- spec/lib/carbon/emission_estimate/request_spec.rb
|
219
|
+
- spec/lib/carbon/emission_estimate/response_spec.rb
|
220
|
+
- spec/lib/carbon/emission_estimate_spec.rb
|
221
|
+
- spec/lib/carbon_spec.rb
|
222
|
+
- spec/spec_helper.rb
|
223
|
+
- spec/specwatchr
|