Class: Kaminari::Generators::ViewsGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Defined in:
lib/generators/kaminari/views_generator.rb

Overview

rails g kaminari:views THEME

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

:nodoc:



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/generators/kaminari/views_generator.rb', line 12

def self.banner #:nodoc:
  <<-BANNER.chomp
rails g kaminari:views THEME [options]

    Copies all paginator partial templates to your application.
    You can choose a template THEME by specifying one from the list below:

  - default
      The default one.
      This one is used internally while you don't override the partials.
#{themes.map {|t| "        - #{t.name}\n#{t.description}"}.join("\n")}
BANNER
end

Instance Method Details

#copy_or_fetchObject

:nodoc:



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/generators/kaminari/views_generator.rb', line 27

def copy_or_fetch #:nodoc:
  return copy_default_views if file_name == 'default'

  if (theme = self.class.themes.detect {|t| t.name == file_name})
    if download_templates(theme).empty?
      say "template_engine: #{template_engine} is not available for theme: #{file_name}"
    end
  else
    say "no such theme: #{file_name}\n  available themes: #{self.class.themes.map(&:name).join ', '}"
  end
end