Sha256: ef0d1d360be6a7c13e34144d2489defdc9be1ce0620b42f878242ae438731bd6

Contents?: true

Size: 1.74 KB

Versions: 1

Compression:

Stored size: 1.74 KB

Contents

#-  Ruby source code

#-  qm.rb ~~
#                                                       ~~ (c) SRW, 12 Apr 2013
#                                                   ~~ last updated 18 Jul 2014

module QM

    def self::launch_client(options = {})
      # This function needs documentation.
        puts '(placeholder: `launch_client`)'
        return
    end

    def self::launch_service(options = {})
      # This function creates, configures, and launches a fresh Sinatra app
      # that inherits from the original "teaching version".
        require 'service.rb'
        require 'defs-mongo'
        #require 'defs-sqlite'
        app = Sinatra.new(QMachineService) do
            register Sinatra::MongoConnect
            #register Sinatra::SQLiteConnect
            configure do
                convert = lambda do |x|
                  # This converts all keys in a hash to symbols recursively.
                    if (x.is_a?(Hash)) then
                        x = x.inject({}) do |memo, (k, v)|
                            memo[k.to_sym] = convert.call(v)
                            memo
                        end
                    end
                    return x
                end
                options = convert.call(options)
                set options
                set bind: :hostname, run: false, static: :enable_web_server
                if (settings.persistent_storage.has_key?(:mongo)) then
                    helpers Sinatra::MongoDefs
                    mongo_connect
                #elsif (settings.persistent_storage.has_key?(:sqlite)) then
                #    helpers Sinatra::SQLiteDefs
                #    sqlite_connect
                end
            end
        end
        return app.run!
    end

end

#-  vim:set syntax=ruby:

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
qm-1.1.12 lib/qm.rb