percy-common 3.1.1 → 3.1.3

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
  SHA256:
3
- metadata.gz: 4a36d99fd5b06fe4959e00e8f13b9bbf1f7d356832c2a56f42e1f177f285b11d
4
- data.tar.gz: a9ce522b6a66d1d96527cbdb774b1fd5dc92738d0c9953cb29ea4371de0bbc04
3
+ metadata.gz: ce7918aeff2ead877459e0bfd675c86caa2378a0b428dca1c8aaf93d427f276a
4
+ data.tar.gz: ed60d47e414a8a9ce3662407ae500bb56bdba6087de7cad21b36473ca8f67487
5
5
  SHA512:
6
- metadata.gz: 3e18a43f607a28a9b6f450470bf7e0bb9c2acaf266cd134ecd499f8da3a9d37fc4f52b6fd8f550d08c8fea2cef83497948935d8025b23756c1cfba2b2dcac08d
7
- data.tar.gz: '0062099d255d3cc75ddf646a939c72b7a82dd77c2da97289134e6d9240e9628603c5d0dd14dfde8d461f76d5dcf389b67295e91bb1d6588325de0f3de9d4331a'
6
+ metadata.gz: 4e8461a0a30b248ecf18d009d935a23a5c8a6076e6b2bf2136282b7235428787f8d62e98c5c00bcf1046525dc075995efd5fe47ac5ec076530aa82dc8915a66b
7
+ data.tar.gz: 731a137bdc7f022685d42562b2b394689874aeb0087e5e1d9b334d14d64cf1aa8bdf01f55af0dddca33d79625a12c9b2dff271ad04304998a95333c05b481f90
@@ -1,3 +1,5 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
1
3
  inherit_gem:
2
4
  percy-style:
3
5
  - default.yml
@@ -0,0 +1,12 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2020-04-30 16:00:36 -0700 using RuboCop version 0.77.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ RSpec/LeakyConstantDeclaration:
11
+ Exclude:
12
+ - 'spec/percy/keyword_struct_spec.rb'
@@ -1,16 +1,13 @@
1
1
  # Releasing
2
2
 
