percy-common 2.1.1 → 3.0.0

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
- SHA1:
3
- metadata.gz: 8c72b6ac18f0d0481edf3be4436cd9d509f01494
4
- data.tar.gz: a117e47adcb706883d4565ddb5c47100adebf926
2
+ SHA256:
3
+ metadata.gz: c0fe4132dddef08590d485a30d755fa43e95bc0cc4569b0f716e25c756c5dca5
4
+ data.tar.gz: 9de9dbc2f26404e03f22175bfc742080df122824d9510197a23a0f55c8ca0c65
5
5
  SHA512:
6
- metadata.gz: 38fa4e30554c706d6d8b77764bab5e0851a9bc6ee126bb64df7a1d2063f58fdfc73142739f7b7476a2eca1e8cdbe4078b00f9791d576626c60661dbb05e5e697
7
- data.tar.gz: 729ee85dd9b7177de77cd5dab68cdfc519b2e7ff8a0628ce58811a0f7b67f3986390153acf4647879d4a69f18aa86411965f6474231e23155b1ab6d835d1bb14
6
+ metadata.gz: 4063a9ab97a6a5e30774733dbe8922dc690b6556f80f6a3c28651043e050043ea5a76b4de1220a2e3f3fa0688968a259fe9eaba7a77f11699fb9a9e5348f68ab
7
+ data.tar.gz: 89cb3605660c98e521e3f08c72be55b3517236ee3702dda10c65d09c35eaa855b5b6715d2e349359c34e8fdb41020139dce834e8a3acb2ff7457e0bfe4e6b641
@@ -0,0 +1,18 @@
1
+ version: 2.1
2
+
3
+ jobs:
4
+ ruby_25:
5
+ docker:
6
+ - image: circleci/ruby:2.5-node-browsers
7
+ steps:
8
+ - checkout
9
+ - run: gem update --system
10
+ - run: gem install bundler
11
+ - run: bundle install
12
+ - run: bundle exec rubocop -D
13
+
14
+ workflows:
15
+ version: 2
16
+ test:
17
+ jobs:
18
+ - ruby_25
data/.rubocop.yml CHANGED
@@ -2,6 +2,10 @@ inherit_gem:
2
2
  percy-style:
3
3
  - default.yml
4
4
 
5
+ inherit_mode:
6
+ merge:
7
+ - Include
8
+
5
9
  RSpec/DescribeClass:
6
10
  Exclude:
7
11
  - spec/percy/logger_spec.rb
@@ -1,5 +1,5 @@
1
1
  module Percy
2
2
  module Common
3
- VERSION = '2.1.1'.freeze
3
+ VERSION = '3.0.0'.freeze
4
4
  end
5
5
  end
data/lib/percy/stats.rb CHANGED
@@ -3,41 +3,58 @@ require 'time'
3
3
 
4
4
  module Percy
5
5
  class Stats < ::Datadog::Statsd
6
- def initialize(host = nil, port = nil, opts = {}, max_buffer_size = 50)
7
- host ||= ENV.fetch('DATADOG_AGENT_HOST', ::Datadog::Statsd::DEFAULT_HOST)
8
- port ||= Integer(ENV.fetch('DATADOG_AGENT_PORT', ::Datadog::Statsd::DEFAULT_PORT))
9
- opts[:tags] ||= []
10
- opts[:tags] << "env:#{ENV['PERCY_ENV'] || 'development'}"
11
- retry_delay = opts[:retry_delay] || 1
12
- retry_count = opts[:retry_count] || 3
13
- retries = 0
14
-
15
- begin
16
- super(host, port, opts, max_buffer_size)
17
- rescue SocketError
18
- host = 'localhost' if retries >= retry_count
19
- sleep retry_delay
20
- retries += 1
21
- retry
22
- end
6
+ DEFAULT_HOST = ENV.fetch(
7
+ 'DATADOG_AGENT_HOST',
8
+ ::Datadog::Statsd::Connection::DEFAULT_HOST,
9
+ )
10
+
11
+ DEFAULT_PORT = Integer(
12
+ ENV.fetch(
13
+ 'DATADOG_AGENT_PORT',
14
+ ::Datadog::Statsd::Connection::DEFAULT_PORT,
15
+ ),
16
+ )
17
+
18
+ DEFAULT_TAGS = %W[
19
+ env:#{ENV.fetch('PERCY_ENV', 'development')}
20
+ ].freeze
21
+
22
+ def initialize(
23
+ host = DEFAULT_HOST,
24
+ port = DEFAULT_PORT,
25
+ tags: DEFAULT_TAGS,
26
+ **kwargs
27
+ )
28
+ super(host, port, tags: tags, **kwargs)
23
29
  end
