Class: JBundle::Writer

Inherits:
Object
  • Object
show all
Defined in:
lib/jbundle/writer.rb

Constant Summary collapse

TOKENS =

Interpolation tokens

{
  :version  => '[:version]'
}

Instance Method Summary collapse

Constructor Details

#initialize(compiler, config, target_dir) ⇒ Writer

Returns a new instance of Writer.



44
45
46
47
# File 'lib/jbundle/writer.rb', line 44

def initialize(compiler, config, target_dir)
  @compiler, @config, @version, @target_dir = compiler, config, config.version, target_dir
  @out = []
end

Instance Method Details

#writeObject



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/jbundle/writer.rb', line 49

def write
  release_targets do |versioned_target, version_string|
    if @compiler.buildable? # versionable JS file
      @out << write_file(
        @compiler.src, 
        versioned_target, 
        @compiler.dir, 
        interpolate(@compiler.name, TOKENS[:version] => version_string)
      )
      @out << write_file(
        @compiler.min, 
        versioned_target, 
        @compiler.dir, 
        interpolate(@compiler.min_name, TOKENS[:version] => version_string)
      )
    else # Other files (HTML, SWF, etc)
      @out << copy_file(
        @compiler.src_path, 
        versioned_target, 
        @compiler.dir, 
        interpolate(@compiler.name, TOKENS[:version] => version_string)
      )
    end
  end
  @out
end