site_prism-all_there 1.1 → 2.0.1

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: e5f8bcaddc7bda74aa9d9da8b7c8fdc302a5ab558e873bb0709886eeb172d30a
4
- data.tar.gz: 72e50de6892de244daa9f073db6a97e0c0b7f633e8fa33d540f8a49576307ec0
3
+ metadata.gz: 30c5d744ba8f905404ca0528296024d8cde291be2e7608d2c50202c74990edbe
4
+ data.tar.gz: 6f10c96510f93848b8ecb2088fb344c28d89a0e0059e686811dd076777d14e05
5
5
  SHA512:
6
- metadata.gz: 00f2faaff2b43479484dd45fb2f5638964e202af40f9584101bc8956f07da8122625beb213f62300bcbe02a44a29bdb1ca11fe9c40a3512e6bb1473069772e1a
7
- data.tar.gz: 38a66bd748671fe71e20f5bd4da0934ac25db52b4d59870b84b7d9458c86435f29f40420a40c48b2bfc3dcf3f1f3b0a9ecc7485e3fc3a2b442c78a32ea2899ed
6
+ metadata.gz: e8a8ec5769a6a32eb9b8c7475544a3d39491e35d4f30b38418e3b8eb59f5daa8b3de8a98ae0bb0d2aa8aa51166a53902db5d41d70750a76493c028c088ae9cdb
7
+ data.tar.gz: d1d7abc5f369069f99681c8488aa1ee500c1ffdaf41702a7496b3292eff9769e8ddf5e11c4261b146691051f0b40ca8df8debb168ec486be5557ed1d6c17daa6
data/LICENSE.md CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2019-2021, The SitePrism team
1
+ Copyright (c) 2019-2023, The SitePrism team
2
2
 
3
3
  All rights reserved.
4
4
 
data/README.md CHANGED
@@ -1,30 +1,59 @@
1
1
  # site_prism-all_there
