Sha256: b8d6ea27b4d3f9f1460eae2d98b5794040704a2d47b13038671dae55f7d70bc1

Contents?: true

Size: 832 Bytes

Versions: 9

Compression:

Stored size: 832 Bytes

Contents

class CabooseStoreHelper
  
  def initialize(app_path, force = false)
    @app_path = app_path
    @force = force
  end
  
  def init_all
    init_routes
  end
     
  # Adds the routes to the host app to point everything to caboose
  def init_routes
    puts "Adding the caboose store routes..."
    
    filename = File.join(@app_path,'config','routes.rb')
    return if !File.exists?(filename)
    return if !@force
    
    str = "" 
    str << "\t# Catch everything with caboose\n"  
    str << "\tmount CabooseStore::Engine => '/'\n"
    
    file = File.open(filename, 'rb')
    contents = file.read
    file.close    
    if (contents.index(str).nil?)
      arr = contents.split('end', -1)
      str2 = arr[0] + "\n" + str + "\nend" + arr[1]
      File.open(filename, 'w') {|file| file.write(str2) }
    end    
  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
caboose-store-0.0.10 lib/caboose-store/caboose_store_helper.rb
caboose-store-0.0.9 lib/caboose-store/caboose_store_helper.rb
caboose-store-0.0.8 lib/caboose-store/caboose_store_helper.rb
caboose-store-0.0.7 lib/caboose-store/caboose_store_helper.rb
caboose-store-0.0.6 lib/caboose-store/caboose_store_helper.rb
caboose-store-0.0.5 lib/caboose-store/caboose_store_helper.rb
caboose-store-0.0.4 lib/caboose-store/caboose_store_helper.rb
caboose-store-0.0.3 lib/caboose-store/caboose_store_helper.rb
caboose-store-0.0.2 lib/caboose-store/caboose_store_helper.rb