Module: LWS
- Includes:
- Errors
- Defined in:
- lib/lws.rb,
lib/lws/config.rb,
lib/lws/errors.rb,
lib/lws/version.rb,
lib/lws/stubbing.rb,
lib/lws/middleware.rb,
lib/lws/middleware/http_logger.rb,
lib/lws/middleware/json_logger.rb,
lib/lws/middleware/json_parser.rb,
lib/lws/middleware/request_headers.rb
Overview
The main LeftClick web services module
This module is the main namespace for the web service/application libraries that are represented by submodules. The LWS module is used to load, set up and configure the supported application/web service libraries.
Defined Under Namespace
Modules: Auth, CorporateWebsite, DigitalSignage, Errors, Generic, Maps, Presence, Resource, Ticket Classes: Config, Stubbing
Constant Summary collapse
- SUPPORTED_APPS =
The list of supported apps (web service libraries) loaded by setup.
[:generic, :auth, :corporate_website, :digital_signage, :maps, :presence, :resource, :ticket].freeze
- VERSION =
Note:
The major and minor version parts match the LWS API version!
The LWS library version.
"7.1.1".freeze
Class Method Summary collapse
-
.app_module(app_name) ⇒ Module
Returns the app module for the given app name.
-
.load_app_modules ⇒ Array<Symbol>
(Re)loads the app modules (usually done by LWS.setup).
-
.load_stubbing ⇒ Stubbing?
(Re)loads the stubbing if enabled (usually done by LWS.setup).
-
.setup {|config| ... } ⇒ LWS
Sets up the application API libraries using the provided configuration (see Config).
Instance Method Summary collapse
-
#config ⇒ Config
The API configuration for the web services.
-
#stubbing ⇒ Stubbing
The stubbing setup for the web service.
Class Method Details
.app_module(app_name) ⇒ Module
Returns the app module for the given app name.
143 144 145 |
# File 'lib/lws.rb', line 143 def self.app_module(app_name) @app_modules[app_name.to_sym] end |
.load_app_modules ⇒ Array<Symbol>
(Re)loads the app modules (usually done by setup).
151 152 153 154 155 156 157 158 |
# File 'lib/lws.rb', line 151 def self.load_app_modules @app_modules = {} app_module_path = File.dirname(__FILE__) SUPPORTED_APPS.each do |app_name| load "#{app_module_path}/lws/apps/#{app_name}.rb" @app_modules[app_name] = LWS.const_get(app_name.to_s.camelize) end end |
.load_stubbing ⇒ Stubbing?
(Re)loads the stubbing if enabled (usually done by setup).
163 164 165 166 167 168 169 170 |
# File 'lib/lws.rb', line 163 def self.load_stubbing if config.stubbing.present? @@stubbing = Stubbing.new(config.stubbing) else @@stubbing.disable! if @@stubbing @@stubbing = nil end end |
.setup {|config| ... } ⇒ LWS
Sets up the application API libraries using the provided configuration (see Config).
The API token can be overridden using the LC_LWS_API_TOKEN
environment variable. The LWS environment can be overriden using the LC_LWS_ENV
environment variable.
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/lws.rb', line 78 def self.setup(&block) @@config = Config.new yield @@config # Override the API token if needed (and no custom API token middleware # is used) if ENV["LC_LWS_API_TOKEN"].present? @@config.api_token = ENV["LC_LWS_API_TOKEN"] end # Override the environment if needed if ENV["LC_LWS_ENV"].present? @@config.environment = ENV["LC_LWS_ENV"].to_sym end if config.api_token.blank? and config.api_token_middleware.blank? raise LWS::Errors::ConfigError, "API token or API token middleware is required" end load_app_modules load_stubbing return self end |