Skip to content

Commit 207e8fd

Browse files
committed
Merge branch 'master' into eb/no-faraday
# Conflicts: # lib/ldclient-rb/requestor.rb # spec/http_util.rb # spec/requestor_spec.rb
2 parents f8997d4 + 76fa71e commit 207e8fd

33 files changed

+894
-196
lines changed

.circleci/config.yml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ ruby-docker-template: &ruby-docker-template
1919
gem install jruby-openssl; # required by bundler, no effect on Ruby MRI
2020
fi
2121
- run: ruby -v
22-
- run: gem install bundler -v "~> 1.7"
22+
- run: gem install bundler -v 1.17.3
2323
- run: bundle install
2424
- run: mkdir ./rspec
2525
- run: bundle exec rspec --format progress --format RspecJunitFormatter -o ./rspec/rspec.xml spec
@@ -33,30 +33,35 @@ jobs:
3333
<<: *ruby-docker-template
3434
docker:
3535
- image: circleci/ruby:2.2.10-jessie
36+
- image: consul
3637
- image: redis
3738
- image: amazon/dynamodb-local
3839
test-2.3:
3940
<<: *ruby-docker-template
4041
docker:
4142
- image: circleci/ruby:2.3.7-jessie
43+
- image: consul
4244
- image: redis
4345
- image: amazon/dynamodb-local
4446
test-2.4:
4547
<<: *ruby-docker-template
4648
docker:
4749
- image: circleci/ruby:2.4.5-stretch
50+
- image: consul
4851
- image: redis
4952
- image: amazon/dynamodb-local
5053
test-2.5:
5154
<<: *ruby-docker-template
5255
docker:
5356
- image: circleci/ruby:2.5.3-stretch
57+
- image: consul
5458
- image: redis
5559
- image: amazon/dynamodb-local
5660
test-jruby-9.2:
5761
<<: *ruby-docker-template
5862
docker:
5963
- image: circleci/jruby:9-jdk
64+
- image: consul
6065
- image: redis
6166
- image: amazon/dynamodb-local
6267

@@ -90,13 +95,24 @@ jobs:
9095
fi
9196
# bundler 2.0 may be preinstalled, we need to remove it if so
9297
yes | gem uninstall bundler --version '>=2.0' || true;
93-
gem install bundler -v "~> 1.7";
98+
gem install bundler -v 1.17.3;
9499
bundle install;
95100
mv Gemfile.lock "Gemfile.lock.$i"
96101
done
97102
- run:
103+
name: start DynamoDB
98104
command: docker run -p 8000:8000 amazon/dynamodb-local
99105
background: true
106+
- run:
107+
name: download Consul
108+
command: wget https://releases.hashicorp.com/consul/0.8.0/consul_0.8.0_linux_amd64.zip
109+
- run:
110+
name: extract Consul
111+
command: unzip consul_0.8.0_linux_amd64.zip
112+
- run:
113+
name: start Consul
114+
command: ./consul agent -dev
115+
background: true
100116
- run:
101117
name: run tests for all versions
102118
shell: /bin/bash -leo pipefail

.yardopts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
--no-private
2+
--markup markdown
3+
--embed-mixins
4+
lib/*.rb
5+
lib/**/*.rb
6+
lib/**/**/*.rb
7+
lib/**/**/**/*.rb
8+
-
9+
README.md

CHANGELOG.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,34 @@
22

33
All notable changes to the LaunchDarkly Ruby SDK will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org).
44

