site_prism-all_there 2.0.1 → 3.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: 30c5d744ba8f905404ca0528296024d8cde291be2e7608d2c50202c74990edbe
4
- data.tar.gz: 6f10c96510f93848b8ecb2088fb344c28d89a0e0059e686811dd076777d14e05
3
+ metadata.gz: 3508b03f4e5a02c0dd04ec670549bd2462b9c749de74373747ced1c10d2b1e5d
4
+ data.tar.gz: 198324b39aa2eb29bb622028e383446043dbd9f8352f545d78e3dd0f35dfc26f
5
5
  SHA512:
6
- metadata.gz: e8a8ec5769a6a32eb9b8c7475544a3d39491e35d4f30b38418e3b8eb59f5daa8b3de8a98ae0bb0d2aa8aa51166a53902db5d41d70750a76493c028c088ae9cdb
7
- data.tar.gz: d1d7abc5f369069f99681c8488aa1ee500c1ffdaf41702a7496b3292eff9769e8ddf5e11c4261b146691051f0b40ca8df8debb168ec486be5557ed1d6c17daa6
6
+ metadata.gz: 1bf75250e248cb6b07c69d88bf7742e79eb31bf6a8d8565d58587dfe93994bbcb292077182035c9d233b2c8e502bf366106003263d3e835120e3ee444f5e0d93
7
+ data.tar.gz: 4a92b0b0d433de1717634d3dcb32ebadce9ce492dfc69cd8efa9f00cf0c65d505615555400d731a323b0a7a2df567755847ba8f5426f1de58b4604124f12d104
@@ -19,63 +19,41 @@ module SitePrism
19
19
  # All defined/expected mapped items
20
20
  def array
21
21
  [
22
- element,
23
- elements,
22
+ mapped_checklist_of(:element),
23
+ mapped_checklist_of(:elements),
24
24
  section,
25
25
  sections,
26
- iframe
26
+ mapped_checklist_of(:iframe)
27
27
  ]
28
28
  end
29
29
 
30
- # @return [Array<Symbol>]
31
- # All defined/expected items that were mapped as +element+
32
- def element
33
- mapped_checklist_of(:element) || []
34
- end
35
-
36
- # @return [Array<Symbol>]
37
- # All defined/expected items that were mapped as +elements+
38
- def elements
39
- mapped_checklist_of(:elements) || []
40
- end
41
-
42
30
  # @return [Array<Symbol>]
43
31
  # All defined/expected items that were mapped as +section+
44
32
  def section
45
- mapped_checklist_of(:section) || []
33
+ mapped_checklist_of(:section)
46
34
  end
47
35
 
48
36
  # @return [Array<Symbol>]
49
37
  # All defined/expected items that were mapped as +sections+
50
38
  def sections
51
- mapped_checklist_of(:sections) || []
52
- end
53
-
54
- # @return [Array<Symbol>]
55
- # All defined/expected items that were mapped as +iframe+
56
- def iframe
57
- mapped_checklist_of(:iframe) || []
39
+ mapped_checklist_of(:sections)
58
40
  end
59
41
 
60
42
  private
61
43
 
62
44
  def mapped_checklist_of(type)
63
- mapped_items.hash[type]&.select { |name| mapped_checklist.include?(name) }
45
+ mapped_items.hash[type] & mapped_checklist
64
46
  end
65
47
 
66
48
  def mapped_checklist
67
- if expected_items
49
+ if instance.class.expected_items
68
50
  SitePrism.logger.debug('Expected Items has been set.')
69
- mapped_items.array.select { |name| expected_items.include?(name) }
51
+ mapped_items.array & instance.class.expected_items
70
52
  else
71
53
  mapped_items.array
72
54
  end
73
55
  end
74
56
 
75
- def expected_items
76
- instance.class.expected_items
77
- end
78
-
79
57
  def mapped_items
80
58
  @mapped_items ||= MappedItems.new(instance)
81
59
  end
@@ -8,11 +8,12 @@ module SitePrism
8
8
  # The Expected Items on a SitePrism Page or Section structured in an enumerable way
9
9
  #
10
10
  class MappedItems
11
- attr_reader :instance
12
- private :instance
11
+ attr_reader :hash
13
12
 
13
+ # @return [Hash]
14
+ # Return a list of all mapped items on a SitePrism class instance (Page or Section)
14
15
  def initialize(instance)
15
- @instance = instance
16
+ @hash = instance.class.mapped_items
16
17
  end
17
18
 
18
19
  # @return [Array<Symbol>]
@@ -20,12 +21,6 @@ module SitePrism
20
21
  def array
21
22
  hash.values.flatten.uniq
22
23
  end
23
-
24
- # @return [Hash<Symbol>]
25
- # All expected mapped items on the SitePrism instance as a Symbol Hash
26
- def hash
27
- instance.class.mapped_items
28
- end
29
24
  end
