lib/docman/docroot_config.rb in docman-0.0.86 vs lib/docman/docroot_config.rb in docman-0.0.87
- old
+ new
@@ -43,36 +43,41 @@
@raw_infos = {}
master_file = File.join(@docroot_config_dir, 'master')
if File.directory? master_file
@structure = structure_build(File.join(@docroot_config_dir, 'master'))
else
- @structure = structure_build_from_config_file(File.join(@docroot_config_dir, 'master'))
+ @structure = structure_build_from_config_file(Docman::Application.instance.config)
end
end
def update(options = '')
Dir.chdir @docroot_config_dir
GitUtil.exec("reset --hard", false)
branch = GitUtil.branch
GitUtil.update @docroot_config_dir, "#{options} #{branch.strip}"
end
- def structure_build_from_config_file(path, prefix = '', parent = nil, parent_key = 'master')
- config = Docman::Application.instance.config
+ def structure_build_from_config_file(config, prefix = '', parent = nil, parent_key = 'master')
return if config['components'][parent_key].nil?
children = []
info = config['components'][parent_key]
+
+ children_components_config = nil
+ unless info['components'].nil?
+ children_components_config = {'components' => info.delete('components')}
+ end
+
@raw_infos[parent_key] = info
unless info['status'].nil?
return if info['status'] == 'disabled'
end
name = parent_key
prefix = prefix.size > 0 ? File.join(prefix, name) : name
- info['full_path'] = path
+ info['full_path'] = @docroot_config_dir
info['docroot_config'] = self
info['build_path'] = prefix
info['full_build_path'] = File.join(@docroot_dir, prefix)
info['temp_path'] = File.join(@docroot_dir, '.docman/tmp', info['build_path'])
info['states_path'] = File.join(@docroot_dir, '.docman/states', info['build_path'])
@@ -89,19 +94,14 @@
@root = i if parent.nil?
i['root'] = @root
@names[name.to_s] = i
- # Dir.foreach(path) do |entry|
- # next if (entry == '..' || entry == '.')
- # full_path = File.join(path, entry)
- # if File.directory?(full_path)
- # dir_hash = structure_build(full_path, prefix, i)
- # unless dir_hash == nil
- # children << dir_hash
- # end
- # end
- # end
+ unless children_components_config.nil?
+ children_components_config['components'].each {|name, config|
+ children << structure_build_from_config_file(children_components_config, prefix, i, name)
+ }
+ end
i
end
def structure_build(path, prefix = '', parent = nil)
return unless File.file? File.join(path, 'info.yaml')