5+
## [5.5.2] - 2019-01-18
6+
### Fixed:
7+
- Like 5.5.1, this release contains only documentation fixes. Implementation classes that are not part of the supported API are now hidden from the [generated documentation](https://www.rubydoc.info/gems/ldclient-rb).
8+
9+
10+
## [5.5.1] - 2019-01-17
11+
### Fixed:
12+
- Fixed several documentation comments that had the wrong parameter names. There are no other changes in this release; it's only to correct the documentation.
13+
14+
## [5.5.0] - 2019-01-17
15+
### Added:
16+
- It is now possible to use Consul or DynamoDB as a persistent feature store, similar to the existing Redis integration. See the `LaunchDarkly::Integrations::Consul` and `LaunchDarkly::Integrations::DynamoDB` modules, and the reference guide [Using a persistent feature store](https://docs.launchdarkly.com/v2.0/docs/using-a-persistent-feature-store).
17+
- There is now a `LaunchDarkly::Integrations::Redis` module, which is the preferred method for creating a Redis feature store.
18+
- All of the database feature stores now support local caching not only for individual feature flag queries, but also for `all_flags_state`.
19+
- The `Config` property `data_source` is the new name for `update_processor` and `update_processor_factory`.
20+
21+
### Changed:
22+
- The implementation of the SSE protocol for streaming has been moved into a separate gem, [`ld-eventsource`](https://github.com/launchdarkly/ruby-eventsource). This has no effect on streaming functionality.
23+
24+
### Fixed:
25+
- Added or corrected a large number of documentation comments. All API classes and methods are now documented, and internal implementation details have been hidden from the documentation. You can view the latest documentation on [RubyDoc](https://www.rubydoc.info/gems/ldclient-rb).
26+
- Fixed a problem in the Redis feature store that would only happen under unlikely circumstances: trying to evaluate a flag when the LaunchDarkly client had not yet been fully initialized and the store did not yet have data in it, and then trying again when the client was still not ready but the store _did_ have data (presumably put there by another process). Previously, the second attempt would fail.
27+
- In polling mode, the SDK did not correctly handle non-ASCII Unicode characters in feature flag data. ([#90](https://github.com/launchdarkly/ruby-client/issues/90))
28+
29+
### Deprecated:
30+
- `RedisFeatureStore.new`. This implementation class may be changed or moved in the future; use `LaunchDarkly::Integrations::Redis::new_feature_store`.
31+
- `Config.update_processor` and `Config.update_processor_factory`; use `Config.data_source`.
32+
533
## [5.4.3] - 2019-01-11
634
### Changed:
735
- The SDK is now compatible with `net-http-persistent` 3.x. (Thanks, [CodingAnarchy](https://github.com/launchdarkly/ruby-client/pull/113)!)

CONTRIBUTING.md

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,3 @@ Contributing to LaunchDarkly SDK for Ruby
22
=========================================
33

44
We encourage pull-requests and other contributions from the community. We've also published an [SDK contributor's guide](http://docs.launchdarkly.com/docs/sdk-contributors-guide) that provides a detailed explanation of how our SDKs work.
5-
6-
Dependencies
7-
------------
8-
[ld-em-eventsource](https://github.com/launchdarkly/em-eventsource)
9-
10-
11-
Style
12-
-----
13-
14-
Our pull requests have [Hound CI](https://houndci.com/) set up to do style checking.
15-
We also run [Rubocop](https://github.com/bbatsov/rubocop).
16-

Gemfile.lock

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ PATH
66
faraday (>= 0.9, < 2)
77
faraday-http-cache (>= 1.3.0, < 3)
88
json (>= 1.8, < 3)
9+
ld-eventsource (~> 1.0)
910
net-http-persistent (>= 2.9, < 4.0)
1011
semantic (~> 1.6)
1112

@@ -28,6 +29,9 @@ GEM
2829
concurrent-ruby (1.1.4)
2930
connection_pool (2.2.1)
3031
diff-lcs (1.3)
32+
diplomat (2.0.2)
33+
faraday (~> 0.9)
34+
json
3135
docile (1.1.5)
3236
faraday (0.15.4)
3337
multipart-post (>= 1.2, < 3)
@@ -36,7 +40,6 @@ GEM
3640
ffi (1.9.25)
3741
ffi (1.9.25-java)
3842
hitimes (1.3.0)
39-
hitimes (1.3.0-java)
4043
http_tools (0.4.5)
4144
jmespath (1.4.0)
4245
json (1.8.6)
@@ -92,6 +95,7 @@ DEPENDENCIES
9295
bundler (~> 1.7)
9396
codeclimate-test-reporter (~> 0)
9497
connection_pool (>= 2.1.2)
98+
diplomat (>= 2.0.2)
9599
ldclient-rb!
96100
listen (~> 3.0)
97101
rake (~> 10.0)

README.md

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -15,37 +15,37 @@ This version of the LaunchDarkly SDK has a minimum Ruby version of 2.2.6, or 9.1
1515
Quick setup
1616
-----------
1717

18-
0. Install the Ruby SDK with `gem`
18+
1. Install the Ruby SDK with `gem`
1919

20-
```shell
20+
```shell
2121
gem install ldclient-rb
2222
```
2323

24-
1. Require the LaunchDarkly client:
24+
2. Require the LaunchDarkly client:
2525

26-
```ruby
26+
```ruby
2727
require 'ldclient-rb'
2828
```
2929

30-
2. Create a new LDClient with your SDK key:
30+
3. Create a new LDClient with your SDK key:
3131

32-
```ruby
32+
```ruby
3333
client = LaunchDarkly::LDClient.new("your_sdk_key")
3434
```
3535

3636
### Ruby on Rails
3737

38-
0. Add `gem 'ldclient-rb'` to your Gemfile and `bundle install`
38+
1. Add `gem 'ldclient-rb'` to your Gemfile and `bundle install`
3939

40-
1. Initialize the launchdarkly client in `config/initializers/launchdarkly.rb`:
40+
2. Initialize the launchdarkly client in `config/initializers/launchdarkly.rb`:
4141

42-
```ruby
42+
```ruby
4343
Rails.configuration.ld_client = LaunchDarkly::LDClient.new("your_sdk_key")
4444
```
4545

46-
2. You may want to include a function in your ApplicationController
46+
3. You may want to include a function in your ApplicationController
4747

48-
```ruby
48+
```ruby
4949
def launchdarkly_settings
5050
if current_user.present?
5151
{
@@ -72,31 +72,44 @@ Rails.configuration.ld_client = LaunchDarkly::LDClient.new("your_sdk_key")
7272
end
7373
```
7474

75-
3. In your controllers, access the client using
75+
4. In your controllers, access the client using
7676

77-
```ruby
77+
```ruby
7878
Rails.application.config.ld_client.variation('your.flag.key', launchdarkly_settings, false)
7979
```
8080

8181
Note that this gem will automatically switch to using the Rails logger it is detected.
8282

8383

84+
Your first feature flag
85+
-----------------------
86+
87+
1. Create a new feature flag on your [dashboard](https://app.launchdarkly.com).
88+
2. In your application code, use the feature's key to check whether the flag is on for each user:
89+
90+
```ruby
91+
if client.variation("your.flag.key", {key: "user@test.com"}, false)
92+
# application code to show the feature
93+
else
94+
# the code to run if the feature is off
95+
end
96+
```
97+
8498
HTTPS proxy
85-
------------
86-
The Ruby SDK uses Faraday and Socketry to handle its network traffic. Both of these provide built-in support for the use of an HTTPS proxy. If the HTTPS_PROXY environment variable is present then the SDK will proxy all network requests through the URL provided.
99+
-----------
100+
101+
The Ruby SDK uses Faraday and Socketry to handle its network traffic. Both of these provide built-in support for the use of an HTTPS proxy. If the HTTPS_PROXY environment variable is present then the SDK will proxy all network requests through the URL provided. (HTTP_PROXY is not used because all LaunchDarkly services require HTTPS.)
87102

88103
How to set the HTTPS_PROXY environment variable on Mac/Linux systems:
89104
```
90105
export HTTPS_PROXY=https://web-proxy.domain.com:8080
91106
```
92107

93-
94108
How to set the HTTPS_PROXY environment variable on Windows systems:
95109
```
96110
set HTTPS_PROXY=https://web-proxy.domain.com:8080
97111
```
98112

99-
100113
If your proxy requires authentication then you can prefix the URN with your login information:
101114
```
102115
export HTTPS_PROXY=http://user:pass@web-proxy.domain.com:8080
@@ -106,34 +119,22 @@ or
106119
set HTTPS_PROXY=http://user:pass@web-proxy.domain.com:8080
107120
```
108121

109-
110-
Your first feature flag
111-
-----------------------
112-
113-
1. Create a new feature flag on your [dashboard](https://app.launchdarkly.com)
114-
2. In your application code, use the feature's key to check whether the flag is on for each user:
115-
116-
```ruby
117-
if client.variation("your.flag.key", {key: "user@test.com"}, false)
118-
# application code to show the feature
119-
else
120-
# the code to run if the feature is off
121-
end
122-
```
123-
124122
Database integrations
125123
---------------------
126124

127-
Feature flag data can be kept in a persistent store using Redis or DynamoDB. These adapters are implemented in the `LaunchDarkly::Integrations::Redis` and `LaunchDarkly::Integrations::DynamoDB` modules; to use them, call the `new_feature_store` method in the module, and put the returned object in the `feature_store` property of your client configuration. See the [source code](https://github.com/launchdarkly/ruby-client-private/tree/master/lib/ldclient-rb/integrations) and the [SDK reference guide](https://docs.launchdarkly.com/v2.0/docs/using-a-persistent-feature-store) for more information.
125+
Feature flag data can be kept in a persistent store using Redis, DynamoDB, or Consul. These adapters are implemented in the `LaunchDarkly::Integrations::Redis`, `LaunchDarkly::Integrations::DynamoDB`, and `LaunchDarkly::Integrations::Consul` modules; to use them, call the `new_feature_store` method in the module, and put the returned object in the `feature_store` property of your client configuration. See the [API documentation](https://www.rubydoc.info/gems/ldclient-rb/LaunchDarkly/Integrations) and the [SDK reference guide](https://docs.launchdarkly.com/v2.0/docs/using-a-persistent-feature-store) for more information.
128126

129127
Using flag data from a file
130128
---------------------------
131-
For testing purposes, the SDK can be made to read feature flag state from a file or files instead of connecting to LaunchDarkly. See [`file_data_source.rb`](https://github.com/launchdarkly/ruby-client/blob/master/lib/ldclient-rb/file_data_source.rb) for more details.
129+
130+
For testing purposes, the SDK can be made to read feature flag state from a file or files instead of connecting to LaunchDarkly. See `LaunchDarkly::FileDataSource` or the [SDK reference guide](https://docs.launchdarkly.com/v2.0/docs/reading-flags-from-a-file) for more details.
132131

133132
Learn more
134133
-----------
135134

136-
Check out our [documentation](http://docs.launchdarkly.com) for in-depth instructions on configuring and using LaunchDarkly. You can also head straight to the [complete reference guide for this SDK](http://docs.launchdarkly.com/docs/ruby-sdk-reference).
135+
Check out our [documentation](http://docs.launchdarkly.com) for in-depth instructions on configuring and using LaunchDarkly. You can also head straight to the [reference guide for this SDK](http://docs.launchdarkly.com/docs/ruby-sdk-reference).
136+
137+
Generated API documentation is on [RubyDoc.info](https://www.rubydoc.info/gems/ldclient-rb).
137138

138139
Testing
139140
-------
@@ -143,10 +144,10 @@ We run integration tests for all our SDKs using a centralized test harness. This
143144
Contributing
144145
------------
145146

146-
See [Contributing](https://github.com/launchdarkly/ruby-client/blob/master/CONTRIBUTING.md)
147+
See [Contributing](https://github.com/launchdarkly/ruby-client/blob/master/CONTRIBUTING.md).
147148

148149
About LaunchDarkly
149-
-----------
150+
------------------
150151

151152
* LaunchDarkly is a continuous delivery platform that provides feature flags as a service and allows developers to iterate quickly and safely. We allow you to easily flag your features and manage them from the LaunchDarkly dashboard. With LaunchDarkly, you can:
152153
* Roll out a new feature to a subset of your users (like a group of users who opt-in to a beta tester group), gathering feedback and bug reports from real-world use cases.

ldclient-rb.gemspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Gem::Specification.new do |spec|
2525
spec.add_development_dependency "bundler", "~> 1.7"
2626
spec.add_development_dependency "rspec", "~> 3.2"
2727
spec.add_development_dependency "codeclimate-test-reporter", "~> 0"
28+
spec.add_development_dependency "diplomat", ">= 2.0.2"
2829
spec.add_development_dependency "redis", "~> 3.3.5"
2930
spec.add_development_dependency "connection_pool", ">= 2.1.2"
3031
spec.add_development_dependency "rake", "~> 10.0"

lib/ldclient-rb/config.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ def self.default_connect_timeout
332332

333333
#
334334
# The default value for {#logger}.
335-
# @return [::Logger] the Rails logger if in Rails, or a default [::Logger] at WARN level otherwise
335+
# @return [Logger] the Rails logger if in Rails, or a default Logger at WARN level otherwise
336336
#
337337
def self.default_logger
338338
if defined?(Rails) && Rails.respond_to?(:logger)

lib/ldclient-rb/impl.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11

22
module LaunchDarkly
33
#
4-
# Low-level implementation classes. Everything in this module should be considered non-public
5-
# and subject to change with any release.
4+
# Internal implementation classes. Everything in this module should be considered unsupported
5+
# and subject to change.
66
#
77
# @since 5.5.0
8+
# @private
89
#
910
module Impl
1011
# code is in ldclient-rb/impl/

0 commit comments

Comments
 (0)