genability 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. data/.document +2 -2
  2. data/Gemfile +11 -10
  3. data/HISTORY.md +8 -0
  4. data/README.md +38 -3
  5. data/Rakefile +1 -0
  6. data/VERSION +2 -1
  7. data/genability.gemspec +46 -32
  8. data/lib/faraday/request/url_encoding_fix.rb +0 -1
  9. data/lib/genability/client.rb +6 -0
  10. data/lib/genability/client/calculate.rb +97 -0
  11. data/lib/genability/client/echo.rb +21 -0
  12. data/lib/genability/client/helpers.rb +2 -1
  13. data/lib/genability/client/load_serving_entity.rb +12 -11
  14. data/lib/genability/client/price.rb +1 -1
  15. data/lib/genability/client/property.rb +26 -0
  16. data/lib/genability/client/season.rb +1 -1
  17. data/lib/genability/client/tariff.rb +2 -2
  18. data/lib/genability/client/territory.rb +2 -2
  19. data/lib/genability/client/time_of_use.rb +3 -2
  20. data/lib/genability/client/zip_code.rb +1 -1
  21. data/lib/genability/configuration.rb +1 -2
  22. data/lib/genability/connection.rb +1 -5
  23. data/lib/genability/error.rb +4 -0
  24. data/lib/genability/request.rb +8 -1
  25. data/lib/mashie_extensions.rb +15 -4
  26. data/spec/cassettes/calculate.yml +55 -0
  27. data/spec/cassettes/echo.yml +57 -0
  28. data/spec/cassettes/load_serving_entities.yml +18 -18
  29. data/spec/cassettes/load_serving_entity.yml +2 -2
  30. data/spec/cassettes/prices.yml +6 -6
  31. data/spec/cassettes/properties.yml +55 -0
  32. data/spec/cassettes/property.yml +28 -0
  33. data/spec/cassettes/seasons.yml +2 -2
  34. data/spec/cassettes/tariff.yml +3 -3
  35. data/spec/cassettes/tariffs.yml +36 -9
  36. data/spec/cassettes/territories.yml +30 -3
  37. data/spec/cassettes/territory.yml +3 -3
  38. data/spec/cassettes/time_of_use.yml +5 -7
  39. data/spec/cassettes/time_of_uses.yml +3 -3
  40. data/spec/cassettes/zipcode.yml +2 -2
  41. data/spec/client/calculate_spec.rb +68 -0
  42. data/spec/client/echo_spec.rb +46 -0
  43. data/spec/client/helpers_spec.rb +34 -0
  44. data/spec/client/load_serving_entity_spec.rb +14 -5
  45. data/spec/client/property_spec.rb +45 -0
  46. data/spec/client/tariff_spec.rb +9 -1
  47. data/spec/client/territory_spec.rb +12 -1
  48. data/spec/client/time_of_use_spec.rb +2 -2
  49. data/spec/faraday/response_spec.rb +2 -2
  50. data/spec/genability_spec.rb +1 -1
  51. data/spec/spec_helper.rb +12 -8
  52. metadata +36 -13
@@ -0,0 +1,34 @@
1
+ require File.expand_path('../../spec_helper', __FILE__)
2
+
3
+ describe Genability::Client do
4
+
5
+ Genability::Configuration::VALID_FORMATS.each do |format|
6
+
7
+ context ".new(:format => '#{format}')" do
8
+
9
+ before(:all) do
10
+ @options = {:format => format}.merge(configuration_defaults)
11
+ @client = Genability::Client.new(@options)
12
+ @time = Time.now
13
+ end
14
+
15
+ # ISO 8601 date format with a syntax of:
16
+ # yyyy-MM-dd'T'HH:mm:ss.SSSZ
17
+ # ex. 2011-06-13T14:30:00.0-0700
18
+ # All fields must be specified even if they are zero. The .SSS
19
+ # are the milliseconds and the Z is the GMT time zone offset.
20
+ context ".format_to_iso8601" do
21
+
22
+ it "should format dates to ISO 8601" do
23
+ @client.send(:format_to_iso8601, @time).
24
+ should =~ /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{1,3}-\d{4}/
25
+ end
26
+
27
+ end
28
+
29
+ end
30
+
31
+ end
32
+
33
+ end
34
+
@@ -18,7 +18,7 @@ describe Genability::Client do
18
18
  it "should return an array of load serving entities" do
