Class: Caligari::Application

Inherits:
Object
  • Object
show all
Defined in:
lib/caligari/application.rb

Overview

This class is instantiated and used to run a single invocation of the ‘caligari` application.

Constant Summary collapse

FLAGS =

The flags to be passed to ‘Pathname#fnmatch?` to filter exclusions.

File::FNM_DOTMATCH | File::FNM_PATHNAME
HOME =

The ‘Pathname` representation of the current user’s home directory.

Pathname.new(Dir.home)

Instance Method Summary collapse

Constructor Details

#initialize(*paths, **options) ⇒ self

Instantiates a new Caligari::Application instance.

Parameters:



24
25
26
27
28
29
30
# File 'lib/caligari/application.rb', line 24

def initialize(*paths, **options)
  @paths = paths.map { |path| Pathname.new(path) }
  options.each do |key, value|
    instance_variable_set(:"@#{key}", value)
  end
  collect_exclusions
end

Instance Method Details

#runself

Runs Caligari.

Returns:

  • (self)


35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/caligari/application.rb', line 35

def run
  @paths.each do |path|
    fail "#{path} is not a valid path" unless path.directory?
    if @traverse
      Dir.chdir(path) do
        each_file(Pathname.new('.')) { |file| link(file) }
      end
    else
      each_file(path) { |file| link(file) }
    end
  end
  self
end