Sha256: fe3b54a84e3cbd5e87ce00cb7127c88ee6f7d98490749589b34fc5f1cca96106

Contents?: true

Size: 1.63 KB

Versions: 4

Compression:

Stored size: 1.63 KB

Contents

require 'script_finder/base_finder'

class RailsFinder < BaseFinder

  def execute_command
    execute_command_if_singleton(matching_commands)
  end

  private

  def too_many_cmds_found(commands)
    super(commands) { |c| "rails #{c}" }
  end

  def cmd_exec(cmd)
    super("rails #{cmd}")
  end
    
  def matching_commands
    known_commands.select{ |cmd| cmd =~ /^#{command.first}.*/ }
  end

  def cmd_not_found
    puts "No rails command found matching '#{command.first}'"
  end

  def known_commands
    # it may be worthwhile to ask rails for the commands and cache
    # them in a .file, in case the rails command is extended to
    # provide more commands
    @known_commands ||= %w{ generate console server dbconsole new application
                             destroy benchmarker profiler plugin runner }
  end

  #Cheat Sheet for Rails Commands
  # generate    Generate new code (short-cut alias: "g")
  # console     Start the Rails console (short-cut alias: "c")
  # server      Start the Rails server (short-cut alias: "s")
  # dbconsole   Start a console for the database specified in config/database.yml
  #             (short-cut alias: "db")
  # new         Create a new Rails application. "rails new my_app" creates a
  #             new application called MyApp in "./my_app"

  #In addition to those, there are:
  # application  Generate the Rails application code
  # destroy      Undo code generated with "generate"
  # benchmarker  See how fast a piece of code runs
  # profiler     Get profile information from a piece of code
  # plugin       Install a plugin
  # runner       Run a piece of code in the application environment
  #
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
script_finder-1.3.1 lib/script_finder/rails_finder.rb
script_finder-1.2.1 lib/script_finder/rails_finder.rb
script_finder-1.2.0 lib/script_finder/rails_finder.rb
script_finder-1.0.0 lib/script_finder/rails_finder.rb