Sha256: 9db0f93f6cc1d72bf3cc8f868a89740d937deb0a3a7f48ce1a82e0b07a30b8ad

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 KB

Contents

require 'rails/generators/base'

module FluxFlex
  module Generators
    class InstallGenerator < Rails::Generators::Base
      desc <<DESC
Description:
    Add files to deploy for fluxflex
DESC
      def self.source_root
        @_flx_tools_source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
      end

      def copy_dot_flx
        template '.flx'
      end

      def copy_sh_files
        template 'fluxflex_deploy.sh'
        template 'fluxflex_rake.sh'
        template 'fluxflex_setup.sh'
      end

      def copy_dispatch_fcgi
        template 'flx_dispatch.fcgi', File.join('public', 'flx_dispatch.fcgi')
      end

      def copy_dot_htaccess
        template '.htaccess', File.join('public', '.htaccess')
      end

      def insert_gems
        gemfile = 'Gemfile'
        if File.exists?(gemfile)
          body = File.read(gemfile)
          File.open(gemfile, 'a') do |f|
            f.puts "gem 'mysql2'" unless body.match(/mysql/)
            f.puts "gem 'fcgi'" unless body.match(/fcgi/)
          end
        else
          raise Rails::Generators::Error, "First, you must setup rspec by 'rails generate rspec:install'"
        end

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
flx-tools-0.1.0 lib/generators/flux_flex/install_generator.rb