-
Notifications
You must be signed in to change notification settings - Fork 15
chore: add type signatures and type checker for CI #58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| target :lib do | ||
| signature "sig" | ||
| check "lib" | ||
| library "pathname" | ||
| library "forwardable" | ||
| library "singleton" | ||
| library "uri" | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,7 +26,7 @@ def initialize(name:, version: nil) | |
| end | ||
|
|
||
| def ==(other) | ||
| raise ArgumentError("Expected comparison to be between Metadata object") unless other.is_a?(Metadata) | ||
| raise ArgumentError, "Expected comparison to be between Metadata object" unless other.is_a?(Metadata) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems unrelated to the RBS changes. Did we pick up a new Rubocop rule?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nope, it's actually Looking at the documentation for |
||
|
|
||
| @name == other.name && @version == other.version | ||
| end | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| type flagValue = bool | Numeric | String | Hash[String, untyped] | ||
| type flagValueType = :bool | :integer | :float | :string | :object | ||
| type evaluationContext = { targeting_key: String? } | ||
| type evaluationDetails = { flag_key: String, flag_value?: flagValue } | ||
|
|
||
| type hookContext[T] = { | ||
| flag_key: String, | ||
| flag_value_type: flagValueType, | ||
| evaluation_context: evaluationContext, | ||
| default_value: T, | ||
| } | ||
|
|
||
| type hookHints = Hash[String, flagValue] | ||
|
|
||
| interface _BeforeHook | ||
| def before: (evaluationContext, ?hookHints) -> (evaluationContext | void) | ||
| end | ||
|
|
||
| interface _AfterHook[T] | ||
| def after: (hookContext[T], evaluationDetails, ?hookHints) -> void | ||
| end | ||
|
|
||
| interface _ErrorHook[T] | ||
| def error: (hookContext[T], Exception, ?hookHints) -> void | ||
| end | ||
|
|
||
| interface _FinallyHook[T] | ||
| def finally: (hookContext[T], ?hookHints) -> void | ||
| end | ||
|
|
||
| type hook = _BeforeHook | _AfterHook[flagValue] | _ErrorHook[flagValue] | _FinallyHook[flagValue] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| module OpenFeature | ||
| module SDK | ||
|
|
||
| interface _Configuration | ||
| def context: () -> void | ||
| end | ||
|
|
||
| class API | ||
| include _Configuration | ||
| extend Forwardable | ||
|
|
||
| attr_reader configuration: Configuration | ||
|
|
||
| def build_client: -> Client | ||
|
|
||
| def configure: () { (Configuration) -> void } -> void | ||
|
|
||
| # Singleton's RBS doesn't quite work | ||
| def self.instance: () -> instance | ||
| end | ||
| end | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| module OpenFeature | ||
| module SDK | ||
| class Client | ||
| RESULT_TYPE: Array[Symbol] | ||
| SUFFIXES: Array[Symbol] | ||
|
|
||
| @context: evaluationContext | ||
| @hooks: Array[hook] | ||
|
|
||
| attr_accessor hooks: Array[hook] | ||
| attr_reader metadata: Metadata? | ||
| attr_reader provider: untyped | ||
|
|
||
| def initialize: (provider: untyped , client_options: untyped, context: untyped) -> void | ||
| end | ||
| end | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
|
|
||
| module Concurrent | ||
| class Array[T] < ::Array[T] | ||
| def initialize: (?::Array[T]) -> void | ||
| end | ||
| end | ||
|
|
||
| module OpenFeature | ||
| module SDK | ||
| class Configuration | ||
| extend Forwardable | ||
|
|
||
| attr_accessor context: evaluationContext | ||
| attr_accessor hooks: [hook] | ||
| attr_accessor metadata: Metadata | ||
| attr_accessor provider: untyped | ||
| end | ||
| end | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| module OpenFeature | ||
| module SDK | ||
| class Metadata | ||
| attr_reader name: String | ||
| attr_reader version: String? | ||
|
|
||
| def initialize: (name: String, ?version: String?) -> void | ||
|
|
||
| def ==: (untyped other) -> untyped | ||
| end | ||
| end | ||
| end |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| module OpenFeature | ||
| module SDK | ||
| module Provider | ||
| class NoOpProvider | ||
| REASON_NO_OP: String | ||
| NAME: String | ||
| class ResolutionDetails[T] < ::Struct[T] | ||
| def initialize : (value: T, reason: String) -> void | ||
|
|
||
| attr_reader value(): T | ||
| attr_reader reason(): untyped | ||
| attr_reader variant(): untyped | ||
| attr_reader error_code(): untyped | ||
| attr_reader error_message(): untyped | ||
| end | ||
|
|
||
| attr_reader metadata: Metadata | ||
|
|
||
| def fetch_boolean_value: (flag_key: String, default_value: bool, ?evaluation_context: evaluationContext?) -> ResolutionDetails[bool] | ||
|
|
||
| def fetch_string_value: (flag_key: String, default_value: String, ?evaluation_context: evaluationContext?) -> ResolutionDetails[String] | ||
|
|
||
| def fetch_number_value: (flag_key: String, default_value: Numeric, ?evaluation_context: evaluationContext?) -> ResolutionDetails[Numeric] | ||
|
|
||
| def fetch_object_value: (flag_key: String, default_value: Hash[String|Symbol, untyped], ?evaluation_context: evaluationContext?) -> ResolutionDetails[Hash[String|Symbol, untyped]] | ||
| def no_op: [X] (X) -> ResolutionDetails[X] | ||
| end | ||
| end | ||
| end | ||
| end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@josecolella @technicalpickles Thoughts on enforcing this check on CI if we're going to start supporting RBS?