Class: Ext::JsHelpers::Controllers::JoinScripts

Inherits:
Object
  • Object
show all
Defined in:
lib/ext/js_helpers.rb

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.rootObject

Returns the value of attribute root.



26
27
28
# File 'lib/ext/js_helpers.rb', line 26

def root
  @root
end

Class Method Details

.urlsObject



27
# File 'lib/ext/js_helpers.rb', line 27

def urls; ['/scripts/(.*).js'] end

Instance Method Details

#get(scripts) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/ext/js_helpers.rb', line 32

def get(scripts)
  scripts = scripts.split(';').uniq
  data = ""
  scripts.each do |script|
    path = File.join(self.class.root, "#{script}.js")
    begin
      data << File.open(path).read
    rescue Errno::ENOENT => ex
      data << "// ERROR : #{ex}\n"
    end
  end

  data
end