class Pronto::Runner

Public Class Methods

new(patches, commit = nil) click to toggle source
# File lib/pronto/runner.rb, line 5
def initialize(patches, commit = nil)
  @patches = patches
  @commit = commit
  @config = Config.new
end
runners() click to toggle source
# File lib/pronto/runner.rb, line 11
def self.runners
  repository
end
title() click to toggle source
# File lib/pronto/runner.rb, line 15
def self.title
  @runner_name ||= begin
    source_path, _line = instance_method(:run).source_location
    file_name, _extension = File.basename(source_path).split('.')
    file_name
  end
end

Public Instance Methods

repo_path() click to toggle source
# File lib/pronto/runner.rb, line 37
def repo_path
  @patches.first.repo.path
end
ruby_file?(path) click to toggle source
# File lib/pronto/runner.rb, line 30
def ruby_file?(path)
  rb_file?(path) ||
    rake_file?(path) ||
    gem_file?(path) ||
    ruby_executable?(path)
end
ruby_patches() click to toggle source
# File lib/pronto/runner.rb, line 23
def ruby_patches
  return [] unless @patches

  @ruby_patches ||= @patches.select { |patch| patch.additions > 0 }
    .select { |patch| ruby_file?(patch.new_file_full_path) }
end

Private Instance Methods

gem_file?(path) click to toggle source
# File lib/pronto/runner.rb, line 51
def gem_file?(path)
  File.basename(path) == 'Gemfile' || File.extname(path) == '.gemspec'
end
rake_file?(path) click to toggle source
# File lib/pronto/runner.rb, line 47
def rake_file?(path)
  File.extname(path) == '.rake'
end
rb_file?(path) click to toggle source
# File lib/pronto/runner.rb, line 43
def rb_file?(path)
  File.extname(path) == '.rb'
end
ruby_executable?(path) click to toggle source
# File lib/pronto/runner.rb, line 55
def ruby_executable?(path)
  return false if File.directory?(path)
  line = File.open(path, &:readline)
  line =~ /#!.*ruby/
rescue ArgumentError, EOFError
  false
end