Class: Inch::Config::Codebase
- Inherits:
-
Object
- Object
- Inch::Config::Codebase
- Defined in:
- lib/inch/config/codebase.rb
Overview
Stores the configuration for an individual single codebase
Constant Summary collapse
- YAML_FILE =
'.inch.yml'
Instance Attribute Summary collapse
-
#excluded_files ⇒ Object
Returns the value of attribute excluded_files.
-
#included_files ⇒ Object
Returns the value of attribute included_files.
-
#language ⇒ Object
Returns the value of attribute language.
-
#read_dump_file ⇒ Object
Returns the value of attribute read_dump_file.
Class Method Summary collapse
-
.yaml(dir) ⇒ Hash?
Returns the contents of
dir
/.inch.yml, if present.
Instance Method Summary collapse
- #exclude_files(*files) ⇒ Object
- #include_files(*files) ⇒ Object
-
#initialize(language = :ruby, included = nil, excluded = nil) ⇒ Codebase
constructor
A new instance of Codebase.
-
#object_provider(sym = nil) ⇒ Symbol
Sets the object provider (e.g. :YARD).
-
#update(&block) ⇒ void
Update this Codebase config with the given block.
-
#update_via_yaml(dir) ⇒ void
Search the given
dir
for YAML_FILE and update this Codebase config with the contents if the file is found.
Constructor Details
#initialize(language = :ruby, included = nil, excluded = nil) ⇒ Codebase
Returns a new instance of Codebase.
12 13 14 15 16 |
# File 'lib/inch/config/codebase.rb', line 12 def initialize(language = :ruby, included = nil, excluded = nil) @language = language @included_files = included || [] @excluded_files = excluded || [] end |
Instance Attribute Details
#excluded_files ⇒ Object
Returns the value of attribute excluded_files.
7 8 9 |
# File 'lib/inch/config/codebase.rb', line 7 def excluded_files @excluded_files end |
#included_files ⇒ Object
Returns the value of attribute included_files.
6 7 8 |
# File 'lib/inch/config/codebase.rb', line 6 def included_files @included_files end |
#language ⇒ Object
Returns the value of attribute language.
5 6 7 |
# File 'lib/inch/config/codebase.rb', line 5 def language @language end |
#read_dump_file ⇒ Object
Returns the value of attribute read_dump_file.
8 9 10 |
# File 'lib/inch/config/codebase.rb', line 8 def read_dump_file @read_dump_file end |
Class Method Details
.yaml(dir) ⇒ Hash?
Returns the contents of dir
/.inch.yml, if present. Returns nil otherwise.
23 24 25 26 |
# File 'lib/inch/config/codebase.rb', line 23 def self.yaml(dir) yaml_file = File.join(dir, YAML_FILE) YAML.load(File.read(yaml_file)) if File.exist?(yaml_file) end |
Instance Method Details
#exclude_files(*files) ⇒ Object
52 53 54 |
# File 'lib/inch/config/codebase.rb', line 52 def exclude_files(*files) @excluded_files.concat(files).flatten! end |
#include_files(*files) ⇒ Object
48 49 50 |
# File 'lib/inch/config/codebase.rb', line 48 def include_files(*files) @included_files.concat(files).flatten! end |
#object_provider(sym = nil) ⇒ Symbol
Sets the object provider (e.g. :YARD)
60 61 62 63 |
# File 'lib/inch/config/codebase.rb', line 60 def object_provider(sym = nil) return @object_provider if sym.nil? @object_provider = sym end |
#update(&block) ⇒ void
This method returns an undefined value.
Update this Codebase config with the given block.
30 31 32 |
# File 'lib/inch/config/codebase.rb', line 30 def update(&block) instance_eval(&block) end |
#update_via_yaml(dir) ⇒ void
This method returns an undefined value.
Search the given dir
for YAML_FILE and update this Codebase config with the contents if the file is found.
39 40 41 42 43 44 45 46 |
# File 'lib/inch/config/codebase.rb', line 39 def update_via_yaml(dir) if (yaml = self.class.yaml(dir)) Dir.chdir(dir) do update_language yaml['language'] update_files yaml['files'] end end end |