Method: Innate::Node#update_mapping_shared

Defined in:
lib/innate/node.rb

#update_mapping_shared(paths) ⇒ Object



829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
# File 'lib/innate/node.rb', line 829

def update_mapping_shared(paths)
  mapping = {}
  paths.reject!{|path| !File.directory?(path) }

  provides.each do |wish_key, engine|
    wish = wish_key[/(.*)_handler/, 1]
    exts = possible_exts_for(wish)

    paths.reverse_each do |path|
      Find.find(path) do |file|
        exts.each do |ext|
          next unless file =~ ext

          case file.sub(path, '').gsub('/', '__')
          when /^(.*)\.(.*)\.(.*)$/
            action_name, wish_ext, engine_ext = $1, $2, $3
          when /^(.*)\.(.*)$/
            action_name, wish_ext, engine_ext = $1, wish, $2
          end

          mapping[wish_ext] ||= {}
          mapping[wish_ext][action_name] = file
        end
      end
    end
  end

  return mapping
end