2
+ - [History](#history)
3
+ - [Enabling gem methods](#enabling-gem-methods)
4
+ - [Usage](#usage)
5
+ - [In-line configuration](#in-line-configuration)
6
+ - [Global configuration](#global-configuration)
7
+ - [Troubleshooting](#troubleshooting)
2
8
 
3
- The breakout gem from SitePrism to perform recursion checks for `#all_there?`
9
+ ## History
10
+
11
+ This in the breakout gem from SitePrism to perform recursion checks for `#all_there?`
4
12
 
5
13
  This gem is a breakout of the current `SitePrism::Page#all_there?` and `SitePrism::Section#all_there?`
6
- methods which already exist in the core gem proper.
14
+ methods which have already existed in the gem since version 2
15
+
16
+ The gem is **now finally** version stable. It is now default functionality in `site_prism` version 4
17
+
18
+ ## Enabling gem methods
7
19
 
8
- The gem is currently released as `1.0.1` meaning it is version stable. It will be added as default
9
- functionality in `site_prism` version 4. Which is slated for release early 2023!
20
+ The gem methods are now (by default), enabled with `site_prism` version 4 and above
10
21
 
11
22
  ## Usage
12
23
 
13
- - Add the following code to either `spec_helper.rb` or `env.rb` (Pre version 4)
14
- - From version 4 onwards this is done by default and isn't required
24
+ ### In-line configuration
15
25
 
16
26
  ```rb
17
- require 'site_prism/all_there'
27
+ your_page = YourPage.new
18
28
 
19
- SitePrism.use_all_there_gem = true
29
+ your_page.all_there?(recursion: :none) # This will do the standard `#all_there?` check on the current page
30
+ your_page.all_there?(recursion: :one) # This will do the standard `#all_there?` check on the current page as well recursing into all `:section` or `:sections` objects and then doing the standard `#all_there?` check on those `Section` instances
31
+ your_page.all_there?(recursion: :invalid) # This will not perform any checks and just log an error
32
+ ```
33
+
34
+ ### Global configuration
35
+
36
+ ```rb
37
+ SitePrism.recursion_setting = :one
38
+ your_page = YourPage.new
39
+ your_page.all_there?(recursion: :ignore) # This will do the standard `#all_there?` check on the current page as well recursing into all `:section` or `:sections` objects and then doing the standard `#all_there?` check on those sections
20
40
 
21
41
  # or...
22
42
 
23
43
  SitePrism.configure do |config|
24
- config.use_all_there_gem = true
44
+ config.recursion_setting = :one
25
45
  end
46
+
47
+ your_page = YourPage.new
48
+ your_page.all_there?(recursion: :ignore) # This will do the standard `#all_there?` check on the current page as well recursing into all `:section` or `:sections` objects and then doing the standard `#all_there?` check on those `Section` instances
26
49
  ```
27
50
 
51
+ Then you can perform the above checks using the global config.
52
+
53
+ ## Troubleshooting
54
+
55
+ **Mixing and matching the global config won't work - To come in v3!**
56
+
28
57
  Happy Testing / Developing!
29
58
 
30
59
  The SitePrism team
@@ -6,6 +6,7 @@ module SitePrism
6
6
  # @api private
7
7
  #
8
8
  # The Expected Items to be present on a SitePrism Page or Section
9
+ #
9
10
  class ExpectedItems
10
11
  attr_reader :instance
11
12
  private :instance
@@ -15,43 +16,43 @@ module SitePrism
15
16
  end
16
17
 
17
18
  # @return [Array<Array<Symbol>>]
18
- # All expected mapped items
19
+ # All defined/expected mapped items
19
20
  def array
20
21
  [
21
22
  element,
22
23
  elements,
23
24
  section,
24
25
  sections,
25
- iframe,
26
+ iframe
26
27
  ]
27
28
  end
28
29
 
29
30
  # @return [Array<Symbol>]
30
- # All expected items that were mapped as +element+
31
+ # All defined/expected items that were mapped as +element+
31
32
  def element
32
33
  mapped_checklist_of(:element) || []
33
34
  end
34
35
 
35
36
  # @return [Array<Symbol>]
36
- # All expected items that were mapped as +elements+
37
+ # All defined/expected items that were mapped as +elements+
37
38
  def elements
38
39
  mapped_checklist_of(:elements) || []
39
40
  end
40
41
 
41
42
  # @return [Array<Symbol>]
42
- # All expected items that were mapped as +section+
43
+ # All defined/expected items that were mapped as +section+
43
44
  def section
44
45
  mapped_checklist_of(:section) || []
45
46
  end
46
47
 
47
48
  # @return [Array<Symbol>]
48
- # All expected items that were mapped as +sections+
49
+ # All defined/expected items that were mapped as +sections+
49
50
  def sections
50
51
  mapped_checklist_of(:sections) || []
51
52
  end
52
53
 
53
54
  # @return [Array<Symbol>]
54
- # All expected items that were mapped as +iframe+
55
+ # All defined/expected items that were mapped as +iframe+
55
56
  def iframe
56
57
  mapped_checklist_of(:iframe) || []
57
58
  end
@@ -63,15 +64,15 @@ module SitePrism
63
64
  end
64
65
 
65
66
  def mapped_checklist
66
- if checklist
67
+ if expected_items
67
68
  SitePrism.logger.debug('Expected Items has been set.')
68
- mapped_items.array.select { |name| checklist.include?(name) }
69
+ mapped_items.array.select { |name| expected_items.include?(name) }
69
70
  else
70
71
  mapped_items.array
71
72
  end
72
73
  end
73
74
 
74
- def checklist
75
+ def expected_items
75
76
  instance.class.expected_items
76
77
  end
77
78
 
@@ -6,6 +6,7 @@ module SitePrism
6
6
  # @api private
7
7
  #
8
8
  # The Expected Items on a SitePrism Page or Section structured in an enumerable way
9
+ #
9
10
  class MappedItems
10
11
  attr_reader :instance
11
12
  private :instance
@@ -23,7 +24,7 @@ module SitePrism
23
24
  # @return [Hash<Symbol>]
24
25
  # All expected mapped items on the SitePrism instance as a Symbol Hash
25
26
  def hash
26
- instance.class.mapped_items(legacy: false)
27
+ instance.class.mapped_items
27
28
  end
28
29
  end
29
30
  end
@@ -2,8 +2,11 @@
2
2
 
3
3
  module SitePrism
4
4
  module AllThere
5
- # Recurse through all of the objects found on an individual Page/Section
6
- # Perform the all_there? check according to what recursion level is specified
5
+ #
6
+ # This will recurse through all of the objects found on an individual Page/Section level
7
+ #
8
+ # It will perform the `#all_there?` check on each `@instance` item that it is initialized with
9
+ #
7
10
  class RecursionChecker
8
11
  attr_reader :instance
9
12
  private :instance
@@ -13,39 +16,36 @@ module SitePrism
13
16
  end
14
17
 
15
18
  # @return [Boolean]
16
- # This currently defaults to perform a recursion of depth +:one+
17
- # It will be refactored to use either no input, +:none+, or +:one+ as the
18
- # regular repo uses currently
19
- def all_there?(recursion: :one)
20
- if recursion == :one || SitePrism.recursion_setting == :one
21
- current_class_all_there? &&
22
- section_classes_all_there? &&
23
- sections_classes_all_there?
24
- else
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
23
+
24
+ case recursion
25
+ when :none
25
26
  current_class_all_there?
27
+ when :one
28
+ current_class_all_there? && section_classes_all_there? && sections_classes_all_there?
29
+ else
30
+ SitePrism.logger.debug("Input value '#{recursion}'. Valid values are :none or :one.")
31
+ SitePrism.logger.error('Invalid recursion setting, Will not run #all_there?.')
26
32
  end
27
33
  end
28
34
 
29
35
  private
30
36
 
31
- # @return [Boolean]
32
- # Are all SitePrism objects that exist in +self+ present?
33
37
  def current_class_all_there?
34
38
  expected_items.array.flatten.all? { |name| there?(name) }.tap do |result|
35
39
  SitePrism.logger.info("Result of current_class_all_there?: #{result}")
36
40
  end
37
41
  end
38
42
 
39
- # @return [Boolean]
40
- # Are all SitePrism objects that exist in all +self.section+ items present?
41
43
  def section_classes_all_there?
42
44
  section_classes_to_check.all?(&:all_there?).tap do |result|
43
45
  SitePrism.logger.debug("Result of section_classes_all_there?: #{result}")
44
46
  end
45
47
  end
46
48
 
47
- # @return [Boolean]
48
- # Are all SitePrism objects that exist in all +self.sections+ items present?
49
49
  def sections_classes_all_there?
50
50
  sections_classes_to_check.flatten.all?(&:all_there?).tap do |result|
51
51
  SitePrism.logger.debug("Result of section_classes_all_there?: #{result}")
@@ -4,6 +4,6 @@ module SitePrism
4
4
  module AllThere
5
5
  # @return [String]
6
6
  # Version of the gem
7
- VERSION = '1.1'
7
+ VERSION = '2.0.1'
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: '1.1'
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luke Hill
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-07 00:00:00.000000000 Z
11
+ date: 2023-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -30,62 +30,56 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.39.0
33
+ version: 1.50.2
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 1.39.0
40
+ version: 1.50.2
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rubocop-performance
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.15.1
47
+ version: 1.17.1
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 1.15.1
54
+ version: 1.17.1
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rubocop-rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 2.15.0
61
+ version: 2.20.0
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 2.15.0
68
+ version: 2.20.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: site_prism
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">"
74
- - !ruby/object:Gem::Version
75
- version: '3.7'
76
- - - "<"
73
+ - - "~>"
77
74
  - !ruby/object:Gem::Version
78
- version: '5'
75
+ version: '4.0'
79
76
  type: :development
80
77
  prerelease: false
81
78
  version_requirements: !ruby/object:Gem::Requirement
82
79
  requirements:
83
- - - ">"
84
- - !ruby/object:Gem::Version
85
- version: '3.7'
86
- - - "<"
80
+ - - "~>"
87
81
  - !ruby/object:Gem::Version
88
- version: '5'
82
+ version: '4.0'
89
83
  - !ruby/object:Gem::Dependency
90
84
  name: yard
91
85
  requirement: !ruby/object:Gem::Requirement
@@ -101,8 +95,8 @@ dependencies:
101
95
  - !ruby/object:Gem::Version
102
96
  version: '0.9'
103
97
  description: |-
104
- SitePrism AllThere gives you a simple DSL in order to recursively query,
105
- page/section/element structures on your page - exclusively for use with the SitePrism gem.
98
+ SitePrism AllThere allows you to recursively query page and section structures
99
+ on your page - exclusively for use with the SitePrism gem.
106
100
  email:
107
101
  - lukehill_uk@hotmail.com
108
102
  executables: []
@@ -138,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
132
  - !ruby/object:Gem::Version
139
133
  version: '0'
140
134
  requirements: []
141
- rubygems_version: 3.0.3.1
135
+ rubygems_version: 3.4.13
142
136
  signing_key:
143
137
  specification_version: 4
144
138
  summary: An extension to allow you to recurse through your SitePrism Pages/Sections