19
19
  lses = @client.load_serving_entities
20
20
  lses.should be_an Array
21
- lses.first.name.should == "Infinite Energy Inc"
21
+ lses.first.name.should_not be_nil
22
22
  end
23
23
 
24
24
  it "should return 25 results by default" do
@@ -30,23 +30,32 @@ describe Genability::Client do
30
30
  end
31
31
 
32
32
  it "should accept a pageStart parameter" do
33
- @client.load_serving_entities(:page => 2).first.name.should == "Nooruddin Investments LLC"
33
+ lses = @client.load_serving_entities(:page => 2)
34
+ lses.should be_an Array
35
+ lses.count.should == 25
36
+ lses.first.name.should_not be_nil
34
37
  end
35
38
 
36
39
  it "should accept a startsWithWildCard parameter" do
37
- @client.load_serving_entities(:starts_with => 'In').each do |result|
40
+ lses = @client.load_serving_entities(:starts_with => 'In')
41
+ lses.should_not be_empty
42
+ lses.each do |result|
38
43
  result.name.should =~ /^In/
39
44
  end
40
45
  end
41
46
 
42
47
  it "should accept an endsWithWildCard parameter" do
43
- @client.load_serving_entities(:ends_with => 'Inc').each do |result|
48
+ lses = @client.load_serving_entities(:ends_with => 'Inc')
49
+ lses.should_not be_empty
50
+ lses.each do |result|
44
51
  result.name.should =~ /Inc$/
45
52
  end
46
53
  end
47
54
 
48
55
  it "should accept a containsWildCard parameter" do
49
- @client.load_serving_entities(:contains => 'Energy').each do |result|
56
+ lses = @client.load_serving_entities(:search_string => 'Energy')
57
+ lses.should_not be_empty
58
+ lses.each do |result|
50
59
  result.name.should =~ /Energy/
51
60
  end
52
61
  end
@@ -0,0 +1,45 @@
1
+ require File.expand_path('../../spec_helper', __FILE__)
2
+
3
+ describe Genability::Client do
4
+
5
+ Genability::Configuration::VALID_FORMATS.each do |format|
6
+
7
+ context ".new(:format => '#{format}')" do
8
+
9
+ before(:all) do
10
+ @options = {:format => format}.merge(configuration_defaults)
11
+ @client = Genability::Client.new(@options)
12
+ end
13
+
14
+ context ".property" do
15
+
16
+ use_vcr_cassette "property"
17
+
18
+ it "should get a single property by key name" do
19
+ property = @client.property("connectionType")
20
+ property.key_name.should == "connectionType"
21
+ end
22
+
23
+ end
24
+
25
+ context ".properties" do
26
+
27
+ use_vcr_cassette "properties"
28
+
29
+ it "should get a list of properties" do
30
+ properties = @client.properties
31
+ properties.first.display_name.should =~ /1000 kWh Block/
32
+ end
33
+
34
+ it "should get a list of properties for a specific entity" do
35
+ properties = @client.properties(:entity_id => 734)
36
+ properties.first.entity_id.should == 734
37
+ end
38
+
39
+ end
40
+
41
+ end
42
+
43
+ end
44
+ end
45
+
@@ -21,6 +21,12 @@ describe Genability::Client do
21
21
  tariffs.first.tariff_id.should == 79
22
22
  end
23
23
 
