Skip to content

Commit

Permalink
v0.3.6 prepared (#61)
Browse files Browse the repository at this point in the history
* v0.3.6 prepared

* Local tests passed but shouldn't?

* :allthethings: travis
  • Loading branch information
jufemaiz committed Mar 11, 2020
1 parent b8702e8 commit 002883e
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 15 deletions.
7 changes: 7 additions & 0 deletions .travis.yml
Expand Up @@ -6,16 +6,23 @@ bundler_args: --retry=3 --jobs=3
cache: bundler
sudo: false
rvm:
- 2.7.0
- 2.6.5
- 2.6.4
- 2.6.3
- 2.6.2
- 2.6.1
- 2.6.0
- 2.5.6
- 2.5.5
- 2.5.4
- 2.5.3
- 2.5.2
- 2.5.1
- 2.5.0
- 2.4.9
- 2.4.8
- 2.4.7
- 2.4.6
- 2.4.5
- 2.4.4
Expand Down
12 changes: 6 additions & 6 deletions Gemfile.lock
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
aemo (0.3.4)
aemo (0.3.6)
activesupport (>= 4.2.6, < 5.2)
httparty (~> 0.15, >= 0.15.6)
json (>= 1.7.5, < 3)
Expand All @@ -21,7 +21,7 @@ GEM
awesome_print (1.8.0)
builder (3.2.3)
coderay (1.1.2)
concurrent-ruby (1.1.5)
concurrent-ruby (1.1.6)
coveralls (0.8.23)
json (>= 1.8, < 3)
simplecov (~> 0.16.1)
Expand Down Expand Up @@ -63,7 +63,7 @@ GEM
highline (2.0.2)
httparty (0.16.2)
multi_xml (>= 0.5.2)
i18n (1.6.0)
i18n (1.8.2)
concurrent-ruby (~> 1.0)
jeweler (2.3.9)
builder
Expand All @@ -86,7 +86,7 @@ GEM
method_source (0.9.2)
mime-types (2.99.3)
mini_portile2 (2.4.0)
minitest (5.11.3)
minitest (5.14.0)
multi_json (1.13.1)
multi_xml (0.6.0)
multipart-post (2.1.1)
Expand Down Expand Up @@ -153,7 +153,7 @@ GEM
thread_safe (0.3.6)
timecop (0.9.1)
tins (1.21.1)
tzinfo (1.2.5)
tzinfo (1.2.6)
thread_safe (~> 0.1)
unicode-display_width (1.6.0)
webmock (3.6.2)
Expand Down Expand Up @@ -183,4 +183,4 @@ DEPENDENCIES
yard (~> 0.9, >= 0.9.11)!

BUNDLED WITH
2.0.2
2.1.4
42 changes: 35 additions & 7 deletions lib/aemo/nem12.rb
Expand Up @@ -274,6 +274,8 @@ class NEM12
attr_accessor :file_contents, :header, :nmi_data_details, :nmi

# Initialize a NEM12 file
# @param [string] nmi
# @param [Hash] options
def initialize(nmi, options = {})
@nmi = AEMO::NMI.new(nmi) unless nmi.empty?
@data_details = []
Expand All @@ -291,6 +293,7 @@ def nmi_identifier

# Parses the header record
# @param [String] line A single line in string format
# @param [Hash] options
# @return [Hash] the line parsed into a hash of information
def self.parse_nem12_100(line, options = {})
csv = line.parse_csv
Expand All @@ -312,6 +315,7 @@ def self.parse_nem12_100(line, options = {})

# Parses the NMI Data Details
# @param [String] line A single line in string format
# @param [Hash] options
# @return [Hash] the line parsed into a hash of information
def parse_nem12_200(line, options = {})
csv = line.parse_csv
Expand Down Expand Up @@ -346,6 +350,7 @@ def parse_nem12_200(line, options = {})
end

# @param [String] line A single line in string format
# @param [Hash] options
# @return [Array of hashes] the line parsed into a hash of information
def parse_nem12_300(line, options = {})
csv = line.parse_csv
Expand Down Expand Up @@ -380,7 +385,7 @@ def parse_nem12_300(line, options = {})
if csv[intervals_offset + 3].match(/\d{14}/).nil? || csv[intervals_offset + 3] != Time.parse(csv[intervals_offset + 3].to_s).strftime('%Y%m%d%H%M%S')
raise ArgumentError, 'UpdateDateTime is not valid'
end
if !csv[intervals_offset + 4].nil? && csv[intervals_offset + 4].match(/\d{14}/).nil? || csv[intervals_offset + 4] != Time.parse(csv[intervals_offset + 4].to_s).strftime('%Y%m%d%H%M%S')
if !csv[intervals_offset + 4].blank? && csv[intervals_offset + 4].match(/\d{14}/).nil? || !csv[intervals_offset + 4].blank? && csv[intervals_offset + 4] != Time.parse(csv[intervals_offset + 4].to_s).strftime('%Y%m%d%H%M%S')
raise ArgumentError, 'MSATSLoadDateTime is not valid'
end
end
Expand All @@ -397,7 +402,23 @@ def parse_nem12_300(line, options = {})
flag[:reason_code] = csv[intervals_offset + 1].to_i unless csv[intervals_offset + 1].nil?
end

base_interval = { data_details: @data_details.last, datetime: Time.parse("#{csv[1]}000000+1000"), value: nil, flag: flag }
# Deal with updated_at & msats_load_at
updated_at = nil
msats_load_at = nil

if options[:strict]
updated_at = Time.parse(csv[intervals_offset + 3]) unless csv[intervals_offset + 3].blank?
msats_load_at = Time.parse(csv[intervals_offset + 4]) unless csv[intervals_offset + 4].blank?
end

base_interval = {
data_details: @data_details.last,
datetime: Time.parse("#{csv[1]}000000+1000"),
value: nil,
flag: flag,
updated_at: updated_at,
msats_load_at: msats_load_at
}

intervals = []
(2..(number_of_intervals + 1)).each do |i|
Expand All @@ -411,8 +432,9 @@ def parse_nem12_300(line, options = {})
end

# @param [String] line A single line in string format
# @param [Hash] options
# @return [Hash] the line parsed into a hash of information
def parse_nem12_400(line)
def parse_nem12_400(line, options = {})
csv = line.parse_csv
raise ArgumentError, 'RecordIndicator is not 400' if csv[0] != '400'
raise ArgumentError, 'StartInterval is not valid' if csv[1].nil? || csv[1].match(/^\d+$/).nil?
Expand Down Expand Up @@ -451,11 +473,17 @@ def parse_nem12_400(line)
interval_events
end

# What even is a 500 row?
#
# @param [String] line A single line in string format
# @param [Hash] _options
# @return [Hash] the line parsed into a hash of information
def parse_nem12_500(_line, _options = {}); end

# 900 is the last row a NEM12 should see...
#
# @param [String] line A single line in string format
# @param [Hash] _options
# @return [Hash] the line parsed into a hash of information
def parse_nem12_900(_line, _options = {}); end

Expand Down Expand Up @@ -522,13 +550,13 @@ def self.parse_nem12(contents, strict = true)
nem12s << AEMO::NEM12.new('')
nem12s.last.parse_nem12_200(line, strict: strict)
when 300
nem12s.last.parse_nem12_300(line)
nem12s.last.parse_nem12_300(line, strict: strict)
when 400
nem12s.last.parse_nem12_400(line)
nem12s.last.parse_nem12_400(line, strict: strict)
# when 500
# nem12s.last.parse_nem12_500(line)
# nem12s.last.parse_nem12_500(line, strict: strict)
# when 900
# nem12s.last.parse_nem12_900(line)
# nem12s.last.parse_nem12_900(line, strict: strict)
end
end
# Return the array of NEM12 groups
Expand Down
2 changes: 1 addition & 1 deletion lib/aemo/nmi/allocation.rb
Expand Up @@ -440,7 +440,7 @@ def find_by_nmi(nmi)
def initialize(title, type, opts = {})
@title = title
@type = parse_allocation_type(type)
@identifier = opts.fetch(:identifier, title.upcase)
@identifier = opts.fetch(:participant_id, title.upcase)
@friendly_title = opts.fetch(:friendly_title, title)
@exclude_nmi_patterns = opts.fetch(:excludes, [])
@include_nmi_patterns = opts.fetch(:includes, [])
Expand Down
2 changes: 1 addition & 1 deletion lib/aemo/version.rb
Expand Up @@ -24,7 +24,7 @@
# @author Joel Courtney <euphemize@gmail.com>
module AEMO
# aemo version
VERSION = '0.3.5'
VERSION = '0.3.6'

# aemo version split amongst different revisions
MAJOR_VERSION, MINOR_VERSION, REVISION = VERSION.split('.').map(&:to_i)
Expand Down

0 comments on commit 002883e

Please sign in to comment.