Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow overriding the file extension. #71

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions lib/flay.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def self.default_options
:liberal => false,
:fuzzy => false,
:only => nil,
:ext => nil,
}
end

Expand Down Expand Up @@ -113,6 +114,11 @@ def self.parse_options args = ARGV
options[:timeout] = t.to_i
end

opts.on("-x", "--ext EXTENSION", String,
"Use specified file type, regardless of filename.") do |s|
options[:ext] = s
end

extensions = ["rb"] + Flay.load_plugins

opts.separator ""
Expand Down Expand Up @@ -186,8 +192,12 @@ def process(*files) # TODO: rename from process - should act as SexpProcessor
files.each do |file|
warn "Processing #{file}" if option[:verbose]

ext = File.extname(file).sub(/^\./, "")
ext = "rb" if ext.nil? || ext.empty?
if option[:ext] then
ext = option[:ext]
else
ext = File.extname(file).sub(/^\./, "")
ext = "rb" if ext.nil? || ext.empty?
end
msg = "process_#{ext}"

unless respond_to? msg then
Expand Down