class Kaminari::Generators::ViewsGenerator

Private Class Methods

themes() click to toggle source
# File lib/generators/kaminari/views_generator.rb, line 38
      def self.themes
        begin
          @themes ||= open ALL_API do |json|
#             @themes ||= open(File.join(File.dirname(__FILE__), '../../../spec/generators/sample.json')) do |json|
            files = ActiveSupport::JSON.decode(json)['blobs']
            hash = files.group_by {|fn, _| fn[0...(fn.index('/') || 0)]}.delete_if {|fn, _| fn.blank?}
            hash.map do |name, files|
              Theme.new name, files
            end
          end
        rescue SocketError
          []
        end
      end

Private Instance Methods

copy_default_views() click to toggle source
# File lib/generators/kaminari/views_generator.rb, line 60
def copy_default_views
  filename_pattern = File.join self.class.source_root, "*.html.#{template_engine}"
  Dir.glob(filename_pattern).map {|f| File.basename f}.each do |f|
    copy_file f, "app/views/kaminari/#{f}"
  end
end
download_templates(theme) click to toggle source
# File lib/generators/kaminari/views_generator.rb, line 53
def download_templates(theme)
  theme.templates_for(template_engine).each do |template|
    say "      downloading #{template.name} from kaminari_themes..."
    get "#{SHOW_API}/#{template.sha}", template.name
  end
end
template_engine() click to toggle source
# File lib/generators/kaminari/views_generator.rb, line 67
def template_engine
  options[:template_engine].try(:to_s).try(:downcase) || 'erb'
end