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



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

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

#concatenateObject



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

def concatenate
  $stdout.puts Cup.concatenate!
end

#create(name) ⇒ Object



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

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



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

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



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

def minify
  $stdout.puts Cup.minify!
end

#rackupObject



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

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



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

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



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

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