Class: Pith::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/pith/config.rb

Constant Summary collapse

DEFAULT_IGNORE_PATTERNS =
["_*", ".git", ".gitignore", ".svn", ".sass-cache", "*~", "*.sw[op]"].to_set.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



9
10
11
12
# File 'lib/pith/config.rb', line 9

def initialize
  @ignore_patterns = DEFAULT_IGNORE_PATTERNS.dup
  @helper_module = Module.new
end

Instance Attribute Details

#assume_content_negotiationObject

Returns the value of attribute assume_content_negotiation.



14
15
16
# File 'lib/pith/config.rb', line 14

def assume_content_negotiation
  @assume_content_negotiation
end

#assume_directory_indexObject

Returns the value of attribute assume_directory_index.



15
16
17
# File 'lib/pith/config.rb', line 15

def assume_directory_index
  @assume_directory_index
end

#helper_moduleObject (readonly)

Returns the value of attribute helper_module.



23
24
25
# File 'lib/pith/config.rb', line 23

def helper_module
  @helper_module
end

#ignore_patternsObject (readonly)

Returns the value of attribute ignore_patterns.



17
18
19
# File 'lib/pith/config.rb', line 17

def ignore_patterns
  @ignore_patterns
end

Class Method Details

.load(config_file) ⇒ Object



31
32
33
34
35
36
37
38
# File 'lib/pith/config.rb', line 31

def load(config_file)
  config = self.new
  if config_file.exist?
    project = config # for backward compatibility
    eval(config_file.read, binding, config_file.to_s, 1)
  end
  config
end

Instance Method Details

#helpers(&block) ⇒ Object



25
26
27
# File 'lib/pith/config.rb', line 25

def helpers(&block)
  helper_module.module_eval(&block)
end

#ignore(*pattern) ⇒ Object



19
20
21
# File 'lib/pith/config.rb', line 19

def ignore(*pattern)
  pattern.flatten.each {|p| ignore_patterns << p }
end