Sha256: a5e5efbc2e961856c0418ff600483df87181ebe9197f3f3f922b3b9f0d63d3ca

Contents?: true

Size: 826 Bytes

Versions: 1

Compression:

Stored size: 826 Bytes

Contents

module Opal

  # Takes a package and builds it ready for the browser
  class Browserify

    def initialize(package)
      @package = package
      @builder = Builder.new
    end

    # Simple build - returns a string which can be written to a file
    # FIXME: hardcoded lib directory to './lib'
    def build
      libs = @package.lib_files
      libs.map! do |f|
        path = File.join @package.root, './lib', f
        src = @builder.compile_source path
        "\"#{f}\": #{src}"
      end

      bundle = []
      bundle << %[opal.package({\n]
      bundle << %[  name: "#{@package.name}",\n]
      bundle << %[  version: "#{@package.version}",\n]
      bundle << %[  libs: {\n]
      bundle << %[    #{libs.join ",\n    "}\n]
      bundle << %[  }\n]
      bundle << %[});\n]

      bundle.join ''
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
opal-0.3.9 lib/opal/browserify.rb