lopata 0.1.11 → 0.1.12

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
  SHA256:
3
- metadata.gz: d30e71eec70c684f9d576aafa08ddac0a63e1e0615c0127dc31791592ccc833f
4
- data.tar.gz: 88f921909bf2e3e7d34c3c6460630d0ae9e87f2ffb4c906916d92f1959df1f59
3
+ metadata.gz: 65f89b815ebe8514f78c803eab2bd2ece867e9fcdc9c28c178a721d717fd0341
4
+ data.tar.gz: c418371982133703b0b97921fd870937052854e6975b4bb47f664105c56ed6b6
5
5
  SHA512:
6
- metadata.gz: e1bd2c858bd6f25e395ff74cad7e1af577a56346a7114ff2baa0cd6818294e148a1b8b91eb9c1219cca7359fa415720c01ffa7dd3c99012963114114aecb9ff3
7
- data.tar.gz: 6c8e08f4148a47b69d40d16b5bf6ef3b6450adb5dc2c41ea9d728fe10d1fd9ffb87a2e07894a2576329b74b505050fe7f8d2c14ddf3ed7e52124242a81b7820d
6
+ metadata.gz: d54572c90bfdaea0aa91747541016d0d0b1ac1710a9d9a54c8278861643a07f5a8ea7157206a85cbaf3f3986c0dbabd14bfa741a5ce7eb7deb6bd2917d2d6b89
7
+ data.tar.gz: 3d82e45bd0fd6c2901c65a4a07437a27df8b8367e1682a67b191f4829bb6bf2a11b583f319804e560e08774f806c675d82547bdb87fec623a1d6fb143d9d2b72
@@ -45,6 +45,24 @@ module Lopata
45
45
  def as(*args, &block)
46
46
  @roles = args.flatten
47
47
  @roles << Lopata::ScenarioBuilder::CalculatedValue.new(&block) if block_given?
48
+ @use_all_roles = true
49
+ @role_options = nil
50
+ end
51
+
52
+ # Enumerate the roles the scenario can be run.
53
+ #
54
+ # The scenario should be set to use the role via before_scenario step using #current_role param.
55
+ #
56
+ # Only first role will be used if scenario has no options or diagonales. Some first roles will be used if
57
+ # options or diagonales are declared, in order of appearence.
58
+ #
59
+ # Use this to describe possible roles, but not needed to run scenario with all of them in order to save time
60
+ # of running.
61
+ #
62
+ # @param args [Array<Symbol>] list of roles the scenario to be runned with.
63
+ def as_first(*args, &block)
64
+ @roles = args.flatten
65
+ @use_all_roles = false
48
66
  @role_options = nil
49
67
  end
50
68
 
@@ -69,7 +87,8 @@ module Lopata
69
87
  # @private
70
88
  def build_role_options
71
89
  return [] unless roles
72
- [Lopata::ScenarioBuilder::Diagonal.new(:as, roles.map { |r| [Lopata.configuration.role_descriptions[r], r] })]
90
+ role_variants = roles.map { |r| [Lopata.configuration.role_descriptions[r], r] }
91
+ [Lopata::ScenarioBuilder::Diagonal.new(:as, role_variants, @use_all_roles)]
73
92
  end
74
93
 
75
94
  # @private
@@ -448,8 +448,8 @@ class Lopata::ScenarioBuilder
448
448
 
449
449
  # @private
450
450
  class Option
451
- attr_reader :variants, :key
452
- def initialize(key, variants)
451
+ attr_reader :variants, :key, :use_all_variants
452
+ def initialize(key, variants, use_all_variants = true)
453
453
  @key = key
454
454
  @variants =
455
455
  if variants.is_a? Hash
@@ -458,6 +458,7 @@ class Lopata::ScenarioBuilder
458
458
  # Array of arrays of two elements
459
459
  variants.map { |v| Variant.new(self, key, *v) }
460
460
  end
461
+ @use_all_variants = use_all_variants
461
462
  end
462
463
 
463
464
  # Variants to apply at one level
@@ -469,6 +470,7 @@ class Lopata::ScenarioBuilder
469
470
  @current ||= 0
470
471
  selected_variant = variants[@current]
471
472
  @current += 1
473
+ @complete = true unless use_all_variants # not need to verify all variants, just use first ones.
472
474
  if @current >= variants.length
473
475
  @current = 0
474
476
  @complete = true # all variants have been selected
@@ -1,6 +1,6 @@
1
1
  module Lopata
2
2
  # @private
3
3
  module Version
4
- STRING = '0.1.11'
4
+ STRING = '0.1.12'
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lopata
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.11
4
+ version: 0.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexey Volochnev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-01-19 00:00:00.000000000 Z
11
+ date: 2021-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -138,5 +138,5 @@ requirements: []
138
138
  rubygems_version: 3.0.3
139
139
  signing_key:
140
140
  specification_version: 4
141
- summary: lopata-0.1.11
141
+ summary: lopata-0.1.12
142
142
  test_files: []