percy-cli 1.2.9 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 64b4abeaf29cbbe7f5a90c445b034795fa4a3978
4
- data.tar.gz: d65287197152cbf4d476408895a78b8d62ebcb2f
3
+ metadata.gz: c733c7f086cb54277cdccea9768c4ea00640bab5
4
+ data.tar.gz: 71cb84b3d65b2f57ffb82e9f3aa07c924f4373e3
5
5
  SHA512:
6
- metadata.gz: c6f264c90ad78f351975f261ab98e68e4257e7277a0e9ea1e4637f5d3e2bfc29d8f3c5ee4ac797434b9c9a4f5f2736aa26df68983ef1e9479d7113649abcb4d9
7
- data.tar.gz: faeceecd9a612cfeb66a8d88dc1573d4125c322260c54fa9254d809c9d005aa7b20508a5878582b5d72fee1dfd9bd9b88dc35b030f3e74aace1805cd0a74a64b
6
+ metadata.gz: cf84886f1b1f8fa4cb7ba6151dbd0e57ec223a89868fd9a97ebb7afc0bfaaba5f4b816c2b185578849c60536af95d03baad280241b13f026a4f85e33f40d2780
7
+ data.tar.gz: ff52d00ba138e5de32e505541dfd260fef882a65b0dc6eae954eee66c655f265fe5789a6accfa02a0e34d397d6d3fb0ee7a9f7341d83e9f27c4d91e23060d32b
@@ -1,113 +1,10 @@
1
- require: rubocop-rspec
2
- inherit_from: .rubocop_todo.yml
3
- AllCops:
4
- Include:
5
- - Rakefile
6
- - lib/**/*.rake
7
- Exclude:
8
- - 'vendor/**/*'
9
- - '*.gemspec'
10
-
11
- Layout/AlignParameters:
12
- EnforcedStyle: with_fixed_indentation
13
-
14
- Layout/CaseIndentation:
15
- EnforcedStyle: end
16
-
17
- Layout/IndentArray:
18
- EnforcedStyle: consistent
19
-
20
- Layout/MultilineMethodCallIndentation:
21
- EnforcedStyle: indented
22
-
23
- Layout/MultilineOperationIndentation:
24
- EnforcedStyle: indented
25
-
26
- Layout/SpaceInsideHashLiteralBraces:
27
- EnforcedStyle: no_space
28
-
29
- Lint/EndAlignment:
30
- EnforcedStyleAlignWith: variable
31
-
32
- Lint/RescueException:
33
- Exclude:
34
- - 'lib/tasks/*.rake'
35
-
36
- Metrics/AbcSize:
37
- Max: 100
38
-
39
- Metrics/LineLength:
40
- Max: 100
41
-
42
- Metrics/MethodLength:
43
- Max: 80
44
-
45
- Style/Documentation:
46
- Enabled: false
47
-
48
- Metrics/ClassLength:
49
- Enabled: false
50
-
51
- Metrics/ModuleLength:
52
- Enabled: false
53
-
54
- Metrics/ParameterLists:
55
- Enabled: false
1
+ inherit_gem:
2
+ percy-style:
3
+ - default.yml
56
4
 
57
- Metrics/BlockLength:
58
- Enabled: false
59
-
60
- Style/DoubleNegation:
61
- Enabled: false
62
-
63
- Style/FileName:
64
- Exclude: ['Gemfile', 'Guardfile']
65
-
66
- Style/FormatStringToken:
67
- EnforcedStyle: template
68
-
69
- # Disable Style/NumericLiterals so numbers don't need underscores
70
- Style/NumericLiterals:
71
- Enabled: false
72
-
73
- Style/NumericPredicate:
74
- EnforcedStyle: comparison
75
-
76
- Style/RedundantBegin:
77
- Enabled: false
5
+ AllCops:
6
+ TargetRubyVersion: 2.1
78
7
 
79
- Style/RegexpLiteral:
80
- EnforcedStyle: slashes
81
- AllowInnerSlashes: true
8
+ Style/GlobalVars:
82
9
  Exclude:
