Class: RadiantGo::Installers::Main
- Inherits:
-
Object
- Object
- RadiantGo::Installers::Main
- Defined in:
- lib/radiant-go/installers/main.rb
Instance Method Summary collapse
- #copy_gemfile ⇒ Object
- #generate_config ⇒ Object
-
#initialize(name) ⇒ Main
constructor
A new instance of Main.
- #run ⇒ Object
Constructor Details
#initialize(name) ⇒ Main
Returns a new instance of Main.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/radiant-go/installers/main.rb', line 7 def initialize(name) @project_name = name if File.exists? @project_name + '/config/radiant-go.rb' require @project_name + '/config/radiant-go.rb' end # setup default gemfile location if File.exists?(@project_name + '/Gemfile') Config.gemfile_location = File.(@project_name) + '/Gemfile' else Config.gemfile_location = File.(File.dirname(__FILE__)) + '/../../../config/Gemfile' end end |
Instance Method Details
#copy_gemfile ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/radiant-go/installers/main.rb', line 46 def copy_gemfile # we only copy the file if it doesn't exist if !File.exists?(@project_name + '/Gemfile') File.new(@project_name + '/Gemfile', File::CREAT) unless File.exists?(@project_name + '/Gemfile') source = File.open(Config.gemfile_location, 'r') target = File.open(@project_name + '/Gemfile', 'w') target.write( source.read(64) ) while not source.eof? target.close source.close end end |
#generate_config ⇒ Object
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 89 90 |
# File 'lib/radiant-go/installers/main.rb', line 62 def generate_config puts '== creating config' if !File.exists? @project_name # create our directory if there isn't one Dir.mkdir @project_name end if !File.exists? @project_name + '/config' # create our config directory if it doesn't already exist! Dir.mkdir @project_name + '/config' end # copy our gemfile source = File.open(File.(File.dirname(__FILE__)) + '/../../../config/Gemfile') target = File.open(@project_name + '/Gemfile', 'w') target.write( source.read(64) ) while not source.eof? target.close source.close # copy our config file source = File.open(File.(File.dirname(__FILE__)) + '/../../../config/config.rb') target = File.open(@project_name + '/config/radiant-go.rb', 'w') target.write( source.read(64) ) while not source.eof? target.close source.close end |
#run ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/radiant-go/installers/main.rb', line 24 def run radiant = Installers::Radiant.new(@project_name, Config.database) bundler = Installers::Bundler.new(@project_name) puts '== generating radiant project' radiant.create puts '== copying gemfile' copy_gemfile puts '== bundler is installing gems' bundler.install puts '== running bootstrap' radiant.bootstrap puts '== updating config' radiant.update_config puts '== updating extensions' radiant.update_extensions puts '== migrating extensions' radiant.migrate_extensions end |