Skip to content

Commit

Permalink
Auto-fix Rubocop offenses
Browse files Browse the repository at this point in the history
  • Loading branch information
jobertabma committed May 31, 2020
1 parent b8a7899 commit 0d3b603
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions extract.rb
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
#!/usr/bin/env ruby

# frozen_string_literal: true

contents = ''

while line = STDIN.gets
contents << line
while (line = STDIN.gets)
contents += line
end

REGEX = %r{(^.*?("|')(/[\w\d\?/&=\#\.\!:_-]*?)(\2).*$)}.freeze
EXCERPT_FORMAT = "------------------------------------------------\r\n%s\r\n"

def sanitize_non_ascii(string)
encoding_options = {
invalid: :replace,
undef: :replace,
replace: '_',
replace: '_'
}

string.encode(Encoding.find('ASCII'), **encoding_options)
end

matched_endpoints = []

sanitize_non_ascii(contents).gsub(/;/, "\n").scan(/(^.*?("|')(\/[\w\d\?\/&=\#\.\!:_-]*?)(\2).*$)/).map do |string|
sanitize_non_ascii(contents).gsub(/;/, "\n").scan(REGEX).map do |string|
next if matched_endpoints.include?(string[2])

matched_endpoints << string[2]
Expand Down

0 comments on commit 0d3b603

Please sign in to comment.