83
- - 'Guardfile'
84
-
85
- Style/SymbolArray:
86
- EnforcedStyle: brackets
87
-
88
- Style/TrailingCommaInArguments:
89
- EnforcedStyleForMultiline: consistent_comma
90
-
91
- Style/TrailingCommaInLiteral:
92
- EnforcedStyleForMultiline: consistent_comma
93
-
94
- RSpec/DescribedClass:
95
- EnforcedStyle: explicit
96
-
97
- RSpec/ExampleLength:
98
- Max: 15
99
-
100
- RSpec/HookArgument:
101
- EnforcedStyle: each
102
-
103
- RSpec/ImplicitExpect:
104
- EnforcedStyle: should
105
-
106
- RSpec/MessageSpies:
107
- EnforcedStyle: receive
108
-
109
- RSpec/NotToNot:
110
- EnforcedStyle: to_not
111
-
112
- RSpec/VerifiedDoubles:
113
- Enabled: false
10
+ - 'lib/percy/cli.rb'
data/Gemfile CHANGED
@@ -3,11 +3,6 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in percy-cli.gemspec
4
4
  gemspec
5
5
 
6
- group :test do
7
- gem 'rubocop'
8
- gem 'rubocop-rspec'
9
- end
10
-
11
6
  group :test, :development do
12
7
  gem 'pry'
13
8
  end
@@ -0,0 +1,22 @@
1
+ # Test on Ruby 2.2 and 2.1
2
+ environment:
3
+ matrix:
4
+ - RUBY_VERSION: 22
5
+ - RUBY_VERSION: 21
6
+
7
+ # Install scripts. (runs after repo cloning)
8
+ install:
9
+ - set PATH=C:\Ruby%RUBY_VERSION%\bin;%PATH%
10
+ - bundle install
11
+
12
+ before_test:
13
+ - ruby -v
14
+ - gem -v
15
+ - bundle -v
16
+
17
+ # Post-install test scripts.
18
+ test_script:
19
+ - bundle exec rspec
20
+
21
+ build:
22
+ off
@@ -15,7 +15,7 @@ module Percy
15
15
  end
16
16
 
17
17
  def say_error(*args)
18
- STDERR.puts *args
18
+ STDERR.puts(*args)
19
19
  end
20
20
 
21
21
  def run
@@ -46,6 +46,10 @@ module Percy
46
46
  '--snapshots_regex REGEX',
47
47
  String,
48
48
  'Regular expression for matching the files to snapshot. Defaults to: "\.(html|htm)$"'
49
+ c.option \
50
+ '--ignore_regex REGEX',
51
+ String,
52
+ 'Regular expression for matching the files NOT to snapshot. Default is nil.'
49
53
  c.option \
50
54
  '--widths CSV',
51
55
  String,
@@ -1,6 +1,6 @@
1
1
  require 'find'
2
2
  require 'digest'
3
- require 'uri'
3
+ require 'addressable/uri'
4
4
  require 'thread/pool'
5
5
 
6
6
  Thread.abort_on_exception = true
@@ -33,6 +33,7 @@ module Percy
33
33
  baseurl = options[:baseurl] || '/'
34
34
  enable_javascript = !!options[:enable_javascript]
35
35
  include_all = !!options[:include_all]
36
+ ignore_regex = options[:ignore_regex]
36
37
  widths = options[:widths].map { |w| Integer(w) }
37
38
  raise ArgumentError, 'baseurl must start with /' if baseurl[0] != '/'
38
39
 
@@ -40,7 +41,8 @@ module Percy
40
41
 
41
42
  # Find all the static files in the given root directory.
42
43
  root_paths = _find_root_paths(root_dir, snapshots_regex: options[:snapshots_regex])
43
- resource_paths = _find_resource_paths(root_dir, include_all: include_all)
44
+ opts = {include_all: include_all, ignore_regex: ignore_regex}
45
+ resource_paths = _find_resource_paths(root_dir, opts)
44
46
  root_resources = _list_resources(root_paths, base_resource_options.merge(is_root: true))
45
47
  build_resources = _list_resources(resource_paths, base_resource_options)
46
48
  all_resources = root_resources + build_resources
@@ -127,7 +129,9 @@ module Percy
127
129
  end
128
130
 
129
131
  def _find_root_paths(dir_path, options = {})
