cucumber-create-meta 2.0.1 → 4.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
2
  SHA256:
3
- metadata.gz: eb02c92607f075dd2131ad7f6e564e11d76cb35d895dc178d20853345a12e39f
4
- data.tar.gz: db20d3ac9d17165204c687fe9cf733ce639510fc0360f57b0a870b9aee02cf47
3
+ metadata.gz: 9c0d4c7da171c38558ed7c0809aa059da8161aeeab9fc0f2a788f757712fc953
4
+ data.tar.gz: 997e930fe502d8a6f58ab7e8489b4b677b077a8f123d4748c40971ac14a235a5
5
5
  SHA512:
6
- metadata.gz: 81f25445789ac4c100cdb7678080a08f2d4a2370632e3b864e4602e05d3aecebd963a74a9d8b4a4f18fdcce5f49bf6447b1cfb4845118294526ac0af237abc17
7
- data.tar.gz: 52c0ce5a5d28b332376cf1eef36ed004f0408978f99d4609bb3e55f3ad6243c9ccfa6801023104d9cd2bcfea9f56d39dd4afd2d28182f4b65937678f20f45450
6
+ metadata.gz: 2a7eabe5cbfcae7db34f143aec073c0341f91e5e09266ad0b417e0419f10ef5daf9ddc1cedec8dabd12976d7f9b24adff217c5b6226511eac758e30aca880463
7
+ data.tar.gz: 94c175d39941c886a7e8322a90f618747a5fffb148c06a3523034c0ff676a377efbd049f33fa7094270308690e9ec099c65c4aee180940262962ca5a92aa2b9c
@@ -1,30 +1,31 @@
1
+ require 'uri'
1
2
  require 'cucumber/messages'
2
3
  require 'sys/uname'
3
4
  require 'json'
4
5
 
5
6
  module Cucumber
6
7
  module CreateMeta
7
- CI_DICT = JSON.parse(IO.read(File.join(File.dirname(__FILE__),"ciDict.json")))
8
+ CI_DICT = JSON.parse(IO.read(File.join(File.dirname(__FILE__), "ciDict.json")))
8
9
 
9
- def create_meta(tool_name, tool_version, env=ENV)
10
+ def create_meta(tool_name, tool_version, env = ENV)
10
11
  Cucumber::Messages::Meta.new(
11
- protocol_version: Cucumber::Messages::VERSION,
12
- implementation: Cucumber::Messages::Meta::Product.new(
13
- name: tool_name,
14
- version: tool_version
15
- ),
16
- runtime: Cucumber::Messages::Meta::Product.new(
17
- name: RUBY_ENGINE,
18
- version: RUBY_VERSION
19
- ),
20
- os: Cucumber::Messages::Meta::Product.new(
21
- name: RbConfig::CONFIG['target_os'],
22
- version: Sys::Uname.uname.version
23
- ),
24
- cpu: Cucumber::Messages::Meta::Product.new(
25
- name: RbConfig::CONFIG['target_cpu']
26
- ),
27
- ci: detect_ci(env)
12
+ protocol_version: Cucumber::Messages::VERSION,
13
+ implementation: Cucumber::Messages::Meta::Product.new(
14
+ name: tool_name,
15
+ version: tool_version
16
+ ),
17
+ runtime: Cucumber::Messages::Meta::Product.new(
18
+ name: RUBY_ENGINE,
19
+ version: RUBY_VERSION
20
+ ),
21
+ os: Cucumber::Messages::Meta::Product.new(
22
+ name: RbConfig::CONFIG['target_os'],
23
+ version: Sys::Uname.uname.version
24
+ ),
25
+ cpu: Cucumber::Messages::Meta::Product.new(
26
+ name: RbConfig::CONFIG['target_cpu']
27
+ ),
28
+ ci: detect_ci(env)
28
29
  )
29
30
  end
30
31
 
@@ -41,14 +42,14 @@ module Cucumber
41
42
  return nil if url.nil?
42
43
 
