cucumber-create-meta 6.0.0 → 6.0.4

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: 5c10212121773a60d2a7818cf9b9e8890cf412243f36a69b1d8ab6248d66b059
4
- data.tar.gz: e8f7eeaa2cb1ba16145c0dc4b0fbf8662bacdd648f7a1fb19cf7a99aab90b0df
3
+ metadata.gz: 63127f1e5e91ab72c44f0bb1bd04fd3c6e135f3d663e527dc5cb9e83333b64bc
4
+ data.tar.gz: fe39fb543eaeb57b6f11e461a669da01348571d8bff54ab88a0cb1ed70afa910
5
5
  SHA512:
6
- metadata.gz: 7fe13c2d94345aeb18f3dea76a177173c32a7b355cf75bae5c63881634443242a8962e6caeffd91be861163917bcbf98a927b6add7f9a82d2d00d76a0c289d4f
7
- data.tar.gz: fef0b73181b7a120a9b3f7467c98a27aa47358ea0c045c5fc9d1cbf97c1bf37d3519d7da9f28062c3773b2b4f6516895656bf1388ea5058ac8339e722cb7d4ae
6
+ metadata.gz: 70de8133e0320a1ecd8a340e69fa5c469c874676b4c65aa7f7ef268c298b875720c9152068366b628183e4cc13d29387adee865defef9da23159465cf42b34ab
7
+ data.tar.gz: 40298073a226c0fd14ed6d3e2342fe01e5b3ef6c60cd3abcfcdcc54c760a572fcb55ccf76ca13e4ebf6a6a47263421977d47efb400e0cbb3b98f4042fcf78cc3
@@ -7,28 +7,28 @@ require 'cucumber/create_meta/variable_expression'
7
7
  module Cucumber
8
8
  module CreateMeta
9
9
  extend Cucumber::CreateMeta::VariableExpression
10
- CI_DICT = JSON.parse(IO.read(File.join(File.dirname(__FILE__), "ciDict.json")))
10
+ CI_DICT = JSON.parse(IO.read(File.join(File.dirname(__FILE__), 'ciDict.json')))
11
11
 
12
12
  def create_meta(tool_name, tool_version, env = ENV)
13
- {
14
- protocol_version: Cucumber::Messages::VERSION,
15
- implementation: {
16
- name: tool_name,
17
- version: tool_version
18
- },
19
- runtime: {
20
- name: RUBY_ENGINE,
21
- version: RUBY_VERSION
22
- },
23
- os: {
24
- name: RbConfig::CONFIG['target_os'],
25
- version: Sys::Uname.uname.version
26
- },
27
- cpu: {
28
- name: RbConfig::CONFIG['target_cpu']
29
- },
30
- ci: detect_ci(env)
31
- }
13
+ Cucumber::Messages::Meta.new(
14
+ protocol_version: Cucumber::Messages::VERSION,
15
+ implementation: Cucumber::Messages::Product.new(
16
+ name: tool_name,
17
+ version: tool_version
18
+ ),
19
+ runtime: Cucumber::Messages::Product.new(
20
+ name: RUBY_ENGINE,
21
+ version: RUBY_VERSION
22
+ ),
23
+ os: Cucumber::Messages::Product.new(
24
+ name: RbConfig::CONFIG['target_os'],
25
+ version: Sys::Uname.uname.version
26
+ ),
27
+ cpu: Cucumber::Messages::Product.new(
28
+ name: RbConfig::CONFIG['target_cpu']
29
+ ),
30
+ ci: detect_ci(env)
31
+ )
32
32
  end
33
33
 
34
34
  def detect_ci(env)
@@ -43,26 +43,27 @@ module Cucumber
43
43
  url = evaluate(ci_system['url'], env)
44
44
  return nil if url.nil?
45
45
 
46
- {
47
- url: url,
48
- name: ci_name,
49
- buildNumber: evaluate(ci_system['buildNumber'], env),
50
- git: {
51
- remote: remove_userinfo_from_url(evaluate(ci_system['git']['remote'], env)),
52
- revision: evaluate(ci_system['git']['revision'], env),
53
- branch: evaluate(ci_system['git']['branch'], env),
54
- tag: evaluate(ci_system['git']['tag'], env),
55
- }.delete_if {|k,v| v.nil?}
56
- }
46
+ Cucumber::Messages::Ci.new(
47
+ url: url,
48
+ name: ci_name,
49
+ build_number: evaluate(ci_system['buildNumber'], env),
50
+ git: Cucumber::Messages::Git.new(
51
+ remote: remove_userinfo_from_url(evaluate(ci_system['git']['remote'], env)),
52
+ revision: evaluate(ci_system['git']['revision'], env),
53
+ branch: evaluate(ci_system['git']['branch'], env),
54
+ tag: evaluate(ci_system['git']['tag'], env)
55
+ )
56
+ )
57
57
  end
58
58
 
59
59
  def remove_userinfo_from_url(value)
60
60
  return nil if value.nil?
61
+
61
62
  begin
62
63
  uri = URI(value)
63
64
  uri.userinfo = ''
64
65
  uri.to_s
65
- rescue
66
+ rescue StandardError
66
67
  value
67
68
  end
68
69
  end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'cucumber/create_meta'
