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

Inherits:
Struct
  • Object
show all
Defined in:
lib/rails/generators/app_base.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, version, comment, options = {}, commented_out = false) ⇒ GemfileEntry

Returns a new instance of GemfileEntry.



378
379
380
# File 'lib/rails/generators/app_base.rb', line 378

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

Class Method Details

.floats(name, comment = nil) ⇒ Object



394
395
396
# File 'lib/rails/generators/app_base.rb', line 394

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

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



382
383
384
385
386
387
388
# File 'lib/rails/generators/app_base.rb', line 382

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) ⇒ Object



398
399
400
# File 'lib/rails/generators/app_base.rb', line 398

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

.version(name, version, comment = nil) ⇒ Object



390
391
392
# File 'lib/rails/generators/app_base.rb', line 390

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

Instance Method Details

#to_sObject



402
403
404
405
406
407
408
409
410
# File 'lib/rails/generators/app_base.rb', line 402

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