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

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Struct

#as_json

Constructor Details

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

Returns a new instance of GemfileEntry.



367
368
369
# File 'railties/lib/rails/generators/app_base.rb', line 367

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

Class Method Details

.floats(name, comment = nil) ⇒ Object



383
384
385
# File 'railties/lib/rails/generators/app_base.rb', line 383

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

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



371
372
373
374
375
376
377
# File 'railties/lib/rails/generators/app_base.rb', line 371

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



387
388
389
# File 'railties/lib/rails/generators/app_base.rb', line 387

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

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



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

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

Instance Method Details

#to_sObject



391
392
393
394
395
396
397
398
399
# File 'railties/lib/rails/generators/app_base.rb', line 391

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