Sha256: baa0efce3862b78e4f787c9ea1e3310bcaf62cccfbb428d70c5840b8cf6e5657

Contents?: true

Size: 1.16 KB

Versions: 4

Compression:

Stored size: 1.16 KB

Contents

module WebFontLoader
  class Modules

    def initialize(*modules)
      @project_root = WebFontLoader::ProjectRoot
      @js_src = "src"
      @js_test = "src-test"
      @modules = modules.empty? ? config.keys : modules
      # Make sure 'core' is first.
      @modules.unshift "core"
      @modules.uniq!
    end

    attr_reader :modules
    attr_accessor :project_root, :js_src, :js_test

    def all_source_files
      @all_source_files ||= begin
        modules.map { |mod| config[mod] }.compact.flatten.map { |f| File.join(js_src, f) }
      end
    end

    def all_test_globs
      @all_test_globs ||= begin
        js_test_dirs = Dir[File.join(project_root, js_test, "*")].map { |d| File.basename(d) }
        js_test_dirs.map { |dir| File.join(js_test, dir, "*.js") if modules.include?(dir) }.compact
      end
    end

    def js_output_wrapper(source, version)
      File.read(File.join(js_src, "closure.js")).sub("{{source}}", source).sub("{{version}}", version).gsub(/\n|\r/,"")
    end

  protected

    def config
      @config ||= begin
        path = File.join(project_root, js_src)
        YAML.load_file(File.join(path, "modules.yml"))
      end
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
webfontloader-1.6.28 lib/webfontloader/modules.rb
webfontloader-1.6.27 lib/webfontloader/modules.rb
webfontloader-1.6.26 lib/webfontloader/modules.rb
webfontloader-1.6.25 lib/webfontloader/modules.rb