Sha256: d66316d2046da9e42d0563dcef56b745d44c52cba27f9ab0c2a8faf38311d2a4

Contents?: true

Size: 919 Bytes

Versions: 3

Compression:

Stored size: 919 Bytes

Contents

class TheCommentsGenerator < Rails::Generators::NamedBase
  source_root File.expand_path('../templates', __FILE__)
  # argument :xname, type: :string, default: :xname

  def generate_controllers
    if gen_name == 'install'
      cp_setup
      cp_controllers
    elsif gen_name == 'controllers'
      cp_controllers
    else
      puts 'TheComments Generator - wrong Name'
      puts 'Try to use [install|controllers]'
    end
  end

  private

  def gen_name
    name.to_s.downcase
  end

  def cp_setup
    copy_file 'the_comments.rb', 'config/initializers/the_comments.rb'
  end

  def cp_controllers
    copy_file 'comments_controller.rb',               'app/controllers/comments_controller.rb'
    copy_file 'ip_black_lists_controller.rb',         'app/controllers/ip_black_lists_controller.rb'
    copy_file 'user_agent_black_lists_controller.rb', 'app/controllers/user_agent_black_lists_controller.rb'
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
the_comments-1.0.0 lib/generators/the_comments/the_comments_generator.rb
the_comments-0.9.9 lib/generators/the_comments/the_comments_generator.rb
the_comments-0.9.0 lib/generators/the_comments/the_comments_generator.rb