Method: Nyx#read_script_configuration
- Defined in:
- lib/nyx.rb
#read_script_configuration(dirpath) ⇒ Object
def
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/nyx.rb', line 82 def read_script_configuration(dirpath) conf = self.mjolnir_config(dirpath, '+scripts.php'); # normalize targeted common if ! conf['targeted-common'].is_a?(Array) temp = []; conf['targeted-common'].each do |key, file| temp.push(file) end#each conf['targeted-common'] = temp; end#if # normalize targeted mapping conf['targeted-mapping'].each do |key, files| if ! files.is_a?(Array) && ! files.is_a?(String) temp = []; files.each do |key, file| temp.push(file) end#each conf['targeted-mapping'][key] = temp; end#if end#each if conf['targeted-common'] == nil conf['targeted-common'] = []; else # not nil conf['targeted-common'] = conf['targeted-common'].find_all do |item| item !~ /(^[a-z]+:\/\/|^\/\/).*$/ end#find_all end#def # remove aliased keys conf['targeted-mapping'].each do |key, files| if files.is_a? String conf['targeted-mapping'].delete(key); end#if end#each # include common files conf['targeted-mapping'].each do |key, files| files = files.find_all do |item| item !~ /(^[a-z]+:\/\/|^\/\/).*$/ end#find_all conf['targeted-mapping'][key] = conf['targeted-common'].clone; files.each do |file| if ( ! conf['targeted-mapping'][key].include?(file)) conf['targeted-mapping'][key].push(file) end#if end#each end#each # convert to paths conf['targeted-mapping'].each do |key, files| files = files.find_all do |item| item !~ /(^[a-z]+:\/\/|^\/\/).*$/ end#find_all cleaned_files = [] files.each do |value| if value.kind_of? Array cleaned_files.push value[1] else # not array cleaned_files.push value end#if end#each cleaned_files.collect! do |file| 'src/'+file+'.js'; end#collect conf['targeted-mapping'][key] = cleaned_files end#each # convert to paths files = conf['complete-mapping'] files = files.find_all do |item| item !~ /(^[a-z]+:\/\/|^\/\/).*$/ end#find_all cleaned_files = [] files.each do |key, value| if value.kind_of? Array cleaned_files.push value[1] else # not array cleaned_files.push value end#if end#each cleaned_files.collect! do |file| 'src/'+file+'.js'; end#collect conf['complete-mapping'] = cleaned_files return conf end |