Skip to content

Commit

Permalink
Allow for Show Numbers to be labeled as 'Show Number' or simply 'show'
Browse files Browse the repository at this point in the history
  • Loading branch information
jkeck committed Jun 1, 2016
1 parent f6b383f commit 76ba9ce
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
5 changes: 3 additions & 2 deletions lib/rwj_reporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ def self.log_file_dir_from_settings
# <body>1,1,21,unlimited,-1,, - Show Number 062<br />1,1,21,unlimited,-1,, - Show Number 196a<br /></body>
#
# where the <body> contains "lines" that end with show numbers (lines are separated by <br> tags, not necessarily line breaks).
# the show number should be the last thing on each line. a show "number" might contain alpha chars, and is not strictly numeric.
# the show number should be the last thing on each line. a show "number" might contain alpha chars, is not strictly numeric,
# and can be labeled both "Show Number" or simply "show".
#
# returns an array of show numbers from such a text file by finding matches for a simple regex in the text.
# so, in the above example, the result would be ["062", "196a"]
def self.get_show_numbers_from_log_file(fname)
log_file_content = open(fname).read
log_file_content.scan(/Show Number (\w+)</).flatten
log_file_content.scan(/Show Number (\w+)<|show(\w+)</).flatten.compact
end

def self.get_filenames_for_date_range(log_file_dir, start_date_str, end_date_str)
Expand Down
2 changes: 1 addition & 1 deletion spec/fixtures/streamguys.160303- 601.log
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>StreamGuys Icecast Server</title>
</head>
<body>1,1,11,unlimited,-1,, - Show Number 156a<br />1,1,11,unlimited,-1,, - Show Number 046b<br /></body>
<body>1,1,11,unlimited,-1,, - Show Number 156a<br />1,1,11,unlimited,-1,, - show046b<br /></body>
</html>
2 changes: 1 addition & 1 deletion spec/fixtures/streamguys.160303-1101.log
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>StreamGuys Icecast Server</title>
</head>
<body>1,1,22,unlimited,-1,, - Show Number 181a<br />1,1,18,unlimited,-1,, - Show Number 101<br /></body>
<body>1,1,22,unlimited,-1,, - Show Number 181a<br />1,1,18,unlimited,-1,, - show101<br /></body>
</html>
5 changes: 5 additions & 0 deletions spec/lib/rwj_reporter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
fname = "#{FIXTURE_DIR}/streamguys.160201- 101.log"
expect(RwjReporter.get_show_numbers_from_log_file(fname)).to eq ['062', '196a']
end

it 'handles show numbers formatted as "show123a" as well as "Show Number 123a"' do
fname = "#{FIXTURE_DIR}/streamguys.160303-1101.log"
expect(RwjReporter.get_show_numbers_from_log_file(fname)).to eq ['181a', '101']
end
end

context '.get_filenames_for_date_range' do
Expand Down

0 comments on commit 76ba9ce

Please sign in to comment.