24
+ # this example also demonstrates searching within results
25
+ it "should allow searches by lse_id" do
26
+ tariffs = @client.tariffs(:lse_id => 734)
27
+ tariffs.select{|x| x['tariffCode'] == "E-7"}.first.tariff_code.should == "E-7"
28
+ end
29
+
24
30
  it "should accept a string for customerClasses and tariffTypes parameters" do
25
31
  @client.tariffs(:customer_classes => 'residential').each do |tariff|
26
32
  tariff.customer_class.should =~ /RESIDENTIAL/
@@ -40,7 +46,9 @@ describe Genability::Client do
40
46
  use_vcr_cassette "tariff"
41
47
 
42
48
  it "should return a tariff" do
43
- @client.tariff(512).tariff_id.should == 512
49
+ tariff = @client.tariff(512)
50
+ tariff.should be_a Hashie::Mash
51
+ tariff.tariff_id.should == 512
44
52
  end
45
53
 
46
54
  end
@@ -21,6 +21,15 @@ describe Genability::Client do
21
21
  territories.first.territory_id.should == 807
22
22
  end
23
23
 
24
+ it "should get the territory ID from a zipcode" do
25
+ territories = @client.territories(
26
+ :lse_id => 734,
27
+ :contains_item_type => 'ZIPCODE',
28
+ :contains_item_value => 94115,
29
+ :master_tariff_id => 522)
30
+ territories.first.territory_id.should == 3538
31
+ end
32
+
24
33
  end
25
34
 
26
35
  context ".territory" do
@@ -28,7 +37,9 @@ describe Genability::Client do
28
37
  use_vcr_cassette "territory"
29
38
 
30
39
  it "should return a territory" do
31
- @client.territory(3539).lse_id.should == 734
40
+ territory = @client.territory(3539)
41
+ territory.should be_a Hashie::Mash
42
+ territory.lse_id.should == 734
32
43
  end
33
44
 
34
45
  end
@@ -27,8 +27,8 @@ describe Genability::Client do
27
27
 
28
28
  use_vcr_cassette "time_of_use"
29
29
 
30
- it "should return a territory" do
31
- intervals = @client.time_of_use_intervals(2756, 1)
30
+ it "should return the intervals for a given LSE and touGroupId" do
31
+ intervals = @client.time_of_use_intervals(734, 1)
32
32
  intervals.should be_an Array
33
33
  intervals.first.tou_group_id.should == 1
34
34
  end
@@ -15,8 +15,8 @@ describe Faraday::Response do
15
15
  }.each do |status, exception|
16
16
  context "when HTTP status is #{status}" do
17
17
 
18
- before do
19
- stub_get('lses.json?appId=ValidAppID&appKey=ValidAppKey').
18
+ before(:each) do
19
+ stub_get('public/lses?appId=ValidAppID&appKey=ValidAppKey').
20
20
  to_return(:status => status)
21
21
  end
22
22
 
@@ -6,7 +6,7 @@ describe "Genability" do
6
6
  it { Genability::Configuration::DEFAULT_ADAPTER.should == :net_http }
7
7
  it { Genability::Configuration::DEFAULT_APPLICATION_ID.should be_nil }
8
8
  it { Genability::Configuration::DEFAULT_APPLICATION_KEY.should be_nil }
9
- it { Genability::Configuration::DEFAULT_ENDPOINT.should == 'http://api.genability.com/rest/public/' }
9
+ it { Genability::Configuration::DEFAULT_ENDPOINT.should == 'http://api.genability.com/rest/' }
10
10
  it { Genability::Configuration::DEFAULT_FORMAT.should == :json }
11
11
  it { Genability::Configuration::DEFAULT_USER_AGENT.should == 'Genability API Ruby Gem' }
12
12
  it { Genability::Configuration::DEFAULT_PROXY.should be_nil }
@@ -36,36 +36,40 @@ def configuration_defaults
36
36
  CONFIGURATION_DEFAULTS
37
37
  end
38
38
 
