Sha256: 697312ce8bcbba0a1bb08e7832d3c6df1f73e35f0ea13962633469e47577298d

Contents?: true

Size: 850 Bytes

Versions: 5

Compression:

Stored size: 850 Bytes

Contents

require 'rails/generators'

class BlacklightHighlightGenerator < Rails::Generators::Base

  argument :model_name, :type => :string, :default => "SolrDocument"
  argument :controller_name, :type => :string, :default => "CatalogController"

  def inject_solr_document_extension
    file_path = "app/models/#{model_name.underscore}.rb"

    if File.exists? file_path
      inject_into_file file_path, :after => "include Blacklight::Solr::Document" do
        "\n  include BlacklightHighlight::SolrDocumentExtension\n"
      end
    end
  end

  def inject_catalog_controller_extension
    file_path = "app/controllers/#{controller_name.underscore}.rb"
    if File.exists? file_path
      inject_into_file file_path, :after => "include Blacklight::Catalog" do
        "\n  include BlacklightHighlight::ControllerExtension\n"
      end
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
blacklight_highlight-0.1.0 lib/generators/blacklight_highlight/blacklight_highlight_generator.rb
blacklight_highlight-0.0.3 lib/generators/blacklight_highlight/blacklight_highlight_generator.rb
blacklight_highlight-0.0.2 lib/generators/blacklight_highlight/blacklight_highlight_generator.rb
blacklight_highlight-0.0.1 lib/generators/blacklight_highlight/blacklight_highlight_generator.rb
blacklight_highlight-0.0.1pre1 lib/generators/blacklight_highlight/blacklight_highlight_generator.rb