Module: Stellwerk
- Defined in:
- lib/stellwerk.rb,
lib/stellwerk/flow.rb,
lib/stellwerk/errors.rb,
lib/stellwerk/result.rb,
lib/stellwerk/license.rb,
lib/stellwerk/version.rb,
lib/stellwerk/metering.rb,
lib/stellwerk/evaluator.rb,
lib/stellwerk/functions.rb,
lib/stellwerk/api_client.rb,
lib/stellwerk/configuration.rb
Overview
Collection & aggregation helper functions for Dentaku. We override common aggregators (SUM, COUNT, MIN, MAX) to be dual-mode:
- Classic Dentaku usage: SUM(a, b, c)
- Array mode: SUM(array) or SUM(array_of_numbers) or SUM(array_of_mixed) Additional functions: FIRST, LAST, TAKE, PROJECT (internal helper) Projection pattern: identifier.field is preprocessed into PROJECT(identifier, "field") Mixed-type coercion:
- Numeric values kept
- Numeric-looking strings converted to Float
- nil ignored
- Other types ignored for numeric aggregations
- If no numeric values remain -> SUM = 0, MIN/MAX = nil, COUNT counts all non-nil projected elements (not just numeric) TAKE(array, n) -> first n elements (n coerced to integer, negative treated as 0) FIRST(array) / LAST(array) -> element or nil
Defined Under Namespace
Modules: Functions Classes: ApiClient, ApiError, Configuration, Error, EvaluationError, Evaluator, Flow, InvalidFlowError, License, LicenseError, Metering, MissingInputError, QuotaExceededError, Result, SubFlowNotFoundError
Constant Summary collapse
- VERSION =
"0.2.1"
Class Method Summary collapse
-
.api_key=(key) ⇒ Object
Convenience setter for API key.
-
.configuration ⇒ Configuration
Returns the configuration instance.
-
.configure {|Configuration| ... } ⇒ Object
Configure Stellwerk.
-
.license ⇒ License
Returns the license instance.
-
.licensed? ⇒ Boolean
Check if the SDK is properly licensed.
-
.logger ⇒ Logger
Returns the configured logger (defaults to a null logger).
-
.logger=(logger) ⇒ Object
Set the logger.
-
.metering ⇒ Metering
Returns the metering instance.
-
.reset! ⇒ Object
Reset all state to defaults.
Class Method Details
.api_key=(key) ⇒ Object
Convenience setter for API key
66 67 68 |
# File 'lib/stellwerk.rb', line 66 def api_key=(key) configuration.api_key = key end |
.configuration ⇒ Configuration
Returns the configuration instance
47 48 49 |
# File 'lib/stellwerk.rb', line 47 def configuration @configuration ||= Configuration.new end |
.configure {|Configuration| ... } ⇒ Object
Configure Stellwerk
59 60 61 |
# File 'lib/stellwerk.rb', line 59 def configure yield configuration end |
.license ⇒ License
Returns the license instance
87 88 89 |
# File 'lib/stellwerk.rb', line 87 def license @license ||= License.new end |
.licensed? ⇒ Boolean
Check if the SDK is properly licensed
Validates the API key on first call and caches the result.
103 104 105 106 107 108 109 |
# File 'lib/stellwerk.rb', line 103 def licensed? return false unless configuration.api_key? license.valid? || license.validate! rescue LicenseError, ApiError false end |
.logger ⇒ Logger
Returns the configured logger (defaults to a null logger)
73 74 75 |
# File 'lib/stellwerk.rb', line 73 def logger configuration.logger || @default_logger ||= Logger.new(File::NULL) end |
.logger=(logger) ⇒ Object
Set the logger
80 81 82 |
# File 'lib/stellwerk.rb', line 80 def logger=(logger) configuration.logger = logger end |
.metering ⇒ Metering
Returns the metering instance
94 95 96 |
# File 'lib/stellwerk.rb', line 94 def metering @metering ||= Metering.new end |
.reset! ⇒ Object
Reset all state to defaults
Resets configuration, license, and metering state.
114 115 116 117 118 119 120 121 |
# File 'lib/stellwerk.rb', line 114 def reset! metering.reset! license.reset! @configuration = nil @license = nil @metering = nil @default_logger = nil end |