Top Level Namespace

Defined Under Namespace

Modules: Decko, Parser Classes: DeckoGenerator

Constant Summary collapse

RAILS_COMMANDS =
%w( generate destroy plugin benchmarker profiler console
server dbconsole application runner ).freeze
DECKO_COMMANDS =
%w(new cucumber rspec jasmine).freeze
DECKO_DB_COMMANDS =
%w(seed reseed load update).freeze
ALIAS =
{
  "rs" => "rspec",
  "cc" => "cucumber",
  "jm" => "jasmine",
  "g"  => "generate",
  "d"  => "destroy",
  "c"  => "console",
  "s"  => "server",
  "db" => "dbconsole",
  "r"  => "runner"
}.freeze

Instance Method Summary collapse

Instance Method Details

#alias_task(name, old_name) ⇒ Object



1
2
3
4
5
6
7
8
9
# File 'lib/decko/tasks/alias.rb', line 1

def alias_task name, old_name
  t = Rake::Task[old_name]
  desc t.full_comment if t.full_comment
  task name, *t.arg_names do |_, args|
    # values_at is broken on Rake::TaskArguments
    args = t.arg_names.map { |a| args[a] }
    t.invoke(args)
  end
end

#append_to_namespace(namespace, part) ⇒ Object



11
12
13
# File 'lib/decko/tasks/alias.rb', line 11

def append_to_namespace namespace, part
  [namespace, part].compact.join(":")
end


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/decko/tasks/alias.rb', line 15

def link_task task, from: nil, to: nil, namespace: nil
  case task
  when Hash
    task.each do |key, val|
      link_task val, from: from, to: to ,
                  namespace: append_to_namespace(namespace, key)

    end
  when Array
    task.each do |t|
     link_task t, from: from, to: to, namespace: namespace
    end
  else
    shared_part = append_to_namespace namespace, task
    alias_task "#{from}:#{shared_part}", "#{to}:#{shared_part}"
  end
end

#load_rake_tasksObject



4
5
6
7
8
# File 'lib/decko/commands.rb', line 4

def load_rake_tasks
  require "./config/environment"
  require "rake"
  Decko::Application.load_tasks
end

#supported_rails_command?(arg) ⇒ Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/decko/commands.rb', line 27

def supported_rails_command? arg
  arg.in?(RAILS_COMMANDS) || ALIAS[arg].in?(RAILS_COMMANDS)
end