Class: MarsConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/mars_config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ MarsConfig

Returns a new instance of MarsConfig.



4
5
6
7
8
9
10
11
# File 'lib/mars_config.rb', line 4

def initialize(args)
  @project = args.first
  # @stack = JQUERY
  # if args.first and args.first.split(':')[0] == "stack"
  #   @project = args.last
  #   @stack = args.first.split(':')[1] == SENCHA ? SENCHA : JQUERY
  # end
end

Instance Attribute Details

#projectObject

Returns the value of attribute project.



2
3
4
# File 'lib/mars_config.rb', line 2

def project
  @project
end

#stackObject

Returns the value of attribute stack.



2
3
4
# File 'lib/mars_config.rb', line 2

def stack
  @stack
end

Instance Method Details

#apply_stackObject



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/mars_config.rb', line 25

def apply_stack
  # Eventually adding stacks
  # if @stack == SENCHA
  #   FileUtils.cp_r File.dirname(__FILE__) + '/../lib/sencha/.', FileUtils.pwd + "/#{@project}/wwwroot"
  # elsif @stack == BLANK
  #   # dont do anything
  # else 
  #   FileUtils.cp_r File.dirname(__FILE__) + '/../lib/public/.', FileUtils.pwd + "/#{@project}/wwwroot"
  # end
  FileUtils.cp_r File.dirname(__FILE__) + '/../lib/public/.', FileUtils.pwd + "/#{@project}/wwwroot"
end

#create_projectObject



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/mars_config.rb', line 13

def create_project
  # Build Directory and add setup files
  FileUtils.mkdir_p @project
  FileUtils.mkdir_p File.join(@project, 'wwwroot')
  FileUtils.mkdir_p File.join(@project, 'tmp')

  config_ru = ["require 'mars'","log = File.new('tmp/mars.log', 'a+')", "$stdout.reopen(log)", "$stderr.reopen(log)", "run Mars::App"].join("\n")
  File.open(File.join(@project, 'config.ru'),'w').write(config_ru)
  gemfile = ['source :gemcutter', "gem 'thin'", "gem 'mars'"].join("\n")
  File.open(File.join(@project, 'Gemfile'),'w').write(gemfile)
end