ruby_pvwatts 0.0.2 → 0.0.3
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.
- checksums.yaml +4 -4
- data/LICENSE.txt +21 -0
- data/README.md +11 -0
- data/Rakefile +3 -1
- data/lib/ruby_pvwatts/version.rb +1 -1
- data/lib/ruby_pvwatts.rb +30 -10
- data/spec/ruby_pvwatts_spec.rb +48 -14
- metadata +4 -5
- data/Gemfile.lock +0 -96
- data/LICENSE +0 -20
- data/tasks/rspec.rake +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 784ed2168be668e37e0c0791d02901836bc31886
|
4
|
+
data.tar.gz: de3ee6d244ee83ed7611b4e27b401871f6bdd082
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d3d074442d8ad27b2c83962a022cec50fbb9f292e122905527808a9a9903cd58ed5fdf78d8f11a295aa8d0399ab163c8931d3e2dcff68e85a8d10994635384a
|
7
|
+
data.tar.gz: 1b8d87c0a2def0420b439d600320b0c92c1947c7b49c773a5f2526756d769e55543755981b8a33f34d8a67b0a00029c3bd89743331cc1cb24b71a83071bbff17
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Shad Self
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# ruby_pvwatts
|
2
|
+
|
3
|
+
Provides a wrapper for NREL PVWatts v5 API. Currently only supports JSON format.
|
4
|
+
Usage:
|
5
|
+
You need to pass in an API Key, which is obtained from the NREL.
|
6
|
+
Additionally, you'll need to include a hash of at least the required parameters.
|
7
|
+
See http://developer.nrel.gov/docs/solar/pvwatts-v5/ for more information.
|
8
|
+
|
9
|
+
This is a work in progress and will have multiple updates coming soon.
|
10
|
+
|
11
|
+
[Licensed under the MIT license](http://www.opensource.org/licenses/mit-license.php)
|
data/Rakefile
CHANGED
data/lib/ruby_pvwatts/version.rb
CHANGED
data/lib/ruby_pvwatts.rb
CHANGED
@@ -57,8 +57,10 @@ class RubyPvWatts
|
|
57
57
|
# [:+gcr+:] Ground coverage ratio
|
58
58
|
# [:+inv_eff+:] Inverter efficiency at rated power.
|
59
59
|
#
|
60
|
-
def initialize(
|
61
|
-
|
60
|
+
def initialize(opts)
|
61
|
+
error_message = check_required_params(opts)
|
62
|
+
raise ArgumentError.new(error_message) if error_message
|
63
|
+
options = { query: opts }
|
62
64
|
@response = self.class.get('/api/pvwatts/v5.json', options)
|
63
65
|
end
|
64
66
|
|
@@ -83,42 +85,42 @@ class RubyPvWatts
|
|
83
85
|
end
|
84
86
|
|
85
87
|
def ac
|
86
|
-
return nil unless
|
88
|
+
return nil unless hourly
|
87
89
|
@response['outputs']['ac']
|
88
90
|
end
|
89
91
|
|
90
92
|
def poa
|
91
|
-
return nil unless
|
93
|
+
return nil unless hourly
|
92
94
|
@response['outputs']['poa']
|
93
95
|
end
|
94
96
|
|
95
97
|
def dn
|
96
|
-
return nil unless
|
98
|
+
return nil unless hourly
|
97
99
|
@response['outputs']['dn']
|
98
100
|
end
|
99
101
|
|
100
102
|
def dc
|
101
|
-
return nil unless
|
103
|
+
return nil unless hourly
|
102
104
|
@response['outputs']['dc']
|
103
105
|
end
|
104
106
|
|
105
107
|
def df
|
106
|
-
return nil unless
|
108
|
+
return nil unless hourly
|
107
109
|
@response['outputs']['df']
|
108
110
|
end
|
109
111
|
|
110
112
|
def tamb
|
111
|
-
return nil unless
|
113
|
+
return nil unless hourly
|
112
114
|
@response['outputs']['tamb']
|
113
115
|
end
|
114
116
|
|
115
117
|
def tcell
|
116
|
-
return nil unless
|
118
|
+
return nil unless hourly
|
117
119
|
@response['outputs']['tcell']
|
118
120
|
end
|
119
121
|
|
120
122
|
def wspd
|
121
|
-
return nil unless
|
123
|
+
return nil unless hourly
|
122
124
|
@response['outputs']['wspd']
|
123
125
|
end
|
124
126
|
|
@@ -129,4 +131,22 @@ class RubyPvWatts
|
|
129
131
|
alias_method :hourly_ambient_temperature, :tamb
|
130
132
|
alias_method :hourly_module_temperature, :tcell
|
131
133
|
alias_method :hourly_windspeed, :wspd
|
134
|
+
|
135
|
+
private
|
136
|
+
|
137
|
+
def check_required_params(opts)
|
138
|
+
missing = []
|
139
|
+
missing << :api_key unless opts[:api_key]
|
140
|
+
missing << :system_capacity unless opts[:system_capacity]
|
141
|
+
missing << :losses unless opts[:losses]
|
142
|
+
missing << :module_type unless opts[:module_type]
|
143
|
+
missing << :array_type unless opts[:array_type]
|
144
|
+
missing << :tilt unless opts[:tilt]
|
145
|
+
missing << :azimuth unless opts[:azimuth]
|
146
|
+
"Required parameters missing: #{missing.join(', ')}" unless missing.empty?
|
147
|
+
end
|
148
|
+
|
149
|
+
def hourly
|
150
|
+
@response['inputs']['timeframe'] == 'hourly'
|
151
|
+
end
|
132
152
|
end
|
data/spec/ruby_pvwatts_spec.rb
CHANGED
@@ -1,11 +1,19 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe RubyPvWatts do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
describe 'Valid input' do
|
5
|
+
before :each do
|
6
|
+
stub_request(
|
7
|
+
:get,
|
8
|
+
'https://developer.nrel.gov/api/pvwatts/v5.json?address=123%20Fake%20Street%20Honolulu,%20HI%2096826&api_key=FAKE_API_KEY&array_type=1&azimuth=143&dataset=tmy3&losses=14&module_type=1&radius=0&system_capacity=5&tilt=22'
|
9
|
+
).with(
|
10
|
+
headers: {
|
11
|
+
'Accept' => '*/*',
|
12
|
+
'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
|
13
|
+
'User-Agent' => 'Ruby' }
|
14
|
+
).to_return(
|
15
|
+
status: 200,
|
16
|
+
body: {
|
9
17
|
'inputs' => {
|
10
18
|
'system_capacity' => '5',
|
11
19
|
'module_type' => '1',
|
@@ -86,17 +94,33 @@ describe RubyPvWatts do
|
|
86
94
|
'solrad_annual' => 5.6461567878723145
|
87
95
|
}
|
88
96
|
}.to_json,
|
89
|
-
headers: {}
|
97
|
+
headers: {}
|
98
|
+
)
|
90
99
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
100
|
+
@ruby_pvwatts = RubyPvWatts.new(api_key: 'FAKE_API_KEY',
|
101
|
+
system_capacity: 5, module_type: 1,
|
102
|
+
losses: 14, array_type: 1, tilt: 22,
|
103
|
+
azimuth: 143,
|
104
|
+
address: '123 Fake Street Honolulu, HI 96826',
|
105
|
+
dataset: 'tmy3', radius: 0)
|
106
|
+
end
|
107
|
+
|
108
|
+
subject { @ruby_pvwatts }
|
109
|
+
|
110
|
+
it { should respond_to :poa_monthly }
|
111
|
+
it { should respond_to :solrad_monthly }
|
112
|
+
it { should respond_to :solrad_annual }
|
113
|
+
it { should respond_to :dc_monthly }
|
114
|
+
it { should respond_to :ac_monthly }
|
115
|
+
it { should respond_to :ac }
|
116
|
+
it { should respond_to :poa }
|
117
|
+
it { should respond_to :dn }
|
118
|
+
it { should respond_to :dc }
|
119
|
+
it { should respond_to :df }
|
120
|
+
it { should respond_to :tamb }
|
121
|
+
it { should respond_to :tcell }
|
122
|
+
it { should respond_to :wspd }
|
98
123
|
|
99
|
-
describe 'Methods' do
|
100
124
|
it 'should have the correct value for poa_monthly' do
|
101
125
|
expect(@ruby_pvwatts.poa_monthly).to eq(
|
102
126
|
[149.582763671875, 149.54965209960938, 179.41624450683594,
|
@@ -116,5 +140,15 @@ describe RubyPvWatts do
|
|
116
140
|
it 'should have the correct value for solrad annual' do
|
117
141
|
expect(@ruby_pvwatts.solrad_annual).to eq(5.6461567878723145)
|
118
142
|
end
|
143
|
+
|
144
|
+
it 'should not report hourly values' do
|
145
|
+
expect(@ruby_pvwatts.wspd).to be_nil
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
describe 'Invalid input' do
|
150
|
+
it 'should raise an ArgumentError' do
|
151
|
+
expect { RubyPvWatts.new({}) }.to raise_error(ArgumentError)
|
152
|
+
end
|
119
153
|
end
|
120
154
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_pvwatts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shad Self
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -147,9 +147,9 @@ files:
|
|
147
147
|
- ".gitignore"
|
148
148
|
- ".rspec"
|
149
149
|
- Gemfile
|
150
|
-
- Gemfile.lock
|
151
150
|
- Guardfile
|
152
|
-
- LICENSE
|
151
|
+
- LICENSE.txt
|
152
|
+
- README.md
|
153
153
|
- Rakefile
|
154
154
|
- bin/_guard-core
|
155
155
|
- bin/guard
|
@@ -158,7 +158,6 @@ files:
|
|
158
158
|
- ruby_pvwatts.gemspec
|
159
159
|
- spec/ruby_pvwatts_spec.rb
|
160
160
|
- spec/spec_helper.rb
|
161
|
-
- tasks/rspec.rake
|
162
161
|
homepage: http://github.com/discypher/ruby_pvwatts
|
163
162
|
licenses:
|
164
163
|
- MIT
|
data/Gemfile.lock
DELETED
@@ -1,96 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
ruby_pvwatts (0.0.2)
|
5
|
-
httparty (~> 0.13.3)
|
6
|
-
json (~> 1.8)
|
7
|
-
|
8
|
-
GEM
|
9
|
-
remote: https://rubygems.org/
|
10
|
-
specs:
|
11
|
-
addressable (2.3.7)
|
12
|
-
celluloid (0.16.0)
|
13
|
-
timers (~> 4.0.0)
|
14
|
-
coderay (1.1.0)
|
15
|
-
crack (0.4.2)
|
16
|
-
safe_yaml (~> 1.0.0)
|
17
|
-
diff-lcs (1.2.5)
|
18
|
-
docile (1.1.5)
|
19
|
-
ffi (1.9.8)
|
20
|
-
formatador (0.2.5)
|
21
|
-
guard (2.12.5)
|
22
|
-
formatador (>= 0.2.4)
|
23
|
-
listen (~> 2.7)
|
24
|
-
lumberjack (~> 1.0)
|
25
|
-
nenv (~> 0.1)
|
26
|
-
notiffany (~> 0.0)
|
27
|
-
pry (>= 0.9.12)
|
28
|
-
shellany (~> 0.0)
|
29
|
-
thor (>= 0.18.1)
|
30
|
-
guard-compat (1.2.1)
|
31
|
-
guard-rspec (4.5.0)
|
32
|
-
guard (~> 2.1)
|
33
|
-
guard-compat (~> 1.1)
|
34
|
-
rspec (>= 2.99.0, < 4.0)
|
35
|
-
hitimes (1.2.2)
|
36
|
-
httparty (0.13.3)
|
37
|
-
json (~> 1.8)
|
38
|
-
multi_xml (>= 0.5.2)
|
39
|
-
json (1.8.2)
|
40
|
-
listen (2.9.0)
|
41
|
-
celluloid (>= 0.15.2)
|
42
|
-
rb-fsevent (>= 0.9.3)
|
43
|
-
rb-inotify (>= 0.9)
|
44
|
-
lumberjack (1.0.9)
|
45
|
-
method_source (0.8.2)
|
46
|
-
multi_json (1.11.0)
|
47
|
-
multi_xml (0.5.5)
|
48
|
-
nenv (0.2.0)
|
49
|
-
notiffany (0.0.6)
|
50
|
-
nenv (~> 0.1)
|
51
|
-
shellany (~> 0.0)
|
52
|
-
pry (0.10.1)
|
53
|
-
coderay (~> 1.1.0)
|
54
|
-
method_source (~> 0.8.1)
|
55
|
-
slop (~> 3.4)
|
56
|
-
rb-fsevent (0.9.4)
|
57
|
-
rb-inotify (0.9.5)
|
58
|
-
ffi (>= 0.5.0)
|
59
|
-
rspec (3.2.0)
|
60
|
-
rspec-core (~> 3.2.0)
|
61
|
-
rspec-expectations (~> 3.2.0)
|
62
|
-
rspec-mocks (~> 3.2.0)
|
63
|
-
rspec-core (3.2.2)
|
64
|
-
rspec-support (~> 3.2.0)
|
65
|
-
rspec-expectations (3.2.0)
|
66
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
67
|
-
rspec-support (~> 3.2.0)
|
68
|
-
rspec-mocks (3.2.1)
|
69
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
70
|
-
rspec-support (~> 3.2.0)
|
71
|
-
rspec-support (3.2.2)
|
72
|
-
safe_yaml (1.0.4)
|
73
|
-
shellany (0.0.1)
|
74
|
-
simplecov (0.9.2)
|
75
|
-
docile (~> 1.1.0)
|
76
|
-
multi_json (~> 1.0)
|
77
|
-
simplecov-html (~> 0.9.0)
|
78
|
-
simplecov-html (0.9.0)
|
79
|
-
slop (3.6.0)
|
80
|
-
thor (0.19.1)
|
81
|
-
timers (4.0.1)
|
82
|
-
hitimes
|
83
|
-
webmock (1.20.4)
|
84
|
-
addressable (>= 2.3.6)
|
85
|
-
crack (>= 0.3.2)
|
86
|
-
|
87
|
-
PLATFORMS
|
88
|
-
ruby
|
89
|
-
|
90
|
-
DEPENDENCIES
|
91
|
-
guard (~> 2.12, >= 2.12.5)
|
92
|
-
guard-rspec (~> 4.5, >= 4.5.0)
|
93
|
-
rspec (~> 3.2, >= 3.2.0)
|
94
|
-
ruby_pvwatts!
|
95
|
-
simplecov (~> 0.9, >= 0.9.2)
|
96
|
-
webmock (~> 1.20, >= 1.20.4)
|
data/LICENSE
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright (c) 2015 Shad Self
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/tasks/rspec.rake
DELETED