Sha256: 29fae768b6dd0151fc662665bb0a65478d1cdde83a3dfaf152eae62b944e6d2e
Contents?: true
Size: 1.57 KB
Versions: 2
Compression:
Stored size: 1.57 KB
Contents
require 'hanami/environment' require 'hanami/commands/command' require 'hanami/generators/generatable' require 'hanami/generators/test_framework' require 'hanami/generators/template_engine' require 'hanami/version' require 'hanami/utils/string' module Hanami module Commands class Generate class Abstract < Commands::Command include Hanami::Generators::Generatable attr_reader :options, :target_path def initialize(options) super @options = Hanami::Utils::Hash.new(options).symbolize! assert_options! @target_path = Hanami.root end def template_source_path generator = self.class.name.split('::').last.downcase Pathname.new(::File.dirname(__FILE__) + "/../../generators/#{generator}/").realpath end private def test_framework @test_framework ||= Hanami::Generators::TestFramework.new(hanamirc, options[:test]) end def hanamirc_options hanamirc.options end def hanamirc @hanamirc ||= Hanamirc.new(target_path) end def template_engine @template_engine ||= Hanami::Generators::TemplateEngine.new(hanamirc, options[:template]) end def assert_options! if options.nil? raise ArgumentError.new('options must not be nil') end end # @since 1.0.0.beta1 # @api private def project_name Utils::String.new(Hanami::Environment.new.project_name).underscore end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
hanami-1.0.0.beta2 | lib/hanami/commands/generate/abstract.rb |
hanami-1.0.0.beta1 | lib/hanami/commands/generate/abstract.rb |