Class: CodeFormatter::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/src/configuration.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ Configuration

Returns a new instance of Configuration.

Yields:

  • (_self)

Yield Parameters:



10
11
12
13
14
15
16
17
# File 'lib/src/configuration.rb', line 10

def initialize
  self.included_files = []
  self.excluded_files = []
  self.included_dirs = []
  self.excluded_dirs = []

  yield self if block_given?
end

Instance Attribute Details

#excluded_dirsObject

Returns the value of attribute excluded_dirs.



6
7
8
# File 'lib/src/configuration.rb', line 6

def excluded_dirs
  @excluded_dirs
end

#excluded_filesObject

Returns the value of attribute excluded_files.



4
5
6
# File 'lib/src/configuration.rb', line 4

def excluded_files
  @excluded_files
end

#included_dirsObject

Returns the value of attribute included_dirs.



5
6
7
# File 'lib/src/configuration.rb', line 5

def included_dirs
  @included_dirs
end

#included_filesObject

Returns the value of attribute included_files.



3
4
5
# File 'lib/src/configuration.rb', line 3

def included_files
  @included_files
end

#source_fileObject

Returns the value of attribute source_file.



8
9
10
# File 'lib/src/configuration.rb', line 8

def source_file
  @source_file
end

Class Method Details

.load_from(file) ⇒ Configuration

Parameters:

  • file (String)

Returns:



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/src/configuration.rb', line 21

def self.load_from(file)
  return unless file || File.file?(file)

  begin
    config = eval(File.read(file), binding, 'config loading problem')
    config.source_file = file
    return config if config.is_a? Config

    warn "[#{file}] isn't a CodeFormatter::Configuration, but #{config.class}."
  rescue SyntaxError, StandardError => e
    warn "Invalid configuration in [#{file}]: #{e}"
  end
end