lib/procemon/function/require.rb in procemon-0.5.0 vs lib/procemon/function/require.rb in procemon-0.6.1

- old
+ new

@@ -1,8 +1,8 @@ module Kernel - # load meta-s + # load meta folders rb files def meta_load(target_folder= File.join(Dir.pwd,"lib","**","meta") ) # find elements begin Dir.glob( File.join(target_folder,"*.{rb,ru}") ).each do |one_rb_file| @@ -10,65 +10,21 @@ end end end - def get_meta_config(target_folder= File.join(Dir.pwd,"lib","**","meta") ) - - # defaults - begin - require "yaml" - target_config_hash= Hash.new() - end - - # find elements - begin - - Dir.glob(File.join(target_folder,"*.{yaml,yml}")).each do |config_object| - - # defaults - begin - config_name_elements= config_object.split(File::SEPARATOR) - type= config_name_elements.pop.split('.')[0] - config_name_elements.pop - category= config_name_elements.pop - tmp_hash= Hash.new() - yaml_data= YAML.load(File.open(config_object)) - end - - # processing - begin - if target_config_hash[category].nil? - target_config_hash[category]= { type => yaml_data } - else - target_config_hash[category][type]= yaml_data - end - end - - end - - end - - # return data - begin - return target_config_hash - end - - end - # mount libs - def mount_libs(target_folder= File.join(Dir.pwd, "lib") ) + def mount_libs(lib_folder= File.join(Dir.pwd, "lib") ) # load lib files begin - Dir.glob(File.join(target_folder,"*.{rb,ru}")).uniq.each do |one_rb_file| + Dir.glob(File.join(lib_folder,"*.{rb,ru}")).uniq.each do |one_rb_file| require one_rb_file end end end - alias :require_folder :mount_libs # Offline repo activate def mount_modules(target_folder= File.join(Dir.pwd,"{module,modules}","{gem,gems}") ) Dir.glob(File.join(target_folder,"**","lib")).select{|f| File.directory?(f)}.each do |one_path| @@ -145,138 +101,8 @@ return Dir.glob(File.join(path,folder,"**","*.{rb,ru}")).each do |one_path| require one_path end end - end - - # generate config from yaml - def generate_config( - target_folder= File.join(Dir.pwd,"lib", "**","meta"), - override= true, - target_config_hash= Application.config - ) - - # defaults - begin - require "yaml" - if target_config_hash.class != Hash - target_config_hash= Hash.new() - end - end - - # find elements - begin - Dir.glob(File.join(target_folder,"*.{yaml,yml}")).each do |config_object| - - # defaults - begin - config_name_elements= config_object.split(File::SEPARATOR) - type= config_name_elements.pop.split('.')[0] - config_name_elements.pop - category= config_name_elements.pop - tmp_hash= Hash.new() - yaml_data= YAML.load(File.open(config_object)) - end - - # processing - begin - if target_config_hash[category].nil? - target_config_hash[category]= { type => yaml_data } - else - unless override == false - target_config_hash[category][type]= yaml_data - end - end - end - - end - end - - - # update by config - begin - - # get config files - begin - target_folder= target_folder.split(File::Separator).pinch(3).join(File::Separator) - config_yaml_paths= Array.new() - Dir.glob(File.join(target_folder, "{config,conf}","*.{yaml,yml}")).uniq.each do |one_path| - - case true - - when one_path.downcase.include?('default') - config_yaml_paths[0]= one_path - - when one_path.downcase.include?('development') - config_yaml_paths[1]= one_path - - when one_path.downcase.include?('test') - config_yaml_paths[2]= one_path - - when one_path.downcase.include?('production') - config_yaml_paths[3]= one_path - - else - config_yaml_paths[config_yaml_paths.count]= one_path - - end - - end - config_yaml_paths.select!{|x| x != nil } - end - - # params config load - unless Application.config_file.nil? - begin - path= File.expand_path(Application.config_file,"r") - File.open(path) - config_yaml_paths.push(path) - rescue Exception - config_yaml_paths.push(Application.config_file) - end - end - - # load to last lvl environment - begin - config_yaml_paths.each do |one_yaml_file_path| - begin - yaml_data= YAML.load(File.open(one_yaml_file_path)) - Application.config.deep_merge!(yaml_data) - - unless Application.environment.nil? - if one_yaml_file_path.include?(Application.environment.to_s) - break - end - end - rescue Exception - end - end - end - - end if target_folder == File.join(Dir.pwd,"lib", "**","meta") - - return target_config_hash - - end - - def generate_documentation(target_folder= File.join(Dir.pwd,"docs"), boolean= false,keyword= "generate") - boolean= false if boolean.nil? - if boolean == true - - document_generators= Array.new - tmp_path_container= Dir.glob(File.join(target_folder, "**", "*.{rb,ru}")) - tmp_path_container.each do |one_path| - if one_path.include? keyword - document_generators.push one_path - end - end - - document_generators.each do |docs_file_path| - require docs_file_path - end - - Process.exit! - end end end \ No newline at end of file