Class: Capucine::Main

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMain

Returns a new instance of Main.



12
13
14
15
16
17
18
19
# File 'lib/capucine.rb', line 12

def initialize
  self.settings = Capucine::Settings.new
  self.tools = Capucine::Tools.new(self)
  self.sass = Capucine::CompassSass.new(self)
  self.coffee = Capucine::CoffeeScript.new(self)
  self.incloudr = Capucine::Incloudr.new(self)
  return self
end

Instance Attribute Details

#coffeeObject

Returns the value of attribute coffee.



7
8
9
# File 'lib/capucine.rb', line 7

def coffee
  @coffee
end

#incloudrObject

Returns the value of attribute incloudr.



9
10
11
# File 'lib/capucine.rb', line 9

def incloudr
  @incloudr
end

#sassObject

Returns the value of attribute sass.



8
9
10
# File 'lib/capucine.rb', line 8

def sass
  @sass
end

#settingsObject

Returns the value of attribute settings.



6
7
8
# File 'lib/capucine.rb', line 6

def settings
  @settings
end

#toolsObject

Returns the value of attribute tools.



10
11
12
# File 'lib/capucine.rb', line 10

def tools
  @tools
end

Instance Method Details

#helpObject



69
70
71
72
73
74
# File 'lib/capucine.rb', line 69

def help
  version = File.open(File.join(self.settings.root_dir, 'VERSION')).read
  template_file = File.join self.settings.content_dir, 'templates', 'cmd_help.erb'
  result = self.tools.render_template template_file, version
  puts result
end

#run_command(command) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/capucine.rb', line 21

def run_command(command)
  # command = ['c', '/path/to/file.yaml']
  # command = ['c:sass', '/path/to/file.yaml']
  # ...

  run = command[0].to_s.split(':') # Rake like capucine compile:sass
  config_or_name = command[1] # second part (the capucine.yaml file or template name/url)

  main = run[0] # c, w, compile, watch, new, init
  run.shift # all, coffee, sass or incloudr | sinatra, wordpress, etc ...
  scope = run # all, coffee, sass or incloudr | sinatra, wordpress, etc ...

  if %w{i init}.include?(main)
    self.tools.init(scope[0], config_or_name)

  elsif %w{n new}.include?(main)
    self.tools.new_project(scope[0], config_or_name)
    self.tools.compile

  elsif %w{c compile}.include?(main)
    self.settings.set_user_config_file(config_or_name)
    self.tools.compile(scope[0])

  elsif %w{j js}.include?(main)
    self.settings.set_user_config_file(config_or_name)
    self.tools.js(scope, config_or_name)

  elsif %w{w watch}.include?(main)
    self.settings.set_user_config_file(config_or_name)
    self.tools.watch(scope[0])

  elsif %w{cl clean}.include?(main)
    self.settings.set_user_config_file(config_or_name)
    self.tools.clean

  elsif %w{u update}.include?(main)
    self.settings.set_user_config_file(config_or_name)
    self.tools.update

  elsif %w{h help}.include?(main)
    self.help
  else
    self.help
  end

  return self
end