Class: Geoblacklight::Install

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/geoblacklight/install_generator.rb

Instance Method Summary collapse

Instance Method Details

#add_unique_keyObject


41
42
43
44
45
# File 'lib/generators/geoblacklight/install_generator.rb', line 41

def add_unique_key
  inject_into_file 'app/models/solr_document.rb', after: "# self.unique_key = 'id'" do
    "\n  self.unique_key = 'layer_slug_s'"
  end
end

#assetsObject


21
22
23
24
# File 'lib/generators/geoblacklight/install_generator.rb', line 21

def assets
  copy_file "geoblacklight.css.scss", "app/assets/stylesheets/geoblacklight.css.scss"
  copy_file "geoblacklight.js", "app/assets/javascripts/geoblacklight.js"
end

#bundle_installObject


67
68
69
70
71
# File 'lib/generators/geoblacklight/install_generator.rb', line 67

def bundle_install
  Bundler.with_clean_env do
    run "bundle install"
  end
end

#create_blacklight_catalogObject


26
27
28
29
# File 'lib/generators/geoblacklight/install_generator.rb', line 26

def create_blacklight_catalog
  remove_file "app/controllers/catalog_controller.rb"
  copy_file "catalog_controller.rb", "app/controllers/catalog_controller.rb"
end

#create_downloads_directoryObject


47
48
49
# File 'lib/generators/geoblacklight/install_generator.rb', line 47

def create_downloads_directory
  FileUtils.mkdir_p("tmp/cache/downloads") unless File.directory?("tmp/cache/downloads")
end

63
64
65
# File 'lib/generators/geoblacklight/install_generator.rb', line 63

def disable_turbolinks
  gsub_file('app/assets/javascripts/application.js', /\/\/= require turbolinks/, '')
end

#include_geoblacklight_solrdocumentObject


35
36
37
38
39
# File 'lib/generators/geoblacklight/install_generator.rb', line 35

def include_geoblacklight_solrdocument
  inject_into_file 'app/models/solr_document.rb', after: 'include Blacklight::Solr::Document' do
    "\n include Geoblacklight::SolrDocument"
  end
end

#inject_sprocketsObject

Necessary for bootstrap-sass 3.2


52
53
54
55
56
57
58
59
60
61
# File 'lib/generators/geoblacklight/install_generator.rb', line 52

def inject_sprockets
  blacklight_css = Dir["app/assets/stylesheets/blacklight.css.scss"].first
  if blacklight_css
    insert_into_file blacklight_css, before: "@import 'bootstrap';" do
      "@import 'bootstrap-sprockets';\n"
    end
  else
    say_status "warning", "Can not find blacklight.css.scss, did not insert our require", :red
  end
end

#install_jettywrapperObject


12
13
14
15
16
17
18
19
# File 'lib/generators/geoblacklight/install_generator.rb', line 12

def install_jettywrapper
  return unless options[:jettywrapper]
  copy_file 'config/jetty.yml'

  append_to_file 'Rakefile',
    "\nZIP_URL = \"https://github.com/projectblacklight/blacklight-jetty/archive/v4.10.3.zip\"\n" +
    "require 'jettywrapper'\n"
end

#rails_configObject


31
32
33
# File 'lib/generators/geoblacklight/install_generator.rb', line 31

def rails_config
  copy_file 'settings.yml', 'config/settings.yml'
end