Skip to content

Commit

Permalink
Treat Gemfile and .gemspecs as Ruby (prontolabs#344)
Browse files Browse the repository at this point in the history
* Treat Gemfile and .gemspecs as Ruby

* Fix path of Gemfile
  • Loading branch information
sunny authored and doomspork committed May 16, 2019
1 parent bd3b3ac commit f81cab5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/pronto/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ def ruby_patches
end

def ruby_file?(path)
rb_file?(path) || rake_file?(path) || ruby_executable?(path)
rb_file?(path) ||
rake_file?(path) ||
gem_file?(path) ||
ruby_executable?(path)
end

def repo_path
Expand All @@ -45,6 +48,10 @@ def rake_file?(path)
File.extname(path) == '.rake'
end

def gem_file?(path)
File.basename(path) == 'Gemfile' || File.extname(path) == '.gemspec'
end

def ruby_executable?(path)
return false if File.directory?(path)
line = File.open(path, &:readline)
Expand Down
15 changes: 15 additions & 0 deletions spec/pronto/runner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,21 @@ module Pronto
it { should be_truthy }
end

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

context 'named Gemfile' do
let(:path) { 'Gemfile' }
it { should be_truthy }
end

context 'named Gemfile in directory' do
let(:path) { 'test/Gemfile' }
it { should be_truthy }
end

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

0 comments on commit f81cab5

Please sign in to comment.