Sha256: 5e86dba3c276fab0ce41f24a49fb29328fc9b1e062cdda0891b83776b678663f

Contents?: true

Size: 1.86 KB

Versions: 4

Compression:

Stored size: 1.86 KB

Contents

require 'orats/commands/common'
require 'orats/commands/inventory'
require 'orats/commands/project/rails'
require 'orats/commands/project/server'

module Orats
  module Commands
    module Project
      class Exec < Commands::Common
        include Rails
        include Server

        PROJECT_TEMPLATES = {
            auth: 'add authentication and authorization'
        }

        def initialize(target_path = '', options = {})
          super

          @active_path = services_path
        end

        def list_templates
          log_status_top 'templates', 'Available templates to choose from:',
                         :blue
          puts
          PROJECT_TEMPLATES.each_pair do |key, value|
            log_status_bottom key, value, :cyan, true
            log_status_bottom 'usage', "orats project /tmp/foo --template #{key}",
                              :white
          end
        end

        def init
          check_exit_conditions

          rails_template 'base' do
            gsub_postgres_info
            gsub_redis_info unless @options[:redis_password].empty?
            gsub_project_path
            gsub_readme

            bundle_install
            bundle_binstubs
            spring_binstub

            create_and_migrate_database
            generate_home_page
            generate_favicons
          end

          if template_exist?(@options[:template])
            rails_template @options[:template], '--skip ' do
              migrate_and_seed_database
            end
          end

          Commands::Inventory.new(@target_path,
                                  @options).init unless @options[:skip_ansible]

          custom_rails_template unless @options[:custom].empty?

          server_start
        end

        private

        def services_path
          "#{@target_path}/services/#{File.basename @target_path}"
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
orats-0.7.3 lib/orats/commands/project/exec.rb
orats-0.7.2 lib/orats/commands/project/exec.rb
orats-0.7.1 lib/orats/commands/project/exec.rb
orats-0.7.0 lib/orats/commands/project/exec.rb