percy-common 3.1.0 → 3.1.2

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: fe94763bb303e12d788d293e1b2a1947fccfb61a1334a04c71179f99590ab639
4
- data.tar.gz: 113a9533d5286c9753d21df7d631b2f6c64601680cd698db5600503d9e638c23
3
+ metadata.gz: e5f341799d420673ccbf3e89c87071851ba6de8f8511f3db298caf0d301e21b2
4
+ data.tar.gz: 9f9ef8f3f3f488ef54fceff7c492e52294e75e66a892a3816a1699c09ac2c48b
5
5
  SHA512:
6
- metadata.gz: 6ea47390164289c6a3402ce8f108f19ba698a69d1b2fb50dcaa58d12961ab10c18a74e1d54ed47e268a827b9851986136766ab436397b5bf475d690631a65f09
7
- data.tar.gz: 1ae7c46e24ff481bb6d986d0cdfdca18450c27b350cb89d0938cd54101f4fc8f8edcd518220b64339edbb14b9846beb7390bffab59f2c94100350614ca736f24
6
+ metadata.gz: 7448ce54194d6faf1a413f667411f1ae8b37979d1f804aa5cfac36e4dbf9fe4208e40fc55c39b142672e39403b7a61d6334d39138c7c510d8b403f62dfbc84d2
7
+ data.tar.gz: d3a713c1ef85413520241bcb5f93db074eeacfe14e3f60c702cf46e4487d0e781c28dedcc8a47b96f1ac39e5957f823a600d348a83d2ac4c3247fd6d6283fbf6
@@ -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.0'.freeze
3
+ VERSION = '3.1.2'.freeze
4
4
  end
5
5
  end
@@ -4,17 +4,15 @@ 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 = options
12
- @client = ::Redis.new(
13
- options.merge(
14
- ssl: ssl_enabled?,
15
- ssl_params: ssl_params,
16
- ),
17
- )
12
+ def initialize(given_options = {})
13
+ @provided_options = given_options
14
+ @options = ssl_options.merge(given_options)
15
+ @client = ::Redis.new(options)
18
16
  end
19
17
 
20
18
  private def ssl_enabled?
@@ -22,59 +20,77 @@ module Percy
22
20
  end
23
21
 
24
22
  private def provided_url
25
- options.dig(:url)
23
+ @provided_options&.dig(:url)
24
+ end
25
+
26
+ private def ssl_options
27
+ {
28
+ ssl: ssl_enabled?,
29
+ ssl_params: ssl_params,
30
+ }
26
31
  end
27
32
 
28
33
  private def ssl_params
29
34
  return {} unless ssl_enabled?
30
35
 
31
36
  {
32
- ca_file: certificate_authority_file,
37
+ ca_file: certificate_authority,
33
38
  cert: OpenSSL::X509::Certificate.new(client_certificate),
34
39
  key: OpenSSL::PKey::RSA.new(private_key),
35
40
  }
36
41
  end
37
42
 
38
43
  private def client_certificate
39
- ENV.fetch(
40
- 'REDIS_SSL_CLIENT_CERTIFICATE',
41
- File.read(client_certificate_path),
42
- )
44
+ @provided_options&.dig(:ssl_params, :cert) ||
45
+ client_certificate_from_env ||
46
+ client_certificate_from_path
43
47
  end
44
48
 
45
- private def client_certificate_path
46
- ENV.fetch(
47
- 'REDIS_SSL_CLIENT_CERTIFICATE_PATH',
48
- File.join(cert_path, 'user.crt'),
49
- )
49
+ private def client_certificate_from_env
50
+ ENV['REDIS_SSL_CLIENT_CERTIFICATE']
51
+ end
52
+
53
+ private def client_certificate_from_path
54
+ File.read(fetch_key('REDIS_SSL_CLIENT_CERTIFICATE_PATH'))
50
55
  end
51
56
 
52
57
  private def private_key
53
- ENV.fetch(
54
- 'REDIS_SSL_PRIVATE_KEY',
55
- File.read(private_key_path),
56
- )
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)
57
82
  end
58
83
 
59
- private def private_key_path
60
- ENV.fetch(
61
- 'REDIS_SSL_PRIVATE_KEY_PATH',
62
- File.join(cert_path, 'user_private.key'),
63
- )
84
+ private def certificate_authority_from_path
85
+ fetch_key('REDIS_SSL_CERTIFICATE_AUTHORITY_PATH')
64
86
  end
65
87
 
66
- private def certificate_authority_file
67
- ENV.fetch(
68
- 'REDIS_SSL_CERTIFICATE_AUTHORITY_PATH',
69
- File.join(cert_path, 'server_ca.pem'),
70
- )
88
+ private def fetch_key(key)
89
+ ENV.fetch(key) { missing_key(key) }
71
90
  end
