Class: Spar::CLI

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/spar/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.source_rootObject



11
12
13
# File 'lib/spar/cli.rb', line 11

def self.source_root
  File.expand_path('../../..', __FILE__)
end

Instance Method Details

#deploy(environment = 'production') ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/spar/cli.rb', line 28

def deploy(environment='production')
  Spar.environment = environment
  say "Deploying #{Spar.root} to the #{Spar.environment} environment"

  if strategy = Spar.settings['deploy_strategy']
    require "spar/deployers/#{strategy}_deployer"

    deployer = Kernel.const_get("#{strategy.capitalize()}Deployer").new

    deployer.run(Spar::Compiler.assets)
  else
    raise "You are trying to deploy to the #{environment} environment, but you have not declared a :deploy_strategy in config.yml for this environment. The available options are: 'local', 's3', and 'cloudfront'."
  end
end

#new(name) ⇒ Object



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/spar/cli.rb', line 56

def new(name)
  # first, copy in the base directory
  directory('lib/spar/generators/templates/base', name)
  
  if !options[:css]
    # copy in the sass files
    directory('lib/spar/generators/templates/styles/sass', name)
  else
    # copy in the css files
    directory('lib/spar/generators/templates/styles/css', name)
  end
  
  if !options[:html]
    # copy in the haml files
    directory('lib/spar/generators/templates/pages/haml', name)
  else
    # copy in the html files
    directory('lib/spar/generators/templates/pages/html', name)
  end
  
  if !options[:js]
    # copy in the coffee files
    directory('lib/spar/generators/templates/scripts/coffee', name)
  else
    # copy in the js files
    directory('lib/spar/generators/templates/scripts/js', name)
  end
end

#serverObject



19
20
21
22
23
24
# File 'lib/spar/cli.rb', line 19

def server
  Rack::Server.start(
    :Port => options[:port] || 8888,
    :app  => Spar.app
  )
end

#versionObject



45
46
47
48
# File 'lib/spar/cli.rb', line 45

def version
  require 'spar/version'
  puts "Spar Version #{Spar::VERSION}"
end