39
+ def genability_request_path(path)
40
+ Genability.endpoint + path
41
+ end
42
+
39
43
  def a_delete(path)
40
- a_request(:delete, Genability.endpoint + path)
44
+ a_request(:delete, genability_request_path(path))
41
45
  end
42
46
 
43
47
  def a_get(path)
44
- a_request(:get, Genability.endpoint + path)
48
+ a_request(:get, genability_request_path(path))
45
49
  end
46
50
 
47
51
  def a_post(path)
48
- a_request(:post, Genability.endpoint + path)
52
+ a_request(:post, genability_request_path(path))
49
53
  end
50
54
 
51
55
  def a_put(path)
52
- a_request(:put, Genability.endpoint + path)
56
+ a_request(:put, genability_request_path(path))
53
57
  end
54
58
 
55
59
  def stub_delete(path)
56
- stub_request(:delete, Genability.endpoint + path)
60
+ stub_request(:delete, genability_request_path(path))
57
61
  end
58
62
 
59
63
  def stub_get(path)
60
- stub_request(:get, Genability.endpoint + path)
64
+ stub_request(:get, genability_request_path(path))
61
65
  end
62
66
 
63
67
  def stub_post(path)
64
- stub_request(:post, Genability.endpoint + path)
68
+ stub_request(:post, genability_request_path(path))
65
69
  end
66
70
 
67
71
  def stub_put(path)
68
- stub_request(:put, Genability.endpoint + path)
72
+ stub_request(:put, genability_request_path(path))
69
73
  end
70
74
 
71
75
  def fixture_path
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: genability
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.0
5
+ version: 0.2.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Matthew Solt
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-07-01 00:00:00 Z
13
+ date: 2011-10-26 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: faraday
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - ~>
22
22
  - !ruby/object:Gem::Version
23
- version: "0.6"
23
+ version: 0.7.4
24
24
  type: :runtime
25
25
  version_requirements: *id001
26
26
  - !ruby/object:Gem::Dependency
@@ -31,7 +31,7 @@ dependencies:
31
31
  requirements:
32
32
  - - ~>
33
33
  - !ruby/object:Gem::Version
34
- version: "0.6"
34
+ version: 0.7.0
35
35
  type: :runtime
36
36
  version_requirements: *id002
37
37
  - !ruby/object:Gem::Dependency
@@ -42,7 +42,7 @@ dependencies:
42
42
  requirements:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
- version: 1.0.0
45
+ version: 1.2.0
46
46
  type: :runtime
47
47
  version_requirements: *id003
48
48
  - !ruby/object:Gem::Dependency
@@ -53,7 +53,7 @@ dependencies:
53
53
  requirements:
54
54
  - - ~>
55
55
  - !ruby/object:Gem::Version
56
- version: 1.0.0
56
+ version: 1.0.3
57
57
  type: :runtime
58
58
  version_requirements: *id004
59
59
  - !ruby/object:Gem::Dependency
@@ -64,7 +64,7 @@ dependencies:
64
64
  requirements:
65
65
  - - ~>
66
66
  - !ruby/object:Gem::Version
67
- version: 0.4.0
67
+ version: 0.6.4
68
68
  type: :runtime
69
69
  version_requirements: *id005
70
70
  - !ruby/object:Gem::Dependency
@@ -75,7 +75,7 @@ dependencies:
75
75
  requirements:
76
76
  - - ~>
77
77
  - !ruby/object:Gem::Version
78
- version: 2.6.0
78
+ version: "2.7"
79
79
  type: :development
80
80
  version_requirements: *id006
81
81
  - !ruby/object:Gem::Dependency
@@ -97,7 +97,7 @@ dependencies:
97
97
  requirements:
98
98
  - - ~>
99
99
  - !ruby/object:Gem::Version
100
- version: 1.0.0
100
+ version: 1.0.7
101
101
  type: :development
102
102
  version_requirements: *id008
103
103
  - !ruby/object:Gem::Dependency
