Sha256: f03b6ca3840364fd5c274780668f85bdfc05b941222edbdab2b0915fb0fdc2b5

Contents?: true

Size: 850 Bytes

Versions: 2

Compression:

Stored size: 850 Bytes

Contents

module TheSortableTree
  module Generators
    class ViewsGenerator < Rails::Generators::NamedBase
      source_root File.expand_path('../../../../app/views', __FILE__)

      def self.banner
        <<-BANNER.chomp
rails g the_sortable_tree:views MODEL [tree|sortable|comments]
  Copies files for rendering sortable nested set
        BANNER
      end

      def copy_sortable_tree_files
        # sortable
        # comments
        # tree
        if ARGV[1] == 'sortable'
          directory "sortable/base", "app/views/#{folder}/sortable/base"
        elsif ARGV[1] == 'comments'
          directory "comments/base", "app/views/#{folder}/comments/base"
        else
          directory "tree/base", "app/views/#{folder}/tree/base"
        end
      end

      private

      def folder
        name.pluralize.downcase
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
the_sortable_tree-1.9.1 lib/generators/the_sortable_tree/views_generator.rb
the_sortable_tree-1.9.0 lib/generators/the_sortable_tree/views_generator.rb