site_prism-all_there 0.1.1 → 0.2

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: 13d340b7a35050d9497c7f8f581bdd9fd52e2e1de277dc8898160f00d589b116
4
- data.tar.gz: 63f61f0accbe52abb0037aeb77d9f4a3f290281f0257e261520e20499beb5298
3
+ metadata.gz: 33b0ff10287854efb639165548ea3718efc57094ab5e0e1f11daf8ec7a0f58c6
4
+ data.tar.gz: 9257c12cd32806afeca3a0891754d942b3cfeac06dc62b082680bf2bac2ee9dd
5
5
  SHA512:
6
- metadata.gz: 82a6b3eaa4873687a697e2f969cf85b20c74ffb72fe84572a47ee37f076a1e5a26868f8be48c6aefce3ac42888d079d846a10cb84eb5eeca6f345c53a2684841
7
- data.tar.gz: 952de2d7fb8aafef01786dadd9e3bc329d0d278fe660fab4835a1f2f085cdc9558ae1ff398c85d60dd2cf72567ed4ed3df605aef641f7da8145ba538fc7a3f59
6
+ metadata.gz: 5a2603278f614090cd7ecca80d1baf2ae6cf4085eec044fbb68df527d89e1dcec8729e634b89b5fcf70f5eef28bcf529e4f8be60bedd5ef2905c002390f02a14
7
+ data.tar.gz: 4357d5ce9856f1e9b0193481d813e3f6aeb9189e1950ed5b212e219144b66b3307ab9a710fb5150e8d3711551b1c57faef52bed3a896395fd2ba46accd320951
data/README.md CHANGED
@@ -8,26 +8,22 @@ As such at the moment, the gem is very much considered a Work in Progress and wo
8
8
 
9
9
  It is fully expected to have a number of bug-fix / refactor PR's in between each minor release.
10
10
 
11
- In order to use this gem you simply need to do the following
11
+ Add the following code to either `spec_helper.rb` or `env.rb`
12
12
 
13
13
  ```rb
14
- # In either spec_helper.rb or env.rb
15
-
16
14
  require 'site_prism/all_there
17
15
 
18
- # Then in either a config or initializer location (Or env.rb / spec_helper.rb)
19
-
20
16
  SitePrism.use_all_there_gem = true
21
17
 
22
- or ...
18
+ # or...
23
19
 
24
20
  SitePrism.configure do |config|
25
21
  config.use_all_there_gem = true
26
22
  end
27
23
  ```
28
24
 
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.
25
+ This gem is currently in the `0.x` phase, meaning it is API unstable and likely to change
26
+ structure going forwards, to conform to the pairing of both gems.
31
27
 
32
28
  Happy Testing / Developing!
33
29
 
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SitePrism
4
+ module AllThere
5
+ # Returns the Mapped Items on a specific SitePrism object
6
+ #
7
+ # api private
8
+ #
9
+ class MappedItems
10
+ attr_reader :instance
11
+ private :instance
12
+
13
+ def initialize(instance)
14
+ @instance = instance
15
+ end
16
+
17
+ # All Mapped items on the SitePrism instance as a Symbol Array
18
+ def array
19
+ hash.values.flatten.uniq
20
+ end
21
+
22
+ # All Mapped items on the SitePrism instance as a Symbol Hash
23
+ def hash
24
+ instance.class.mapped_items(legacy: false)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -12,19 +12,23 @@ module SitePrism
12
12
  @instance = instance
13
13
  end
14
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
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
17
  # regular repo uses currently
18
- def all_there?
19
- current_class_all_there? &&
20
- section_classes_all_there? &&
21
- sections_classes_all_there?
18
+ def all_there?(recursion: :one)
19
+ if recursion == :one || SitePrism.recursion_setting == :one
20
+ current_class_all_there? &&
21
+ section_classes_all_there? &&
22
+ sections_classes_all_there?
23
+ else
24
+ current_class_all_there?
25
+ end
22
26
  end
23
27
 
24
28
  private
25
29
 
26
30
  # This will check all elements that are in the current scope
27
- # This is equivalent to checking a recursion value of +:none+
31
+ # This is equivalent to checking with a recursion value of +:none+
28
32
  def current_class_all_there?
29
33
  expected_item_map.flatten.all? { |name| there?(name) }
30
34
  end
@@ -51,16 +55,16 @@ module SitePrism
51
55
 
52
56
  def expected_item_map
53
57
  [
54
- expected(mapped_items, :element),
55
- expected(mapped_items, :elements),
56
- expected(mapped_items, :section),
57
- expected(mapped_items, :sections),
58
- expected(mapped_items, :iframe),
58
+ expected(:element),
59
+ expected(:elements),
60
+ expected(:section),
61
+ expected(:sections),
62
+ expected(:iframe),
59
63
  ]
60
64
  end
61
65
 
62
- def expected(map, type)
63
- map[type].select { |name| elements_to_check.include?(name) }
66
+ def expected(type)
67
+ MappedItems.new(instance).hash[type].select { |name| elements_to_check.include?(name) }
64
68
  end
65
69
 
66
70
  # If the page or section has expected_items set, return expected_items that are mapped
@@ -68,16 +72,14 @@ module SitePrism
68
72
  def elements_to_check
69
73
  if _expected_items
70
74
  SitePrism.logger.debug('Expected Items has been set.')
71
- _mapped_items.select { |name| _expected_items.include?(name) }
75
+ MappedItems.new(instance).array.select do |name|
76
+ _expected_items.include?(name)
77
+ end
72
78
  else
73
- _mapped_items
79
+ MappedItems.new(instance).array
74
80
  end
75
81
  end
76
82
 
77
- def _mapped_items
78
- mapped_items.values.flatten.uniq
79
- end
80
-
81
83
  def _expected_items
82
84
  instance.class.expected_items
83
85
  end
@@ -85,10 +87,6 @@ module SitePrism
85
87
  def there?(name)
86
88
  instance.send("has_#{name}?")
87
89
  end
88
-
89
- def mapped_items
90
- @mapped_items ||= instance.class.mapped_items(legacy: false)
91
- end
92
90
  end
93
91
  end
94
92
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module SitePrism
4
4
  module AllThere
5
- VERSION = '0.1.1'
5
+ VERSION = '0.2'
6
6
  end
7
7
  end
@@ -1,20 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'site_prism/all_there/mapped_items'
3
4
  require 'site_prism/all_there/recursion_checker'
4
5
 
5
6
  # Configure the behaviour of the site_prism-all_there gem
6
7
  module SitePrism
7
8
  class << self
8
- attr_writer :recursion_setting
9
+ # Configuration setting to use on a global scale
10
+ # Note this global setting can be overridden at runtime for each individual call
11
+ attr_accessor :recursion_setting
9
12
 
10
13
  def configure
11
14
  yield self
12
15
  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
16
  end
20
17
  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.1
4
+ version: '0.2'
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-03 00:00:00.000000000 Z
11
+ date: 2019-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -92,6 +92,7 @@ files:
92
92
  - LICENSE.md
93
93
  - README.md
94
94
  - lib/site_prism/all_there.rb
95
+ - lib/site_prism/all_there/mapped_items.rb
95
96
  - lib/site_prism/all_there/recursion_checker.rb
96
97
  - lib/site_prism/all_there/version.rb
97
98
  homepage: https://github.com/site-prism/site_prism-all_there