cucumber-create-meta 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: fc6fadee5d6df3e7e90f5f21741bd7eb9850b645efa7b120098329932dc9f165
4
+ data.tar.gz: 8e9553277de8b14d988529b320489685c9a104f60a31a6adf35160ed751e9e76
5
+ SHA512:
6
+ metadata.gz: cf282b4a220dfb292340b9d216b379a46094ca932d30227382a94f3ec14fca86025504d74f8c334903ff354818ea94b82d7515966ee2550c2d185ca4377dfeb9
7
+ data.tar.gz: cc3c3328c0c32dc453f2dd5d4fd4a5821aa8ec09fd7e3a4ddeca96b059dea802d6aabf29dee78270c0079acf21272707af9b516d0a5b45066a5f2fefd11c75f0
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) Cucumber Ltd
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,110 @@
1
+ {
2
+ "Azure Pipelines": {
3
+ "url": "${BUILD_URI}",
4
+ "git": {
5
+ "remote": "${BUILD_REPOSITORY_URI}",
6
+ "revision": "${BUILD_SOURCEVERSION}",
7
+ "branch": "${refbranch BUILD_SOURCEBRANCH}",
8
+ "tag": "${reftag BUILD_SOURCEBRANCH}"
9
+ }
10
+ },
11
+ "Bamboo": {
12
+ "url": "${bamboo.buildResultsUrl}",
13
+ "git": {
14
+ "remote": "${bamboo.planRepository.1.repositoryUrl}",
15
+ "revision": "${bamboo.planRepository.1.revision}",
16
+ "branch": "${bamboo.planRepository.1.branch}",
17
+ "tag": null
18
+ }
19
+ },
20
+ "Buddy": {
21
+ "url": "${BUDDY_EXECUTION_URL}",
22
+ "git": {
23
+ "remote": "${BUDDY_SCM_URL}",
24
+ "revision": "${BUDDY_EXECUTION_REVISION}",
25
+ "branch": "${BUDDY_EXECUTION_BRANCH}",
26
+ "tag": "${BUDDY_EXECUTION_TAG}"
27
+ }
28
+ },
29
+ "CircleCI": {
30
+ "url": "${CIRCLE_BUILD_URL}",
31
+ "git": {
32
+ "remote": "${CIRCLE_REPOSITORY_URL}",
33
+ "revision": "${CIRCLE_SHA1}",
34
+ "branch": "${CIRCLE_BRANCH}",
35
+ "tag": "${CIRCLE_TAG}"
36
+ }
37
+ },
38
+ "CodeShip": {
39
+ "url": "${CF_BUILD_URL}",
40
+ "git": {
41
+ "remote": "${CF_COMMIT_URL}",
42
+ "revision": "${CF_REVISION}",
43
+ "branch": "${CF_BRANCH}",
44
+ "tag": null
45
+ }
46
+ },
47
+ "GitHub Actions": {
48
+ "url": "${_GITHUB_BASEURL | https://github.com/}${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}",
49
+ "git": {
50
+ "remote": "${_GITHUB_BASEURL | https://github.com/}${GITHUB_REPOSITORY}.git",
51
+ "revision": "${GITHUB_SHA}",
52
+ "branch": "${refbranch GITHUB_REF}",
53
+ "tag": "${reftag GITHUB_REF}"
54
+ }
55
+ },
56
+ "GitLab": {
57
+ "url": "${CI_JOB_URL}",
58
+ "git": {
59
+ "remote": "${CI_REPOSITORY_URL}",
60
+ "revision": "${CI_COMMIT_SHA}",
61
+ "branch": "${CI_COMMIT_BRANCH}",
62
+ "tag": "${CI_COMMIT_TAG}"
63
+ }
64
+ },
65
+ "GoCD": {
66
+ "url": "${GO_SERVER_URL}/???",
67
+ "git": {
68
+ "remote": null,
69
+ "revision": "${GO_REVISION}",
70
+ "branch": null,
71
+ "tag": null
72
+ }
73
+ },
74
+ "Semaphore": {
75
+ "url": "${SEMAPHORE_ORGANIZATION_URL}/${}",
76
+ "git": {
77
+ "remote": "${SEMAPHORE_GIT_URL}",
78
+ "revision": "${SEMAPHORE_GIT_SHA}",
79
+ "branch": "${SEMAPHORE_GIT_BRANCH}",
80
+ "tag": "${SEMAPHORE_GIT_TAG_NAME}"
81
+ }
82
+ },
83
+ "TeamCity": {
84
+ "url": "${teamcity.serverUrl}/app/rest/builds/id:${teamcity.build.id}",
85
+ "git": {
86
+ "remote": null,
87
+ "revision": "${build.vcs.number}",
88
+ "branch": "${teamcity.build.branch}",
89
+ "tag": null
90
+ }
91
+ },
92
+ "Travis CI": {
93
+ "url": "${TRAVIS_BUILD_WEB_URL}",
94
+ "git": {
95
+ "remote": "https://github.com/${TRAVIS_REPO_SLUG}.git",
96
+ "revision": "${TRAVIS_COMMIT}",
97
+ "branch": "${TRAVIS_BRANCH}",
98
+ "tag": "${TRAVIS_TAG}"
99
+ }
100
+ },
101
+ "Wercker": {
102
+ "url": "${WERCKER_RUN_URL}",
103
+ "git": {
104
+ "remote": "https://${WERCKER_GIT_DOMAIN}/${WERCKER_GIT_OWNER}/${WERCKER_GIT_REPOSITORY}.git",
105
+ "revision": "${WERCKER_GIT_COMMIT}",
106
+ "branch": "${WERCKER_GIT_BRANCH}",
107
+ "tag": null
108
+ }
109
+ }
110
+ }
@@ -0,0 +1,84 @@
1
+ require 'cucumber/messages'
2
+ require 'sys/uname'
3
+ require 'json'
4
+
5
+ module Cucumber
6
+ module CreateMeta
7
+ CI_DICT = JSON.parse(IO.read(File.join(File.dirname(__FILE__),"ciDict.json")))
8
+
9
+ def create_meta(tool_name, tool_version)
10
+ 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
+ )
28
+ end
29
+
30
+ def detect_ci(env)
31
+ detected = CI_DICT.map do |ci_name, ci_system|
32
+ create_ci(ci_name, ci_system, env)
33
+ end.compact
34
+
35
+ detected.length == 1 ? detected[0] : nil
36
+ end
37
+
38
+ def create_ci(ci_name, ci_system, env)
39
+ url = evaluate(ci_system['url'], env)
40
+ return nil if url.nil?
41
+
42
+ Cucumber::Messages::Meta::CI.new(
43
+ url: url,
44
+ name: ci_name,
45
+ git: Cucumber::Messages::Meta::CI::Git.new(
46
+ remote: evaluate(ci_system['git']['remote'], env),
47
+ revision: evaluate(ci_system['git']['revision'], env),
48
+ branch: evaluate(ci_system['git']['branch'], env),
49
+ tag: evaluate(ci_system['git']['tag'], env),
50
+ )
51
+ )
52
+ end
53
+
54
+ def evaluate(template, env)
55
+ return nil if template.nil?
56
+ begin
57
+ template.gsub(/\${((refbranch|reftag)\s+)?([^\s}]+)(\s+\|\s+([^}]+))?}/) do
58
+ func = $2
59
+ variable = $3
60
+ default_value = $5 == "" ? nil : $5
61
+ value = env[variable] || default_value
62
+
63
+ if func == 'refbranch'
64
+ value = group1(value, /^refs\/heads\/(.*)/)
65
+ elsif func == 'reftag'
66
+ value = group1(value, /^refs\/tags\/(.*)/)
67
+ end
68
+ raise "Undefined variable: #{variable}" if value.nil?
69
+ value
70
+ end
71
+ rescue
72
+ nil
73
+ end
74
+ end
75
+
76
+ def group1(value, regexp)
77
+ m = value.match(regexp)
78
+ raise "No match" if m.nil?
79
+ m[1]
80
+ end
81
+
82
+ module_function :create_meta, :detect_ci, :create_ci, :group1, :evaluate
83
+ end
84
+ 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,16 @@
1
+ require 'cucumber/create_meta'
2
+
3
+ describe 'createMeta' do
4
+ it 'generates a Meta message with platform information' do
5
+ meta = Cucumber::CreateMeta.create_meta('cucumba-ruby', 'X.Y.Z')
6
+
7
+ expect(meta.protocol_version).to match(/\d+\.\d+\.\d+/)
8
+ expect(meta.implementation.name).to eq('cucumba-ruby')
9
+ expect(meta.implementation.version).to eq('X.Y.Z')
10
+ expect(meta.runtime.name).to match(/(jruby|ruby)/)
11
+ expect(meta.runtime.version).to eq(RUBY_VERSION)
12
+ expect(meta.os.name).to match(/.+/)
13
+ expect(meta.os.version).to match(/.+/)
14
+ expect(meta.cpu.name).to match(/.+/)
15
+ end
16
+ end
metadata ADDED
@@ -0,0 +1,135 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cucumber-create-meta
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Vincent Prêtre
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-06-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: cucumber-messages
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '12.2'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 12.2.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '12.2'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 12.2.0
33
+ - !ruby/object:Gem::Dependency
34
+ name: sys-uname
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.2'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 1.2.1
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '1.2'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 1.2.1
53
+ - !ruby/object:Gem::Dependency
54
+ name: rake
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '13.0'
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: 13.0.1
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '13.0'
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: 13.0.1
73
+ - !ruby/object:Gem::Dependency
74
+ name: rspec
75
+ requirement: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - "~>"
78
+ - !ruby/object:Gem::Version
79
+ version: '3.9'
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 3.9.0
83
+ type: :development
84
+ prerelease: false
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.9'
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: 3.9.0
93
+ description: Produce the meta message for Cucumber Ruby
94
+ email: cukes@googlegroups.com
95
+ executables: []
96
+ extensions: []
97
+ extra_rdoc_files: []
98
+ files:
99
+ - LICENSE
100
+ - lib/cucumber/ciDict.json
101
+ - lib/cucumber/create_meta.rb
102
+ - spec/capture_warnings.rb
103
+ - spec/cucumber/create_meta_spec.rb
104
+ homepage: https://github.com/cucumber/create-meta-ruby
105
+ licenses:
106
+ - MIT
107
+ metadata:
108
+ bug_tracker_uri: https://github.com/cucumber/cucumber/issues
109
+ changelog_uri: https://github.com/cucumber/cucumber/blob/master/gherkin/CHANGELOG.md
110
+ documentation_uri: https://cucumber.io/docs/gherkin/
111
+ mailing_list_uri: https://groups.google.com/forum/#!forum/cukes
112
+ source_code_uri: https://github.com/cucumber/cucumber/blob/master/gherkin/ruby
113
+ post_install_message:
114
+ rdoc_options:
115
+ - "--charset=UTF-8"
116
+ require_paths:
117
+ - lib
118
+ required_ruby_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '2.3'
123
+ required_rubygems_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ requirements: []
129
+ rubygems_version: 3.1.2
130
+ signing_key:
131
+ specification_version: 4
132
+ summary: cucumber-create-meta-1.0.0
133
+ test_files:
134
+ - spec/cucumber/create_meta_spec.rb
135
+ - spec/capture_warnings.rb