class Knitter::Package
Constants
- PackageConfig
Attributes
dependency_type[R]
name[R]
yarn[W]
Public Class Methods
new(name, yarn: nil)
click to toggle source
# File lib/knitter/package.rb, line 12 def initialize(name, yarn: nil) @name = name @yarn = yarn end
Public Instance Methods
add()
click to toggle source
# File lib/knitter/package.rb, line 37 def add yarn.add(self) @config = nil end
config()
click to toggle source
# File lib/knitter/package.rb, line 42 def config @config ||= read_config end
dependency_type=(type)
click to toggle source
# File lib/knitter/package.rb, line 25 def dependency_type=(type) @dependency_type = type end
installed?()
click to toggle source
# File lib/knitter/package.rb, line 33 def installed? !config.area.nil? end
version()
click to toggle source
# File lib/knitter/package.rb, line 17 def version @version ||= PackageVersion.new(config.version) end
version=(ver)
click to toggle source
# File lib/knitter/package.rb, line 21 def version=(ver) @version = PackageVersion.new(ver) end
Protected Instance Methods
read_config()
click to toggle source
# File lib/knitter/package.rb, line 52 def read_config config = PackageConfig.new json = yarn.package_file_contents %w{dependencies devDependencies optionalDependencies}.each do | part_name | part = json[part_name] next unless part && (version = part[@name]) config.area = part_name config.version = version end config end
yarn()
click to toggle source
# File lib/knitter/package.rb, line 48 def yarn @yarn ||= Yarn.new(Dir.pwd) end