groundcontrolsh 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.
- checksums.yaml +7 -0
- data/lib/groundcontrolsh.rb +35 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e1815a625435acc5d42f202b22a7063f341e3eb9c0c05facc27ddfb1d8ad03be
|
4
|
+
data.tar.gz: 0f82baed500dee1353a7739da580a1cf3d0d3ba71cfe65f2ae324dcbfb340d6e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4768ee64d4ece417d18f777e6757249ab96e1d7f86de50a90a0d6c69c92eaac5b5f19a4be6b7913db4aa92fe8a631edbf8d18244e0e6860fabf5d04f26369099
|
7
|
+
data.tar.gz: 004aeef30d08c454dd05c49d800cfc2bfbd9a618cef24240b2ffcf86abafbfc754196ee74c2d0bcab777165df36c56024ab1610d80bfc2936d79a017f6b3453e
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'net/http'
|
3
|
+
require 'openssl'
|
4
|
+
require 'json'
|
5
|
+
require 'cgi'
|
6
|
+
|
7
|
+
class GroundControl
|
8
|
+
def initialize(project_id:, api_key:, **options)
|
9
|
+
@project_id = project_id
|
10
|
+
@api_key = api_key
|
11
|
+
@base_url = options[:base_url] || 'https://api.groundcontrol.sh'
|
12
|
+
# @cache = options[:cache] || nil
|
13
|
+
end
|
14
|
+
|
15
|
+
def feature_flag_enabled?(feature_name, options = {})
|
16
|
+
actors = options[:actors] || []
|
17
|
+
|
18
|
+
query = actors.map { |actor| "actorIds=#{CGI.escape(actor)}" }
|
19
|
+
# query << "cache=#{@cache}" if @cache
|
20
|
+
|
21
|
+
url = URI("#{@base_url}/projects/#{@project_id}/flags/#{feature_name}/check?#{query.join('&')}")
|
22
|
+
http = Net::HTTP.new(url.host, url.port)
|
23
|
+
http.use_ssl = true
|
24
|
+
|
25
|
+
request = Net::HTTP::Get.new(url)
|
26
|
+
request["Authorization"] = "Bearer #{@api_key}"
|
27
|
+
response = http.request(request)
|
28
|
+
|
29
|
+
return nil if response.code != '200'
|
30
|
+
|
31
|
+
body = JSON.parse(response.body)
|
32
|
+
|
33
|
+
return body["enabled"]
|
34
|
+
end
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: groundcontrolsh
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alberto Gimeno
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-05-17 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Verify the rollout status of feature flags created in your groundcontrol.sh
|
14
|
+
project
|
15
|
+
email: gimenete@groundcontrol.sh
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/groundcontrolsh.rb
|
21
|
+
homepage: https://groundcontrol.sh
|
22
|
+
licenses:
|
23
|
+
- MIT
|
24
|
+
metadata: {}
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
requirements: []
|
40
|
+
rubygems_version: 3.2.3
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: Ruby SDK for groundcontrol.sh
|
44
|
+
test_files: []
|