Sha256: 7e3464380229b050cc7c2ba45cc947c21b76a460258aec8d8a8cb79ce0c998dd

Contents?: true

Size: 766 Bytes

Versions: 4

Compression:

Stored size: 766 Bytes

Contents

require 'requirejs/rails'

require 'pathname'
require 'ostruct'

module Requirejs::Rails
  class Builder
    # config should be an instance of Requirejs::Rails::Config
    
    def initialize(config)
      @config = config
    end
    
    def build      
      @config.tmp_dir
    end

    def digest_for(path)
      if !Rails.application.assets.file_digest(path).nil?
        Rails.application.assets.file_digest(path).hexdigest
      else
        raise Requirejs::BuildError, "Cannot compute digest for missing asset: #{path}"
      end
    end

    def generate_rjs_driver
      templ = Erubis::Eruby.new(@config.driver_template_path.read)
      @config.driver_path.open('w') do |f|
        f.write(templ.result(@config.get_binding))
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
requirejs-rails-0.9.5 lib/requirejs/rails/builder.rb
requirejs-rails-0.9.4 lib/requirejs/rails/builder.rb
requirejs-rails-0.9.3 lib/requirejs/rails/builder.rb
requirejs-rails-0.9.2 lib/requirejs/rails/builder.rb