Sha256: 62793ff835d7317b2ac2dda9f23d02c96a23873444f5777a77a0d3f8e772a6fa

Contents?: true

Size: 815 Bytes

Versions: 2

Compression:

Stored size: 815 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,coffee}") }.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.manifest_key
      "javascripts"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
papers-2.0.0 lib/papers/dependency_specification/javascript.rb
papers-1.4.0 lib/papers/dependency_specification/javascript.rb