toggly 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/toggly.rb ADDED
@@ -0,0 +1,94 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "toggly/version"
4
+ require_relative "toggly/config"
5
+ require_relative "toggly/context"
6
+ require_relative "toggly/errors"
7
+ require_relative "toggly/feature_definition"
8
+ require_relative "toggly/evaluators/base"
9
+ require_relative "toggly/evaluators/always_on"
10
+ require_relative "toggly/evaluators/always_off"
11
+ require_relative "toggly/evaluators/percentage"
12
+ require_relative "toggly/evaluators/targeting"
13
+ require_relative "toggly/evaluators/time_window"
14
+ require_relative "toggly/evaluators/contextual_targeting"
15
+ require_relative "toggly/registry"
16
+ require_relative "toggly/evaluation_engine"
17
+ require_relative "toggly/snapshot_providers/base"
18
+ require_relative "toggly/snapshot_providers/memory"
19
+ require_relative "toggly/snapshot_providers/file"
20
+ require_relative "toggly/definitions_provider"
21
+ require_relative "toggly/client"
22
+
23
+ # Toggly - Feature Flag Management SDK for Ruby
24
+ #
25
+ # @example Basic usage
26
+ # client = Toggly::Client.new(
27
+ # app_key: "your-app-key",
28
+ # environment: "Production"
29
+ # )
30
+ #
31
+ # if client.enabled?("my-feature")
32
+ # # Feature is enabled
33
+ # end
34
+ #
35
+ # @example With user context
36
+ # context = Toggly::Context.new(
37
+ # identity: "user-123",
38
+ # groups: ["beta-testers"],
39
+ # traits: { country: "US" }
40
+ # )
41
+ #
42
+ # if client.enabled?("premium-feature", context: context)
43
+ # # Feature is enabled for this user
44
+ # end
45
+ #
46
+ # @example Offline mode with defaults
47
+ # client = Toggly::Client.new(
48
+ # defaults: {
49
+ # "feature-a" => true,
50
+ # "feature-b" => false
51
+ # }
52
+ # )
53
+ module Toggly
54
+ class << self
55
+ # Global client instance
56
+ attr_accessor :client
57
+
58
+ # Configure and initialize the global client
59
+ #
60
+ # @yield [config] Configuration block
61
+ # @return [Client] The configured client
62
+ def configure
63
+ config = Config.new
64
+ yield(config) if block_given?
65
+ @client = Client.new(config)
66
+ end
67
+
68
+ # Check if a feature is enabled using the global client
69
+ #
70
+ # @param feature_key [String, Symbol] The feature key
71
+ # @param context [Context, nil] Optional evaluation context
72
+ # @return [Boolean]
73
+ def enabled?(feature_key, context: nil)
74
+ raise Error, "Toggly not configured. Call Toggly.configure first." unless @client
75
+
76
+ @client.enabled?(feature_key, context: context)
77
+ end
78
+
79
+ # Check if a feature is disabled using the global client
80
+ #
81
+ # @param feature_key [String, Symbol] The feature key
82
+ # @param context [Context, nil] Optional evaluation context
83
+ # @return [Boolean]
84
+ def disabled?(feature_key, context: nil)
85
+ !enabled?(feature_key, context: context)
86
+ end
87
+
88
+ # Reset the global client (mainly for testing)
89
+ def reset!
90
+ @client&.close
91
+ @client = nil
92
+ end
93
+ end
94
+ end
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: toggly
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ops.ai
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2026-03-03 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: High-performance Ruby SDK for Toggly feature flag management. Works with
14
+ or without Toggly.io.
15
+ email:
16
+ - support@ops.ai
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - CHANGELOG.md
22
+ - LICENSE
23
+ - README.md
24
+ - lib/toggly.rb
25
+ - lib/toggly/client.rb
26
+ - lib/toggly/config.rb
27
+ - lib/toggly/context.rb
28
+ - lib/toggly/definitions_provider.rb
29
+ - lib/toggly/errors.rb
30
+ - lib/toggly/evaluation_engine.rb
31
+ - lib/toggly/evaluators/always_off.rb
32
+ - lib/toggly/evaluators/always_on.rb
33
+ - lib/toggly/evaluators/base.rb
34
+ - lib/toggly/evaluators/contextual_targeting.rb
35
+ - lib/toggly/evaluators/percentage.rb
36
+ - lib/toggly/evaluators/targeting.rb
37
+ - lib/toggly/evaluators/time_window.rb
38
+ - lib/toggly/feature_definition.rb
39
+ - lib/toggly/registry.rb
40
+ - lib/toggly/snapshot_providers/base.rb
41
+ - lib/toggly/snapshot_providers/file.rb
42
+ - lib/toggly/snapshot_providers/memory.rb
43
+ - lib/toggly/version.rb
44
+ homepage: https://toggly.io
45
+ licenses:
46
+ - MIT
47
+ metadata:
48
+ homepage_uri: https://toggly.io
49
+ source_code_uri: https://github.com/ops-ai/toggly-ruby
50
+ changelog_uri: https://github.com/ops-ai/toggly-ruby/blob/main/CHANGELOG.md
51
+ documentation_uri: https://docs.toggly.io/sdks/ruby
52
+ rubygems_mfa_required: 'true'
53
+ optional_dependencies: websocket-client-simple
54
+ post_install_message:
55
+ rdoc_options: []
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: 3.0.0
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ requirements: []
69
+ rubygems_version: 3.5.22
70
+ signing_key:
71
+ specification_version: 4
72
+ summary: Ruby SDK for Toggly feature flags
73
+ test_files: []