Class: RubyAppraiser

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-appraiser.rb,
lib/ruby-appraiser/cli.rb,
lib/ruby-appraiser/git.rb,
lib/ruby-appraiser/defect.rb,
lib/ruby-appraiser/version.rb,
lib/ruby-appraiser/appraisal.rb

Defined Under Namespace

Modules: Git Classes: Adapter, Appraisal, CLI, Defect

Constant Summary collapse

VERSION =
'1.0.3'

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ RubyAppraiser

Returns a new instance of RubyAppraiser.



13
14
15
# File 'lib/ruby-appraiser.rb', line 13

def initialize(options)
  @options = options.dup
end

Class Method Details

.rubytype?(filepath) ⇒ Boolean

Returns:

  • (Boolean)


45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/ruby-appraiser.rb', line 45

def rubytype?(filepath)
  # true if the extension matches
  filename = File::basename(filepath)
  return true if rubytypes.any? do |rubytype|
    File::fnmatch(rubytype, filename)
  end

  # true if file has a ruby shebang
  begin
    return true if File.open(filepath) do |file|
      file.readline(20).chomp =~ /\A#\!.+ruby/
    end
  rescue EOFError      # file was empty
  rescue ArgumentError # invalid byte sequence
  end

  false
end

.rubytypesObject



35
36
37
38
39
40
41
42
43
# File 'lib/ruby-appraiser.rb', line 35

def rubytypes
  %w(
    *.rb
    *.gemspec
    Capfile
    Gemfile
    Rakefile
  )
end

Instance Method Details

#appraisalObject



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/ruby-appraiser.rb', line 22

def appraisal
  unless @appraisal
    @appraisal = Appraisal.new(options)

    unless @appraisal.relevant_files.empty?
      appraisers(@appraisal).each(&:appraise)
    end
  end

  @appraisal
end

#optionsObject



17
18
19
# File 'lib/ruby-appraiser.rb', line 17

def options
  @options.dup
end