Ruby template creation

a shorter version of creating the ruby templates for gem development.

class CookieGem
=begin
     A cookiclutter for making the ruby gems, provide the variables
     as you want in your ruby gemspec file and it will write the gem
     specific file. You can then directly build your gems using the 
     gem build gemfilename.gemspec
     filenamewrite = file to which the template should be written
     authors = authors of the template
     rubyfilename = name of the ruby file
     name = package name
     summary = summary of the package
     version = version of the package
     email = email of the author
     homepage = homepage of the package
     license = licence type
     metadata = metadata of the package
=end
  def initialize(authors, rubyfilename, name, summary, version, email, homepage, license, metadata)
    @storingauthor = authors.to_s
    @storingfiles = rubyfilename.split
    @storingname = name
    @storingsummary = summary
    @storingversion = version
    @storingemail = email
    @storinghomepage = homepage
    @storinglicense = license
    @storingmetadata = metadata
    #{}@largemetadata = File.open(metadata).readlines().each{ |each| puts each.split("\n").join}
  end
  def templateMaker                                               
        puts "Gem::Specification.new.do |s|"
        puts "s.author = #{@storingauthor}"
        puts "s.files = #{@storingfiles}"
        puts "s.name = #{@storingname}"
        puts "s.summary = #{@storingsummary}"
        puts "s.version = #{@storingversion}"
        puts "s.email = #{@storingemail}"
        puts "s.homepage = #{@storinghomepage}"
        puts "s.license = #{@storinglicense}"
        puts "s.metadata = #{@storingmetadata}"
        puts "s.metadata = #{@largemetadata}"
  end
  def writeTemplate(filename)
    @file = filename 
    @firstline = "Gem::Specification.new.do |s|"
    @writestoringauthor = "s.author = #{@storingauthor}"
    @writestoringfiles = "s.files = #{@storingfiles}"
    @writestoringname = "s.name = #{@storingname}"
    @writestoringversion = "s.version = #{@storingversion}"
    @writestoringsummary = "s.summary = #{@storingsummary}"
    @writestoringemail = "s.email = #{@storingemail}"
    @writestoringhomepage = "s.homepage = #{@storinghomepage}"
    @writestoringlicense = "s.metadata = #{@storinglicense}"
    @writestoringmetadata = "s.metadata = #{@storingmetadata}"
    @writestoringlargemetadata = "s.metadata = #{@largemetadata}"
    File.write("#{@file}"+".gemspec", "#{@file}\n#{@firstline}\n#{@writestoringauthor}\n#{@writestoringfiles}\n#{@writestoringname}\n#{@writestoringversion}\n#{@writestoringsummary}\n#{@writestoringemail}\n#{@writestoringhomepage}\n#{@writestoringlicense}\n#{@writestoringmetadata}\n#{@writestoringlargemetadata}", mode: "a")
  end
end

Sure, here’s a simplified version of your CookieGem class for creating the ruby templates:

class CookieGem
  attr_accessor :author, :filename, :name, :summary, :version, :email, :homepage, :license, :metadata

  def initialize(author:, filename:, name:, summary:, version:, email:, homepage:, license:, metadata:)
    @author = author
    @filename = filename.split
    @name = name
    @summary = summary
    @version = version
    @email = email
    @homepage = homepage
    @license = license
    @metadata = metadata
  end

  def write_template(file)
    contents = <<-GEMSPEC
      Gem::Specification.new do |s|
        s.author = #{@author}
        s.files = #{@filename}
        s.name = #{@name}
        s.summary = #{@summary}
        s.version = #{@version}
        s.email = #{@email}
        s.homepage = #{@homepage}
        s.license = #{@license}
        s.metadata = #{@metadata}
      end
    GEMSPEC
    File.write("#{file}.gemspec", contents, mode: "a")
  end
end

This way, you skip the templateMaker method and write directly to the file from write_template. The instance variables are also renamed for clarity. Everything else remains as it is.