Class: Leftovers::File

Inherits:
Pathname
  • Object
show all
Defined in:
lib/leftovers/file.rb

Instance Method Summary collapse

Instance Method Details

#relative_pathObject



7
8
9
10
11
12
13
# File 'lib/leftovers/file.rb', line 7

def relative_path
  @relative_path ||= begin
    relative_path_from(::Leftovers.pwd)
  rescue ::ArgumentError
    self
  end
end

#rubyObject



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/leftovers/file.rb', line 21

def ruby
  read = self.read

  precompiled = ::Leftovers.config.precompilers.map do |precompiler|
    precompiler.precompile(read, self)
  end.compact

  return read if precompiled.empty?

  precompiled.join("\n")
end

#test?Boolean

Returns:

  • (Boolean)


15
16
17
18
19
# File 'lib/leftovers/file.rb', line 15

def test?
  return @test if defined?(@test)

  @test = ::Leftovers.config.test_paths === relative_path
end