Class: Umlaut::Install

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
ActionView::Helpers::TextHelper
Defined in:
lib/generators/umlaut/install_generator.rb

Instance Method Summary collapse

Instance Method Details

#asset_hooksObject



109
110
111
112
113
# File 'lib/generators/umlaut/install_generator.rb', line 109

def asset_hooks
  guarded(:asset_hooks) do
    generate("umlaut:asset_hooks")
  end
end

#config_cache_classesObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/generators/umlaut/install_generator.rb', line 12

def config_cache_classes
  guarded(:config_cache_classes) do
    /^((\s*)config\.cache_classes +\= +false\s*)$/
    gsub_file("config/environments/development.rb", /^(\s*)config\.cache_classes +\= +false\s*$/) do |match|
      # for some reason we can't make access to $1 in here from the above
      # regexp work, so we need to match again
      match =~ /^(\s*)/        
      <<-EOS
#{$1}#
#{$1}# UMLAUT: Umlaut's use of threading is not compatible with class
#{$1}# reloading, even in development. Umlaut requires true here.
#{$1}# Rails 3.2 _might_ let you get away with false when it comes out.
#{$1}config.cache_classes = true
        EOS
    end
  end
end

#database_yml_hintsObject



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/generators/umlaut/install_generator.rb', line 30

def database_yml_hints
  guarded(:database_yml_hints) do
    insert_into_file("config/database.yml", :before => /^(\s*)development:/) do                     
      <<-eos
#
# UMLAUT: mysql db with mysql2 adapter strongly recommended for Umlaut, in both 
# production and development. sqlite3 has unclear semantics under threaded 
# concurrency which umlaut uses, and in many cases simply does not work. 
#
# A higher pool size than ordinary is recommended because of umlaut's
# use of concurrency. Perhaps as large as the number of services
# you have configured to run in the same wave, plus another few. 
#
# development:
#   adapter: mysql2
#   host: 
#   username:
#   password:
#   database:
#   pool: 15 

      eos
    end
    append_to_file("config/database.yml") do
      <<-eos
      
#
# UMLAUT: for the 'search' functions (A-Z title lookup) to work, you need
# a direct database connection to the SFX database, under 'sfx_db' key. 
# You should manually set up a new read-only MySQL account in the SFX db
# for this purpose, rather than use one of the full-access existing SFX
# mysql accounts. 
#
#sfx_db:
#  adapter: mysql2
#  host: my_sfx_host.u.edu
#  port: 3310 # 3310 is defualt SFX embedded mysql port
#  database: sfxlcl41 # or other sfx instance db
#  username:
#  password:
#  pool: 5
#  encoding: utf8
# 
# UMLAUT: for Sfx4Solr functionality.  If you're not using SFX 4 indexed in 
# Solr via Sunspot, feel free to ignore this.
#sfx4_global:
#  adapter: mysql2
#  host: my_sfx_host.u.edu
#  port: 3310 # 3310 is defualt SFX embedded mysql port
#  database: sfxglb41 # or other sfx global db
#  username:
#  password:
#  pool: 5
#  encoding: utf8
# 
      eos
    end
  end
end

#local_umlaut_controllerObject



115
116
117
118
119
# File 'lib/generators/umlaut/install_generator.rb', line 115

def local_umlaut_controller
  guarded(:local_umlaut_controller) do
    copy_file("app/controllers/umlaut_controller.rb")
  end
end

#migrationsObject



103
104
105
106
107
# File 'lib/generators/umlaut/install_generator.rb', line 103

def migrations
  guarded(:migrations) do
    rake("umlaut:install:migrations")
  end
end

#post_install_messageObject



121
122
123
124
125
126
127
128
129
130
# File 'lib/generators/umlaut/install_generator.rb', line 121

def post_install_message            
    say("\n              Umlaut installed, now:", :yellow)
    $stdout.puts(
      "              " +
      word_wrap("After setting up your 'development' database in config/databases.yml, run `rake db:migrate`", :line_width => 60).
        split("\n").
        join("\n              ") + "\n"
      )
    
end

#routesObject



91
92
93
94
95
# File 'lib/generators/umlaut/install_generator.rb', line 91

def routes
  guarded(:routes) do
    route("Umlaut::Routes.new(self).draw")
  end
end

#umlaut_services_skeletonObject



97
98
99
100
101
# File 'lib/generators/umlaut/install_generator.rb', line 97

def umlaut_services_skeleton
  guarded(:umlaut_services_skeleton) do
    copy_file("lib/generators/templates/umlaut_services.yml", "config/umlaut_services.yml")
  end
end