130
- _find_files(dir_path).select { |path| _include_root_path?(path, options) }
132
+ _find_files(dir_path)
133
+ .select { |path| _include_root_path?(path, options) }
134
+ .reject { |path| _ignore_resource_path?(path, options) }
131
135
  end
132
136
 
133
137
  def _find_resource_paths(dir_path, options = {})
@@ -145,7 +149,7 @@ module Percy
145
149
  paths.each do |path|
146
150
  sha = Digest::SHA256.hexdigest(File.read(path))
147
151
  next if File.size(path) > MAX_FILESIZE_BYTES
148
- resource_url = URI.escape(File.join(baseurl, path.sub(strip_prefix, '')))
152
+ resource_url = Addressable::URI.escape(File.join(baseurl, path.sub(strip_prefix, '')))
149
153
 
150
154
  resources << Percy::Client::Resource.new(
151
155
  resource_url, sha: sha, is_root: options[:is_root], path: path,
@@ -212,6 +216,16 @@ module Percy
212
216
  STATIC_RESOURCE_EXTENSIONS.include?(File.extname(path))
213
217
  end
214
218
 
219
+ def _ignore_resource_path?(path, options)
220
+ return false unless options[:ignore_regex]
221
+
222
+ begin
223
+ path.match(options[:ignore_regex])
224
+ rescue StandardError
225
+ false
226
+ end
227
+ end
228
+
215
229
  def _include_root_path?(path, options)
216
230
  # Skip git files.
217
231
  return false if path =~ /\/\.git\//
@@ -1,5 +1,5 @@
1
1
  module Percy
2
2
  class Cli
3
- VERSION = '1.2.9'.freeze
3
+ VERSION = '1.3.0'.freeze
4
4
  end
5
5
  end
@@ -22,9 +22,11 @@ Gem::Specification.new do |spec|
22
22
  spec.add_dependency 'commander', '~> 4.3'
23
23
  spec.add_dependency 'percy-client', '~> 1.12'
24
24
  spec.add_dependency 'thread', '~> 0.2'
25
+ spec.add_dependency 'addressable', '~> 2'
25
26
 
26
27
  spec.add_development_dependency 'bundler', '~> 1.7'
27
28
  spec.add_development_dependency 'rake', '~> 10.0'
28
29
  spec.add_development_dependency 'rspec', '~> 3'
29
30
  spec.add_development_dependency 'webmock', '~> 1'
31
+ spec.add_development_dependency 'percy-style'
30
32
  end
@@ -78,17 +78,47 @@ RSpec.describe Percy::Cli::SnapshotRunner do
78
78
  it 'returns only the HTML files in the directory' do
79
79
  paths = runner._find_root_paths root_dir
80
80
 
81
- expect(paths).to match_array(
82
- [
83
- File.join(root_dir, 'index.html'),
84
- File.join(root_dir, 'subdir/test.html'),
85
- # Make sure file symlinks are followed.
86
- File.join(root_dir, 'subdir/test_symlink.html'),
81
+ expected_results = [
82
+ File.join(root_dir, 'index.html'),
83
+ File.join(root_dir, 'ignore.html'),
84
+ File.join(root_dir, 'skip.html'),
85
+ File.join(root_dir, 'subdir/test.html'),
86
+ # Make sure file symlinks are followed.
87
+ File.join(root_dir, 'subdir/test_symlink.html'),
88
+ ]
89
+
90
+ # Symlinked folders don't work out-of-the-box upon git clone on windows
91
+ unless Gem.win_platform?
92
+ expected_results += [
87
93
  # Make sure directory symlinks are followed.
88
94
  File.join(root_dir, 'subdir_symlink/test.html'),
89
95
  File.join(root_dir, 'subdir_symlink/test_symlink.html'),
90
- ],
91
- )
96
+ ]
97
+ end
98
+
99
+ expect(paths).to match_array(expected_results)
100
+ end
101
+
102
+ it 'skips files passed into the ignore_regex option' do
103
+ paths = runner._find_root_paths root_dir, ignore_regex: 'skip|ignore'
104
+
105
+ expected_results = [
106
+ File.join(root_dir, 'index.html'),
107
+ File.join(root_dir, 'subdir/test.html'),
108
+ # Make sure file symlinks are followed.
109
+ File.join(root_dir, 'subdir/test_symlink.html'),
110
+ ]
111
+
112
+ # Symlinked folders don't work out-of-the-box upon git clone on windows
113
+ unless Gem.win_platform?
114
+ expected_results += [
115
+ # Make sure directory symlinks are followed.
116
+ File.join(root_dir, 'subdir_symlink/test.html'),
117
+ File.join(root_dir, 'subdir_symlink/test_symlink.html'),
118
+ ]
119
+ end
120
+
121
+ expect(paths).to match_array(expected_results)
92
122
  end
93
123
  end
94
124
 
@@ -96,20 +126,26 @@ RSpec.describe Percy::Cli::SnapshotRunner do
96
126
  it 'returns only the related static files in the directory' do
97
127
  paths = runner._find_resource_paths root_dir
98
128
 
99
- expect(paths).to match_array(
100
- [
101
- File.join(root_dir, 'css/base.css'),
102
- File.join(root_dir, 'css/test with spaces.css'),
103
- File.join(root_dir, 'images/jellybeans.png'),
104
- File.join(root_dir, 'images/large-file-skipped.png'),
105
- # Make sure file symlinks are followed.
106
- File.join(root_dir, 'images/jellybeans-symlink.png'),
129
+ expected_results = [
130
+ File.join(root_dir, 'css/base.css'),
131
+ File.join(root_dir, 'css/test with spaces.css'),
132
+ File.join(root_dir, 'images/jellybeans.png'),
133
+ File.join(root_dir, 'images/large-file-skipped.png'),
134
+ # Make sure file symlinks are followed.
135
+ File.join(root_dir, 'images/jellybeans-symlink.png'),
136
+ ]
137
+
138
+ # Symlinked folders don't work out-of-the-box upon git clone on windows
139
+ unless Gem.win_platform?
140
+ expected_results += [
107
141
  # Make sure directory symlinks are followed.
108
142
  File.join(root_dir, 'images_symlink/jellybeans.png'),
109
143
  File.join(root_dir, 'images_symlink/large-file-skipped.png'),
110
144
  File.join(root_dir, 'images_symlink/jellybeans-symlink.png'),
111
- ],
112
- )
145
+ ]
146
+ end
147
+
148
+ expect(paths).to match_array(expected_results)
113
149
  end
114
150
  end
115
151
 
@@ -0,0 +1,4 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <h1>Hello World!</h1>
4
+ </html>
@@ -0,0 +1 @@
1
+ spec/percy/cli/testdata/images/jellybeans.png
@@ -0,0 +1 @@
1
+ spec/percy/cli/testdata/images/
@@ -0,0 +1,4 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <h1>Hello World!</h1>
4
+ </html>
@@ -0,0 +1 @@
1
+ spec/percy/cli/testdata/subdir/test.html
@@ -0,0 +1 @@
1
+ spec/percy/cli/testdata/subdir
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: percy-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.9
4
+ version: 1.3.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: 2017-06-27 00:00:00.000000000 Z
11
+ date: 2018-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commander
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0.2'
55
+ - !ruby/object:Gem::Dependency
56
+ name: addressable
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: bundler
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -108,6 +122,20 @@ dependencies:
108
122
  - - "~>"
109
123
  - !ruby/object:Gem::Version
110
124
  version: '1'
125
+ - !ruby/object:Gem::Dependency
126
+ name: percy-style
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
111
139
  description: ''
112
140
  email:
113
141
  - team@percy.io
@@ -119,13 +147,13 @@ files:
119
147
  - ".gitignore"
120
148
  - ".rspec"
121
149
  - ".rubocop.yml"
122
- - ".rubocop_todo.yml"
123
150
  - ".travis.yml"
124
151
  - Gemfile
125
152
  - LICENSE
126
153
  - README.md
127
154
  - RELEASING.md
128
155
  - Rakefile
156
+ - appveyor.yml
129
157
  - bin/percy
130
158
  - lib/percy/cli.rb
131
159
  - lib/percy/cli/snapshot_runner.rb
@@ -135,12 +163,16 @@ files:
135
163
  - spec/percy/cli/testdata/css/base.css
136
164
  - spec/percy/cli/testdata/css/test with spaces.css
137
165
  - spec/percy/cli/testdata/css/unrelated-no-extension
166
+ - spec/percy/cli/testdata/ignore.html
138
167
  - spec/percy/cli/testdata/images/jellybeans-symlink.png
139
168
  - spec/percy/cli/testdata/images/jellybeans.png
140
169
  - spec/percy/cli/testdata/images/large-file-skipped.png
170
+ - spec/percy/cli/testdata/images_symlink
141
171
  - spec/percy/cli/testdata/index.html
172
+ - spec/percy/cli/testdata/skip.html
142
173
  - spec/percy/cli/testdata/subdir/test.html
143
174
  - spec/percy/cli/testdata/subdir/test_symlink.html
175
+ - spec/percy/cli/testdata/subdir_symlink
144
176
  - spec/spec_helper.rb
145
177
  homepage: ''
146
178
  licenses:
@@ -162,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
162
194
  version: '0'
163
195
  requirements: []
164
196
  rubyforge_project:
165
- rubygems_version: 2.4.5.2
197
+ rubygems_version: 2.6.13
166
198
  signing_key:
167
199
  specification_version: 4
168
200
  summary: Percy command-line interface
@@ -171,10 +203,14 @@ test_files:
171
203
  - spec/percy/cli/testdata/css/base.css
172
204
  - spec/percy/cli/testdata/css/test with spaces.css
173
205
  - spec/percy/cli/testdata/css/unrelated-no-extension
206
+ - spec/percy/cli/testdata/ignore.html
174
207
  - spec/percy/cli/testdata/images/jellybeans-symlink.png
175
208
  - spec/percy/cli/testdata/images/jellybeans.png
176
209
  - spec/percy/cli/testdata/images/large-file-skipped.png
210
+ - spec/percy/cli/testdata/images_symlink
177
211
  - spec/percy/cli/testdata/index.html
212
+ - spec/percy/cli/testdata/skip.html
178
213
  - spec/percy/cli/testdata/subdir/test.html
179
214
  - spec/percy/cli/testdata/subdir/test_symlink.html
215
+ - spec/percy/cli/testdata/subdir_symlink
180
216
  - spec/spec_helper.rb
@@ -1,63 +0,0 @@
1
- # This configuration was generated by
2
- # `rubocop --auto-gen-config`
3
- # on 2017-02-09 21:30:53 -0800 using RuboCop version 0.47.1.
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
- Lint/AmbiguousOperator:
11
- Exclude:
12
- - 'lib/percy/cli.rb'
13
-
14
- # Offense count: 4
15
- Metrics/AbcSize:
16
- Max: 81
17
-
18
- # Offense count: 4
19
- # Configuration parameters: CountComments, ExcludedMethods.
20
- Metrics/BlockLength:
21
- Max: 139
22
-
23
- # Offense count: 1
24
- Metrics/CyclomaticComplexity:
25
- Max: 12
26
-
27
- # Offense count: 5
28
- # Configuration parameters: CountComments.
29
- Metrics/MethodLength:
30
- Max: 61
31
-
32
- # Offense count: 1
33
- # Configuration parameters: CountComments.
34
- Metrics/ModuleLength:
35
- Max: 159
36
-
37
- # Offense count: 1
38
- Metrics/PerceivedComplexity:
39
- Max: 12
40
-
41
- # Offense count: 6
42
- # Configuration parameters: Max.
43
- RSpec/ExampleLength:
44
- Exclude:
45
- - 'spec/percy/cli/snapshot_spec.rb'
46
-
47
- # Offense count: 11
48
- RSpec/MultipleExpectations:
49
- Max: 6
50
-
51
- # Offense count: 1
52
- # Configuration parameters: AllowedVariables.
53
- Style/GlobalVars:
54
- Exclude:
55
- - 'lib/percy/cli.rb'
56
-
57
- # Offense count: 2
58
- # Cop supports --auto-correct.
59
- # Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes.
60
- # SupportedStyles: slashes, percent_r, mixed
61
- Style/RegexpLiteral:
62
- Exclude:
63
- - 'lib/percy/cli/snapshot.rb'
@@ -1 +0,0 @@
1
- <!DOCTYPE html><html>Hello World!</html>