Class: CreateNewGem::Templates::Mainfile

Inherits:
Object
  • Object
show all
Defined in:
lib/create_new_gem/templates.rb

Instance Method Summary collapse

Constructor Details

#initialize(gemname:, gemclass:, requires:, executables:) ⇒ Mainfile

Returns a new instance of Mainfile.



40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/create_new_gem/templates.rb', line 40

def initialize(gemname:,gemclass:,requires:,executables:)
  require_statements = []
  requires.each do |req|
    require_statements << "require '#{req}'"
  end

  @template = File.read("#{File.dirname __FILE__}/templates/mainfile.rb.template")
    .gsub("<<!gemclass!>>", gemclass)
    .gsub("<<!gemname!>>", gemname)
    .gsub("<<!requires!>>", require_statements.join("\n"))
    .gsub("<<!executables!>>", executables)
end

Instance Method Details

#to_sObject



53
54
55
# File 'lib/create_new_gem/templates.rb', line 53

def to_s
  return @template
end