43
44
  Cucumber::Messages::Meta::CI.new(
44
- url: url,
45
- name: ci_name,
46
- git: Cucumber::Messages::Meta::CI::Git.new(
47
- remote: evaluate(ci_system['git']['remote'], env),
48
- revision: evaluate(ci_system['git']['revision'], env),
49
- branch: evaluate(ci_system['git']['branch'], env),
50
- tag: evaluate(ci_system['git']['tag'], env),
51
- )
45
+ url: url,
46
+ name: ci_name,
47
+ git: Cucumber::Messages::Meta::CI::Git.new(
48
+ remote: remove_userinfo_from_url(evaluate(ci_system['git']['remote'], env)),
49
+ revision: evaluate(ci_system['git']['revision'], env),
50
+ branch: evaluate(ci_system['git']['branch'], env),
51
+ tag: evaluate(ci_system['git']['tag'], env),
52
+ )
52
53
  )
53
54
  end
54
55
 
@@ -80,6 +81,17 @@ module Cucumber
80
81
  m[1]
81
82
  end
82
83
 
83
- module_function :create_meta, :detect_ci, :create_ci, :group1, :evaluate
84
+ def remove_userinfo_from_url(value)
85
+ return nil if value.nil?
86
+ begin
87
+ uri = URI(value)
88
+ uri.userinfo = ''
89
+ uri.to_s
90
+ rescue
91
+ value
92
+ end
93
+ end
94
+
95
+ module_function :create_meta, :detect_ci, :create_ci, :group1, :evaluate, :remove_userinfo_from_url
84
96
  end
85
97
  end
@@ -0,0 +1,74 @@
1
+ # frozen_string_literal: true
2
+ # With thanks to @myronmarston
3
+ # https://github.com/vcr/vcr/blob/master/spec/capture_warnings.rb
4
+
5
+ module CaptureWarnings
6
+ def report_warnings(&block)
7
+ current_dir = Dir.pwd
8
+ warnings, errors = capture_error(&block).partition { |line| line.include?('warning') }
9
+ project_warnings, other_warnings = warnings.uniq.partition { |line| line.include?(current_dir) }
10
+
11
+ if errors.any?
12
+ puts errors.join("\n")
13
+ end
14
+
15
+ if other_warnings.any?
16
+ puts "#{ other_warnings.count } warnings detected, set VIEW_OTHER_WARNINGS=true to see them."
17
+ print_warnings('other', other_warnings) if ENV['VIEW_OTHER_WARNINGS']
18
+ end
19
+
20
+ # Until they fix https://bugs.ruby-lang.org/issues/10661
21
+ if RUBY_VERSION == "2.2.0"
22
+ project_warnings = project_warnings.reject { |w| w =~ /warning: possible reference to past scope/ }
23
+ end
24
+
25
+ if project_warnings.any?
26
+ puts "#{ project_warnings.count } warnings detected"
27
+ print_warnings('cucumber-expressions', project_warnings)
28
+ fail "Please remove all cucumber-expressions warnings."
29
+ end
30
+
31
+ ensure_system_exit_if_required
32
+ end
33
+
34
+ def capture_error(&block)
35
+ old_stderr = STDERR.clone
36
+ pipe_r, pipe_w = IO.pipe
37
+ pipe_r.sync = true
38
+ error = String.new
39
+ reader = Thread.new do
40
+ begin
41
+ loop do
42
+ error << pipe_r.readpartial(1024)
43
+ end
44
+ rescue EOFError
45
+ end
46
+ end
47
+ STDERR.reopen(pipe_w)
48
+ block.call
49
+ ensure
50
+ capture_system_exit
51
+ STDERR.reopen(old_stderr)
52
+ pipe_w.close
53
+ reader.join
54
+ return error.split("\n")
55
+ end
56
+
57
+ def print_warnings(type, warnings)
58
+ puts
59
+ puts "-" * 30 + " #{type} warnings: " + "-" * 30
60
+ puts
61
+ puts warnings.join("\n")
62
+ puts
63
+ puts "-" * 75
64
+ puts
65
+ end
66
+
67
+ def ensure_system_exit_if_required
68
+ raise @system_exit if @system_exit
69
+ end
70
+
71
+ def capture_system_exit
72
+ @system_exit = $!
73
+ end
74
+ end
@@ -0,0 +1,29 @@
1
+ require 'cucumber/create_meta'
2
+
3
+ describe 'remove_user_info_from_url' do
4
+ it 'returns nil for nil' do
5
+ expect(Cucumber::CreateMeta.remove_userinfo_from_url(nil)).to be_nil
6
+ end
7
+
8
+ it 'returns empty string for empty string' do
9
+ expect(Cucumber::CreateMeta.remove_userinfo_from_url('')).to eq('')
10
+ end
11
+
12
+ it 'leaves the data intact when no sensitive information is detected' do
13
+ expect(Cucumber::CreateMeta.remove_userinfo_from_url('pretty safe')).to eq('pretty safe')
14
+ end
15
+
16
+ context 'with URLs' do
17
+ it 'leaves intact when no password is found' do
18
+ expect(Cucumber::CreateMeta.remove_userinfo_from_url('https://example.com/git/repo.git')).to eq('https://example.com/git/repo.git')
19
+ end
20
+
21
+ it 'removes credentials when found' do
22
+ expect(Cucumber::CreateMeta.remove_userinfo_from_url('http://login@example.com/git/repo.git')).to eq('http://example.com/git/repo.git')
23
+ end
24
+
25
+ it 'removes credentials and passwords when found' do
26
+ expect(Cucumber::CreateMeta.remove_userinfo_from_url('ssh://login:password@example.com/git/repo.git')).to eq('ssh://example.com/git/repo.git')
27
+ end
28
+ end
29
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cucumber-create-meta
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vincent Prêtre
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-18 00:00:00.000000000 Z
11
+ date: 2021-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cucumber-messages
@@ -16,20 +16,20 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '13.0'
19
+ version: '15.0'
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 13.0.1
22
+ version: 15.0.0
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - "~>"
28
28
  - !ruby/object:Gem::Version
