Module: Cyborg::Command
Instance Method Summary collapse
- #from_rails(command = nil, &blk) ⇒ Object
- #from_root(command = nil, &blk) ⇒ Object
- #run(options) ⇒ Object
Instance Method Details
#from_rails(command = nil, &blk) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/cyborg/command.rb', line 29 def from_rails(command=nil, &blk) unless dir = Cyborg.rails_path abort "Command must be run from the root of a Cyborg Plugin project, or in its Rails 'site' directory." end Dir.chdir(dir) do if command system command else blk.call end end end |
#from_root(command = nil, &blk) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/cyborg/command.rb', line 43 def from_root(command=nil, &blk) unless dir = Cyborg.gem_path abort "Command must be run from the root of a Cyborg Plugin (adjacent to the gemspec)." end Dir.chdir(dir) do if command system command else blk.call end end end |
#run(options) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/cyborg/command.rb', line 9 def run() case [:command] when 'new' Scaffold.new([:name]) when 'npm' from_root { NPM.setup } when 'build' from_rails "bundle exec rake cyborg:build" when 'watch' from_rails "rake cyborg:watch" when 'server' from_rails "rake cyborg:server" when 'rails' from_rails "rails s" else puts "Command `#{[:command]}` not recognized" end end |