Class: Kaminari::Generators::ViewsGenerator

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

:nodoc:



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

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:



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

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

  themes = self.class.themes
  if theme = themes.detect {|t| t.name == file_name}
    download_templates theme
  else
    say %Q[no such theme: #{file_name}\n  avaliable themes: #{themes.map(&:name).join ", "}]
  end
end