Class: ExpressionEngine::Initializer
- Inherits:
-
Object
- Object
- ExpressionEngine::Initializer
- Defined in:
- lib/vendor/initializer.rb
Constant Summary collapse
- CONFIGURATION_FILENAME =
'rbee.yml'
Instance Attribute Summary collapse
-
#configuration ⇒ Object
Returns the value of attribute configuration.
Class Method Summary collapse
Instance Method Summary collapse
- #configuration_file ⇒ Object
- #configuration_path ⇒ Object
-
#initialize(path) ⇒ Initializer
constructor
A new instance of Initializer.
- #initialized? ⇒ Boolean
- #root_path ⇒ Object
- #source_configuration_file ⇒ Object
- #system_path ⇒ Object
- #write_configuration ⇒ Object
Constructor Details
#initialize(path) ⇒ Initializer
Returns a new instance of Initializer.
13 14 15 |
# File 'lib/vendor/initializer.rb', line 13 def initialize(path) @current_path = path end |
Instance Attribute Details
#configuration ⇒ Object
Returns the value of attribute configuration.
6 7 8 |
# File 'lib/vendor/initializer.rb', line 6 def configuration @configuration end |
Class Method Details
.root_directory?(path) ⇒ Boolean
8 9 10 11 |
# File 'lib/vendor/initializer.rb', line 8 def self.root_directory?(path) directory = Dir.new(path) directory.entries.include?('index.php') && directory.entries.include?('path.php') end |
Instance Method Details
#configuration_file ⇒ Object
33 34 35 |
# File 'lib/vendor/initializer.rb', line 33 def configuration_file "#{self.configuration_path}/#{CONFIGURATION_FILENAME}" unless self.configuration_path.nil? end |
#configuration_path ⇒ Object
23 24 25 |
# File 'lib/vendor/initializer.rb', line 23 def configuration_path find_in_path(@current_path) {|path| File.exist?("#{path}/#{CONFIGURATION_FILENAME}")} end |
#initialized? ⇒ Boolean
41 42 43 |
# File 'lib/vendor/initializer.rb', line 41 def initialized? !self.configuration_file.nil? end |
#root_path ⇒ Object
17 18 19 20 21 |
# File 'lib/vendor/initializer.rb', line 17 def root_path path = self.configuration_path path = find_in_path(@current_path) {|path| self.class.root_directory?(path) } if path.nil? path end |
#source_configuration_file ⇒ Object
37 38 39 |
# File 'lib/vendor/initializer.rb', line 37 def source_configuration_file "#{self.system_path}/config.php" if self.system_path end |
#system_path ⇒ Object
27 28 29 30 31 |
# File 'lib/vendor/initializer.rb', line 27 def system_path config_file = 'config.php' paths = Dir["#{self.root_path}/**/#{config_file}"] paths.first.sub(/\/#{Regexp.escape(config_file)}$/, '') unless paths.empty? end |
#write_configuration ⇒ Object
45 46 47 |
# File 'lib/vendor/initializer.rb', line 45 def write_configuration File.open("#{self.root_path}/#{CONFIGURATION_FILENAME}", 'w') {|f| f << self.configuration.to_yaml } end |