green-button-data 0.1.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.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/.rspec +2 -0
- data/Gemfile +11 -0
- data/Guardfile +50 -0
- data/LICENSE.txt +26 -0
- data/README.md +72 -0
- data/Rakefile +5 -0
- data/green-button-data.gemspec +24 -0
- data/lib/green-button-data/core_ext/date.rb +9 -0
- data/lib/green-button-data/core_ext/fixnum.rb +10 -0
- data/lib/green-button-data/core_ext.rb +2 -0
- data/lib/green-button-data/dst.rb +49 -0
- data/lib/green-button-data/enumerations.rb +523 -0
- data/lib/green-button-data/feed.rb +7 -0
- data/lib/green-button-data/parser/application_information.rb +180 -0
- data/lib/green-button-data/parser/authorization.rb +45 -0
- data/lib/green-button-data/parser/content.rb +36 -0
- data/lib/green-button-data/parser/entry.rb +47 -0
- data/lib/green-button-data/parser/feed.rb +47 -0
- data/lib/green-button-data/parser/interval.rb +32 -0
- data/lib/green-button-data/parser/interval_block.rb +32 -0
- data/lib/green-button-data/parser/interval_reading.rb +30 -0
- data/lib/green-button-data/parser/local_time_parameters.rb +105 -0
- data/lib/green-button-data/parser/rational_number.rb +22 -0
- data/lib/green-button-data/parser/reading_type.rb +134 -0
- data/lib/green-button-data/parser/service_category.rb +17 -0
- data/lib/green-button-data/parser/usage_point.rb +20 -0
- data/lib/green-button-data/parser.rb +2 -0
- data/lib/green-button-data/utilities.rb +106 -0
- data/lib/green-button-data/version.rb +3 -0
- data/lib/green-button-data.rb +24 -0
- data/spec/fixtures/ESPIApplicationInformation.xml +49 -0
- data/spec/fixtures/ESPIAuthorization.xml +25 -0
- data/spec/fixtures/ESPIIntervalBlock.xml +3814 -0
- data/spec/fixtures/ESPILocalTimeParameters.xml +16 -0
- data/spec/fixtures/ESPIReadingType.xml +535 -0
- data/spec/fixtures/ESPIUsagePoint.xml +18 -0
- data/spec/fixtures.rb +22 -0
- data/spec/green-button-data/core_ext/date_spec.rb +18 -0
- data/spec/green-button-data/core_ext/fixnum_spec.rb +13 -0
- data/spec/green-button-data/parser/application_information_spec.rb +154 -0
- data/spec/green-button-data/parser/authorization_spec.rb +52 -0
- data/spec/green-button-data/parser/interval_block_spec.rb +39 -0
- data/spec/green-button-data/parser/local_time_parameter_spec.rb +56 -0
- data/spec/green-button-data/parser/reading_type_spec.rb +76 -0
- data/spec/green-button-data/parser/usage_point_spec.rb +22 -0
- data/spec/green-button-data/utilities_spec.rb +63 -0
- data/spec/spec_helper.rb +20 -0
- data/spec/support/custom_expectations/warn_expectation.rb +31 -0
- metadata +148 -0
@@ -0,0 +1,154 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe GreenButtonData::Parser::ApplicationInformation do
|
4
|
+
context "espi namespace" do
|
5
|
+
let(:feed) { GreenButtonData::Feed }
|
6
|
+
let :application_information do
|
7
|
+
feed.parse(espi_application_information)
|
8
|
+
.entries
|
9
|
+
.first
|
10
|
+
.content
|
11
|
+
.application_information
|
12
|
+
end
|
13
|
+
|
14
|
+
subject { application_information }
|
15
|
+
|
16
|
+
it "should parse data custodian id" do
|
17
|
+
expect(subject.data_custodian_id).to eq "data_custodian"
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should parse data custodian application status" do
|
21
|
+
expect(subject.data_custodian_application_status).to eq 1
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should parse data custodian scope selection URI" do
|
25
|
+
expect(subject.data_custodian_scope_selection_screen_uri).to eq "https://services.greenbuttondata.org//DataCustodian/RetailCustomer/ScopeSelectionList?ThirdPartyID=third_party"
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should parse data custodian bulk request URI" do
|
29
|
+
expect(subject.data_custodian_bulk_request_uri).to eq "https://services.greenbuttondata.org//DataCustodian/espi/1_1/resource/Batch/Bulk"
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should parse data custodian resource endpoint" do
|
33
|
+
expect(subject.data_custodian_resource_endpoint).to eq "https://services.greenbuttondata.org//DataCustodian/espi/1_1/resource"
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should parse third party application type" do
|
37
|
+
expect(subject.third_party_application_type).to eq 1
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should parse third party application use" do
|
41
|
+
expect(subject.third_party_application_use).to eq 1
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should parse third party application description" do
|
45
|
+
expect(subject.third_party_application_description).to eq "EnergyOS OpenESPI Example Third Party"
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should parse third party scope selection URI" do
|
49
|
+
expect(subject.third_party_scope_selection_screen_uri).to eq "https://services.greenbuttondata.org/ThirdParty/RetailCustomer/ScopeSelection"
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should parse third party user portal URI" do
|
53
|
+
expect(subject.third_party_user_portal_screen_uri).to eq "https://services.greenbuttondata.org/ThirdParty"
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should parse third party notify URI" do
|
57
|
+
expect(subject.third_party_notify_uri).to eq "https://services.greenbuttondata.org/ThirdParty/espi/1_1/Notification"
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should parse authorization server URI" do
|
61
|
+
expect(subject.authorization_server_uri).to eq "https://services.greenbuttondata.org//DataCustodian/"
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should parse authorization server's authorization endpoint" do
|
65
|
+
expect(subject.authorization_server_authorization_endpoint).to eq "https://services.greenbuttondata.org//DataCustodian/oauth/authorize"
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should parse authorization server's registration endpoint" do
|
69
|
+
expect(subject.authorization_server_registration_endpoint).to eq "https://services.greenbuttondata.org//DataCustodian/espi/1_1/register"
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should parse authorization server's token endpoint" do
|
73
|
+
expect(subject.authorization_server_token_endpoint).to eq "https://services.greenbuttondata.org//DataCustodian/oauth/token"
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should parse token endpoint's authentication method" do
|
77
|
+
expect(subject.token_endpoint_auth_method).to eq "client_secret_basic"
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should parse client name" do
|
81
|
+
expect(subject.client_name).to eq "Green Button Third Party"
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should parse client id" do
|
85
|
+
expect(subject.client_id).to eq "third_party"
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should parse client secret" do
|
89
|
+
expect(subject.client_secret).to eq "secret"
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should parse date when client ID was issued" do
|
93
|
+
expect(subject.client_id_issued_at).to eq DateTime.new 2014, 6, 19, 15
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should parse when client secret expires" do
|
97
|
+
expect(subject.client_secret_expires_at).to eq DateTime.new 9999, 12, 31, 23, 59, 59
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should parse redirect URI" do
|
101
|
+
expect(subject.redirect_uri).to eq "https://services.greenbuttondata.org/ThirdParty/espi/1_1/OAuthCallBack"
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should parse software id" do
|
105
|
+
expect(subject.software_id).to eq "EnergyOS OpenESPI Example Third Party"
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should parse software version" do
|
109
|
+
expect(subject.software_version).to eq "1.2"
|
110
|
+
end
|
111
|
+
|
112
|
+
it "should parse scopes" do
|
113
|
+
expect(subject.scopes.size).to eq 3
|
114
|
+
expect(subject.scopes.first).to eq "FB=1_3_4_5_13_14_39;IntervalDuration=3600;BlockDuration=monthly;HistoryLength=13"
|
115
|
+
expect(subject.scopes.last).to eq "FB=1_3_4_5_6_7_8_9_10_11_29_12_13_14_15_16_17_18_19_27_28_32_33_34_35_37_38_39_40_41_44;IntervalDuration=3600;BlockDuration=monthly;HistoryLength=13"
|
116
|
+
end
|
117
|
+
|
118
|
+
it "should parse grant types" do
|
119
|
+
expect(subject.grant_types.size).to eq 3
|
120
|
+
expect(subject.grant_types.first).to eq "authorization_code"
|
121
|
+
end
|
122
|
+
|
123
|
+
it "should parse response types" do
|
124
|
+
expect(subject.response_types.size).to eq 1
|
125
|
+
expect(subject.response_types.first).to eq "token"
|
126
|
+
end
|
127
|
+
|
128
|
+
it "should parse registration_client_uri" do
|
129
|
+
expect(subject.registration_client_uri).to eq "https://services.greenbuttondata.org//DataCustodian/espi/1_1/resource/ApplicationInformation/2"
|
130
|
+
end
|
131
|
+
|
132
|
+
it "should parse registration_access_token" do
|
133
|
+
expect(subject.registration_access_token).to eq "d89bb056-0f02-4d47-9fd2-ec6a19ba8d0c"
|
134
|
+
end
|
135
|
+
|
136
|
+
describe "#application_status" do
|
137
|
+
it "should return application status as a symbol" do
|
138
|
+
expect(subject.application_status).to eq :review
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
describe "#application_type" do
|
143
|
+
it "should return application type as a symbol" do
|
144
|
+
expect(subject.application_type).to eq :web
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
describe "#application_use" do
|
149
|
+
it "should return application use as a symbol" do
|
150
|
+
expect(subject.application_use).to eq :energy_management
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe GreenButtonData::Parser::Authorization do
|
4
|
+
context "espi namespace" do
|
5
|
+
let(:feed) { GreenButtonData::Feed }
|
6
|
+
let :authorization do
|
7
|
+
feed.parse(espi_authorization)
|
8
|
+
.entries
|
9
|
+
.first
|
10
|
+
.content
|
11
|
+
.authorization
|
12
|
+
end
|
13
|
+
|
14
|
+
subject { authorization }
|
15
|
+
|
16
|
+
it "should parse authorized period" do
|
17
|
+
expect(subject.authorized_period.start).to eq 0
|
18
|
+
expect(subject.authorized_period.duration).to eq 0
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should parse published period" do
|
22
|
+
expect(subject.published_period.start).to eq 0
|
23
|
+
expect(subject.published_period.duration).to eq 0
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should parse expiry date" do
|
27
|
+
expect(subject.expires_at).to eq DateTime.new 2025, 5, 12, 19, 3, 1
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should parse status" do
|
31
|
+
expect(subject.status).to eq 1
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should parse scope" do
|
35
|
+
expect(subject.scope).to eq "FB=36_40"
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should parse resource URI" do
|
39
|
+
expect(subject.resource_uri).to eq "https://services.greenbuttondata.org/DataCustodian/espi/1_1/resource/ApplicationInformation/2"
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should parse authorization URI" do
|
43
|
+
expect(subject.authorization_uri).to eq "https://services.greenbuttondata.org/DataCustodian/espi/1_1/resource/Authorization/4"
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "#active?" do
|
47
|
+
it "should return true if status is not 0" do
|
48
|
+
expect(subject.active?).to eq true
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe GreenButtonData::Parser::IntervalBlock do
|
4
|
+
context "espi namespace" do
|
5
|
+
let(:feed) { GreenButtonData::Feed }
|
6
|
+
let :interval_block do
|
7
|
+
feed.parse(espi_interval_block).entries.first.content.interval_block
|
8
|
+
end
|
9
|
+
|
10
|
+
subject { interval_block }
|
11
|
+
|
12
|
+
it "should parse interval" do
|
13
|
+
expect(subject.interval).to be_an_instance_of GreenButtonData::Parser::Interval
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should parse interval readings" do
|
17
|
+
expect(subject.interval_readings.size).to eq 31
|
18
|
+
expect(subject.interval_readings.first).to be_an_instance_of GreenButtonData::Parser::IntervalReading
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "#duration" do
|
22
|
+
it "should return the duration of the current interval block" do
|
23
|
+
expect(subject.duration).to eq 2678400
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "#starts_at" do
|
28
|
+
it "should return the start datetime" do
|
29
|
+
expect(subject.starts_at).to eq DateTime.new 2013, 1, 1, 5
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "#ends_at" do
|
34
|
+
it "should return the end datetime" do
|
35
|
+
expect(subject.ends_at).to eq DateTime.new 2013, 2, 1, 5
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe GreenButtonData::Parser::LocalTimeParameters do
|
4
|
+
context "espi namespace" do
|
5
|
+
let(:feed) { GreenButtonData::Feed }
|
6
|
+
let :local_time_parameters do
|
7
|
+
feed.parse(espi_local_time_parameters)
|
8
|
+
.entries
|
9
|
+
.first
|
10
|
+
.content
|
11
|
+
.local_time_parameters
|
12
|
+
end
|
13
|
+
|
14
|
+
subject { local_time_parameters }
|
15
|
+
|
16
|
+
it "should parse DST start rule" do
|
17
|
+
expect(subject.dst_start_rule).to eq 0x360e2000
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should parse DST end rule" do
|
21
|
+
expect(subject.dst_end_rule).to eq 0xb40e2000
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should parse DST offset" do
|
25
|
+
expect(subject.dst_offset).to eq 3600
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should parse timezone offset" do
|
29
|
+
expect(subject.tz_offset).to eq -18000
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "#dst_starts_at" do
|
33
|
+
it "should return DateTime object representation of DST rule" do
|
34
|
+
expect(subject.dst_starts_at(2015)).to eq DateTime.new 2015, 3, 8, 2
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "#dst_ends_at" do
|
39
|
+
it "should return DateTime object representation of DST rule" do
|
40
|
+
expect(subject.dst_ends_at(2015)).to eq DateTime.new 2015, 11, 1, 2
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "#total_offset" do
|
45
|
+
it "should return total offset from DST and timezone offsets in seconds" do
|
46
|
+
expect(subject.total_offset).to eq -14400
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "#total_offset_hours" do
|
51
|
+
it "should return total offset in hours" do
|
52
|
+
expect(subject.total_offset_hours).to eq -4
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe GreenButtonData::Parser::ReadingType do
|
4
|
+
context "espi namespace" do
|
5
|
+
let(:feed) { GreenButtonData::Feed }
|
6
|
+
let :reading_type do
|
7
|
+
feed.parse(espi_reading_type).entries.first.content.reading_type
|
8
|
+
end
|
9
|
+
|
10
|
+
subject { reading_type }
|
11
|
+
|
12
|
+
it "should parse accumulation behavior" do
|
13
|
+
expect(subject.accumulation_behaviour).to eq :delta_data
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should parse commodity" do
|
17
|
+
expect(subject.commodity).to eq :electricity_secondary_metered
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should parse consumption tier" do
|
21
|
+
expect(subject.consumption_tier).to eq nil
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should parse currency" do
|
25
|
+
expect(subject.currency).to eq :usd
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should parse data qualifier" do
|
29
|
+
expect(subject.data_qualifier).to eq :normal
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should parse flow direction" do
|
33
|
+
expect(subject.flow_direction).to eq :forward
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should parse interval length" do
|
37
|
+
expect(subject.interval_length).to eq 300
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should parse measurement kind" do
|
41
|
+
expect(subject.kind).to eq :energy
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should parse phase" do
|
45
|
+
expect(subject.phase).to eq :s12_n
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should parse power of ten multiplier" do
|
49
|
+
expect(subject.power_of_ten_multiplier).to eq 1
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should parse time attribute" do
|
53
|
+
expect(subject.time_attribute).to eq :none
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should parse unit of measurement" do
|
57
|
+
expect(subject.uom).to eq :Wh
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should parse cpp" do
|
61
|
+
expect(subject.cpp).to eq nil
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should parse interharmonic" do
|
65
|
+
expect(subject.interharmonic).to eq nil
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should parse measuring period" do
|
69
|
+
expect(subject.measuring_period).to eq nil
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should parse argument" do
|
73
|
+
expect(subject.argument).to eq nil
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe GreenButtonData::Parser::UsagePoint do
|
4
|
+
context "espi namespace" do
|
5
|
+
let(:feed) { GreenButtonData::Feed }
|
6
|
+
let :usage_point do
|
7
|
+
feed.parse(espi_usage_point).entries.first.content.usage_point
|
8
|
+
end
|
9
|
+
|
10
|
+
subject { usage_point }
|
11
|
+
|
12
|
+
it "should parse kind" do
|
13
|
+
expect(subject.kind).to eq 0
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#service_category" do
|
17
|
+
it "should return service category as a symbol" do
|
18
|
+
expect(subject.service_category).to eq :electricity
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require "#{File.dirname(__FILE__)}/../spec_helper"
|
2
|
+
|
3
|
+
describe GreenButtonData::Utilities do
|
4
|
+
before(:each) { @klass = Class.new { include GreenButtonData::Utilities } }
|
5
|
+
|
6
|
+
describe "#parse_datetime" do
|
7
|
+
it "should parse an ISO 8601 formatted datetime into DateTime" do
|
8
|
+
datetime = @klass.new.parse_datetime "2015-10-21T16:21:00.0-07:00"
|
9
|
+
expect(datetime.class).to eq DateTime
|
10
|
+
expect(datetime).to eq DateTime.new 2015, 10, 21, 23, 21, 0
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should warn and return nil when not a valid ISO 8601 format" do
|
14
|
+
# Ensure datetime is an instance of Object so we can properly test for nil
|
15
|
+
datetime = Object.new
|
16
|
+
expect {
|
17
|
+
datetime = @klass.new.parse_datetime "Hill Valley"
|
18
|
+
}.to warn("Parsing failed for string: \"Hill Valley\"")
|
19
|
+
expect(datetime).to be_nil
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "#normalize_epoch" do
|
24
|
+
it "should normalize UNIX epoch in microseconds to seconds" do
|
25
|
+
epoch = @klass.new.normalize_epoch 144546968100000
|
26
|
+
expect(epoch).to eq 1445469681
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should normalize UNIX epoch in milliseconds to seconds" do
|
30
|
+
epoch = @klass.new.normalize_epoch 1445469681000
|
31
|
+
expect(epoch).to eq 1445469681
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should keep UNIX epoch in seconds" do
|
35
|
+
epoch = @klass.new.normalize_epoch 1445469681
|
36
|
+
expect(epoch).to eq 1445469681
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "#first_sunday_of" do
|
41
|
+
it "should return the first Sunday of a given month" do
|
42
|
+
date = @klass.new.first_sunday_of 2015, 10
|
43
|
+
expect(date.day).to eq 4
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "#nth_weekday_of" do
|
48
|
+
it "should return the Nth weekday of a given month" do
|
49
|
+
third_wednesday = @klass.new.nth_weekday_of 2015, 10, 3, 3
|
50
|
+
expect(third_wednesday.day).to eq 21
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "#last_weekday_of" do
|
55
|
+
it "should return the last given day of the week of a given month" do
|
56
|
+
last_thursday = @klass.new.last_weekday_of 2015, 10, 4
|
57
|
+
last_friday = @klass.new.last_weekday_of 2015, 9, 5
|
58
|
+
|
59
|
+
expect(last_thursday.day).to eq 29
|
60
|
+
expect(last_friday.day).to eq 25
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
|
3
|
+
SimpleCov.start do
|
4
|
+
add_filter "/spec/"
|
5
|
+
end
|
6
|
+
|
7
|
+
if ENV['CI'] == 'true'
|
8
|
+
require 'codecov'
|
9
|
+
SimpleCov.formatter = SimpleCov::Formatter::Codecov
|
10
|
+
end
|
11
|
+
|
12
|
+
require File.expand_path(File.dirname(__FILE__) + '/../lib/green-button-data')
|
13
|
+
require 'fixtures'
|
14
|
+
require 'support/custom_expectations/warn_expectation'
|
15
|
+
|
16
|
+
SAXMachine.handler = ENV['HANDLER'].to_sym if ENV['HANDLER']
|
17
|
+
|
18
|
+
RSpec.configure do |c|
|
19
|
+
c.include Fixtures
|
20
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
RSpec::Matchers.define :warn do |message|
|
2
|
+
match do |block|
|
3
|
+
output = fake_stderr(&block)
|
4
|
+
output.include? message
|
5
|
+
end
|
6
|
+
|
7
|
+
description do
|
8
|
+
"write \"#{message}\" to standard error"
|
9
|
+
end
|
10
|
+
|
11
|
+
failure_message do
|
12
|
+
"expected to #{description}"
|
13
|
+
end
|
14
|
+
|
15
|
+
failure_message_when_negated do
|
16
|
+
"expected to not #{description}"
|
17
|
+
end
|
18
|
+
|
19
|
+
def fake_stderr
|
20
|
+
original_stderr = $stderr
|
21
|
+
$stderr = StringIO.new
|
22
|
+
yield
|
23
|
+
$stderr.string
|
24
|
+
ensure
|
25
|
+
$stderr = original_stderr
|
26
|
+
end
|
27
|
+
|
28
|
+
def supports_block_expectations?
|
29
|
+
true
|
30
|
+
end
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,148 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: green-button-data
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Andrew Jo
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-08-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: nokogiri
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sax-machine
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: guard
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: A library to parse large Green Button feed quickly
|
70
|
+
email: engineering@verdigris.co
|
71
|
+
executables: []
|
72
|
+
extensions: []
|
73
|
+
extra_rdoc_files: []
|
74
|
+
files:
|
75
|
+
- .gitignore
|
76
|
+
- .rspec
|
77
|
+
- Gemfile
|
78
|
+
- Guardfile
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- green-button-data.gemspec
|
83
|
+
- lib/green-button-data.rb
|
84
|
+
- lib/green-button-data/core_ext.rb
|
85
|
+
- lib/green-button-data/core_ext/date.rb
|
86
|
+
- lib/green-button-data/core_ext/fixnum.rb
|
87
|
+
- lib/green-button-data/dst.rb
|
88
|
+
- lib/green-button-data/enumerations.rb
|
89
|
+
- lib/green-button-data/feed.rb
|
90
|
+
- lib/green-button-data/parser.rb
|
91
|
+
- lib/green-button-data/parser/application_information.rb
|
92
|
+
- lib/green-button-data/parser/authorization.rb
|
93
|
+
- lib/green-button-data/parser/content.rb
|
94
|
+
- lib/green-button-data/parser/entry.rb
|
95
|
+
- lib/green-button-data/parser/feed.rb
|
96
|
+
- lib/green-button-data/parser/interval.rb
|
97
|
+
- lib/green-button-data/parser/interval_block.rb
|
98
|
+
- lib/green-button-data/parser/interval_reading.rb
|
99
|
+
- lib/green-button-data/parser/local_time_parameters.rb
|
100
|
+
- lib/green-button-data/parser/rational_number.rb
|
101
|
+
- lib/green-button-data/parser/reading_type.rb
|
102
|
+
- lib/green-button-data/parser/service_category.rb
|
103
|
+
- lib/green-button-data/parser/usage_point.rb
|
104
|
+
- lib/green-button-data/utilities.rb
|
105
|
+
- lib/green-button-data/version.rb
|
106
|
+
- spec/fixtures.rb
|
107
|
+
- spec/fixtures/ESPIApplicationInformation.xml
|
108
|
+
- spec/fixtures/ESPIAuthorization.xml
|
109
|
+
- spec/fixtures/ESPIIntervalBlock.xml
|
110
|
+
- spec/fixtures/ESPILocalTimeParameters.xml
|
111
|
+
- spec/fixtures/ESPIReadingType.xml
|
112
|
+
- spec/fixtures/ESPIUsagePoint.xml
|
113
|
+
- spec/green-button-data/core_ext/date_spec.rb
|
114
|
+
- spec/green-button-data/core_ext/fixnum_spec.rb
|
115
|
+
- spec/green-button-data/parser/application_information_spec.rb
|
116
|
+
- spec/green-button-data/parser/authorization_spec.rb
|
117
|
+
- spec/green-button-data/parser/interval_block_spec.rb
|
118
|
+
- spec/green-button-data/parser/local_time_parameter_spec.rb
|
119
|
+
- spec/green-button-data/parser/reading_type_spec.rb
|
120
|
+
- spec/green-button-data/parser/usage_point_spec.rb
|
121
|
+
- spec/green-button-data/utilities_spec.rb
|
122
|
+
- spec/spec_helper.rb
|
123
|
+
- spec/support/custom_expectations/warn_expectation.rb
|
124
|
+
homepage: http://verdigris.co
|
125
|
+
licenses: []
|
126
|
+
metadata: {}
|
127
|
+
post_install_message:
|
128
|
+
rdoc_options: []
|
129
|
+
require_paths:
|
130
|
+
- lib
|
131
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
132
|
+
requirements:
|
133
|
+
- - '>='
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: '0'
|
136
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
|
+
requirements:
|
138
|
+
- - '>='
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: '0'
|
141
|
+
requirements: []
|
142
|
+
rubyforge_project:
|
143
|
+
rubygems_version: 2.4.6
|
144
|
+
signing_key:
|
145
|
+
specification_version: 4
|
146
|
+
summary: Parser for Green Button data format
|
147
|
+
test_files: []
|
148
|
+
has_rdoc:
|