carbon 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/carbon.gemspec +1 -1
- data/lib/carbon/emission_estimate.rb +4 -0
- data/spec/lib/carbon_spec.rb +5 -0
- data/spec/spec_helper.rb +2 -1
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.2
|
data/carbon.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{carbon}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Derek Kastner", "Seamus Abshere", "Andy Rossmeissl"]
|
@@ -76,6 +76,10 @@ module Carbon
|
|
76
76
|
def key
|
77
77
|
@key || ::Carbon.key
|
78
78
|
end
|
79
|
+
# The timeframe being looked at in the emission calculation.
|
80
|
+
def active_subtimeframe
|
81
|
+
::Timeframe.interval(response.data['active_subtimeframe']) if response.data.has_key? 'active_subtimeframe'
|
82
|
+
end
|
79
83
|
# Another way to access the emission value.
|
80
84
|
# Useful if you don't like treating <tt>EmissionEstimate</tt> objects like <tt>Numeric</tt> objects (even though they do quack like numbers...)
|
81
85
|
def emission_value
|
data/spec/lib/carbon_spec.rb
CHANGED
@@ -156,6 +156,11 @@ describe Carbon do
|
|
156
156
|
c.emission(:timeframe => t)
|
157
157
|
c.emission.request.body.should include(t.to_query(:timeframe))
|
158
158
|
end
|
159
|
+
|
160
|
+
it 'should read active subtimeframes back from calculations' do
|
161
|
+
c = RentalCar.new
|
162
|
+
c.emission.active_subtimeframe.should == Timeframe.new(:year => 2008)
|
163
|
+
end
|
159
164
|
|
160
165
|
it 'should not generate post bodies with lots of empty params' do
|
161
166
|
c = RentalCar.new
|
data/spec/spec_helper.rb
CHANGED
@@ -14,7 +14,8 @@ require 'fakeweb'
|
|
14
14
|
[ /http:\/\/carbon.brighterplanet.com\/automobiles/, {
|
15
15
|
'emission' => '134.599',
|
16
16
|
'emission_units' => 'kilograms',
|
17
|
-
'methodology' => 'http://carbon.brighterplanet.com/something'
|
17
|
+
'methodology' => 'http://carbon.brighterplanet.com/something',
|
18
|
+
'active_subtimeframe' => Timeframe.new(:year => 2008)
|
18
19
|
}.to_json],
|
19
20
|
[ /http:\/\/carbon.brighterplanet.com\/factories/, {
|
20
21
|
'emission' => 1000.0,
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carbon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 2
|
10
|
+
version: 0.2.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Derek Kastner
|