Class: CommandLine

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

Class Method Summary collapse

Class Method Details

.set_template(args) ⇒ Object

Sets the correct Rails application to use. -m demo -> Becomes the /path/to/browsercms/gem/templates/demo.rb -m module -> Becomes the /path/to/browsercms/gem/templates/modeule.rb If blank, becomes the /path/to/browsercms/gem/templates/blank.rb



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/command_line.rb', line 7

def self.set_template(args)
  if args.include?("-m")
    index = args.index("-m")
    if args[index + 1] == "demo"
      args[index + 1] = template("demo.rb")
    elsif args[index+1] == "module"
      args[index + 1] = template("module.rb")
    end
  elsif args.include?("--template")
    index = args.index("--template")
    if args[index + 1] == "demo"
      args[index + 1] = template("demo.rb")
    elsif args[index+1] == "module"
      args[index + 1] = template("module.rb")
    end
  else
    args << "-m" << template("blank.rb")
  end

end

.template(file_name) ⇒ Object

Return the file for the given template.



36
37
38
# File 'lib/command_line.rb', line 36

def self.template(file_name)
  File.join(template_dir, file_name)
end

.template_dirObject

Return the directory where the BrowserCMS templates reside.



29
30
31
32
33
# File 'lib/command_line.rb', line 29

def self.template_dir
  current_file = File.expand_path(File.dirname(__FILE__))
  gem_dir = File.join(current_file, "..")
  template_dir = File.join(gem_dir, "templates")
end