Class: Dependence::JsModule

Inherits:
Object
  • Object
show all
Defined in:
lib/dependence/js_module.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ JsModule

Returns a new instance of JsModule.



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

def initialize(config)
  raise "need to pass :source_dir to constructor" unless config[:source_dir]
  raise "need to pass :source_type to constructor" unless config[:source_type]

  @config = config
  @name = File.basename(config[:source_dir])
  @output_file = File.join(@config[:output_dir], "#{@name}.js")

  @file_list = get_file_list_for_module(@config[:source_dir], @config[:source_type])
  @concat = Concatenator.new(@file_list)
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/dependence/js_module.rb', line 6

def name
  @name
end

Instance Method Details

#to_fileObject



21
22
23
24
25
26
27
28
# File 'lib/dependence/js_module.rb', line 21

def to_file
  File.open(@output_file, 'w') do |f|
    f.syswrite build()
  end

  JsCompressor.new(@output_file).compress if @config[:compress] == true
  stdout_compile_complete_msg(@name, @output_file)
end