4
+ require 'json'
5
+
6
+ TEST_DATA_DIR = '../testdata'
7
+
8
+ describe 'CreateMeta' do
9
+ Dir.each_child(TEST_DATA_DIR) do |test_data_file|
10
+ next unless File.extname(test_data_file) == '.txt'
11
+
12
+ context "with #{File.basename(test_data_file, '.*')}" do
13
+ subject { JSON.parse(meta.ci.to_json) }
14
+
15
+ let(:meta) { Cucumber::CreateMeta.create_meta('cucumber-something', '1.2.3', env) }
16
+ let(:env) { Hash[entries] }
17
+ let(:entries) { env_data.split(/\n/).map { |line| line.split(/=/) } }
18
+ let(:env_data) { IO.read("#{TEST_DATA_DIR}/#{test_data_file}") }
19
+
20
+ let(:expected_json) { File.read("#{TEST_DATA_DIR}/#{test_data_file}.json") }
21
+
22
+ it { is_expected.to eq JSON.parse(expected_json) }
23
+ end
24
+ end
25
+ end
@@ -2,15 +2,35 @@ require 'cucumber/create_meta'
2
2
 
3
3
  describe 'create_meta' do
4
4
  it 'generates a Meta message with platform information' do
5
- meta = Cucumber::CreateMeta.create_meta('cucumba-ruby', 'X.Y.Z')
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
+ expect(meta.ci).to be_nil
16
+ end
17
+
18
+ it 'generates a Meta message with CI information' do
19
+ env = {
20
+ 'BUILD_URL' => 'url of the build',
21
+ 'BUILD_NUMBER' => '42',
22
+ 'GIT_URL' => 'url of git',
23
+ 'GIT_COMMIT' => 'git_sha1',
24
+ 'GIT_LOCAL_BRANCH' => 'main'
25
+ }
26
+
27
+ meta = Cucumber::CreateMeta.create_meta('cucumba-ruby', 'X.Y.Z', env)
28
+
29
+ expect(meta.ci).not_to be_nil
30
+ expect(meta.ci.url).to eq env['BUILD_URL']
31
+ expect(meta.ci.build_number).to eq env['BUILD_NUMBER']
32
+ expect(meta.ci.git.remote).to eq env['GIT_URL']
33
+ expect(meta.ci.git.revision).to eq env['GIT_COMMIT']
34
+ expect(meta.ci.git.branch).to eq env['GIT_LOCAL_BRANCH']
15
35
  end
16
36
  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: 6.0.0
4
+ version: 6.0.4
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-07-08 00:00:00.000000000 Z
11
+ date: 2021-11-16 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: '17.0'
19
+ version: '17.1'
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 17.0.0
22
+ version: 17.1.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: '17.0'
29
+ version: '17.1'
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: 17.0.0
32
+ version: 17.1.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.5
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.5
72
+ version: 13.0.6
73
73
  - !ruby/object:Gem::Dependency
74
74
  name: rspec
75
75
  requirement: !ruby/object:Gem::Requirement
@@ -100,19 +100,20 @@ files:
100
100
  - lib/cucumber/ciDict.json
101
101
  - lib/cucumber/create_meta.rb
102
102
  - lib/cucumber/create_meta/variable_expression.rb
103
+ - spec/acceptance/create_meta_spec.rb
103
104
  - spec/capture_warnings.rb
104
105
  - spec/cucumber/create_meta_spec.rb
105
106
  - spec/cucumber/evaluate_variable_expression_spec.rb
106
107
  - spec/cucumber/remove_userinfo_from_url_spec.rb
107
- homepage: https://github.com/cucumber/create-meta-ruby
108
+ homepage: https://github.com/cucumber/create-meta
108
109
  licenses:
109
110
  - MIT
110
111
  metadata:
111
- bug_tracker_uri: https://github.com/cucumber/cucumber/issues
112
- changelog_uri: https://github.com/cucumber/common/blob/main/gherkin/CHANGELOG.md
112
+ bug_tracker_uri: https://github.com/cucumber/create-meta/issues
113
+ changelog_uri: https://github.com/cucumber/create-meta/blob/main/CHANGELOG.md
113
114
  documentation_uri: https://cucumber.io/docs/gherkin/
114
115
  mailing_list_uri: https://groups.google.com/forum/#!forum/cukes
115
- source_code_uri: https://github.com/cucumber/common/blob/main/gherkin/ruby
116
+ source_code_uri: https://github.com/cucumber/create-meta/tree/main/ruby
116
117
  post_install_message:
117
118
  rdoc_options:
118
119
  - "--charset=UTF-8"
@@ -132,9 +133,10 @@ requirements: []
132
133
  rubygems_version: 3.1.2
133
134
  signing_key:
134
135
  specification_version: 4
135
- summary: cucumber-create-meta-6.0.0
136
+ summary: cucumber-create-meta-6.0.4
136
137
  test_files:
137
- - spec/capture_warnings.rb
138
+ - spec/acceptance/create_meta_spec.rb
138
139
  - spec/cucumber/remove_userinfo_from_url_spec.rb
139
140
  - spec/cucumber/evaluate_variable_expression_spec.rb
140
141
  - spec/cucumber/create_meta_spec.rb
142
+ - spec/capture_warnings.rb