Class: Luban::Deployment::Package::Dependency

Inherits:
Object
  • Object
show all
Defined in:
lib/luban/deployment/cli/package/dependency.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(apply_to, type, name, version, **opts) ⇒ Dependency

Returns a new instance of Dependency.



13
14
15
16
17
18
19
20
# File 'lib/luban/deployment/cli/package/dependency.rb', line 13

def initialize(apply_to, type, name, version, **opts)
  @apply_to = apply_to
  @type = type
  @name = name
  @version = version
  @options = opts
  validate
end

Instance Attribute Details

#apply_toObject (readonly)

Returns the value of attribute apply_to.



7
8
9
# File 'lib/luban/deployment/cli/package/dependency.rb', line 7

def apply_to
  @apply_to
end

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'lib/luban/deployment/cli/package/dependency.rb', line 9

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



11
12
13
# File 'lib/luban/deployment/cli/package/dependency.rb', line 11

def options
  @options
end

#typeObject (readonly)

Returns the value of attribute type.



8
9
10
# File 'lib/luban/deployment/cli/package/dependency.rb', line 8

def type
  @type
end

#versionObject (readonly)

Returns the value of attribute version.



10
11
12
# File 'lib/luban/deployment/cli/package/dependency.rb', line 10

def version
  @version
end

Instance Method Details

#applicable_to?(version) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
25
26
27
28
# File 'lib/luban/deployment/cli/package/dependency.rb', line 22

def applicable_to?(version)
  if @apply_to == :all
    true
  else
    Gem::Requirement.new(@apply_to).satisfied_by?(Gem::Version.new(version))
  end
end