Module: Webui::Helper

Defined in:
lib/webui/helper.rb

Instance Method Summary collapse

Instance Method Details

#webui_modules_paths(path, relative_path, arr_name = 'modules') ⇒ String

Parameters:

  • path (Array)
  • arr_name (String) (defaults to: 'modules')
  • relative_path (String)

Returns:

  • (String)


7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/webui/helper.rb', line 7

def webui_modules_paths(path, relative_path, arr_name='modules')
  files = Dir.glob(path.join(*%w( ** *.js)))
  files += Dir.glob(path.join(*%w( ** *.js.erb)))
  code = ''
  files.each do |file|
    module_name = file[0, file.index('.')]
    module_filename = javascript_path(module_name.sub(Rails.root.to_s + '/' + relative_path + '/', ''))
    code += arr_name + "['" + module_name.sub(path.to_s + '/', '') + "'] = '" + module_filename.sub('.js', '') + "'\n"
  end

  code
end