site_prism-all_there 0.1 → 0.1.1

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: a8336dc1b0631ca12cefaac99dbcc056d4f3711670647848f5d8a9d98e5bd17c
4
- data.tar.gz: 61f56cfd1073989ae922c244236d732fce4395053db7e9ac05e500834da290c5
3
+ metadata.gz: 13d340b7a35050d9497c7f8f581bdd9fd52e2e1de277dc8898160f00d589b116
4
+ data.tar.gz: 63f61f0accbe52abb0037aeb77d9f4a3f290281f0257e261520e20499beb5298
5
5
  SHA512:
6
- metadata.gz: c40aa2a060d407a3f38781627a3d8ca5294025add8b05a7118896a574835144e4835a2394cc51988435b0937882271c6cadb4d4f69fb7c9d87d851846b6461b9
7
- data.tar.gz: 96eeb9d5e0fbc82042bff60f88e4146581cad2329a135ec2179aff4c6d5b53ba271b87f3648b65670903c600d475d913957485b950b33b18d4e8ff7d95ff9880
6
+ metadata.gz: 82a6b3eaa4873687a697e2f969cf85b20c74ffb72fe84572a47ee37f076a1e5a26868f8be48c6aefce3ac42888d079d846a10cb84eb5eeca6f345c53a2684841
7
+ data.tar.gz: 952de2d7fb8aafef01786dadd9e3bc329d0d278fe660fab4835a1f2f085cdc9558ae1ff398c85d60dd2cf72567ed4ed3df605aef641f7da8145ba538fc7a3f59
data/LICENSE.md CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2018-2019, The SitePrism team
1
+ Copyright (c) 2019+, The SitePrism team
2
2
 
3
3
  All rights reserved.
4
4
 
data/README.md CHANGED
@@ -1,2 +1,34 @@
1
1
  # site_prism-all_there
2
- The breakout gem from SitePrism to perform recursion checks for all_there?
2
+ The breakout gem from SitePrism to perform recursion checks for `#all_there?`
3
+
4
+ This gem is currently being developed by copying over the code-base from the existing
5
+ SitePrism repo and slowly refactoring it and breaking it out
6
+
7
+ As such at the moment, the gem is very much considered a Work in Progress and works "as is".
8
+
9
+ It is fully expected to have a number of bug-fix / refactor PR's in between each minor release.
10
+
11
+ In order to use this gem you simply need to do the following
12
+
13
+ ```rb
14
+ # In either spec_helper.rb or env.rb
15
+
16
+ require 'site_prism/all_there
17
+
18
+ # Then in either a config or initializer location (Or env.rb / spec_helper.rb)
19
+
20
+ SitePrism.use_all_there_gem = true
21
+
22
+ or ...
23
+
24
+ SitePrism.configure do |config|
25
+ config.use_all_there_gem = true
26
+ end
27
+ ```
28
+
29
+ v1.0 is slated for release some-time in the Autumn/Winter of 2019, with a variety of small interim
30
+ releases being planned in the meantime.
31
+
32
+ Happy Testing / Developing!
33
+
34
+ The SitePrism team
@@ -2,6 +2,8 @@
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
7
  class RecursionChecker
6
8
  attr_reader :instance
7
9
  private :instance
@@ -10,17 +12,41 @@ module SitePrism
10
12
  @instance = instance
11
13
  end
12
14
 
15
+ # This is currently hard-coded to perform a recursion of depth :one
16
+ # It will be refactored to use either no input, :none, or :one as the
17
+ # regular repo uses currently
13
18
  def all_there?
14
- regular_items_all_there = expected_item_map.flatten.all? { |name| there?(name) }
15
- return false unless regular_items_all_there
19
+ current_class_all_there? &&
20
+ section_classes_all_there? &&
21
+ sections_classes_all_there?
22
+ end
23
+
24
+ private
16
25
 
17
- section_all_there =
18
- section_classes_to_check.all?(&:all_there?)
19
- return false unless section_all_there
26
+ # This will check all elements that are in the current scope
27
+ # This is equivalent to checking a recursion value of +:none+
28
+ def current_class_all_there?
29
+ expected_item_map.flatten.all? { |name| there?(name) }
30
+ end
31
+
32
+ # This will check all elements that are in any of the individual
33
+ # +section+ items defined in the current scope
34
+ def section_classes_all_there?
35
+ section_classes_to_check.all?(&:all_there?)
36
+ end
37
+
38
+ # This will check all elements that are in any instance of any of the
39
+ # +sections+ items defined in the current scope
40
+ def sections_classes_all_there?
41
+ sections_classes_to_check.flatten.all?(&:all_there?)
42
+ end
43
+
44
+ def section_classes_to_check
45
+ expected_item_map[2].map { |name| instance.send(name) }
46
+ end
20
47
 
