Class: Arpa::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/generators/arpa/install_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(dirname) ⇒ Object



8
9
10
11
# File 'lib/generators/arpa/install_generator.rb', line 8

def self.next_migration_number(dirname)
  return Time.new.utc.strftime("%Y%m%d%H%M%S") if ActiveRecord::Base.timestamped_migrations
  "%.3d" % (current_migration_number(dirname) + 1)
end

Instance Method Details

#add_controllersObject



38
39
40
41
42
# File 'lib/generators/arpa/install_generator.rb', line 38

def add_controllers
  copy_file '../../arpa/controllers/resources_controller.rb', 'app/controllers/arpa/resources_controller.rb'
  copy_file '../../arpa/controllers/roles_controller.rb', 'app/controllers/arpa/roles_controller.rb'
  copy_file '../../arpa/controllers/profiles_controller.rb', 'app/controllers/arpa/profiles_controller.rb'
end

#add_routesObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/generators/arpa/install_generator.rb', line 44

def add_routes
  route "scope module: :arpa do\n    resources :resources do\ncollection do\n  get 'generate_resources_and_actions'\nend\n    end\n\n    resources :roles do\ncollection do\n  delete ':id', to: 'roles#remove'\nend\n    end\n\n    resources :profiles do\ncollection do\n  delete ':id', to: 'profiles#remove'\nend\n    end\n  end\n  RUBY\nend\n"

#copy_localesObject



68
69
70
# File 'lib/generators/arpa/install_generator.rb', line 68

def copy_locales
  copy_file '../../config/locales/arpa.en.yml', 'config/locales/arpa.en.yml'
end

#copy_resources_views_filesObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/generators/arpa/install_generator.rb', line 17

def copy_resources_views_files
  copy_file '../../arpa/views/resources/index.html.erb', 'app/views/arpa/resources/index.html.erb'
  copy_file '../../arpa/views/resources/show.html.erb', 'app/views/arpa/resources/show.html.erb'

  copy_file '../../arpa/views/roles/index.html.erb', 'app/views/arpa/roles/index.html.erb'
  copy_file '../../arpa/views/roles/show.html.erb', 'app/views/arpa/roles/show.html.erb'
  copy_file '../../arpa/views/roles/new.html.erb', 'app/views/arpa/roles/new.html.erb'
  copy_file '../../arpa/views/roles/edit.html.erb', 'app/views/arpa/roles/edit.html.erb'
  copy_file '../../arpa/views/roles/_form.html.erb', 'app/views/arpa/roles/_form.html.erb'

  copy_file '../../arpa/views/profiles/index.html.erb', 'app/views/arpa/profiles/index.html.erb'
  copy_file '../../arpa/views/profiles/show.html.erb', 'app/views/arpa/profiles/show.html.erb'
  copy_file '../../arpa/views/profiles/new.html.erb', 'app/views/arpa/profiles/new.html.erb'
  copy_file '../../arpa/views/profiles/edit.html.erb', 'app/views/arpa/profiles/edit.html.erb'
  copy_file '../../arpa/views/profiles/_form.html.erb', 'app/views/arpa/profiles/_form.html.erb'
end

#copy_stylesheet_filesObject



34
35
36
# File 'lib/generators/arpa/install_generator.rb', line 34

def copy_stylesheet_files
  copy_file '../../arpa/assets/stylesheets/arpa_accordion.scss', 'app/assets/stylesheets/arpa/arpa_accordion.scss'
end

#create_migrate_filesObject



13
14
15
# File 'lib/generators/arpa/install_generator.rb', line 13

def create_migrate_files
  migration_template 'templates/migration.rb', 'db/migrate/create_arpa_tables.rb'
end