Class: CrudGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/scaffolding/crud_generator.rb

Constant Summary collapse

ACTIONS =
%w[list create detail edit].freeze

Instance Method Summary collapse

Constructor Details

#initialize(base_name, scaffolding_class, config_loader) ⇒ CrudGenerator

Returns a new instance of CrudGenerator.



8
9
10
11
12
# File 'lib/scaffolding/crud_generator.rb', line 8

def initialize(base_name, scaffolding_class, config_loader)
  @base_name = NameNormalizer.normalize(base_name)
  @scaffolding_class = scaffolding_class
  @config_loader = config_loader
end

Instance Method Details

#generateObject



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/scaffolding/crud_generator.rb', line 14

def generate
  generated = []
  ACTIONS.each do |action|
    name = "#{@base_name}_#{action}"
    generate_page(name)
    generate_test(name)
    generated << name
  end
  generate_model
  generated
end

#planned_filesObject



26
27
28
29
30
31
32
33
34
35
# File 'lib/scaffolding/crud_generator.rb', line 26

def planned_files
  files = []
  ACTIONS.each do |action|
    name = "#{@base_name}_#{action}"
    files << "page_objects/pages/#{name}.rb"
    files << test_path(name)
  end
  files << "models/data/#{@base_name}.yml"
  files
end