aemo 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fa7de5acdc8241646f30953344189284f92dafaecedece6bcd17d506a30c3ef8
4
- data.tar.gz: d94d22fc41ae2803a1fe1dde01271870e0527cd793668e87042926d1b5137da2
3
+ metadata.gz: fdbbd213839d4e575a4486126edc6e7294ae5b1536eb5a41b4a00498e14b422d
4
+ data.tar.gz: c07c4c97550ad396c02cebeaf763a14f9a38902234162d54eef257153366f4cd
5
5
  SHA512:
6
- metadata.gz: 39afcd7e6075b1629cfb3e7f5d2a6a5390023d24964f9d4450e47988235a27e93c6d0cf0e0d406673421587abba19d68e03a22844c17367211d6eb6094f7d512
7
- data.tar.gz: 3cdfce782976e5e7471fecca7d500a508e98c55c7cbd4b504af1a576df7b0bf971003ceb9951993d34d10e11b3e7b0c7cf609a4a8906928d590bff5e10c0013f
6
+ metadata.gz: e127180a5548361631948231a34a93cbee1a074bf8be093a7efcbea0bfa971ef953f4d807f1a0624093f18c4a6440df3fbe8d79a819ade07c97ff65d67062ac4
7
+ data.tar.gz: 5bbfe5e1431e689f146660164097c7a4ee47ad5c6a2f45d6384569c64118e52809ac5282fbdc80480d39d659025e49e83a38da71e3cbcccf4de2509c82c55238
@@ -349,15 +349,19 @@ module AEMO
349
349
  # @return [Array of hashes] the line parsed into a hash of information
350
350
  def parse_nem12_300(line, options = {})
351
351
  csv = line.parse_csv
352
-
353
352
  raise TypeError, 'Expected NMI Data Details to exist with IntervalLength specified' if @data_details.last.nil? || @data_details.last[:interval_length].nil?
353
+
354
+ # ref: AEMO's MDFF Spec NEM12 and NEM13 v1.01 (2014-05-14)
355
+ record_fixed_fields = %w[RecordIndicator IntervalDate QualityMethod ReasonCode ReasonDescription UpdateDatetime MSATSLoadDateTime]
354
356
  number_of_intervals = 1440 / @data_details.last[:interval_length]
357
+ raise TypeError, 'Invalid record length' if csv.length != record_fixed_fields.length + number_of_intervals
358
+
355
359
  intervals_offset = number_of_intervals + 2
356
360
 
357
361
  raise ArgumentError, 'RecordIndicator is not 300' if csv[0] != '300'
358
362
  raise ArgumentError, 'IntervalDate is not valid' if csv[1].match(/\d{8}/).nil? || csv[1] != Time.parse(csv[1].to_s).strftime('%Y%m%d')
359
363
  (2..(number_of_intervals + 1)).each do |i|
360
- raise ArgumentError, "Interval number #{i - 1} is not valid" if csv[i].match(/\d+(\.\d+)?/).nil?
364
+ raise ArgumentError, "Interval number #{i - 1} is not valid" if csv[i].nil? || csv[i].match(/\d+(\.\d+)?/).nil?
361
365
  end
362
366
  raise ArgumentError, 'QualityMethod is not valid' unless csv[intervals_offset + 0].class == String
363
367
  raise ArgumentError, 'QualityMethod does not have valid length' unless [1, 3].include?(csv[intervals_offset + 0].length)
@@ -411,9 +415,9 @@ module AEMO
411
415
  def parse_nem12_400(line)
412
416
  csv = line.parse_csv
413
417
  raise ArgumentError, 'RecordIndicator is not 400' if csv[0] != '400'
414
- raise ArgumentError, 'StartInterval is not valid' if csv[1].match(/^\d+$/).nil?
415
- raise ArgumentError, 'EndInterval is not valid' if csv[2].match(/^\d+$/).nil?
416
- raise ArgumentError, 'QualityMethod is not valid' if csv[3].match(/^([AN]|([AEFNSV]\d{2}))$/).nil?
418
+ raise ArgumentError, 'StartInterval is not valid' if csv[1].nil? || csv[1].match(/^\d+$/).nil?
419
+ raise ArgumentError, 'EndInterval is not valid' if csv[2].nil? || csv[2].match(/^\d+$/).nil?
420
+ raise ArgumentError, 'QualityMethod is not valid' if csv[3].nil? || csv[3].match(/^([AN]|([AEFNSV]\d{2}))$/).nil?
417
421
  # raise ArgumentError, 'ReasonCode is not valid' if (csv[4].nil? && csv[3].match(/^ANE/)) || csv[4].match(/^\d{3}?$/) || csv[3].match(/^ANE/)
