Class: RadiantGo::Installers::Radiant
- Inherits:
-
Object
- Object
- RadiantGo::Installers::Radiant
- Defined in:
- lib/radiant-go/installers/radiant.rb
Instance Method Summary collapse
- #bootstrap ⇒ Object
- #create ⇒ Object
-
#initialize(name, database) ⇒ Radiant
constructor
A new instance of Radiant.
- #migrate_extensions ⇒ Object
- #update_config ⇒ Object
- #update_extensions ⇒ Object
Constructor Details
#initialize(name, database) ⇒ Radiant
Returns a new instance of Radiant.
7 8 9 10 |
# File 'lib/radiant-go/installers/radiant.rb', line 7 def initialize(name, database) @name = name @database = database end |
Instance Method Details
#bootstrap ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'lib/radiant-go/installers/radiant.rb', line 16 def bootstrap # we only bootstrap if there's no database! if File.exists?(@name + '/db/development.' + Config.database + '.db') == false Dir.chdir(@name) do %x[rake db:bootstrap OVERWRITE=true ADMIN_NAME=#{Config.admin_name} ADMIN_USERNAME=#{Config.admin_user} ADMIN_PASSWORD=#{Config.admin_pass} DATABASE_TEMPLATE=#{Config.database_template}] end end end |
#create ⇒ Object
12 13 14 |
# File 'lib/radiant-go/installers/radiant.rb', line 12 def create %x[radiant #{@name} --skip --database=#{@database}] end |
#migrate_extensions ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/radiant-go/installers/radiant.rb', line 83 def migrate_extensions Dir.chdir(@name) do all_extensions.each do |gem| # we need to use the short name for our migration, eg forms instead of radiant-forms-extension extension = gem[:name].scan(/^radiant-(.*)-extension$/) %x[rake radiant:extensions:#{extension}:migrate] end end end |
#update_config ⇒ Object
25 26 27 28 29 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 |
# File 'lib/radiant-go/installers/radiant.rb', line 25 def update_config Dir.chdir(@name) do # open our config config_file = File.open 'config/environment.rb' current_gems = [] # get a list of the gems in the config while (line = config_file.gets) if gem = line.match(/config.gem\s*['"](.*?)['"]/) current_gems << gem[1] end end # go back to the beginning of our environment file and blank out our strings config_file.rewind line = '' config_string = '' # read up to the part where we are loading gems while(line.index('config.gem') == nil) line = config_file.gets config_string += line end # loop through all our radiant extensions and add the lines we need for config all_extensions.each do |gem| # we only add the gem to our config if it's not already there! if !current_gems.any? {|current_gem| current_gem == gem[:name]} config_string += " config.gem '#{gem[:name]}', :version => '#{gem[:requirement]}', :lib => false\n" end end # read the rest of the config while(line = config_file.gets) config_string += line end # close the file, open it for reading and dump our string config_file.close config_file = File.open('config/environment.rb', 'w') config_file.write(config_string) config_file.close end end |
#update_extensions ⇒ Object
75 76 77 78 79 80 81 |
# File 'lib/radiant-go/installers/radiant.rb', line 75 def update_extensions Dir.chdir(@name) do %x[rake radiant:extensions:update_all] end end |