Sha256: e1c0deb01afdeb2baba3454ccd23f29d0ed42a892d9390c2e450bd98145da332

Contents?: true

Size: 906 Bytes

Versions: 33

Compression:

Stored size: 906 Bytes

Contents

module CabooseStore
  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
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
caboose-store-0.0.43 lib/caboose-store/caboose_store_helper.rb
caboose-store-0.0.42 lib/caboose-store/caboose_store_helper.rb
caboose-store-0.0.41 lib/caboose-store/caboose_store_helper.rb
caboose-store-0.0.40 lib/caboose-store/caboose_store_helper.rb
caboose-store-0.0.39 lib/caboose-store/caboose_store_helper.rb
caboose-store-0.0.38 lib/caboose-store/caboose_store_helper.rb
caboose-store-0.0.37 lib/caboose-store/caboose_store_helper.rb
caboose-store-0.0.36 lib/caboose-store/caboose_store_helper.rb
caboose-store-0.0.35 lib/caboose-store/caboose_store_helper.rb
caboose-store-0.0.34 lib/caboose-store/caboose_store_helper.rb
caboose-store-0.0.33 lib/caboose-store/caboose_store_helper.rb
caboose-store-0.0.32 lib/caboose-store/caboose_store_helper.rb
caboose-store-0.0.31 lib/caboose-store/caboose_store_helper.rb
caboose-store-0.0.30 lib/caboose-store/caboose_store_helper.rb
caboose-store-0.0.29 lib/caboose-store/caboose_store_helper.rb
caboose-store-0.0.28 lib/caboose-store/caboose_store_helper.rb
caboose-store-0.0.27 lib/caboose-store/caboose_store_helper.rb
caboose-store-0.0.26 lib/caboose-store/caboose_store_helper.rb
caboose-store-0.0.25 lib/caboose-store/caboose_store_helper.rb
caboose-store-0.0.24 lib/caboose-store/caboose_store_helper.rb