418
422
  # raise ArgumentError, 'ReasonDescription is not valid' if (csv[4].nil? && csv[3].match(/^ANE/)) || ( csv[5].match(/^$/) && csv[4].match(/^0$/) )
419
423
 
@@ -24,7 +24,7 @@
24
24
  # @author Joel Courtney <euphemize@gmail.com>
25
25
  module AEMO
26
26
  # aemo version
27
- VERSION = '0.3.0'
27
+ VERSION = '0.3.1'
28
28
 
29
29
  # aemo version split amongst different revisions
30
30
  MAJOR_VERSION, MINOR_VERSION, REVISION = VERSION.split('.').map(&:to_i)
@@ -0,0 +1,4 @@
1
+ 100,NEM12,200505181432,CNRGYMDP,NEMMCO
2
+ 200,NEM1201002,E1,E1,E1,N1,01002,KWH,30,
3
+ 300,20050315,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,A,,,20050316014209,
4
+ 900
@@ -0,0 +1,8 @@
1
+ 100,NEM12,200504210935,WBAYM,NEMMCO
2
+ 200,NEM1201010,E1E2,,E1,N1,01010,kWh,30,
3
+ 300,20050305,1832.51,1707.74,1608.67,1628.47,1644.39,1617.39,1539.87,1492.38,1499.55,1491.75,1427.61,1450.55,1487.92,1377.05,1371.61,1407.45,1249.92,1309.85,1296.15,1285.1,1342.47,1303.87,1255.95,1294.83,1361.27,1383.39,1403.07,1486.87,1613.53,1581.35,1466.69,1297.42,1169.94,1094.91,1459.1,1335.62,1278.71,1319.1,1292.94,1243.86,1299.5,1257.6,1287.33,1227.28,1293.34,1244.71,1282.68,1258.1,A,,,20050421081805,
4
+ 300,20050306,1254.43,1221.69,1208.19,1214.3,1271.1,1203.55,1161.82,1161.41,1170.96,1152.25,1118.34,1125.05,1186.6,1183.8,1215.59,1241.14,1250.63,1228.9,1224.77,1252.75,1238.03,1284.19,1264.23,1285.67,1322.01,1308.02,1290.7,1335.53,1368.84,1480.85,1223.51,1277.96,1300.66,1328.22,1265.31,1254.55,1231.74,1239.16,1174.06,1211.66,1172.19,1191.44,1231.58,1279.82,1253.19,1183.71,1181.86,1141.48,A,,,20050421081805,
5
+ 300,20050307,1208.34,1245.41,1242,1210.67,1389.96,1343.92,1419.53,1364.32,1422.17,1452.68,1548.35,1756.84,1995.47,2252.12,2629.64,2673.19,2682.86,2559.22,2740.62,2735.74,2797.83,2782.9,2849.85,2892.1,2760.26,2932.58,2916.79,3006.37,2997.92,2982.44,2843.39,2650.55,2366.95,2414.74,2433.92,2393,2481.81,2420.54,2339.02,2294.67,2267.39,2225.93,2215.23,2254.36,2215.43,2176.78,2097.44,1960.64,A,,,20050421081805,
6
+ 300,20050308,1911.77,1887.22,1848.15,1837.62,1894.4,1976.38,1962.79,1938.92,1904.96,1866.19,2055.67,2186.99,2448.23,2563.53,2637.81,2833.17,2848.7,2725.29,2878.08,2818.36,2841.61,2927.15,2929.52,2880,2799.11,2952.93,2960.64,2986.41,3047.51,3035.36,2899.8,2724.43,2620.27,2486.11,2507.44,2561.05,2583.66,2382.79,1849.87,1821.83,1839.49,2094.05,2273.56,2218.17,2256.87,2266.54,2199.18,2090.56,A,,,20050421081805,
7
+ 400,,,F56,45,
8
+ 900
@@ -0,0 +1,4 @@
1
+ 100,NEM12,200505181432,CNRGYMDP,NEMMCO
2
+ 200,NEM1201002,E1E2,E1,E1,N1,01002,KWH,30,
3
+ 300,20050315,300.000,266.100,191.550,247.800,288.600,280.800,282.450,206.100,407.700,432.600,435.000,491.850,600.900,541.950,474.600,565.350,548.550,491.850,593.250,602.400,571.350,450.150,509.400,559.950,522.000,520.950,541.200,538.050,484.800,330.900,329.250,331.650,330.750,333.750,335.250,294.150,185.250,184.800,186.450,256.800,329.700,320.100,316.500,321.150,A,,,20050316014209,
4
+ 900
@@ -67,9 +67,22 @@ describe AEMO::NEM12 do
67
67
  end
