Sha256: 90e445c39415b246d08e55abf5acacf17b11b93648726583fa27bbac5329ffd3

Contents?: true

Size: 1.37 KB

Versions: 32

Compression:

Stored size: 1.37 KB

Contents

require 'fileutils'
require 'classiccms/version'

module Classiccms
  class Cli
    def self.command(arguments)
      case arguments[0]
      when 'new'    then self.new arguments[1]
      when 'server' then self.server
      when 's'      then self.server
      when '-v' then puts "version #{VERSION}"
      else
        puts "you are so smart! I don't know what you mean! (try using new or server)"
      end
    end

    def self.new(app_name)
      if app_name == nil
        puts 'hmm you are using the command wrong: classicCMS new [app name]'
      elsif File::directory? app_name
        puts 'hmm I think that app already exists!'
      else
        #copy scaffold
        FileUtils.cp_r File.join(File.dirname(__FILE__), "scaffold"),  Dir.pwd + "/#{app_name}"

        #replace database
        mongoid = File.read(File.join(Dir.pwd, app_name, 'config/mongoid.yml')).gsub('$', app_name)
        File.open(File.join(Dir.pwd, app_name, 'config/mongoid.yml'), 'w') do |f|
          f.puts mongoid
        end

        gemfile = File.join(Dir.pwd, app_name, 'Gemfile')
        gemfile_text = File.read(gemfile)
        gemfile_text = gemfile_text.gsub(/VERSION/, VERSION)
        File.open(gemfile, "w") {|file| file.puts gemfile_text}

        puts "#{app_name} created!"
      end
    end
    def self.server
      #first check if this is actualy an app
      system('rackup')
    end
  end
end

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
classiccms-0.7.5 lib/classiccms/cli.rb
classiccms-0.7.4 lib/classiccms/cli.rb
classiccms-0.7.3 lib/classiccms/cli.rb
classiccms-0.7.2 lib/classiccms/cli.rb
classiccms-0.7.1 lib/classiccms/cli.rb
classiccms-0.7.0 lib/classiccms/cli.rb
classiccms-0.6.9 lib/classiccms/cli.rb
classiccms-0.6.8 lib/classiccms/cli.rb
classiccms-0.6.7 lib/classiccms/cli.rb
classiccms-0.6.6 lib/classiccms/cli.rb
classiccms-0.6.5 lib/classiccms/cli.rb
classiccms-0.6.4 lib/classiccms/cli.rb
classiccms-0.6.3 lib/classiccms/cli.rb
classiccms-0.6.2 lib/classiccms/cli.rb
classiccms-0.6.1 lib/classiccms/cli.rb
classiccms-0.6.0 lib/classiccms/cli.rb
classiccms-0.5.17 lib/classiccms/cli.rb
classiccms-0.5.16 lib/classiccms/cli.rb
classiccms-0.5.15 lib/classiccms/cli.rb
classiccms-0.5.14 lib/classiccms/cli.rb