cucumber-create-meta 3.0.0 → 6.0.1

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: 0444456cd7e3d135ce1393117b37b0804d1b027365e8ad6ded7eb2999cc3704e
4
- data.tar.gz: bfb0927d6316a1dd577326f59c314c3d69e7f3144adcdba2b4aea1d3a58309f1
3
+ metadata.gz: d6ee53160861ac80fab521c7c68e65d3f67992a253096b1bc86eebf071e93084
4
+ data.tar.gz: b3a3a1a5272e75af443cb88f736924209563e92f40d8d37bac855a71ddcc9608
5
5
  SHA512:
6
- metadata.gz: 7b1251604b3d8617bd1c4cc3845099c0b48e482d7d162145311d3698d23cd9db861b5320e367174657ec639b49bd7ab8cb187a7529fa7c14f3945912af91d2e1
7
- data.tar.gz: 6144894e4f5f5826e3060717eff1c83ae5db6c4c426b7ac264694810268f9f18713c6b1b6ac8dd90b2e888039ece6f7507f82d62471a9e88906630134a23156a
6
+ metadata.gz: 8a3d47bf29d4e21381473159abafa1262f179c3049eacfbad3725ac0a8c054ba061849d66c585b1f60167e0ca5ecab06615bfc7e73a8d9f19b8d547504cabeb6
7
+ data.tar.gz: 451316acb36b939dff9e89e772585bd1acac9d6c07e3d61847bff0b5bad97e7e18e02e8eed097f43b3b61caf4c716eb9f4e798fbc64f5ee6578cddbd3430677c
@@ -1,24 +1,27 @@
1
1
  {
2
2
  "Azure Pipelines": {
3
- "url": "${BUILD_URI}",
3
+ "url": "${BUILD_BUILDURI}",
4
+ "buildNumber": "${BUILD_BUILDNUMBER}",
4
5
  "git": {
5
6
  "remote": "${BUILD_REPOSITORY_URI}",
6
7
  "revision": "${BUILD_SOURCEVERSION}",
7
- "branch": "${refbranch BUILD_SOURCEBRANCH}",
8
- "tag": "${reftag BUILD_SOURCEBRANCH}"
8
+ "branch": "${BUILD_SOURCEBRANCH/refs\/heads\/(.*)/\\1}",
9
+ "tag": "${BUILD_SOURCEBRANCH/refs\/tags\/(.*)/\\1}"
9
10
  }
10
11
  },
11
12
  "Bamboo": {
12
- "url": "${bamboo.buildResultsUrl}",
13
+ "url": "${bamboo_buildResultsUrl}",
14
+ "buildNumber": "${bamboo_buildNumber}",
13
15
  "git": {
14
- "remote": "${bamboo.planRepository.1.repositoryUrl}",
15
- "revision": "${bamboo.planRepository.1.revision}",
16
- "branch": "${bamboo.planRepository.1.branch}",
16
+ "remote": "${bamboo_planRepository_repositoryUrl}",
17
+ "revision": "${bamboo_planRepository_revision}",
18
+ "branch": "${bamboo_planRepository_branch}",
17
19
  "tag": null
18
20
  }
19
21
  },
20
22
  "Buddy": {
21
23
  "url": "${BUDDY_EXECUTION_URL}",
24
+ "buildNumber": "${BUDDY_EXECUTION_ID}",
22
25
  "git": {
23
26
  "remote": "${BUDDY_SCM_URL}",
24
27
  "revision": "${BUDDY_EXECUTION_REVISION}",
@@ -26,8 +29,19 @@
26
29
  "tag": "${BUDDY_EXECUTION_TAG}"
27
30
  }
28
31
  },
32
+ "Bitrise": {
33
+ "url": "${BITRISE_BUILD_URL}",
34
+ "buildNumber": "${BITRISE_BUILD_NUMBER}",
35
+ "git": {
36
+ "remote": "${GIT_REPOSITORY_URL}",
37
+ "revision": "${BITRISE_GIT_COMMIT}",
38
+ "branch": "${BITRISE_GIT_BRANCH}",
39
+ "tag": "${BITRISE_GIT_TAG}"
40
+ }
41
+ },
29
42
  "CircleCI": {
30
43
  "url": "${CIRCLE_BUILD_URL}",
44
+ "buildNumber": "${CIRCLE_BUILD_NUM}",
31
45
  "git": {
32
46
  "remote": "${CIRCLE_REPOSITORY_URL}",
33
47
  "revision": "${CIRCLE_SHA1}",
@@ -35,26 +49,39 @@
35
49
  "tag": "${CIRCLE_TAG}"
36
50
  }
37
51
  },
38
- "CodeShip": {
52
+ "CodeFresh": {
39
53
  "url": "${CF_BUILD_URL}",
54
+ "buildNumber": "${CF_BUILD_ID}",
40
55
  "git": {
41
- "remote": "${CF_COMMIT_URL}",
56
+ "remote": "${CF_COMMIT_URL/(.*)\\/commit.+$/\\1}.git",
42
57
  "revision": "${CF_REVISION}",
43
58
  "branch": "${CF_BRANCH}",
44
59
  "tag": null
45
60
  }
46
61
  },
62
+ "CodeShip": {
63
+ "url": "${CI_BUILD_URL}",
64
+ "buildNumber": "${CI_BUILD_NUMBER}",
65
+ "git": {
66
+ "remote": "${CI_PULL_REQUEST/(.*)\\/pull\\/\\d+/\\1.git}",
67
+ "revision": "${CI_COMMIT_ID}",
68
+ "branch": "${CI_BRANCH}",
69
+ "tag": null
70
+ }
71
+ },
47
72
  "GitHub Actions": {
48
73
  "url": "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}",
74
+ "buildNumber": "${GITHUB_RUN_ID}",
49
75
  "git": {
50
76
  "remote": "${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git",
51
77
  "revision": "${GITHUB_SHA}",
52
- "branch": "${refbranch GITHUB_REF}",
53
- "tag": "${reftag GITHUB_REF}"
78
+ "branch": "${GITHUB_REF/refs\/heads\/(.*)/\\1}",
79
+ "tag": "${GITHUB_REF/refs\/tags\/(.*)/\\1}"
54
80
  }
55
81
  },
56
82
  "GitLab": {
57
83
  "url": "${CI_JOB_URL}",
84
+ "buildNumber": "${CI_JOB_ID}",
58
85
  "git": {
59
86
  "remote": "${CI_REPOSITORY_URL}",
60
87
  "revision": "${CI_COMMIT_SHA}",
@@ -63,16 +90,28 @@
63
90
  }
64
91
  },
65
92
  "GoCD": {
66
- "url": "${GO_SERVER_URL}/???",
93
+ "url": "${GO_SERVER_URL}/pipelines/${GO_PIPELINE_NAME}/${GO_PIPELINE_COUNTER}/${GO_STAGE_NAME}/${GO_STAGE_COUNTER}",
94
+ "buildNumber": "${GO_PIPELINE_NAME}/${GO_PIPELINE_COUNTER}/${GO_STAGE_NAME}/${GO_STAGE_COUNTER}",
67
95
  "git": {
68
- "remote": null,
96
+ "remote": "${GO_SCM_*_PR_URL/(.*)\\/pull\\/\\d+/\\1.git}",
69
97
  "revision": "${GO_REVISION}",
70
- "branch": null,
98
+ "branch": "${GO_SCM_*_PR_BRANCH/.*:(.*)/\\1}",
99
+ "tag": null
100
+ }
101
+ },
102
+ "Jenkins": {
103
+ "url": "${BUILD_URL}",
104
+ "buildNumber": "${BUILD_NUMBER}",
105
+ "git": {
106
+ "remote": "${GIT_URL}",
107
+ "revision": "${GIT_COMMIT}",
108
+ "branch": "${GIT_LOCAL_BRANCH}",
71
109
  "tag": null
72
110
  }
73
111
  },
74
112
  "Semaphore": {
75
- "url": "${SEMAPHORE_ORGANIZATION_URL}/${}",
113
+ "url": "${SEMAPHORE_ORGANIZATION_URL}/jobs/${SEMAPHORE_JOB_ID}",
114
+ "buildNumber": "${SEMAPHORE_JOB_ID}",
76
115
  "git": {
77
116
  "remote": "${SEMAPHORE_GIT_URL}",
78
117
  "revision": "${SEMAPHORE_GIT_SHA}",
@@ -80,17 +119,9 @@
80
119
  "tag": "${SEMAPHORE_GIT_TAG_NAME}"
81
120
  }
82
121
  },
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
122
  "Travis CI": {
93
123
  "url": "${TRAVIS_BUILD_WEB_URL}",
124
+ "buildNumber": "${TRAVIS_JOB_NUMBER}",
94
125
  "git": {
95
126
  "remote": "https://github.com/${TRAVIS_REPO_SLUG}.git",
96
127
  "revision": "${TRAVIS_COMMIT}",
@@ -100,6 +131,7 @@
100
131
  },
101
132
  "Wercker": {
102
133
  "url": "${WERCKER_RUN_URL}",
134
+ "buildNumber": "${WERCKER_RUN_URL/.*\\/([^\\/]+)$/\\1}",
103
135
  "git": {
104
136
  "remote": "https://${WERCKER_GIT_DOMAIN}/${WERCKER_GIT_OWNER}/${WERCKER_GIT_REPOSITORY}.git",
105
137
  "revision": "${WERCKER_GIT_COMMIT}",
@@ -1,32 +1,34 @@
1
1
  require 'uri'
2
- require 'cucumber/messages'
3
2
  require 'sys/uname'
4
3
  require 'json'
4
+ require 'cucumber/messages'
5
+ require 'cucumber/create_meta/variable_expression'
5
6
 
6
7
  module Cucumber
7
8
  module CreateMeta
9
+ extend Cucumber::CreateMeta::VariableExpression
8
10
  CI_DICT = JSON.parse(IO.read(File.join(File.dirname(__FILE__), "ciDict.json")))
9
11
 
10
12
  def create_meta(tool_name, tool_version, env = ENV)
11
- Cucumber::Messages::Meta.new(
13
+ {
12
14
  protocol_version: Cucumber::Messages::VERSION,
13
- implementation: Cucumber::Messages::Meta::Product.new(
15
+ implementation: {
14
16
  name: tool_name,
15
17
  version: tool_version
16
- ),
17
- runtime: Cucumber::Messages::Meta::Product.new(
18
+ },
19
+ runtime: {
18
20
  name: RUBY_ENGINE,
19
21
  version: RUBY_VERSION
20
- ),
21
- os: Cucumber::Messages::Meta::Product.new(
22
+ },
23
+ os: {
22
24
  name: RbConfig::CONFIG['target_os'],
23
25
  version: Sys::Uname.uname.version
24
- ),
25
- cpu: Cucumber::Messages::Meta::Product.new(
26
+ },
27
+ cpu: {
26
28
  name: RbConfig::CONFIG['target_cpu']
27
- ),
29
+ },
28
30
  ci: detect_ci(env)
29
- )
31
+ }
30
32
  end
31
33
 
32
34
  def detect_ci(env)
@@ -41,44 +43,17 @@ module Cucumber
41
43
  url = evaluate(ci_system['url'], env)
42
44
  return nil if url.nil?
43
45
 
44
- Cucumber::Messages::Meta::CI.new(
46
+ {
45
47
  url: url,
46
48
  name: ci_name,
47
- git: Cucumber::Messages::Meta::CI::Git.new(
49
+ buildNumber: evaluate(ci_system['buildNumber'], env),
50
+ git: {
48
51
  remote: remove_userinfo_from_url(evaluate(ci_system['git']['remote'], env)),
49
52
  revision: evaluate(ci_system['git']['revision'], env),
50
53
  branch: evaluate(ci_system['git']['branch'], env),
51
54
  tag: evaluate(ci_system['git']['tag'], env),
52
- )
53
- )
54
- end
55
-
56
- def evaluate(template, env)
57
- return nil if template.nil?
58
- begin
59
- template.gsub(/\${((refbranch|reftag)\s+)?([^\s}]+)(\s+\|\s+([^}]+))?}/) do
60
- func = $2
61
- variable = $3
62
- default_value = $5 == "" ? nil : $5
63
- value = env[variable] || default_value
64
-
65
- if func == 'refbranch'
66
- value = group1(value, /^refs\/heads\/(.*)/)
67
- elsif func == 'reftag'
68
- value = group1(value, /^refs\/tags\/(.*)/)
69
- end
70
- raise "Undefined variable: #{variable}" if value.nil?
71
- value
72
- end
73
- rescue
74
- nil
75
- end
76
- end
77
-
78
- def group1(value, regexp)
79
- m = value.match(regexp)
80
- raise "No match" if m.nil?
81
- m[1]
55
+ }.delete_if {|k,v| v.nil?}
56
+ }
82
57
  end
83
58
 
84
59
  def remove_userinfo_from_url(value)
@@ -92,6 +67,6 @@ module Cucumber
92
67
  end
93
68
  end
94
69
 
95
- module_function :create_meta, :detect_ci, :create_ci, :group1, :evaluate, :remove_userinfo_from_url
70
+ module_function :create_meta, :detect_ci, :create_ci, :remove_userinfo_from_url
96
71
  end
97
72
  end
@@ -0,0 +1,41 @@
1
+ module Cucumber
2
+ module CreateMeta
3
+ module VariableExpression
4
+ def evaluate(expression, env)
5
+ return nil if expression.nil?
6
+ begin
7
+ expression.gsub(/\${(.*?)(?:(?<!\\)\/(.*)\/(.*))?}/) do
8
+ variable = $1
9
+ pattern = $2
10
+ replacement = $3
11
+
12
+ value = get_value(variable, env)
13
+ raise "Undefined variable #{variable}" if value.nil?
14
+ if pattern.nil?
15
+ value
16
+ else
17
+ regexp = Regexp.new(pattern.gsub('\/', '/'))
18
+ match = value.match(regexp)
19
+ raise "No match for variable #{variable}" if match.nil?
20
+ match[1..-1].each_with_index do |group, i|
21
+ replacement = replacement.gsub("\\#{i+1}", group)
22
+ end
23
+ replacement
24
+ end
25
+ end
26
+ rescue
27
+ nil
28
+ end
29
+ end
30
+
31
+ def get_value(variable, env)
32
+ if variable.index('*')
33
+ env.each do |name, value|
34
+ return value if Regexp.new(variable.gsub('*', '.*')) =~ name
35
+ end
36
+ end
37
+ env[variable]
38
+ end
39
+ end
40
+ end
41
+ end
@@ -1,16 +1,16 @@
1
1
  require 'cucumber/create_meta'
2
2
 
3
- describe 'createMeta' do
3
+ describe 'create_meta' do
4
4
  it 'generates a Meta message with platform information' do
5
5
  meta = Cucumber::CreateMeta.create_meta('cucumba-ruby', 'X.Y.Z')
6
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(/.+/)
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
15
  end
16
16
  end
@@ -0,0 +1,38 @@
1
+ require 'cucumber/create_meta'
2
+
3
+ describe 'Cucumber::CreateMeta::VariableExpression.evaluate' do
4
+ include Cucumber::CreateMeta::VariableExpression
5
+
6
+ it 'returns nil when a variable is undefined' do
7
+ expression = "hello-${SOME_VAR}";
8
+ result = evaluate(expression, {});
9
+ expect(result).to eq(nil)
10
+ end
11
+
12
+ it 'gets a value without replacement' do
13
+ expression = "${SOME_VAR}";
14
+ result = evaluate(expression, {'SOME_VAR' => 'some_value'});
15
+ expect(result).to eq('some_value')
16
+ end
17
+
18
+ it 'captures a group' do
19
+ expression = "${SOME_REF/refs\/heads\/(.*)/\\1}";
20
+ result = evaluate(expression, {'SOME_REF' => 'refs/heads/main'});
21
+ expect(result).to eq('main')
22
+ end
23
+
24
+ it 'works with star wildcard in var' do
25
+ expression = "${GO_SCM_*_PR_BRANCH/.*:(.*)/\\1}";
26
+ result = evaluate(expression, {'GO_SCM_MY_MATERIAL_PR_BRANCH' => 'ashwankthkumar:feature-1'});
27
+ expect(result).to eq('feature-1')
28
+ end
29
+
30
+ it 'evaluates a complex expression' do
31
+ expression = "hello-${VAR1}-${VAR2/(.*) (.*)/\\2-\\1}-world";
32
+ result = evaluate(expression, {
33
+ 'VAR1' => 'amazing',
34
+ 'VAR2' => 'gorgeous beautiful'
35
+ })
36
+ expect(result).to eq('hello-amazing-beautiful-gorgeous-world')
37
+ end
38
+ 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: 3.0.0
4
+ version: 6.0.1
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: 2021-02-09 00:00:00.000000000 Z
11
+ date: 2021-07-19 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: '14.0'
19
+ version: '17.0'
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 14.0.1
22
+ version: 17.0.1
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: '14.0'
29
+ version: '17.0'
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 14.0.1
32
+ version: 17.0.1
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: sys-uname
35
35
  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.3
62
+ version: 13.0.6
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
@@ -69,7 +69,7 @@ dependencies:
69
69
  version: '13.0'
70
70
  - - ">="
71
71
  - !ruby/object:Gem::Version
72
- version: 13.0.3
72
+ version: 13.0.6
73
73
  - !ruby/object:Gem::Dependency
74
74
  name: rspec
75
75
  requirement: !ruby/object:Gem::Requirement
@@ -99,18 +99,20 @@ files:
99
99
  - LICENSE
100
100
  - lib/cucumber/ciDict.json
101
101
  - lib/cucumber/create_meta.rb
102
+ - lib/cucumber/create_meta/variable_expression.rb
102
103
  - spec/capture_warnings.rb
103
104
  - spec/cucumber/create_meta_spec.rb
105
+ - spec/cucumber/evaluate_variable_expression_spec.rb
104
106
  - spec/cucumber/remove_userinfo_from_url_spec.rb
105
107
  homepage: https://github.com/cucumber/create-meta-ruby
106
108
  licenses:
107
109
  - MIT
108
110
  metadata:
109
111
  bug_tracker_uri: https://github.com/cucumber/cucumber/issues
110
- changelog_uri: https://github.com/cucumber/cucumber/blob/master/gherkin/CHANGELOG.md
112
+ changelog_uri: https://github.com/cucumber/common/blob/main/gherkin/CHANGELOG.md
111
113
  documentation_uri: https://cucumber.io/docs/gherkin/
112
114
  mailing_list_uri: https://groups.google.com/forum/#!forum/cukes
113
- source_code_uri: https://github.com/cucumber/cucumber/blob/master/gherkin/ruby
115
+ source_code_uri: https://github.com/cucumber/common/blob/main/gherkin/ruby
114
116
  post_install_message:
115
117
  rdoc_options:
116
118
  - "--charset=UTF-8"
@@ -130,8 +132,9 @@ requirements: []
130
132
  rubygems_version: 3.1.2
131
133
  signing_key:
132
134
  specification_version: 4
133
- summary: cucumber-create-meta-3.0.0
135
+ summary: cucumber-create-meta-6.0.1
134
136
  test_files:
135
137
  - spec/capture_warnings.rb
136
- - spec/cucumber/create_meta_spec.rb
137
138
  - spec/cucumber/remove_userinfo_from_url_spec.rb
139
+ - spec/cucumber/evaluate_variable_expression_spec.rb
140
+ - spec/cucumber/create_meta_spec.rb