68
68
 
69
69
  describe '#parse_nem12_300' do
70
+ it 'should raise invalid record length error' do
71
+ bad_file = fixture(File.join('NEM12-Errors', 'NEM12#InvalidIntervalDataLength#CNRGYMDP#NEMMCO.csv'))
72
+ expect { AEMO::NEM12.parse_nem12_file(bad_file) }.to raise_error(TypeError, 'Invalid record length')
73
+ end
74
+
75
+ it 'should raise argument error on 300 empty cells' do
76
+ nem12_empty_cells_300_record = fixture(File.join('NEM12-Errors', 'NEM12#EmptyCells300Record#CNRGYMDP#NEMMCO.csv'))
77
+ expect { AEMO::NEM12.parse_nem12_file(nem12_empty_cells_300_record) }.to raise_error(ArgumentError)
78
+ end
70
79
  end
71
80
 
72
81
  describe '#parse_nem12_400' do
82
+ it 'should raise argument error on 400 empty cells' do
83
+ nem12_empty_cells_400_record = fixture(File.join('NEM12-Errors', 'NEM12#EmptyCells400Record#CNRGYMDP#NEMMCO.csv'))
84
+ expect { AEMO::NEM12.parse_nem12_file(nem12_empty_cells_400_record) }.to raise_error(ArgumentError)
85
+ end
73
86
  end
74
87
 
75
88
  describe '#parse_nem12_500' do
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aemo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Courtney
8
8
  - Stuart Auld
9
9
  - Neil Parikh
10
+ - Olivier Nsabimana
10
11
  autorequire:
11
12
  bindir: bin
12
13
  cert_chain: []
@@ -352,6 +353,7 @@ email:
352
353
  - jcourtney@cozero.com.au
353
354
  - sauld@cozero.com.au
354
355
  - nparikh@cozero.com.au
356
+ - onsabimana@cozero.com.au
355
357
  executables: []
356
358
  extensions: []
357
359
  extra_rdoc_files: []
@@ -395,6 +397,9 @@ files:
395
397
  - spec/fixtures/NEM12-Errors/NEM12#000000000000024#CNRGYMDP#NEMMCO
396
398
  - spec/fixtures/NEM12-Errors/NEM12#000000000000025#CNRGYMDP#NEMMCO
397
399
  - spec/fixtures/NEM12-Errors/NEM12#DerpyNMIConfig#CNRGYMDP#NEMMCO.csv
400
+ - spec/fixtures/NEM12-Errors/NEM12#EmptyCells300Record#CNRGYMDP#NEMMCO.csv
401
+ - spec/fixtures/NEM12-Errors/NEM12#EmptyCells400Record#CNRGYMDP#NEMMCO.csv
402
+ - spec/fixtures/NEM12-Errors/NEM12#InvalidIntervalDataLength#CNRGYMDP#NEMMCO.csv
398
403
  - spec/fixtures/NEM12/NEM12#000000000000001#CNRGYMDP#NEMMCO.csv
399
404
  - spec/fixtures/NEM12/NEM12#000000000000002#CNRGYMDP#NEMMCO.csv
400
405
  - spec/fixtures/NEM12/NEM12#000000000000003#CNRGYMDP#NEMMCO.csv
@@ -543,6 +548,9 @@ test_files:
543
548
  - spec/fixtures/NEM12-Errors/NEM12#000000000000024#CNRGYMDP#NEMMCO
544
549
  - spec/fixtures/NEM12-Errors/NEM12#000000000000025#CNRGYMDP#NEMMCO
545
550
  - spec/fixtures/NEM12-Errors/NEM12#DerpyNMIConfig#CNRGYMDP#NEMMCO.csv
551
+ - spec/fixtures/NEM12-Errors/NEM12#EmptyCells300Record#CNRGYMDP#NEMMCO.csv
552
+ - spec/fixtures/NEM12-Errors/NEM12#EmptyCells400Record#CNRGYMDP#NEMMCO.csv
553
+ - spec/fixtures/NEM12-Errors/NEM12#InvalidIntervalDataLength#CNRGYMDP#NEMMCO.csv
546
554
  - spec/fixtures/NEM12/NEM12#000000000000001#CNRGYMDP#NEMMCO.csv
547
555
  - spec/fixtures/NEM12/NEM12#000000000000002#CNRGYMDP#NEMMCO.csv
548
556
  - spec/fixtures/NEM12/NEM12#000000000000003#CNRGYMDP#NEMMCO.csv