Class: RoCommands::Rails

Inherits:
Base
  • Object
show all
Defined in:
lib/ro_commands/rails.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

describe, start, usage

Methods included from Bash

#_bash, #bash, #bash_lines, #bash_per, #bashc, err, #handle_path, out, status

Class Method Details

.generators_mapObject



21
22
23
24
25
26
27
28
29
30
# File 'lib/ro_commands/rails.rb', line 21

def generators_map
  @generators_map ||= {
      scaffold: 's',
      migration: 'm',
      model: 'mo',
      controller: 'c',
      assets: 'a',
      task: 't'
  }
end

.itemsObject



52
53
54
# File 'lib/ro_commands/rails.rb', line 52

def items
  @items ||= %w(migration scaffold model)
end

.items2Object



56
57
58
# File 'lib/ro_commands/rails.rb', line 56

def items2
  @items2 ||= %w(controller task assets)
end

.method_added(method) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/ro_commands/rails.rb', line 9

def method_added(method)
  super
  unless method.match(%r{})
    meths << method
  end
  meths.uniq!
end

.methsObject



17
18
19
# File 'lib/ro_commands/rails.rb', line 17

def meths
  @meths ||= []
end

.set_shortcut_method(item) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/ro_commands/rails.rb', line 32

def set_shortcut_method(item)
  class_eval do
    #shortcut_item = generators_map[item.to_sym]
    #desc usage(shortcut_item), describe('generate', item, shortcut_item)
    #
    #define_method shortcut_item.to_sym do |*args|
    #  send item.to_sym, *args
    #end

    #shortcut_item_d = "#{shortcut_item}_d"
    #item_d = "#{item}_d"
    #
    #desc usage(shortcut_item_d), describe('destroy', item, shortcut_item_d)
    #define_method shortcut_item_d.to_sym do |*args|
    #  send item_d.to_sym, *args
    #end
  end
end

Instance Method Details

#get_assetsObject



120
121
122
123
124
# File 'lib/ro_commands/rails.rb', line 120

def get_assets
  get_files('assets') do |f|
    f.match(%r{(js|coffee|scss|css)$})
  end
end

#get_controllersObject



128
129
130
# File 'lib/ro_commands/rails.rb', line 128

def get_controllers
  get_rails_files('controllers')
end

#get_migrationsObject



104
105
106
107
108
109
110
# File 'lib/ro_commands/rails.rb', line 104

def get_migrations
  Find.find('db/migrate').select do |f|
    f.match(%r{rb$})
  end.map do |f|
    File.basename(f).gsub(%r(^\d+_), "")
  end
end

#get_modelsObject



114
115
116
# File 'lib/ro_commands/rails.rb', line 114

def get_models
  get_rails_files('models')
end

#scaffoldsObject



98
99
100
# File 'lib/ro_commands/rails.rb', line 98

def scaffolds
  get_controllers
end