Sha256: 1aeb8ffb742dd034ba8b4f7aa9f6d992dd94e9c5d3b364a7a169ad169836bae5

Contents?: true

Size: 1.66 KB

Versions: 3

Compression:

Stored size: 1.66 KB

Contents

require 'active_support/core_ext'
require File.join(File.dirname(__FILE__), "../../../jax")

module Jax
  module Generators
    module App
      class AppGenerator < Thor::Group
        include Thor::Actions
        argument :path_to_app

        def self.source_root
          File.expand_path("templates", File.dirname(__FILE__))
        end

        def create_root
          self.destination_root = File.expand_path(path_to_app, destination_root)
          empty_directory '.'
          FileUtils.cd destination_root
        end

        def app
          directory 'app'
        end

        def config
          directory 'config'
        end

        def public
          directory 'public'
        end

        def spec
          directory 'spec'
        end
        
        def rakefile
          copy_file 'Rakefile'
        end
        
        def script_jax
          copy_file "script/jax", "script/jax"
        end
        
        def script_permissions
          chmod("script/jax", 0755)
        end
        
        def gemfile
          if ENV['gemdev']
            create_file "Gemfile", "gem 'jax', :path => '../'"
          else
            template 'Gemfile.tt', 'Gemfile'
          end
        end
        
        def git
          if File.exist? '.git'
            say_status :exist, 'git', :blue
          else
            `git init`
            `git add *`
            say_status :init, 'git', :green
          end
        end

        protected
        def self.banner
          "jax new #{self.arguments.map { |a| a.usage }.join(' ')}"
        end
        
        def class_name
          path_to_app.gsub(/\-/, '_').camelize
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
jax-0.0.0.3 lib/jax/generators/app/app_generator.rb
jax-0.0.0.2 lib/jax/generators/app/app_generator.rb
jax-0.0.0.1 lib/jax/generators/app/app_generator.rb