Class: Bundler::GemBytes::Actions::Gemspec::Dependency

Inherits:
Struct
  • Object
show all
Defined in:
lib/bundler/gem_bytes/actions/gemspec/dependency.rb

Overview

Holds the components of a dependency declaration

A dependency declaration is a call to ‘add_dependency`, `add_runtime_dependency`, or `add_development_dependency` in the Gem::Specification block.

For example, the following is a dependency declaration:

“‘ruby spec.add_dependency ’rubocop’, ‘~> 1.0’ “‘

Would be represented by a Dependency object with the following attributes:

* method_name: :add_dependency
* gem_name: 'rubocop'
* version_constraint: '~> 1.0'

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#gem_nameString (readonly)

The name of the gem being depended on

Examples:

dependency.gem_name #=> "rubocop"

Returns:

  • (String)


67
68
69
# File 'lib/bundler/gem_bytes/actions/gemspec/dependency.rb', line 67

Dependency = Struct.new(:method_name, :gem_name, :version_constraints) do
  def to_a = [method_name, gem_name, *version_constraints]
end

#method_nameSymbol (readonly)

The name of the method called to add the dependency

Must be one of the following:

  • :add_dependency

  • :add_runtime_dependency

  • :add_development_dependency

Examples:

dependency.method_name #=> :add_dependency

Returns:

  • (Symbol)


67
68
69
# File 'lib/bundler/gem_bytes/actions/gemspec/dependency.rb', line 67

Dependency = Struct.new(:method_name, :gem_name, :version_constraints) do
  def to_a = [method_name, gem_name, *version_constraints]
end

#version_constraintsArray<String> (readonly)

The version constraints for the dependency

Examples:

dependency.version_constraints #=> ["~> 1.68", ">= 1.68.3"]

Returns:

  • (Array<String>)


67
68
69
# File 'lib/bundler/gem_bytes/actions/gemspec/dependency.rb', line 67

Dependency = Struct.new(:method_name, :gem_name, :version_constraints) do
  def to_a = [method_name, gem_name, *version_constraints]
end

Instance Method Details

#to_aArray

Converts the dependency into an array

Examples:

dependency.to_a #=> [:add_runtime_dependency, "rubocop", "~> 1.68"]

Returns:

  • (Array)


67
68
69
# File 'lib/bundler/gem_bytes/actions/gemspec/dependency.rb', line 67

Dependency = Struct.new(:method_name, :gem_name, :version_constraints) do
  def to_a = [method_name, gem_name, *version_constraints]
end