123456789_123456789_123456789_123456789_123456789_

Class: Rails::Generators::AppBase::GemfileEntry

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, ::Struct
Instance Chain:
self, ::Struct
Inherits: Struct
Defined in: railties/lib/rails/generators/app_base.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

::Struct - Inherited

Constructor Details

.new(name, version, comment, options = {}, commented_out = false) ⇒ GemfileEntry

[ GitHub ]

  
# File 'railties/lib/rails/generators/app_base.rb', line 421

def initialize(name, version, comment, options = {}, commented_out = false)
  super
end

Class Method Details

.floats(name, comment = nil)

[ GitHub ]

  
# File 'railties/lib/rails/generators/app_base.rb', line 437

def self.floats(name, comment = nil)
  new(name, nil, comment)
end

.github(name, github, branch = nil, comment = nil)

[ GitHub ]

  
# File 'railties/lib/rails/generators/app_base.rb', line 425

def self.github(name, github, branch = nil, comment = nil)
  if branch
    new(name, nil, comment, github: github, branch: branch)
  else
    new(name, nil, comment, github: github)
  end
end

.path(name, path, comment = nil)

[ GitHub ]

  
# File 'railties/lib/rails/generators/app_base.rb', line 441

def self.path(name, path, comment = nil)
  new(name, nil, comment, path: path)
end

.version(name, version, comment = nil)

[ GitHub ]

  
# File 'railties/lib/rails/generators/app_base.rb', line 433

def self.version(name, version, comment = nil)
  new(name, version, comment)
end

Instance Attribute Details

#comment (rw)

[ GitHub ]

  
# File 'railties/lib/rails/generators/app_base.rb', line 420

class GemfileEntry < Struct.new(:name, :version, :comment, :options, :commented_out)

#commented_out (rw)

[ GitHub ]

  
# File 'railties/lib/rails/generators/app_base.rb', line 420

class GemfileEntry < Struct.new(:name, :version, :comment, :options, :commented_out)

#name (rw)

[ GitHub ]

  
# File 'railties/lib/rails/generators/app_base.rb', line 420

class GemfileEntry < Struct.new(:name, :version, :comment, :options, :commented_out)

#options (rw)

[ GitHub ]

  
# File 'railties/lib/rails/generators/app_base.rb', line 420

class GemfileEntry < Struct.new(:name, :version, :comment, :options, :commented_out)

#version (rw)

[ GitHub ]

  
# File 'railties/lib/rails/generators/app_base.rb', line 420

class GemfileEntry < Struct.new(:name, :version, :comment, :options, :commented_out)

Instance Method Details

#to_s

[ GitHub ]

  
# File 'railties/lib/rails/generators/app_base.rb', line 445

def to_s
  [
    (comment.gsub(/^/, "# ").chomp + "\n" if comment),
    ("# " if commented_out),
    "gem \"#{name}\"",
    *Array(version).map { |constraint| ", \"#{constraint}\"" },
    *options.map { |key, value| ", #{key}: #{value.inspect}" },
  ].compact.join
end