29
- version: '13.0'
29
+ version: '15.0'
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 13.0.1
32
+ version: 15.0.0
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: sys-uname
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -39,7 +39,7 @@ dependencies:
39
39
  version: '1.2'
40
40
  - - ">="
41
41
  - !ruby/object:Gem::Version
42
- version: 1.2.1
42
+ version: 1.2.2
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
@@ -49,7 +49,7 @@ dependencies:
49
49
  version: '1.2'
50
50
  - - ">="
51
51
  - !ruby/object:Gem::Version
52
- version: 1.2.1
52
+ version: 1.2.2
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: rake
55
55
  requirement: !ruby/object:Gem::Requirement
@@ -59,7 +59,7 @@ dependencies:
59
59
  version: '13.0'
60
60
  - - ">="
61
61
  - !ruby/object:Gem::Version
62
- version: 13.0.1
62
+ version: 13.0.3
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
@@ -69,27 +69,27 @@ dependencies:
69
69
  version: '13.0'
70
70
  - - ">="
71
71
  - !ruby/object:Gem::Version
72
- version: 13.0.1
72
+ version: 13.0.3
73
73
  - !ruby/object:Gem::Dependency
74
74
  name: rspec
75
75
  requirement: !ruby/object:Gem::Requirement
76
76
  requirements:
77
77
  - - "~>"
78
78
  - !ruby/object:Gem::Version
79
- version: '3.9'
79
+ version: '3.10'
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: 3.9.0
82
+ version: 3.10.0
83
83
  type: :development
84
84
  prerelease: false
85
85
  version_requirements: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '3.9'
89
+ version: '3.10'
90
90
  - - ">="
91
91
  - !ruby/object:Gem::Version
92
- version: 3.9.0
92
+ version: 3.10.0
93
93
  description: Produce the meta message for Cucumber Ruby
94
94
  email: cukes@googlegroups.com
95
95
  executables: []
@@ -99,7 +99,9 @@ files:
99
99
  - LICENSE
100
100
  - lib/cucumber/ciDict.json
101
101
  - lib/cucumber/create_meta.rb
102
+ - spec/capture_warnings.rb
102
103
  - spec/cucumber/create_meta_spec.rb
104
+ - spec/cucumber/remove_userinfo_from_url_spec.rb
103
105
  homepage: https://github.com/cucumber/create-meta-ruby
104
106
  licenses:
105
107
  - MIT
@@ -128,6 +130,8 @@ requirements: []
128
130
  rubygems_version: 3.1.2
129
131
  signing_key:
130
132
  specification_version: 4
131
- summary: cucumber-create-meta-2.0.1
133
+ summary: cucumber-create-meta-4.0.0
132
134
  test_files:
135
+ - spec/capture_warnings.rb
133
136
  - spec/cucumber/create_meta_spec.rb
137
+ - spec/cucumber/remove_userinfo_from_url_spec.rb