Sha256: c63f4e3b5bbdd40e16f7a6412f52bacc478a476d64df5783c85677df0e14c635

Contents?: true

Size: 964 Bytes

Versions: 4

Compression:

Stored size: 964 Bytes

Contents

# External
require 'active_support/core_ext/string/inflections'

# Internal
require 'gem_newgem/newgem/validations'
require 'gem_newgem/newgem/configuration'
require 'gem_newgem/newgem/template'

module GemNewgem
  class Newgem
    include Validations

    attr_reader :gem_name, :gem_summary, :template, :config

    def initialize(gem_name, gem_summary, template)
      @config        = Configuration.instance
      @gem_name      = gem_name    || ''
      @gem_summary   = gem_summary || config.default_summary
      template_name  = template    || config.default_template
      @template      = Template.new(template_name)
    end

    def generate!
      load "#{File.join(template.path, template.name)}.thor"
      args = [gem_name, template.name]
      opts = { gem_summary: gem_summary }
      const_name = "GemNewgem::Templates::#{template.name.capitalize}".constantize
      script = const_name.new(args, opts)
      script.invoke_all
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gem-newgem-0.1.3 lib/gem_newgem/newgem.rb
gem-newgem-0.1.2 lib/gem_newgem/newgem.rb
gem-newgem-0.1.1 lib/gem_newgem/newgem.rb
gem-newgem-0.1.0 lib/gem_newgem/newgem.rb