class Frontline::Controllers

Public Instance Methods

delete_controller() click to toggle source

return a command that will delete given controller. `@name` variable are set by the triggered hooks(see frontline/app.rb for hooks)

# File lib/frontline/controllers/controllers.rb, line 27
def delete_controller
  'delete:controller:yes %s' % @name
end
delete_route(controller) click to toggle source

return a command that will delete the given route of given controller. `@name` variable are set by the triggered hooks(see frontline/app.rb for hooks)

# File lib/frontline/controllers/controllers.rb, line 39
def delete_route controller
  'delete:route:yes %s %s' % [controller, @name]
end
get_route_editor(controller, route) click to toggle source

renders a editor for given route. editor will allow to edit the route file, the route views and the route specs

# File lib/frontline/controllers/controllers.rb, line 8
def get_route_editor controller, route
  @controller = controllers[controller] ||
    halt(400, '"%s" controller not found' % escape_html(controller))
  @route = (@controller[:routes].find {|(n)| n == route} ||
    halt(400, '"%s#%s" route not found' % [controller, escape_html(route)])).last
  @files = ([@route[:file]] + @route[:views] + @route[:specs]).inject([]) do |m,f|
    m << [f, File.basename(f), f.gsub(/\W/, '_'), f == @route[:file]]
  end
  render_p action_name
end
post_controller() click to toggle source

return a command that will generate a new controller. `@name` and `@setups` variables are set by the triggered hooks(see frontline/app.rb for hooks)

# File lib/frontline/controllers/controllers.rb, line 21
def post_controller
  'g:c %s %s' % [@name, @setups]
end
post_route(controller) click to toggle source

return a command that will generate a new route for given controller. `@name` and `@setups` variables are set by the triggered hooks(see frontline/app.rb for hooks)

# File lib/frontline/controllers/controllers.rb, line 33
def post_route controller
  'g:r %s %s %s' % [controller, @name, @setups]
end
post_run_specs() click to toggle source

run specs for given controllers or for all if no controllers given and stream results to browser.

# File lib/frontline/controllers/controllers.rb, line 45
def post_run_specs
  @uuid = params[:uuid]
  controllers = (c = params[:controller]) ? [c] : controllers().keys
  stream do
    failed = false
    pty_stream 'modal', 'show'

    controllers.each do |controller|
      cmd = 'bundle exec rake test:' << controller
      passed, failure_id = pty_spawn(cmd)
      unless passed
        failed = true
        pty_stream 'failures', failure_id
      end
    end
    pty_stream 'modal', 'hide' unless failed
  end
end
route_layout(controller) click to toggle source
# File lib/frontline/controllers/controllers.rb, line 64
def route_layout controller
  controller = controllers[controller] ||
    halt(400, '"%s" controller does not exists' % escape_html(controller))
  render_p controller: controller
end