Sha256: adb571be84c2c4fbc3f594c61acc8a1e24c2d0794e84489e2e024a63912fe739

Contents?: true

Size: 658 Bytes

Versions: 2

Compression:

Stored size: 658 Bytes

Contents

require 'json'

module EnginePack
  class PackageConfig
    attr_reader :path

    def initialize(package_path)
      @path = package_path

      raise ArgumentError, "#{package_path} does not have a package.json file." unless File.exist?(config_path)

      @config = JSON.parse(File.read(config_path))
    end

    def package_files_paths
      specified_files.map { |f| "#{path}/#{f}" }.tap do |paths|
        paths << config_path unless paths.include?(config_path)
      end
    end

    private

    attr_reader :config

    def config_path
      "#{path}/package.json"
    end

    def specified_files
      config.fetch('files', [])
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
engine_pack-0.2.0 lib/engine_pack/package_config.rb
engine_pack-0.1.0 lib/engine_pack/package_config.rb