72
91
 
73
- private def cert_path
74
- ENV.fetch(
75
- 'REDIS_SSL_CERTIFICATE_PATH',
76
- File.expand_path('../../redis', __dir__),
77
- )
92
+ private def missing_key(key)
93
+ raise InvalidConfiguration, "#{key} is not defined"
78
94
  end
79
95
  end
80
96
  end
@@ -19,11 +19,11 @@ Gem::Specification.new do |spec|
19
19
 
20
20
  spec.add_dependency 'dogstatsd-ruby', '~> 4.4.0'
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'
26
+ spec.add_development_dependency 'percy-style', '~> 0.7.0'
27
27
  spec.add_development_dependency 'rake', '~> 12.3'
28
28
  spec.add_development_dependency 'rspec', '~> 3.2'
29
29
  end
@@ -0,0 +1,67 @@
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
+ gem yank percy-common -v "$1" || true
23
+ }
24
+
25
+ if [[ $1 =~ ^.*delete$ ]]; then
26
+ shift
27
+ echo "Preparing to delete $1"
28
+ sleep 3
29
+ delete_existing_version "$PERCY_COMMON_VERSION"
30
+ else
31
+ CLEAN=$(
32
+ git diff-index --quiet HEAD --
33
+ echo $?
34
+ )
35
+ if [[ "$CLEAN" == "0" ]]; then
36
+ if [[ $1 == '--force' ]]; then
37
+ shift
38
+ if [[ -n $1 ]]; then
39
+ echo "Deleting version $1"
40
+ sleep 1
41
+ delete_existing_version "$1"
42
+ else
43
+ echo "Missing release version"
44
+ exit 1
45
+ fi
46
+ fi
47
+ VERSION=$1
48
+ echo "Releasing $VERSION"
49
+ sleep 1
50
+
51
+ sed -i "" -e "s/$PERCY_COMMON_VERSION/$VERSION/g" "lib/percy/common/version.rb"
52
+ git add "lib/percy/common/version.rb"
53
+ git commit -a -m "Release $VERSION" || true
54
+
55
+ git tag -a "v$VERSION" -m "$1" || true
56
+ git push origin "v$VERSION" || true
57
+
58
+ bundle exec rake build
59
+ gem push "$CURDIR/pkg/percy-common-"*.gem
60
+ open "https://github.com/percy/percy-common/releases/new?tag=v$VERSION&title=$VERSION"
61
+ rm "$CURDIR/pkg/percy-common-"*.gem
62
+ else
63
+ echo "Please commit your changes and try again"
64
+ exit 1
65
+ fi
66
+ fi
67
+ echo "Done"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: percy-common
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.1.2
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-04-28 00:00:00.000000000 Z
11
+ date: 2020-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dogstatsd-ruby
@@ -42,16 +42,22 @@ dependencies:
42
42
  name: redis
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: 4.1.3
48
+ - - "<"
49
+ - !ruby/object:Gem::Version
50
+ version: 5.0.0
48
51
  type: :runtime
49
52
  prerelease: false
50
53
  version_requirements: !ruby/object:Gem::Requirement
51
54
  requirements:
52
- - - "~>"
55
+ - - ">="
53
56
  - !ruby/object:Gem::Version
54
57
  version: 4.1.3
58
+ - - "<"
59
+ - !ruby/object:Gem::Version
60
+ version: 5.0.0
55
61
  - !ruby/object:Gem::Dependency
56
62
  name: bundler
57
63
  requirement: !ruby/object:Gem::Requirement
@@ -86,14 +92,14 @@ dependencies:
86
92
  requirements:
87
93
  - - "~>"
88
94
  - !ruby/object:Gem::Version
89
- version: 0.6.0
95
+ version: 0.7.0
90
96
  type: :development
91
97
  prerelease: false
92
98
  version_requirements: !ruby/object:Gem::Requirement
93
99
  requirements:
94
100
  - - "~>"
95
101
  - !ruby/object:Gem::Version
96
- version: 0.6.0
102
+ version: 0.7.0
97
103
  - !ruby/object:Gem::Dependency
98
104
  name: rake
99
105
  requirement: !ruby/object:Gem::Requirement
@@ -133,6 +139,7 @@ files:
133
139
  - ".gitignore"
134
140
  - ".rspec"
135
141
  - ".rubocop.yml"
142
+ - ".rubocop_todo.yml"
136
143
  - Gemfile
137
144
  - Guardfile
138
145
  - LICENSE
@@ -149,6 +156,7 @@ files:
149
156
  - lib/percy/redis_client.rb
150
157
  - lib/percy/stats.rb
151
158
  - percy-common.gemspec
159
+ - release.sh
152
160
  homepage: ''
153
161
  licenses: []
154
162
  metadata: {}