Sha256: 514e075c7ca76a5c356964a948a7fcd22688652274d110b4bb27578c71113856

Contents?: true

Size: 1.35 KB

Versions: 1

Compression:

Stored size: 1.35 KB

Contents

require 'rack'
require 'rack/blogengine'

module Rack
  module Blogengine
    class CommandLineInterface
      def method_missing(name, *args)
        puts "Command #{name} not available"
        print "Available Commands are: \n\n"
        self.class.instance_methods(false).each do |method|
          print "\t #{method}\n" unless method == :method_missing
        end
        print "\n"
      end

    	# Method to run the cli command
    	# @param [String] target
    	def run(target)
    	  unless target.empty? 
            $targetfolder = target
            app = Rack::Builder.new do
              use Rack::CommonLogger
              use Rack::ShowExceptions

              map "/assets" do
                run Rack::Directory.new("#{$targetfolder}/assets")
              end

              use Rack::Lint
              run Rack::Blogengine::Application
            end

            Rack::Server.start( :app => app, :Port => 3000 )
          else 
            puts "Specify a targetfolder!"
          end
    	end

    	# TODO write generate method to generate blog skeleton (assets, layout etc)
    	def generate(folder)
        puts "Generating folder skeleton"
        system("mkdir #{folder} && mkdir #{folder}/assets && mkdir #{folder}/assets/layout && mkdir #{folder}/assets/js && mkdir #{folder}/assets/style && mkdir #{folder}/assets/images")
    	end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rack-blogengine-0.1.1 lib/rack/blogengine/command_line_interface.rb