30
25
  end
31
26
  end
@@ -3,8 +3,9 @@
3
3
  module SitePrism
4
4
  module AllThere
5
5
  #
6
- # This will recurse through all of the objects found on an individual Page/Section level
6
+ # @api private
7
7
  #
8
+ # This will recurse through all of the objects found on an individual Page/Section level
8
9
  # It will perform the `#all_there?` check on each `@instance` item that it is initialized with
9
10
  #
10
11
  class RecursionChecker
@@ -15,40 +16,39 @@ module SitePrism
15
16
  @instance = instance
16
17
  end
17
18
 
18
- # @return [Boolean]
19
- # This currently defaults to perform a recursion of depth +:one+ (From the main `site_prism` gem)
20
- # It will be refactored to use either no input, +:none+, or +:one+ as the regular repo uses currently
21
- def all_there?(recursion:)
22
- recursion = SitePrism.recursion_setting if SitePrism.recursion_setting
19
+ # @return [Boolean || Nil]
20
+ # This is only meant to be invoked from the main site_prism gem where it will use whatever inputs it is given
21
+ def all_there?(recursion: nil, options: {})
22
+ setting = recursion || SitePrism.recursion_setting
23
23
 
24
- case recursion
25
- when :none
26
- current_class_all_there?
24
+ case setting
25
+ when nil, :none
26
+ current_class_all_there?(options)
27
27
  when :one
28
- current_class_all_there? && section_classes_all_there? && sections_classes_all_there?
28
+ current_class_all_there?(options) && section_classes_all_there?(options) && sections_classes_all_there?(options)
29
29
  else
30
- SitePrism.logger.debug("Input value '#{recursion}'. Valid values are :none or :one.")
30
+ SitePrism.logger.debug("Invalid input value '#{recursion}'. Valid values are nil, :none or :one.")
31
31
  SitePrism.logger.error('Invalid recursion setting, Will not run #all_there?.')
32
32
  end
33
33
  end
34
34
 
35
35
  private
36
36
 
37
- def current_class_all_there?
38
- expected_items.array.flatten.all? { |name| there?(name) }.tap do |result|
37
+ def current_class_all_there?(**opts)
38
+ expected_items.array.flatten.all? { |name| there?(name, opts) }.tap do |result|
39
39
  SitePrism.logger.info("Result of current_class_all_there?: #{result}")
40
40
  end
41
41
  end
42
42
 
43
- def section_classes_all_there?
44
- section_classes_to_check.all?(&:all_there?).tap do |result|
43
+ def section_classes_all_there?(**opts)
44
+ section_classes_to_check.all? { |section| section.all_there?(opts) }.tap do |result|
45
45
  SitePrism.logger.debug("Result of section_classes_all_there?: #{result}")
46
46
  end
47
47
  end
48
48
 
49
- def sections_classes_all_there?
50
- sections_classes_to_check.flatten.all?(&:all_there?).tap do |result|
51
- SitePrism.logger.debug("Result of section_classes_all_there?: #{result}")
49
+ def sections_classes_all_there?(**opts)
50
+ sections_classes_to_check.flatten.all? { |section| section.all_there?(opts) }.tap do |result|
51
+ SitePrism.logger.debug("Result of sections_classes_all_there?: #{result}")
52
52
  end
53
53
  end
54
54
 
@@ -64,8 +64,8 @@ module SitePrism
64
64
  @expected_items ||= ExpectedItems.new(instance)
65
65
  end
66
66
 
67
- def there?(name)
68
- instance.send("has_#{name}?")
67
+ def there?(name, **opts)
68
+ instance.send("has_#{name}?", opts)
69
69
  end
70
70
  end
71
71
  end
@@ -4,6 +4,6 @@ module SitePrism
4
4
  module AllThere
5
5
  # @return [String]
6
6
  # Version of the gem
7
- VERSION = '2.0.1'
7
+ VERSION = '3.0'
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: site_prism-all_there
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: '3.0'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luke Hill
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-01 00:00:00.000000000 Z
11
+ date: 2023-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -125,14 +125,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
125
125
  requirements:
126
126
  - - ">="
127
127
  - !ruby/object:Gem::Version
128
- version: '2.6'
128
+ version: '2.7'
129
129
  required_rubygems_version: !ruby/object:Gem::Requirement
130
130
  requirements:
131
131
  - - ">="
132
132
  - !ruby/object:Gem::Version
133
133
  version: '0'
134
134
  requirements: []
135
- rubygems_version: 3.4.13
135
+ rubygems_version: 3.1.6
136
136
  signing_key:
137
137
  specification_version: 4
138
138
  summary: An extension to allow you to recurse through your SitePrism Pages/Sections