Class: Vitae::CLI
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.source_root ⇒ Object
7 8 9 |
# File 'lib/vitae/cli.rb', line 7 def self.source_root File.('templates', File.dirname(__FILE__)) end |
Instance Method Details
#create(name, *cv_names) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/vitae/cli.rb', line 15 def create(name, *cv_names) self.destination_root = name puts "creating #{name}..." copy_file "config.ru" if cv_names.size > 0 cv_names.each do |cv_name| @name = cv_name @human_name = cv_name.split(/[^a-z]+/i).map{|w|w.capitalize}.join(" ") @url_name = @name.gsub(/[^a-z\-]+/i, "-") template "cvs/default.yaml.tt", "cvs/#{cv_name}.yaml" end else templates = Dir.glob(File.join(CLI.source_root, "cvs/*.yaml*")). map{|f| File.basename(f)} -["default.yaml.tt"] templates.each do |template_name| template "cvs/#{template_name}", "cvs/#{template_name.sub(/\.tt$/, '')}" end end themes = Dir.glob(File.join(CLI.source_root, "themes/*")).map{|f| File.basename(f)} themes.each do |theme_name| copy_file "themes/#{theme_name}/application.js" copy_file "themes/#{theme_name}/application.css" end end |
#server(project_path = ".") ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/vitae/cli.rb', line 46 def server(project_path=".") require "rack" just_pretend = ARGV.delete "--pretend" port_set_by_user = ARGV.any? { |a| %w[-p --port].include?( a ) } Vitae::project_root = File.(project_path, Dir.pwd) server = Rack::Server.new.tap do |s| s.[:config] = File.join(Vitae::project_root, "config.ru") s.[:Port] = 3141 unless port_set_by_user end opts = server. cv_count = CV.all.size cvs = "#{cv_count} CV#{'s' unless cv_count==1}" project_dir_name = File.basename(Vitae::project_root) say "Serving #{cvs} at http://#{opts[:Host]}:#{opts[:Port]}/ from #{project_dir_name}\n", :green server.start unless just_pretend end |