Sha256: 6a4a9d24db44f7163ededaac12ac4fc30c9fab9c33ffe98bee6282fc852e49b3

Contents?: true

Size: 878 Bytes

Versions: 5

Compression:

Stored size: 878 Bytes

Contents

require 'rails/generators'

class BlacklightOaiProviderGenerator < 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  SolrDocument.use_extension( BlacklightOaiProvider::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 BlacklightOaiProvider::ControllerExtension\n"
      end
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
blacklight_oai_provider-0.1.0 lib/generators/blacklight_oai_provider/blacklight_oai_provider_generator.rb
blacklight_oai_provider-0.0.2 lib/generators/blacklight_oai_provider/blacklight_oai_provider_generator.rb
blacklight_oai_provider-0.0.1 lib/generators/blacklight_oai_provider/blacklight_oai_provider_generator.rb
blacklight_oai_provider-0.0.1pre2 lib/generators/blacklight_oai_provider/blacklight_oai_provider_generator.rb
blacklight_oai_provider-0.0.1pre1 lib/generators/blacklight_oai_provider/blacklight_oai_provider_generator.rb