Class: Cup::CommandLine

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/cup/command_line.rb

Defined Under Namespace

Classes: Helper

Instance Method Summary collapse

Instance Method Details

#buildObject



158
159
160
# File 'lib/cup/command_line.rb', line 158

def build
  Cup.build! :cli => self
end

#concatenateObject



163
164
165
# File 'lib/cup/command_line.rb', line 163

def concatenate
  $stdout.puts Cup.concatenate!
end

#create(name) ⇒ Object



130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/cup/command_line.rb', line 130

def create(name)

  unless valid_cup_name?(name)
    raise "#{name} is not a valid filename (letters, numbers, underscore and dashes only)"
  end

  helper = Helper.new(name)

  if Dir.exists? helper.root
    say_status :halted, "Cannot cup '#{name}'. A directory of that name already exists", :red
    return
  end

  cupify_with helper, name
end

#ifyObject



147
148
149
150
151
152
153
154
155
# File 'lib/cup/command_line.rb', line 147

def ify
  path = current_path

  name = File.basename(path)
  name = 'new cup' unless valid_cup_name? name

  helper = Helper.new(path)
  cupify_with(helper, name)
end

#minifyObject



168
169
170
# File 'lib/cup/command_line.rb', line 168

def minify
  $stdout.puts Cup.minify!
end

#rackupObject



191
192
193
194
195
196
197
198
199
200
201
202
203
204
# File 'lib/cup/command_line.rb', line 191

def rackup

  helper = pwd_helper

  return no_cupfile unless helper.cupfile?

  create_file helper.rackup_file, <<-CONFIG_RU
require 'rubygems' # for ruby 1.8.x
require 'rack'
require 'cup/server/app'

run Cup::Server::App
CONFIG_RU
end

#server(port = 5555) ⇒ Object



173
174
175
176
177
178
179
180
181
182
# File 'lib/cup/command_line.rb', line 173

def server(port=5555)

  helper = pwd_helper

  return no_cupfile unless helper.cupfile?

  say(shell.set_color "cup server for '#{Cup.cup_name}' starting on port #{port}", :cyan, true)
  Cup::Server::App.set :port => port
  Cup::Server::App.run!
end

#versionObject



185
186
187
188
# File 'lib/cup/command_line.rb', line 185

def version
  say("#{Cup.cup_name} v#{Cup.version}", :cyan) if File.exist?('Cupfile')
  say("cup v#{Cup::VERSION}")
end