Class: Golf::CLI
Class Method Summary collapse
Instance Method Summary collapse
- #compile(dir) ⇒ Object
- #generate(type, name) ⇒ Object
- #new(name, template = false) ⇒ Object
- #raw ⇒ Object
- #server ⇒ Object
- #version ⇒ Object
Class Method Details
.source_root ⇒ Object
10 11 12 |
# File 'lib/golf/cli.rb', line 10 def self.source_root File.("../../../", __FILE__) end |
Instance Method Details
#compile(dir) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/golf/cli.rb', line 52 def compile(dir) if Golf::Compiler.valid?(self.destination_root) compiler = Golf::Compiler.new directory('resources', dir) directory("#{self.destination_root}/golfapp", dir) create_file "#{dir}/components.js" do compiler.generate_componentsjs end else puts "#{self.destination_root}/golfapp/components not found" end end |
#generate(type, name) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/golf/cli.rb', line 29 def generate(type, name) case type when "component" if name.include?('.') component_name = name.split('.').last package_name = name.gsub('.','/').split('/')[0...-1].join('/') create_file "golfapp/components/#{package_name}/#{component_name}/#{component_name}.html" do File.read(File.("../../../templates/component/Component.html", __FILE__)) end else create_file "golfapp/components/#{name}/#{name}.html" do File.read(File.("../../../templates/component/Component.html", __FILE__)) end end end end |
#new(name, template = false) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/golf/cli.rb', line 15 def new(name, template = false) unless template directory("templates/new", name) else directory("templates/#{template}", name) end end |
#raw ⇒ Object
24 25 26 |
# File 'lib/golf/cli.rb', line 24 def raw directory("templates/raw", "golfapp") end |
#server ⇒ Object
47 48 49 |
# File 'lib/golf/cli.rb', line 47 def server `rackup` end |