3
- 1. `git pull origin master`
4
- 1. Bump the version number in `lib/percy/common/version.rb`
5
- 1. `git add lib/percy/common/version.rb`
6
- 1. `git commit -m "version bump to X.X.X"`
7
- 1. `git push origin master`
8
- 1. `git tag vX.X.X`
9
- 1. `git push --tags`
10
- 1. `bundle exec rake build`
11
- 1. `gem push pkg/percy-common-X.X.X.gem`
3
+ 1. Ensure you are on the expected branch (presumably `master`) and the current branch is up-to-date.
4
+ 1. Run `./release.sh`
12
5
  1. Visit [RubyGems.org](https://rubygems.org/gems/percy-common) and see the gem has been published
13
- 1. Document the release on Github by first [creating a new release](https://github.com/percy/percy-common/releases/new)
6
+
7
+ # Creating a Release on GitHub
8
+
9
+ Finish the pre-started release opened by the script, or [create a new release](https://github.com/percy/percy-common/releases/new):
10
+
14
11
  1. Enter "vX.X.X" as the tag version. It should auto complete to say "Existing Tag"
15
12
  1. Enter "vX.X.X" as the release title
16
13
  1. Write a brief description as to what is included in this release. Linking to specific PRs is great.
@@ -1,5 +1,5 @@
1
1
  module Percy
2
2
  module Common
3
- VERSION = '3.1.1'.freeze
3
+ VERSION = '3.1.3'.freeze
4
4
  end
5
5
  end
@@ -4,11 +4,14 @@ require 'redis'
4
4
 
5
5
  module Percy
6
6
  class RedisClient
7
- attr_reader :options
7
+ class InvalidConfiguration < ArgumentError
8
+ end
8
9
  attr_reader :client
10
+ attr_reader :options
9
11
 
10
- def initialize(options = {})
11
- @options = ssl_options.merge(options)
12
+ def initialize(given_options = {})
13
+ @provided_options = given_options
14
+ @options = ssl_options.merge(given_options)
12
15
  @client = ::Redis.new(options)
13
16
  end
14
17
 
@@ -17,7 +20,7 @@ module Percy
17
20
  end
18
21
 
19
22
  private def provided_url
20
- options&.dig(:url)
23
+ @provided_options&.dig(:url)
21
24
  end
22
25
 
23
26
  private def ssl_options
@@ -31,52 +34,63 @@ module Percy
31
34
  return {} unless ssl_enabled?
32
35
 
33
36
  {
34
- ca_file: certificate_authority_file,
37
+ ca_file: certificate_authority,
35
38
  cert: OpenSSL::X509::Certificate.new(client_certificate),
36
39
  key: OpenSSL::PKey::RSA.new(private_key),
37
40
  }
38
41
  end
39
42
 
40
43
  private def client_certificate
41
- ENV.fetch(
42
- 'REDIS_SSL_CLIENT_CERTIFICATE',
43
- File.read(client_certificate_path),
44
- )
44
+ @provided_options&.dig(:ssl_params, :cert) ||
45
+ client_certificate_from_env ||
46
+ client_certificate_from_path
47
+ end
48
+
49
+ private def client_certificate_from_env
50
+ ENV['REDIS_SSL_CLIENT_CERTIFICATE']
45
51
  end
46
52
 
47
- private def client_certificate_path
48
- ENV.fetch(
49
- 'REDIS_SSL_CLIENT_CERTIFICATE_PATH',
50
- File.join(cert_path, 'user.crt'),
51
- )
53
+ private def client_certificate_from_path
54
+ File.read(fetch_key('REDIS_SSL_CLIENT_CERTIFICATE_PATH'))
52
55
  end
53
56
 
54
57
  private def private_key
55
- ENV.fetch(
56
- 'REDIS_SSL_PRIVATE_KEY',
57
- File.read(private_key_path),
58
- )
58
+ provided_private_key ||
59
+ private_key_from_env ||
60
+ private_key_from_path
61
+ end
62
+
63
+ private def provided_private_key
64
+ @provided_options&.dig(:ssl_params, :key)
65
+ end
66
+
67
+ private def private_key_from_env
68
+ ENV['REDIS_SSL_PRIVATE_KEY']
69
+ end
70
+
71
+ private def private_key_from_path
72
+ File.read(fetch_key('REDIS_SSL_PRIVATE_KEY_PATH'))
73
+ end
74
+
75
+ private def certificate_authority
76
+ provided_certificate_authority ||
77
+ certificate_authority_from_path
78
+ end
79
+
80
+ private def provided_certificate_authority
81
+ @provided_options&.dig(:ssl_params, :ca_file)
59
82
  end
60
83
 
61
- private def private_key_path
62
- ENV.fetch(
63
- 'REDIS_SSL_PRIVATE_KEY_PATH',
64
- File.join(cert_path, 'user_private.key'),
65
- )
84
+ private def certificate_authority_from_path
85
+ fetch_key('REDIS_SSL_CERTIFICATE_AUTHORITY_PATH')
66
86
  end
67
87
 
68
- private def certificate_authority_file
69
- ENV.fetch(
70
- 'REDIS_SSL_CERTIFICATE_AUTHORITY_PATH',
71
- File.join(cert_path, 'server_ca.pem'),
72
- )
88
+ private def fetch_key(key)
89
+ ENV.fetch(key) { missing_key(key) }
73
90
  end
74
91
 
75
- private def cert_path
76
- ENV.fetch(
77
- 'REDIS_SSL_CERTIFICATE_PATH',
78
- File.expand_path('../../redis', __dir__),
79
- )
92
+ private def missing_key(key)
93
+ raise InvalidConfiguration, "#{key} is not defined"
80
94
  end
81
95
  end
82
96
  end
@@ -17,13 +17,13 @@ Gem::Specification.new do |spec|
17
17
  end
18
18
  spec.require_paths = ['lib']
19
19
 
20
- spec.add_dependency 'dogstatsd-ruby', '~> 4.4.0'
20
+ spec.add_dependency 'dogstatsd-ruby', '>= 4.4', '< 4.9'
21
21
  spec.add_dependency 'excon', '~> 0.57'
22
- spec.add_dependency 'redis', '~> 4.1.3'
22
+ spec.add_dependency 'redis', '>= 4.1.3', '< 5.0.0'
23
23
 
24
24
  spec.add_development_dependency 'bundler', '~> 2.1.4'
25
25
  spec.add_development_dependency 'guard-rspec', '~> 4.7'
26
- spec.add_development_dependency 'percy-style', '~> 0.6.0'
27
- spec.add_development_dependency 'rake', '~> 12.3'
26
+ spec.add_development_dependency 'percy-style', '~> 0.7.0'
27
+ spec.add_development_dependency 'rake', '~> 13.0'
28
28
  spec.add_development_dependency 'rspec', '~> 3.2'
29
29
  end
@@ -0,0 +1,76 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -e
4
+
5
+ cd "$(dirname "$0")" || exit 1
6
+ CURDIR="$(pwd)"
7
+
8
+ PERCY_COMMON_VERSION="$(grep "VERSION" lib/percy/common/version.rb | awk -F "'" '{print $2}')"
9
+
10
+ echo "Current percy-common version: $PERCY_COMMON_VERSION"
11
+
12
+ if [[ $# -lt 1 ]]; then
13
+ echo "Usage $0 <version>"
14
+ exit 1
15
+ fi
16
+
17
+ rm "$CURDIR/"percy-common*.gem >/dev/null 2>&1 || true
18
+
19
+ delete_existing_version() {
20
+ git tag -d "v$1" || true
21
+ git push origin ":v$1" || true
22
+ # Replace - with .pre. in version string for rubygems compatibility
23
+ GEM_VERSION=${1/-/.pre.}
24
+ gem yank percy-common -v "$GEM_VERSION" || true
25
+ }
26
+
27
+ if [[ $1 =~ ^.*delete$ ]]; then
28
+ shift
29
+ echo "Preparing to delete $1"
30
+ sleep 3
31
+ delete_existing_version "$PERCY_COMMON_VERSION"
32
+ else
33
+ CLEAN=$(
34
+ git diff-index --quiet HEAD --
35
+ echo $?
36
+ )
37
+ if [[ "$CLEAN" == "0" ]]; then
38
+ if [[ $1 == '--force' ]]; then
39
+ shift
40
+ VERSION=$1
41
+ if [[ -n $VERSION ]]; then
42
+ echo "Deleting version $VERSION"
43
+ sleep 1
44
+ delete_existing_version "$VERSION"
45
+ else
46
+ echo "Missing release version"
47
+ exit 1
48
+ fi
49
+ fi
50
+ VERSION=$1
51
+ # Replace - with .pre. in version string for rubygems compatibility
52
+ GEM_VERSION="${VERSION/-/.pre.}"
53
+ if [[ "$GEM_VERSION" == "$VERSION" ]]; then
54
+ echo "Releasing $VERSION"
55
+ else
56
+ echo "Releasing $VERSION as $GEM_VERSION"
57
+ fi
58
+ sleep 1
59
+
60
+ sed -i "" -e "s/$PERCY_COMMON_VERSION/$VERSION/g" "lib/percy/common/version.rb"
61
+ git add "lib/percy/common/version.rb"
62
+ git commit -a -m "Release $VERSION" || true
63
+
64
+ git tag -a "v$VERSION" -m "$1" || true
65
+ git push origin "v$VERSION" || true
66
+
67
+ bundle exec rake build
68
+ gem push "$CURDIR/pkg/percy-common-$GEM_VERSION.gem"
69
+ open "https://github.com/percy/percy-common/releases/new?tag=v$VERSION&title=$VERSION"
70
+ rm "$CURDIR/pkg/percy-common-$GEM_VERSION.gem"
71
+ else
72
+ echo "Please commit your changes and try again"
73
+ exit 1
74
+ fi
75
+ fi
76
+ echo "Done"
metadata CHANGED
@@ -1,29 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: percy-common
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.1
4
+ version: 3.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Perceptual Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-07 00:00:00.000000000 Z
11
+ date: 2020-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dogstatsd-ruby
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '4.4'
20
+ - - "<"
18
21
  - !ruby/object:Gem::Version
19
- version: 4.4.0
22
+ version: '4.9'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '4.4'
30
+ - - "<"
25
31
  - !ruby/object:Gem::Version
26
- version: 4.4.0
32
+ version: '4.9'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: excon
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -42,16 +48,22 @@ dependencies:
42
48
  name: redis
43
49
  requirement: !ruby/object:Gem::Requirement
44
50
  requirements:
45
- - - "~>"
51
+ - - ">="
46
52
  - !ruby/object:Gem::Version
47
53
  version: 4.1.3
54
+ - - "<"
55
+ - !ruby/object:Gem::Version
56
+ version: 5.0.0
48
57
  type: :runtime
49
58
  prerelease: false
50
59
  version_requirements: !ruby/object:Gem::Requirement
51
60
  requirements:
52
- - - "~>"
61
+ - - ">="
53
62
  - !ruby/object:Gem::Version
54
63
  version: 4.1.3
64
+ - - "<"
65
+ - !ruby/object:Gem::Version
66
+ version: 5.0.0
55
67
  - !ruby/object:Gem::Dependency
56
68
  name: bundler
57
69
  requirement: !ruby/object:Gem::Requirement
@@ -86,28 +98,28 @@ dependencies:
86
98
  requirements:
87
99
  - - "~>"
88
100
  - !ruby/object:Gem::Version
89
- version: 0.6.0
101
+ version: 0.7.0
90
102
  type: :development
91
103
  prerelease: false
92
104
  version_requirements: !ruby/object:Gem::Requirement
93
105
  requirements:
94
106
  - - "~>"
95
107
  - !ruby/object:Gem::Version
96
- version: 0.6.0
108
+ version: 0.7.0
97
109
  - !ruby/object:Gem::Dependency
98
110
  name: rake
99
111
  requirement: !ruby/object:Gem::Requirement
100
112
  requirements:
101
113
  - - "~>"
102
114
  - !ruby/object:Gem::Version
103
- version: '12.3'
115
+ version: '13.0'
104
116
  type: :development
105
117
  prerelease: false
106
118
  version_requirements: !ruby/object:Gem::Requirement
107
119
  requirements:
108
120
  - - "~>"
109
121
  - !ruby/object:Gem::Version
110
- version: '12.3'
122
+ version: '13.0'
111
123
  - !ruby/object:Gem::Dependency
112
124
  name: rspec
113
125
  requirement: !ruby/object:Gem::Requirement
@@ -133,6 +145,7 @@ files:
133
145
  - ".gitignore"
134
146
  - ".rspec"
135
147
  - ".rubocop.yml"
148
+ - ".rubocop_todo.yml"
136
149
  - Gemfile
137
150
  - Guardfile
138
151
  - LICENSE
@@ -149,6 +162,7 @@ files:
149
162
  - lib/percy/redis_client.rb
150
163
  - lib/percy/stats.rb
151
164
  - percy-common.gemspec
165
+ - release.sh
152
166
  homepage: ''
153
167
  licenses: []
154
168
  metadata: {}