Sha256: 05aabde80bce99cabe231951442cf64e26f137188ea304d5cfbae54c48487460

Contents?: true

Size: 895 Bytes

Versions: 7

Compression:

Stored size: 895 Bytes

Contents

module Papers
  class Javascript < DependencySpecification
    def pretty_hash
      {
        name: @name,
        license: license,
        license_url: @license_url,
        project_url: @project_url
      }
    end

    def self.introspected
      dirs = Papers.config.javascript_paths
      whitelist_dirs = Papers.config.whitelist_javascript_paths

      # TODO: add logic for determining rails. Is Rails.root better than Dir.pwd for such a case?
      root_regexp = /^#{Regexp.escape Dir.pwd.to_s}\//
      files = dirs.map { |dir| Dir.glob("#{dir}/**/*.{js,js.erb,coffee,coffee.erb}") }.flatten.map do |name|
        name = name.sub(root_regexp, '')
        name unless whitelist_dirs.any? { |dir| name.start_with?(dir) }
      end
      files.compact
    end

    def self.asset_type_name
      'JavaScript file'
    end

    def self.manifest_key
      "javascripts"
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
papers-2.4.4 lib/papers/dependency_specification/javascript.rb
papers-2.4.3 lib/papers/dependency_specification/javascript.rb
papers-2.4.2 lib/papers/dependency_specification/javascript.rb
papers-2.4.1 lib/papers/dependency_specification/javascript.rb
papers-2.4.0 lib/papers/dependency_specification/javascript.rb
papers-2.3.0 lib/papers/dependency_specification/javascript.rb
papers-2.2.0 lib/papers/dependency_specification/javascript.rb