Sha256: edfdd79eac0b0c82c378d169fb748d09971af1e242077f0b9a73c20641f1955d
Contents?: true
Size: 1.73 KB
Versions: 1
Compression:
Stored size: 1.73 KB
Contents
# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"). You may not # use this file except in compliance with the License. A copy of the License is # located at # # http://aws.amazon.com/apache2.0/ # # or in the "license" file accompanying this file. This file is distributed on # an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express # or implied. See the License for the specific language governing permissions # and limitations under the License. require "rails/generators/erb" require "rails/generators/resource_helpers" module AwsRecord module Generators class ErbGenerator < Base include Rails::Generators::ResourceHelpers source_root File.expand_path('../templates', __FILE__) argument :attributes, type: :array, default: [], banner: "field:type field:type" def initialize(args, *options) options[0] << "--skip-table-config" super end def create_root_folder empty_directory File.join("app/views", controller_file_path) end def copy_view_files available_views.each do |view| formats.each do |format| filename = filename_with_extensions(view, format) template filename, File.join("app/views", controller_file_path, filename) end end end private def available_views %w(index edit show new _form) end def formats [format] end def format :html end def handler :erb end def filename_with_extensions(name, file_format = format) [name, file_format, handler].compact.join(".") end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
aws-record-generator-1.0.0.pre.2 | lib/generators/aws_record/erb/erb_generator.rb |