24
30
 
25
- # Equivalent to stats.time, but without wrapping in blocks and dealing with var scoping issues.
31
+ # Equivalent to stats.time, but without wrapping in blocks and dealing with
32
+ # var scoping issues.
26
33
  #
27
34
  # @example Report the time taken to activate an account.
28
35
  # stats.start_timing
29
36
  # account.activate!
30
37
  # stats.stop_timing('account.activate')
31
38
  def start_timing
32
- @_timing_start = Time.now
39
+ @_timing_start = now
33
40
  true
34
41
  end
35
42
 
36
43
  def stop_timing(stat, options = {})
37
- raise 'no timing started' unless @_timing_start # Programmer mistake, so raise an error.
44
+ # Programmer mistake, so raise an error.
45
+ raise 'no timing started' unless @_timing_start
46
+
38
47
  time_since(stat, @_timing_start, options)
39
48
  @_timing_start = nil
40
49
  true
41
50
  end
51
+
52
+ def time_since(stat, start, opts = {})
53
+ timing(stat, ((now.to_f - start.to_f) * 1000).round, opts)
54
+ end
55
+
56
+ private def now
57
+ Process.clock_gettime(Process::CLOCK_MONOTONIC)
58
+ end
42
59
  end
43
60
  end
data/percy-common.gemspec CHANGED
@@ -16,14 +16,12 @@ Gem::Specification.new do |spec|
16
16
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
17
  spec.require_paths = ['lib']
18
18
 
19
- # Pinned as we rely on `time_since` which was taken out after this version.
20
- spec.add_dependency 'dogstatsd-ruby', '3.2.0'
21
-
19
+ spec.add_dependency 'dogstatsd-ruby', '~> 4.4.0'
22
20
  spec.add_dependency 'excon', '~> 0.57'
23
21
 
24
- spec.add_development_dependency 'bundler', '~> 1.15'
22
+ spec.add_development_dependency 'bundler', '~> 2.0.2'
25
23
  spec.add_development_dependency 'rake', '~> 10.0'
26
24
  spec.add_development_dependency 'rspec', '~> 3.2'
27
25
  spec.add_development_dependency 'guard-rspec', '~> 4.7'
28
- spec.add_development_dependency 'percy-style'
26
+ spec.add_development_dependency 'percy-style', '~> 0.6.0'
29
27
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: percy-common
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Perceptual Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-26 00:00:00.000000000 Z
11
+ date: 2019-07-16 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
18
  - !ruby/object:Gem::Version
19
- version: 3.2.0
19
+ version: 4.4.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '='
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 3.2.0
26
+ version: 4.4.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: excon
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.15'
47
+ version: 2.0.2
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '1.15'
54
+ version: 2.0.2
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -98,16 +98,16 @@ dependencies:
98
98
  name: percy-style
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ">="
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '0'
103
+ version: 0.6.0
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ">="
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '0'
110
+ version: 0.6.0
111
111
  description: ''
112
112
  email:
113
113
  - team@percy.io
@@ -115,10 +115,10 @@ executables: []
115
115
  extensions: []
116
116
  extra_rdoc_files: []
117
117
  files:
118
+ - ".circleci/config.yml"
118
119
  - ".gitignore"
119
120
  - ".rspec"
120
121
  - ".rubocop.yml"
121
- - ".travis.yml"
122
122
  - Gemfile
123
123
  - Guardfile
124
124
  - LICENSE
@@ -153,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
153
  version: '0'
154
154
  requirements: []
155
155
  rubyforge_project:
156
- rubygems_version: 2.6.13
156
+ rubygems_version: 2.7.8
157
157
  signing_key:
158
158
  specification_version: 4
159
159
  summary: Server-side common library for Percy.
data/.travis.yml DELETED
@@ -1,12 +0,0 @@
1
- language: ruby
2
- sudo: false
3
- cache: bundler
4
- rvm:
5
- - 2.4
6
- - 2.5
7
- before_install:
8
- - gem update --system
9
- - gem update bundler
10
- script:
11
- - bundle exec rubocop -D
12
- - bundle exec rspec