Class: Zfben_libjs::Rb

Inherits:
Source
  • Object
show all
Defined in:
lib/zfben_libjs/support_source/rb.rb

Instance Attribute Summary

Attributes inherited from Source

#compiled, #filepath, #minified, #options, #source

Class Method Summary collapse

Methods inherited from Source

#compile, #download!, #initialize, #minify, #name, #remote?, #type

Constructor Details

This class inherits a constructor from Zfben_libjs::Source

Class Method Details

.new(*options) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/zfben_libjs/support_source/rb.rb', line 2

def self.new *options
  filepath = options[0][:filepath]
  if !filepath.nil?
    p filepath
    script = eval(File.read(filepath))
    class_name = script.keys[0].capitalize
    source = script.values[0]
    if Zfben_libjs.const_defined?(class_name, false)
      source_class = Zfben_libjs.const_get(class_name)
    else
      raise Exception.new(class_name + ' isn\'t exists!')
    end

    return source_class.new :filepath => filepath, :source => source, :options => options[0][:options]
  else
    raise Exception.new('filepath isn\'t exists!') 
  end
end