@@ -108,7 +108,7 @@ dependencies:
108
108
  requirements:
109
109
  - - ~>
110
110
  - !ruby/object:Gem::Version
111
- version: 1.6.2
111
+ version: 1.6.4
112
112
  type: :development
113
113
  version_requirements: *id009
114
114
  - !ruby/object:Gem::Dependency
@@ -130,7 +130,7 @@ dependencies:
130
130
  requirements:
131
131
  - - ~>
132
132
  - !ruby/object:Gem::Version
133
- version: 1.10.0
133
+ version: 1.11.3
134
134
  type: :development
135
135
  version_requirements: *id011
136
136
  - !ruby/object:Gem::Dependency
@@ -141,9 +141,20 @@ dependencies:
141
141
  requirements:
142
142
  - - ~>
143
143
  - !ruby/object:Gem::Version
144
- version: 1.6.0
144
+ version: 1.7.4
145
145
  type: :development
146
146
  version_requirements: *id012
147
+ - !ruby/object:Gem::Dependency
148
+ name: ruby-debug19
149
+ prerelease: false
150
+ requirement: &id013 !ruby/object:Gem::Requirement
151
+ none: false
152
+ requirements:
153
+ - - ">="
154
+ - !ruby/object:Gem::Version
155
+ version: "0"
156
+ type: :development
157
+ version_requirements: *id013
147
158
  description: Ruby client for the Genability power pricing and related APIs - learn more at https://developer.genability.com
148
159
  email: mattsolt@gmail.com
149
160
  executables: []
@@ -170,9 +181,12 @@ files:
170
181
  - lib/genability.rb
171
182
  - lib/genability/api.rb
172
183
  - lib/genability/client.rb
184
+ - lib/genability/client/calculate.rb
185
+ - lib/genability/client/echo.rb
173
186
  - lib/genability/client/helpers.rb
174
187
  - lib/genability/client/load_serving_entity.rb
175
188
  - lib/genability/client/price.rb
189
+ - lib/genability/client/property.rb
176
190
  - lib/genability/client/season.rb
177
191
  - lib/genability/client/tariff.rb
178
192
  - lib/genability/client/territory.rb
@@ -183,9 +197,13 @@ files:
183
197
  - lib/genability/error.rb
184
198
  - lib/genability/request.rb
185
199
  - lib/mashie_extensions.rb
200
+ - spec/cassettes/calculate.yml
201
+ - spec/cassettes/echo.yml
186
202
  - spec/cassettes/load_serving_entities.yml
187
203
  - spec/cassettes/load_serving_entity.yml
188
204
  - spec/cassettes/prices.yml
205
+ - spec/cassettes/properties.yml
206
+ - spec/cassettes/property.yml
189
207
  - spec/cassettes/seasons.yml
190
208
  - spec/cassettes/tariff.yml
191
209
  - spec/cassettes/tariffs.yml
@@ -194,8 +212,12 @@ files:
194
212
  - spec/cassettes/time_of_use.yml
195
213
  - spec/cassettes/time_of_uses.yml
196
214
  - spec/cassettes/zipcode.yml
215
+ - spec/client/calculate_spec.rb
216
+ - spec/client/echo_spec.rb
217
+ - spec/client/helpers_spec.rb
197
218
  - spec/client/load_serving_entity_spec.rb
198
219
  - spec/client/price_spec.rb
220
+ - spec/client/property_spec.rb
199
221
  - spec/client/season_spec.rb
200
222
  - spec/client/tariff_spec.rb
201
223
  - spec/client/territory_spec.rb
@@ -228,9 +250,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
228
250
  requirements: []
229
251
 
230
252
  rubyforge_project:
231
- rubygems_version: 1.8.5
253
+ rubygems_version: 1.8.11
232
254
  signing_key:
233
255
  specification_version: 3
234
256
  summary: Ruby client for the Genability API
235
257
  test_files: []
236
258
 
259
+ has_rdoc: