doppler-client 0.1.2 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9bb08eeff831da656b658d211696f8fc98b9c306
4
- data.tar.gz: f80ffc0eee91e244d990bbc06bda63882ee46a4d
3
+ metadata.gz: e70c73c3d8540dab77ce8289398cd3c2f731d9f6
4
+ data.tar.gz: 8a1d7b5e816df0023d5d75e2593f383811193090
5
5
  SHA512:
6
- metadata.gz: 7127af99279f088c652c1e90e4b1644c78a02d140729c0e52b4210e5bf4b4776e4c35f71635006899fd78a02ec471825497930862170b1f5d1c255006bfb79e2
7
- data.tar.gz: 0d8c635f4911b7f92edf01b1754c200a60effe17665fe00e5a8ef5828f02b950822afd06bc891395120409186c94c169f8f27c67d41b461a4fb78c864929a55d
6
+ metadata.gz: 801682828160e601e16147f06db404019a8b65e2aff722910452cd15fe89be8572e47e7fdc14d1df3b420bf0229dc14d3578ffdea0c33bedc53b966624994513
7
+ data.tar.gz: 594a85c3d6c109686d8528ee38bcdf73a400a71421763f5632fe7f4fb89020128c21a9f1560c9e22897574fa54a4fe47dada0d1cea12321a1d10155da001b4ce
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- git_source(:github) {|repo_name| "https://github.com/DopplerHQ/ruby-client" }
3
+ git_source(:github) { "https://github.com/DopplerHQ/ruby-client" }
4
4
 
5
5
  # Specify your gem's dependencies in doppler-client.gemspec
6
6
  gemspec
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Doppler Ruby Library
2
2
 
3
3
  [![image](https://img.shields.io/gem/v/doppler-client.svg)](https://rubygems.org/gems/doppler-client)
4
+ [![Codacy Badge](https://api.codacy.com/project/badge/Grade/92ec3d37764c40da8dffb6a85c6cbfa4)](https://www.codacy.com/app/Doppler/ruby-client?utm_source=github.com&utm_medium=referral&utm_content=DopplerHQ/ruby-client&utm_campaign=Badge_Grade)
4
5
 
5
6
  The Doppler Ruby library provides convenient access to the Doppler API from
6
7
  applications written for **only** server-side code.
@@ -28,7 +29,6 @@ doppler = Doppler::Client.new(
28
29
  # Rest of Application
29
30
  ```
30
31
 
31
-
32
32
  ## Key Best Practices
33
33
 
34
34
  So if Doppler stores my environment keys, where should I keep my Doppler API keys?
@@ -36,7 +36,6 @@ So if Doppler stores my environment keys, where should I keep my Doppler API key
36
36
  That is a great question! We recommend storing your `API_KEY`, `PIPELINE_ID`, and `ENVIRONMENT_NAME`
37
37
  in local environment. That means the only keys you should be storing in your local environment are the Doppler keys. All other keys should be be fetched by the Doppler client.
38
38
 
39
-
40
39
  ### Fetch Environment Keys
41
40
 
42
41
  You can fetch your environment keys from Doppler by calling the `get(name)` method.
@@ -55,7 +54,6 @@ config = {
55
54
 
56
55
  ```
57
56
 
58
-
59
57
  If there are differences between the values your local environment sets and the ones on Doppler, the client will use the ones provided by Doppler. You can override this behavior by passing in a second argument to the `get(key_name, priority)` method that sets the priority to favor your local environment.
60
58
 
61
59
  For example:
@@ -87,7 +85,6 @@ doppler = Doppler::Client.new(
87
85
 
88
86
  ```
89
87
 
90
-
91
88
  ## Local Key Privacy
92
89
 
93
90
  By default the Doppler client will only track the local environment keys that are used during `doppler.get()`.
@@ -111,7 +108,6 @@ doppler = Doppler::Client.new(
111
108
  )
112
109
  ```
113
110
 
114
-
115
111
  ### Ignoring Specific Keys
116
112
  Inversely, you can also ignore specific local keys by adding them to the `ignore_keys` array.
117
113
 
@@ -128,9 +124,7 @@ doppler = Doppler::Client.new(
128
124
  )
129
125
  ```
130
126
 
131
-
132
127
  ## Extra Information
133
128
 
134
129
  - [Doppler](https://doppler.market)
135
130
  - [API KEY](https://doppler.market/workplace/api_key)
136
-
@@ -1,9 +1,11 @@
1
1
  lib = File.expand_path("../lib", __FILE__)
2
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
+ require "doppler/version"
5
+
4
6
  Gem::Specification.new do |spec|
5
7
  spec.name = "doppler-client"
6
- spec.version = "0.1.2"
8
+ spec.version = Doppler::VERSION
7
9
  spec.authors = ["Doppler Team"]
8
10
  spec.email = "brian@doppler.market"
9
11
 
@@ -2,24 +2,22 @@ require 'net/https'
2
2
  require 'json'
3
3
  require 'set'
4
4
 
5
+ require "doppler/version"
6
+
5
7
  module Doppler
6
8
  class Priority
7
- @@local = 0
9
+ @local = 0
8
10
  def self.local
9
- @@local
11
+ @local
10
12
  end
11
13
 
12
- @@remote = 1
14
+ @remote = 1
13
15
  def self.remote
14
- @@remote
16
+ @remote
15
17
  end
16
18
  end
17
19
 
18
20
  class Client
19
- @@host_key = 'DOPPLER_HOST'
20
- @@default_host = 'https://api.doppler.market'
21
- @@environ_segment = '/environments/'
22
- @@max_retries = 0
23
21
 
24
22
  def initialize(api_key, pipeline, environment, priority = Priority.remote, track_keys = [], ignore_keys = [])
25
23
  raise ArgumentError, 'api_key not string' unless api_key.is_a? String
@@ -35,8 +33,11 @@ module Doppler
35
33
  @default_priority = priority
36
34
  @track_keys = track_keys.to_set
37
35
  @ignore_keys = ignore_keys.to_set
38
- @host = ENV[@@host_key] ? ENV[@@host_key] : @@default_host
39
-
36
+ @max_retries = 10
37
+ @environ_segment = '/environments/'
38
+ @default_host = 'https://api.doppler.market'
39
+ @host = ENV['DOPPLER_HOST'].nil? ? @default_host : ENV['DOPPLER_HOST']
40
+
40
41
  startup()
41
42
  end
42
43
 
@@ -60,7 +61,7 @@ module Doppler
60
61
  end
61
62
 
62
63
  def get(key_name, priority = nil)
63
- priority = priority != nil ? priority : @default_priority
64
+ priority = priority.nil? ? @default_priority : priority
64
65
  value = nil
65
66
 
66
67
  if priority == Priority.local
@@ -69,8 +70,8 @@ module Doppler
69
70
  value = @remote_keys[key_name] ? @remote_keys[key_name] : ENV[key_name]
70
71
  end
71
72
 
72
- if not @ignore_keys.include?(key_name)
73
- if value != nil
73
+ unless @ignore_keys.include?(key_name)
74
+ if !value.nil?
74
75
  if ENV[key_name] != @remote_keys[key_name]
75
76
  local_keys = {}
76
77
  local_keys[key_name] = ENV[key_name]
@@ -93,12 +94,14 @@ module Doppler
93
94
  def _request(endpoint, body, retry_count=0)
94
95
  raise ArgumentError, 'endpoint not string' unless endpoint.is_a? String
95
96
 
96
- raw_url = @host + @@environ_segment + @environment + endpoint
97
+ raw_url = @host + @environ_segment + @environment + endpoint
97
98
  uri = URI.parse(raw_url)
98
99
  header = {
99
100
  'Content-Type': 'application/json',
100
101
  'api-key': @api_key,
101
- 'pipeline': @pipeline
102
+ 'pipeline': @pipeline,
103
+ 'client-sdk': 'ruby',
104
+ 'client-version': Doppler::VERSION
102
105
 
103
106
  }
104
107
  http = Net::HTTP.new(uri.host, uri.port)
@@ -113,7 +116,7 @@ module Doppler
113
116
  rescue => e
114
117
  retry_count += 1
115
118
 
116
- if retry_count > @@max_retries
119
+ if retry_count > @max_retries
117
120
  raise e
118
121
  else
119
122
  return _request(endpoint, body, retry_count)
@@ -0,0 +1,3 @@
1
+ module Doppler
2
+ VERSION = "0.1.4".freeze
3
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: doppler-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Doppler Team
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-10-19 00:00:00.000000000 Z
11
+ date: 2018-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -83,7 +83,8 @@ files:
83
83
  - bin/console
84
84
  - bin/setup
85
85
  - doppler-client.gemspec
86
- - lib/doppler/client.rb
86
+ - lib/doppler.rb
87
+ - lib/doppler/version.rb
87
88
  homepage: https://github.com/DopplerHQ/ruby-client
88
89
  licenses:
89
90
  - Apache-2.0