configly-ruby 0.0.7 → 1.0.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 +4 -4
- data/README.md +21 -9
- data/configly-ruby.gemspec +1 -1
- data/lib/configly/client.rb +1 -0
- data/lib/configly/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5cd1a5ca5bd4fff4a416180ea014a83b38c53abb3bf88c95c73a1847acab147
|
4
|
+
data.tar.gz: 39f1058a0f232c79c974c3b3f40225e2bf9c686f2fa2a6a35ea1957d101d6ea7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b62c2e1201994d6d6b7e657a4f0ff8054f7fdf27a4c0f72d5321da02aa9216326329ed9c5ce269c53141587a565e6facfccfb206465d7662c378860463826b8
|
7
|
+
data.tar.gz: c8faaf70b43269cb72058eb129378de450bd5186135131d9200b4e77e9ea4c3899094e0c7f33d5499d4c10d8a73b9bc931d06e034dbd43c23eae60056f7f0dbc
|
data/README.md
CHANGED
@@ -9,12 +9,17 @@ Table of Contents
|
|
9
9
|
|
10
10
|
* [What is Configly?](#what-is-configly)
|
11
11
|
* [Core Features](#core-features)
|
12
|
+
* [Concepts/ Data Model](#concepts--data-model)
|
12
13
|
* [Getting Started](#getting-started)
|
13
|
-
|
14
|
-
|
14
|
+
+ [1. Get your API Key](#1-get-your-api-key)
|
15
|
+
+ [2. Create your first Config](#2-create-your-first-config)
|
16
|
+
+ [3. Install the client library](#3-install-the-client-library)
|
17
|
+
+ [4. Fetch the Config](#4-fetch-the-config)
|
15
18
|
* [Usage](#usage)
|
16
|
-
|
19
|
+
* [Feature Flags](#feature-flags)
|
20
|
+
* [Configuring this library to use websockets](#configuring-this-library-to-use-websockets)
|
17
21
|
* [License](#license)
|
22
|
+
- [Configly Ruby Library](#configly-ruby-library)
|
18
23
|
|
19
24
|
|
20
25
|
## What is Configly?
|
@@ -38,7 +43,7 @@ read more about the benefits at [Configly](config.ly).
|
|
38
43
|
|
39
44
|
- API to fetch Strings, JSON Blobs (arrays and objects), Booleans, and Numbers from the Configly backend
|
40
45
|
- [Web interface](https://www.config.ly/config) for modifying these values without having to deploy code (we call our beloved web interface _the Configulator_).
|
41
|
-
|
46
|
+
- High availability, high-throughput, low-latency backend.
|
42
47
|
- Smart caching on the client libraries to minimize server requests.
|
43
48
|
- Client libraries available in an expanding amount of languages.
|
44
49
|
|
@@ -128,9 +133,9 @@ Be sure to save via clicking 'Send to Clients'. Now, we'll write client code to
|
|
128
133
|
|
129
134
|
### 3. Install the client library
|
130
135
|
|
131
|
-
If you're using bundler, add the following line to your project's `Gemfile`:
|
136
|
+
If you're using [Bundler](https://bundler.io/) (as is often the case with Rails), add the following line to your project's `Gemfile`:
|
132
137
|
```sh
|
133
|
-
gem 'configly-ruby', '~> 0.0
|
138
|
+
gem 'configly-ruby', '~> 1.0.0'
|
134
139
|
```
|
135
140
|
|
136
141
|
Or, if you're using the Gem directly from your application, you can run:
|
@@ -138,7 +143,7 @@ Or, if you're using the Gem directly from your application, you can run:
|
|
138
143
|
gem install configly-ruby
|
139
144
|
```
|
140
145
|
|
141
|
-
You will need to set the `CONFIGLY_API_KEY` environment variable.
|
146
|
+
You will need to set the `CONFIGLY_API_KEY` [environment variable](https://www.rubyguides.com/2019/01/ruby-environment-variables/).
|
142
147
|
|
143
148
|
### 4. Fetch the Config
|
144
149
|
In a Rails controller, add the following code
|
@@ -184,8 +189,9 @@ store_catalog:
|
|
184
189
|
On the Ruby client:
|
185
190
|
|
186
191
|
```ruby
|
192
|
+
# You can try this example out by setting the `CONFIGLY_API_KEY` environmental variable to our demo account: 'Dem0apiKEY'
|
187
193
|
begin
|
188
|
-
catalog = Configly::Client.get(
|
194
|
+
catalog = Configly::Client.get("store_catalog")
|
189
195
|
items = catalog['items']
|
190
196
|
prices = catalog['prices']
|
191
197
|
|
@@ -199,9 +205,12 @@ end
|
|
199
205
|
|
200
206
|
Note: If the key doesn't exist, this will raise a `Configly::KeyError`
|
201
207
|
|
208
|
+
### Feature Flags
|
202
209
|
Here is an example with feature flags.
|
203
|
-
|
210
|
+
|
204
211
|
```
|
212
|
+
// These values are stored on the Config.ly server
|
213
|
+
|
205
214
|
feature1_enabled: true
|
206
215
|
feature2_enabled: false
|
207
216
|
```
|
@@ -209,6 +218,9 @@ feature2_enabled: false
|
|
209
218
|
On the ruby client:
|
210
219
|
|
211
220
|
```ruby
|
221
|
+
# Remember, you need to set the `CONFIGLY_API_KEY` environment variable.
|
222
|
+
# You can find your API Key on https://www.config.ly/config.
|
223
|
+
|
212
224
|
begin
|
213
225
|
if Configly::Client.get('feature1_enabled')
|
214
226
|
# Logic for feature 1
|
data/configly-ruby.gemspec
CHANGED
data/lib/configly/client.rb
CHANGED
@@ -84,6 +84,7 @@ module Configly
|
|
84
84
|
|
85
85
|
Net::HTTP.start(uri.host, uri.port, :use_ssl => true) do |http|
|
86
86
|
request = Net::HTTP::Get.new uri
|
87
|
+
request['X-Lib-Version'] = "configly-ruby/#{Configly::VERSION}"
|
87
88
|
request.basic_auth get_api_key, ''
|
88
89
|
response = http.request request
|
89
90
|
data = JSON.parse(response.body)['data']
|
data/lib/configly/version.rb
CHANGED