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

Treat rake files as ruby files #82

Merged
merged 1 commit into from
Sep 20, 2015
Merged
Show file tree
Hide file tree
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
10 changes: 9 additions & 1 deletion lib/pronto/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,19 @@ def self.runners
end

def ruby_file?(path)
File.extname(path) == '.rb' || ruby_executable?(path)
rb_file?(path) || rake_file?(path) || ruby_executable?(path)
end

private

def rb_file?(path)
File.extname(path) == '.rb'
end

def rake_file?(path)
File.extname(path) == '.rake'
end

def ruby_executable?(path)
line = File.open(path) { |file| file.readline }
line =~ /#!.*ruby/
Expand Down
5 changes: 5 additions & 0 deletions spec/pronto/runner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ module Pronto
it { should be_truthy }
end

context 'ending with .rake' do
let(:path) { 'test.rake' }
it { should be_truthy }
end

context 'executable' do
let(:path) { 'test' }
before { File.stub(:open).with(path).and_return(shebang) }
Expand Down