bin/nephos-generator in nephos-server-0.4.6 vs bin/nephos-generator in nephos-server-0.4.7

- old
+ new

@@ -68,20 +68,23 @@ end end end module Controller - def self.generate!(name, file) + def self.generate!(ctr) + uname = "#{ctr[0].upcase}#{ctr[1..-1]}Controller".gsub(/ControllerController$/, "Controller") + lname = uname.gsub(/([A-Z])/, '_\1')[1..-1].downcase + file = "app/#{lname}.rb" raise_invalid_appli if File.exists? file print "The file #{file} already exists. Are you sure to erase it ? (y/N)" r = STDIN.gets.to_s.chomp raise "File #{file} already exists" unless r.match(/y(es)?/) end f = File.open(file, 'w') f << <<EOF -class #{name} < Nephos::Controller +class #{uname} < Nephos::Controller def root return {plain: "index"} end end EOF @@ -118,10 +121,10 @@ def self.main opt case opt[0] when "c", "controller" if opt[1].to_s.match(/[\w\-\.]+/) - Controller.generate!("#{opt[1].capitalize}Controller", "app/#{opt[1].downcase}_controller.rb") + Controller.generate!(opt[1]) else puts "error" end when "a", "appli", "application" if not opt[1].to_s.empty?