From f81cab501c46c8c48c1eb08c66f7607c4d04fbae Mon Sep 17 00:00:00 2001 From: Sunny Ripert Date: Thu, 16 May 2019 15:08:53 +0200 Subject: [PATCH] Treat Gemfile and .gemspecs as Ruby (#344) * Treat Gemfile and .gemspecs as Ruby * Fix path of Gemfile --- lib/pronto/runner.rb | 9 ++++++++- spec/pronto/runner_spec.rb | 15 +++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/lib/pronto/runner.rb b/lib/pronto/runner.rb index 8a55e632..d787ec8d 100644 --- a/lib/pronto/runner.rb +++ b/lib/pronto/runner.rb @@ -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 @@ -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) diff --git a/spec/pronto/runner_spec.rb b/spec/pronto/runner_spec.rb index 994d3e41..40f3b57e 100644 --- a/spec/pronto/runner_spec.rb +++ b/spec/pronto/runner_spec.rb @@ -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) }