21
- # Returning this final check here is fine, as the previous two checks must
22
- # have returned +true+ in order to hit this part of the method-call
23
- sections_classes_to_check.all?(&:all_there?)
48
+ def sections_classes_to_check
49
+ expected_item_map[3].map { |name| instance.send(name) }
24
50
  end
25
51
 
26
52
  def expected_item_map
@@ -37,16 +63,6 @@ module SitePrism
37
63
  map[type].select { |name| elements_to_check.include?(name) }
38
64
  end
39
65
 
40
- def section_classes_to_check
41
- expected_item_map[2].map { |name| instance.send(name) }
42
- end
43
-
44
- def sections_classes_to_check
45
- expected_item_map[3].map { |name| instance.send(name) }.flatten
46
- end
47
-
48
- private
49
-
50
66
  # If the page or section has expected_items set, return expected_items that are mapped
51
67
  # otherwise just return the list of all mapped_items
52
68
  def elements_to_check
@@ -2,6 +2,6 @@
2
2
 
3
3
  module SitePrism
4
4
  module AllThere
5
- VERSION = '0.1'
5
+ VERSION = '0.1.1'
6
6
  end
7
7
  end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'site_prism/all_there/recursion_checker'
4
+
5
+ # Configure the behaviour of the site_prism-all_there gem
6
+ module SitePrism
7
+ class << self
8
+ attr_writer :recursion_setting
9
+
10
+ def configure
11
+ yield self
12
+ end
13
+
14
+ # Pass in a configuration setting to use on a global scale
15
+ # Note this can be overridden at runtime for each individual call
16
+ def recursion_setting
17
+ @recursion_setting ||= :none
18
+ end
19
+ end
20
+ 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: '0.1'
4
+ version: 0.1.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: 2019-07-01 00:00:00.000000000 Z
11
+ date: 2019-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.67.0
47
+ version: 0.71.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: 0.67.0
54
+ version: 0.71.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rubocop-performance
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -91,16 +91,16 @@ extra_rdoc_files: []
91
91
  files:
92
92
  - LICENSE.md
93
93
  - README.md
94
- - lib/site_prism.rb
94
+ - lib/site_prism/all_there.rb
95
95
  - lib/site_prism/all_there/recursion_checker.rb
96
96
  - lib/site_prism/all_there/version.rb
97
- homepage: https://github.com/site_prism/site_prism-all_there
97
+ homepage: https://github.com/site-prism/site_prism-all_there
98
98
  licenses:
99
99
  - BSD-3-Clause
100
100
  metadata:
101
- bug_tracker_uri: https://github.com/site_prism/site_prism-all_there/issues
102
- changelog_uri: https://github.com/site_prism/site_prism-all_there/blob/master/CHANGELOG.md
103
- source_code_uri: https://github.com/site_prism/site_prism-all_there
101
+ bug_tracker_uri: https://github.com/site-prism/site_prism-all_there/issues
102
+ changelog_uri: https://github.com/site-prism/site_prism-all_there/blob/master/CHANGELOG.md
103
+ source_code_uri: https://github.com/site-prism/site_prism-all_there
104
104
  post_install_message:
105
105
  rdoc_options: []
106
106
  require_paths:
@@ -120,5 +120,5 @@ rubyforge_project:
120
120
  rubygems_version: 2.7.8
121
121
  signing_key:
122
122
  specification_version: 4
123
- summary: 'An extension to SitePrism to allow you to use recursive checks on #all_there?'
123
+ summary: An extension to allow you to recurse through your SitePrism Pages/Sections
124
124
  test_files: []
data/lib/site_prism.rb DELETED
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module SitePrism
4
- autoload :RecursionChecker, 'site_prism/all_there/recursion_checker'
5
-
6
- class << self
7
- attr_writer :recursion_setting
8
-
9
- def configure
10
- yield self
11
- end
12
-
13
- def recursion_setting
14
- @recursion_setting ||= :none
15
- end
16
- end
17
- end