class Librarian::RSpec::Support::CliMacro::FileMatcher

Attributes

base_path[RW]
content[RW]
rel_path[RW]
type[RW]

Public Class Methods

new(rel_path, content, options = { }) click to toggle source
# File lib/librarian/rspec/support/cli_macro.rb, line 28
def initialize(rel_path, content, options = { })
  self.rel_path = rel_path
  self.content = content
  self.type = options[:type]
end

Public Instance Methods

actual_content() click to toggle source
# File lib/librarian/rspec/support/cli_macro.rb, line 36
def actual_content
  @actual_content ||= begin
    s = full_path.read
    s = JSON.parse(s) if type == :json
    s
  end
end
full_path() click to toggle source
# File lib/librarian/rspec/support/cli_macro.rb, line 33
def full_path
  @full_path ||= base_path + rel_path
end
matches?(base_path) click to toggle source
# File lib/librarian/rspec/support/cli_macro.rb, line 43
def matches?(base_path)
  base_path = Pathname(base_path) unless Pathname === base_path
  self.base_path = base_path

  full_path.file? && (!content || actual_content == content)
end