percy-common 2.0.0 → 3.0.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
- SHA1:
3
- metadata.gz: ff0436bf3b67e3b1ba96ceef1acb452769389899
4
- data.tar.gz: 9f89386fbf9f6e0b64b6246f09700d08af9f3e17
2
+ SHA256:
3
+ metadata.gz: 9fd27d7a6c0fa5188832abb43534aef2681d8dae719b823dbed82bdbd2c40f85
4
+ data.tar.gz: '08d2f567ecf0ef5b70772f9b5080d48dea45461ace3245fb729f0c00f8e4c028'
5
5
  SHA512:
6
- metadata.gz: 07a215cba17815974cf1ef9d9b8e577a5739e7d47c8d3cd652bc1563cbc82dfb17cecbe79ffcd01d6766f6ba199de7231157d8f35b320e75fc075f0aa65ee91d
7
- data.tar.gz: 6030828cb677b3ba831d8626a5045f859d95c537b72cee5531c684eba0679e388d3a9231af649098112829c8f4edf64d173b5a7361a4ac6d020a4a3669d84752
6
+ metadata.gz: a6b81c030ef1251a4440508ad153fb567a738f0a84c98ec922db41fcc24c628c7a9d4c67372f03973fb169015158f1639b80a9919cd94e6c295106287006c3f7
7
+ data.tar.gz: 4b4f7eb6f01b10fb3625696c672cd5b45c498a5c975dd27b52d5258c60730f6326d25fc9057c733d01ea4aaeeed2787ef641d11182f64f10581ca75e9695c779
@@ -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
@@ -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.0.0'.freeze
3
+ VERSION = '3.0.2'.freeze
4
4
  end
5
5
  end
@@ -2,7 +2,7 @@ require 'logger'
2
2
 
3
3
  module Percy
4
4
  def self.logger
5
- @logger if defined?(@logger)
5
+ return @logger if defined?(@logger)
6
6
  @logger ||= Logger.new(STDOUT)
7
7
  @logger.level = Logger::INFO if ENV['PERCY_ENV'] == 'production'
8
8
  @logger.formatter = proc do |severity, _datetime, _progname, msg|
@@ -3,30 +3,74 @@ 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
- super(host, port, opts, max_buffer_size)
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)
12
29
  end
13
30
 
14
- # 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.
15
33
  #
16
34
  # @example Report the time taken to activate an account.
17
35
  # stats.start_timing
18
36
  # account.activate!
19
37
  # stats.stop_timing('account.activate')
20
38
  def start_timing
21
- @_timing_start = Time.now
39
+ @_timing_start = now
22
40
  true
23
41
  end
24
42
 
25
43
  def stop_timing(stat, options = {})
26
- raise 'no timing started' unless @_timing_start # Programmer mistake, so raise an error.
27
- time_since(stat, @_timing_start, options)
44
+ # Programmer mistake, so raise an error.
45
+ raise 'no timing started' unless @_timing_start
46
+
47
+ time_since_monotonic(stat, @_timing_start, options)
28
48
  @_timing_start = nil
29
49
  true
30
50
  end
51
+
52
+ # dogstatsd uses a monotonic (linearly increasing) clock to calculate time
53
+ # intervals, so this should be used where necessary. However, it's not
54
+ # possible to compare monotonic time values with fixed times, so both are
55
+ # available.
56
+ def time_since_monotonic(stat, start, opts = {})
57
+ unless start.instance_of? Float
58
+ raise ArgumentError, 'start value must be Float'
59
+ end
60
+
61
+ timing(stat, ((now.to_f - start.to_f) * 1000).round, opts)
62
+ end
63
+
64
+ def time_since(stat, start, opts = {})
65
+ unless start.instance_of? Time
66
+ raise ArgumentError, 'start value must be Time'
67
+ end
68
+
69
+ timing(stat, ((Time.now.to_f - start.to_f) * 1000).round, opts)
70
+ end
71
+
72
+ private def now
73
+ Process.clock_gettime(Process::CLOCK_MONOTONIC)
74
+ end
31
75
  end
32
76
  end
@@ -16,12 +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
- spec.add_dependency 'dogstatsd-ruby', '~> 3.1'
19
+ spec.add_dependency 'dogstatsd-ruby', '~> 4.4.0'
20
20
  spec.add_dependency 'excon', '~> 0.57'
21
21
 
22
- spec.add_development_dependency 'bundler', '~> 1.15'
23
- spec.add_development_dependency 'rake', '~> 10.0'
22
+ spec.add_development_dependency 'bundler', '~> 2.0.2'
23
+ spec.add_development_dependency 'rake', '~> 12.3'
24
24
  spec.add_development_dependency 'rspec', '~> 3.2'
25
25
  spec.add_development_dependency 'guard-rspec', '~> 4.7'
26
- spec.add_development_dependency 'percy-style'
26
+ spec.add_development_dependency 'percy-style', '~> 0.6.0'
27
27
  end
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: 2.0.0
4
+ version: 3.0.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: 2017-12-13 00:00:00.000000000 Z
11
+ date: 2019-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dogstatsd-ruby
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '3.1'
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.1'
26
+ version: 4.4.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: excon
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,28 +44,28 @@ 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
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '10.0'
61
+ version: '12.3'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '10.0'
68
+ version: '12.3'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  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
@@ -152,8 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
152
  - !ruby/object:Gem::Version
153
153
  version: '0'
154
154
  requirements: []
155
- rubyforge_project:
156
- rubygems_version: 2.6.13
155
+ rubygems_version: 3.0.4
157
156
  signing_key:
158
157
  specification_version: 4
159
158
  summary: Server-side common library for Percy.
@@ -1,11 +0,0 @@
1
- language: ruby
2
- sudo: false
3
- cache: bundler
4
- rvm:
5
- - 2.4
6
- - ruby-head
7
- before_install:
8
- - gem update bundler
9
- script:
10
- - bundle exec rubocop -D
11
- - bundle exec rspec