site_prism-all_there 0.2 → 1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -7
- data/lib/site_prism/all_there.rb +7 -3
- data/lib/site_prism/all_there/expected_items.rb +83 -0
- data/lib/site_prism/all_there/mapped_items.rb +6 -4
- data/lib/site_prism/all_there/recursion_checker.rb +21 -41
- data/lib/site_prism/all_there/version.rb +3 -1
- metadata +44 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dfdb2e58753050c18dafb4f340680c2b0457eac8e14df383ea489f0d54d43732
|
4
|
+
data.tar.gz: 89adfcebffec1dcea1354ce4d34c2836d87346807569759ff5e5c7e9b151bdf8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2db1c79b4ed2c79920d4f230b494e6de494d6a476d8ba688e1bcac3993cb4cbf48a65e7b12eb65303e220016574bb497f2289b198d1b052635cce488799cb298
|
7
|
+
data.tar.gz: af7bc4602c1ac4e49da866a4f1ef75ac4a247c578f567d894936c100aa4b6be5ea23899a7e836df4fe7d28c1a548cdfe72199a24d225f4b5c7c8dc2250d9f2b6
|
data/README.md
CHANGED
@@ -1,17 +1,18 @@
|
|
1
1
|
# site_prism-all_there
|
2
|
+
|
2
3
|
The breakout gem from SitePrism to perform recursion checks for `#all_there?`
|
3
4
|
|
4
|
-
This gem is
|
5
|
-
|
5
|
+
This gem is a breakout of the current `SitePrism::Page#all_there?` and `SitePrism::Section#all_there?`
|
6
|
+
methods which already exist.
|
6
7
|
|
7
|
-
|
8
|
+
At the moment, the gem is currently released as a `0.x` version meaning it is **not** fully API stable.
|
8
9
|
|
9
|
-
|
10
|
+
## Usage
|
10
11
|
|
11
12
|
Add the following code to either `spec_helper.rb` or `env.rb`
|
12
13
|
|
13
14
|
```rb
|
14
|
-
require 'site_prism/all_there
|
15
|
+
require 'site_prism/all_there'
|
15
16
|
|
16
17
|
SitePrism.use_all_there_gem = true
|
17
18
|
|
@@ -22,8 +23,7 @@ SitePrism.configure do |config|
|
|
22
23
|
end
|
23
24
|
```
|
24
25
|
|
25
|
-
This gem is
|
26
|
-
structure going forwards, to conform to the pairing of both gems.
|
26
|
+
This gem is likely to change structure going forwards, to conform to the pairing of both gems, expected in 2020.
|
27
27
|
|
28
28
|
Happy Testing / Developing!
|
29
29
|
|
data/lib/site_prism/all_there.rb
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'site_prism/all_there/expected_items'
|
3
4
|
require 'site_prism/all_there/mapped_items'
|
4
5
|
require 'site_prism/all_there/recursion_checker'
|
5
6
|
|
6
|
-
#
|
7
|
+
# {SitePrism} namespace - In different folder to avoid namespace clashes with core gem
|
7
8
|
module SitePrism
|
8
9
|
class << self
|
9
|
-
# Configuration setting to use on a global scale
|
10
|
-
# Note this global setting can be overridden at runtime for each individual call
|
11
10
|
attr_accessor :recursion_setting
|
12
11
|
|
13
12
|
def configure
|
@@ -15,3 +14,8 @@ module SitePrism
|
|
15
14
|
end
|
16
15
|
end
|
17
16
|
end
|
17
|
+
|
18
|
+
module SitePrism
|
19
|
+
# {SitePrism::AllThere} namespace
|
20
|
+
module AllThere; end
|
21
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SitePrism
|
4
|
+
module AllThere
|
5
|
+
#
|
6
|
+
# @api private
|
7
|
+
#
|
8
|
+
# The Expected Items to be present on a SitePrism Page or Section
|
9
|
+
class ExpectedItems
|
10
|
+
attr_reader :instance
|
11
|
+
private :instance
|
12
|
+
|
13
|
+
def initialize(instance)
|
14
|
+
@instance = instance
|
15
|
+
end
|
16
|
+
|
17
|
+
# @return [Array<Hash<Symbol>>]
|
18
|
+
# All expected mapped items
|
19
|
+
def array
|
20
|
+
[
|
21
|
+
element,
|
22
|
+
elements,
|
23
|
+
section,
|
24
|
+
sections,
|
25
|
+
iframe,
|
26
|
+
]
|
27
|
+
end
|
28
|
+
|
29
|
+
# @return [Hash<Symbol>]
|
30
|
+
# All expected items that were mapped as +element+
|
31
|
+
def element
|
32
|
+
mapped_checklist_of(:element)
|
33
|
+
end
|
34
|
+
|
35
|
+
# @return [Hash<Symbol>]
|
36
|
+
# All expected items that were mapped as +elements+
|
37
|
+
def elements
|
38
|
+
mapped_checklist_of(:elements)
|
39
|
+
end
|
40
|
+
|
41
|
+
# @return [Hash<Symbol>]
|
42
|
+
# All expected items that were mapped as +section+
|
43
|
+
def section
|
44
|
+
mapped_checklist_of(:section)
|
45
|
+
end
|
46
|
+
|
47
|
+
# @return [Hash<Symbol>]
|
48
|
+
# All expected items that were mapped as +sections+
|
49
|
+
def sections
|
50
|
+
mapped_checklist_of(:sections)
|
51
|
+
end
|
52
|
+
|
53
|
+
# @return [Hash<Symbol>]
|
54
|
+
# All expected items that were mapped as +iframe+
|
55
|
+
def iframe
|
56
|
+
mapped_checklist_of(:iframe)
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def mapped_checklist_of(type)
|
62
|
+
mapped_items.hash[type].select { |name| mapped_checklist.include?(name) }
|
63
|
+
end
|
64
|
+
|
65
|
+
def mapped_checklist
|
66
|
+
if checklist
|
67
|
+
SitePrism.logger.debug('Expected Items has been set.')
|
68
|
+
mapped_items.array.select { |name| checklist.include?(name) }
|
69
|
+
else
|
70
|
+
mapped_items.array
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def checklist
|
75
|
+
instance.class.expected_items
|
76
|
+
end
|
77
|
+
|
78
|
+
def mapped_items
|
79
|
+
@mapped_items ||= MappedItems.new(instance)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -2,10 +2,10 @@
|
|
2
2
|
|
3
3
|
module SitePrism
|
4
4
|
module AllThere
|
5
|
-
# Returns the Mapped Items on a specific SitePrism object
|
6
5
|
#
|
7
|
-
# api private
|
6
|
+
# @api private
|
8
7
|
#
|
8
|
+
# The Expected Items on a SitePrism Page or Section structured in an enumerable way
|
9
9
|
class MappedItems
|
10
10
|
attr_reader :instance
|
11
11
|
private :instance
|
@@ -14,12 +14,14 @@ module SitePrism
|
|
14
14
|
@instance = instance
|
15
15
|
end
|
16
16
|
|
17
|
-
#
|
17
|
+
# @return [Array<Symbol>]
|
18
|
+
# All expected mapped items on the SitePrism instance as a Symbol Array
|
18
19
|
def array
|
19
20
|
hash.values.flatten.uniq
|
20
21
|
end
|
21
22
|
|
22
|
-
#
|
23
|
+
# @return [Hash<Symbol>]
|
24
|
+
# All expected mapped items on the SitePrism instance as a Symbol Hash
|
23
25
|
def hash
|
24
26
|
instance.class.mapped_items(legacy: false)
|
25
27
|
end
|
@@ -12,7 +12,8 @@ module SitePrism
|
|
12
12
|
@instance = instance
|
13
13
|
end
|
14
14
|
|
15
|
-
#
|
15
|
+
# @return [Boolean]
|
16
|
+
# This currently defaults to perform a recursion of depth +:one+
|
16
17
|
# It will be refactored to use either no input, +:none+, or +:one+ as the
|
17
18
|
# regular repo uses currently
|
18
19
|
def all_there?(recursion: :one)
|
@@ -27,61 +28,40 @@ module SitePrism
|
|
27
28
|
|
28
29
|
private
|
29
30
|
|
30
|
-
#
|
31
|
-
#
|
31
|
+
# @return [Boolean]
|
32
|
+
# Are all SitePrism objects that exist in +self+ present?
|
32
33
|
def current_class_all_there?
|
33
|
-
|
34
|
+
expected_items.array.flatten.all? { |name| there?(name) }.tap do |result|
|
35
|
+
SitePrism.logger.info("Result of current_class_all_there?: #{result}")
|
36
|
+
end
|
34
37
|
end
|
35
38
|
|
36
|
-
#
|
37
|
-
#
|
39
|
+
# @return [Boolean]
|
40
|
+
# Are all SitePrism objects that exist in all +self.section+ items present?
|
38
41
|
def section_classes_all_there?
|
39
|
-
section_classes_to_check.all?(&:all_there?)
|
42
|
+
section_classes_to_check.all?(&:all_there?).tap do |result|
|
43
|
+
SitePrism.logger.debug("Result of section_classes_all_there?: #{result}")
|
44
|
+
end
|
40
45
|
end
|
41
46
|
|
42
|
-
#
|
43
|
-
#
|
47
|
+
# @return [Boolean]
|
48
|
+
# Are all SitePrism objects that exist in all +self.sections+ items present?
|
44
49
|
def sections_classes_all_there?
|
45
|
-
sections_classes_to_check.flatten.all?(&: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}")
|
52
|
+
end
|
46
53
|
end
|
47
54
|
|
48
55
|
def section_classes_to_check
|
49
|
-
|
56
|
+
expected_items.section.map { |name| instance.send(name) }
|
50
57
|
end
|
51
58
|
|
52
59
|
def sections_classes_to_check
|
53
|
-
|
54
|
-
end
|
55
|
-
|
56
|
-
def expected_item_map
|
57
|
-
[
|
58
|
-
expected(:element),
|
59
|
-
expected(:elements),
|
60
|
-
expected(:section),
|
61
|
-
expected(:sections),
|
62
|
-
expected(:iframe),
|
63
|
-
]
|
64
|
-
end
|
65
|
-
|
66
|
-
def expected(type)
|
67
|
-
MappedItems.new(instance).hash[type].select { |name| elements_to_check.include?(name) }
|
68
|
-
end
|
69
|
-
|
70
|
-
# If the page or section has expected_items set, return expected_items that are mapped
|
71
|
-
# otherwise just return the list of all mapped_items
|
72
|
-
def elements_to_check
|
73
|
-
if _expected_items
|
74
|
-
SitePrism.logger.debug('Expected Items has been set.')
|
75
|
-
MappedItems.new(instance).array.select do |name|
|
76
|
-
_expected_items.include?(name)
|
77
|
-
end
|
78
|
-
else
|
79
|
-
MappedItems.new(instance).array
|
80
|
-
end
|
60
|
+
expected_items.sections.map { |name| instance.send(name) }
|
81
61
|
end
|
82
62
|
|
83
|
-
def
|
84
|
-
instance
|
63
|
+
def expected_items
|
64
|
+
@expected_items ||= ExpectedItems.new(instance)
|
85
65
|
end
|
86
66
|
|
87
67
|
def there?(name)
|
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: '0
|
4
|
+
version: '1.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:
|
11
|
+
date: 2021-03-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -16,70 +16,98 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '13.0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '13.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '3.
|
33
|
+
version: '3.10'
|
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: '3.
|
40
|
+
version: '3.10'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rubocop
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 1.6.0
|
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:
|
54
|
+
version: 1.6.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rubocop-performance
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.
|
61
|
+
version: 1.10.2
|
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: 1.
|
68
|
+
version: 1.10.2
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop-rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 2.1.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 2.1.0
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: site_prism
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
87
|
- - "~>"
|
74
88
|
- !ruby/object:Gem::Version
|
75
|
-
version: '3.
|
89
|
+
version: '3.7'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.7'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: yard
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.9'
|
76
104
|
type: :development
|
77
105
|
prerelease: false
|
78
106
|
version_requirements: !ruby/object:Gem::Requirement
|
79
107
|
requirements:
|
80
108
|
- - "~>"
|
81
109
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
110
|
+
version: '0.9'
|
83
111
|
description: |-
|
84
112
|
SitePrism AllThere gives you a simple DSL in order to recursively query,
|
85
113
|
page/section/element structures on your page - exclusively for use with the SitePrism gem.
|
@@ -92,6 +120,7 @@ files:
|
|
92
120
|
- LICENSE.md
|
93
121
|
- README.md
|
94
122
|
- lib/site_prism/all_there.rb
|
123
|
+
- lib/site_prism/all_there/expected_items.rb
|
95
124
|
- lib/site_prism/all_there/mapped_items.rb
|
96
125
|
- lib/site_prism/all_there/recursion_checker.rb
|
97
126
|
- lib/site_prism/all_there/version.rb
|
@@ -100,7 +129,7 @@ licenses:
|
|
100
129
|
- BSD-3-Clause
|
101
130
|
metadata:
|
102
131
|
bug_tracker_uri: https://github.com/site-prism/site_prism-all_there/issues
|
103
|
-
changelog_uri: https://github.com/site-prism/site_prism-all_there/blob/
|
132
|
+
changelog_uri: https://github.com/site-prism/site_prism-all_there/blob/main/CHANGELOG.md
|
104
133
|
source_code_uri: https://github.com/site-prism/site_prism-all_there
|
105
134
|
post_install_message:
|
106
135
|
rdoc_options: []
|
@@ -110,15 +139,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
110
139
|
requirements:
|
111
140
|
- - ">="
|
112
141
|
- !ruby/object:Gem::Version
|
113
|
-
version: '2.
|
142
|
+
version: '2.5'
|
114
143
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
144
|
requirements:
|
116
145
|
- - ">="
|
117
146
|
- !ruby/object:Gem::Version
|
118
147
|
version: '0'
|
119
148
|
requirements: []
|
120
|
-
|
121
|
-
rubygems_version: 2.7.8
|
149
|
+
rubygems_version: 3.0.8
|
122
150
|
signing_key:
|
123
151
|
specification_version: 4
|
124
152
|
summary: An extension to allow you to recurse through your SitePrism Pages/Sections
|