insite 0.0.5 → 0.0.6

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
  SHA1:
3
- metadata.gz: db6875ab42b0dc5e67d04b58ed8e2784688c3638
4
- data.tar.gz: a634d3df6da0647fda5665f615a1dec6282f027f
3
+ metadata.gz: ba6a1246b6338a57653604a433afaa8c31985d7b
4
+ data.tar.gz: 5adef870b2e99c96391706fed734f262988b6ff4
5
5
  SHA512:
6
- metadata.gz: b17d8b1d92af6f10c38b17999cc69a1c9895d408a3a571a34c634bd91ffbd80eda9ab08e662b61c5bcb918feb9adb810a3e06910fc5a1d97bdca0eb5076e191c
7
- data.tar.gz: 4f4b65feeaa634894a8a237d0863921524ad5ffed17d8439aa4fdb934d95aff16dea9b6faf66c0b3a5a4da6c6b717ac6cd69d446d56951fa0fafcd1f90a5eb93
6
+ metadata.gz: e6e270c71cdf68c39edcb78e9f4082add0b14003a90334e98a874b22c2dff4e3e8b0d5aa79a0ec57b185bd2bac2dd518fc11f254c0349b90845fa135e20c7316
7
+ data.tar.gz: d397bc85b7362a3aafafd278caf8c8880a75c5e8b7b7a8638a13f998e4a3a4b3464427cd27fd68697622546e772a91daaee81cab463483c1018de376c6b989a6
@@ -7,7 +7,7 @@ require 'pry'
7
7
  # into components that can be reused across multiple pages.
8
8
  module Insite
9
9
  class Component
10
- attr_reader :args, :browser, :non_relative, :selector, :site, :type, :target
10
+ attr_reader :args, :browser, :non_relative, :parent, :selector, :site, :type, :target
11
11
  class_attribute :selector, default: {}
12
12
  self.selector = self.selector.clone
13
13
 
@@ -187,21 +187,14 @@ module Insite
187
187
  # here and that makes the code more confusing. And there should be a proper
188
188
  # collection class for element collections, with possibly some AR-like accessors.
189
189
  def initialize(parent, *args)
190
- # Figure out the correct query scope.
191
- parent.respond_to?(:target) ? obj = parent : obj = parent.site
192
- @parent = obj
193
-
194
- # @parent = parent
195
190
  @site = parent.class.ancestors.include?(Insite) ? parent : parent.site
196
191
  @browser = @site.browser
197
192
  @component_elements = self.class.component_elements
198
193
 
199
- if args[0].is_a?(Insite::Element) || args[0].is_a?(Insite::ElementCollection)
200
- @dom_type = nil
194
+ if args[0].is_a?(Insite::Element) || args[0].is_a?(Watir::Element)
201
195
  @args = nil
202
196
  @target = args[0].target
203
- elsif args[0].is_a?(Watir::Element) || args[0].is_a?(Watir::ElementCollection)
204
- @dom_type = nil
197
+ elsif args[0].is_a?(Insite::ElementCollection) || args[0].is_a?(Watir::ElementCollection)
205
198
  @args = nil
206
199
  @target = args[0]
207
200
  else
@@ -217,26 +210,23 @@ module Insite
217
210
 
218
211
  @selector = self.class.selector.merge(parse_args(args))
219
212
  @args = @selector
220
- @non_relative = @args.delete(:non_relative) || false
221
213
 
214
+ # Figure out the correct query scope.
215
+ @non_relative = @args.delete(:non_relative) || false
222
216
  if @non_relative
223
- # @args = parse_args(args)
224
- # @selector = @args
225
- @target = @browser.send(@args)
217
+ @parent = parent.site
226
218
  else
227
- # @args = parse_args(args)
228
-
229
- # # Figure out the correct query scope.
230
- # @parent.respond_to?(:target) ? obj = @parent.target : obj = @browser
219
+ parent.respond_to?(:target) ? obj = parent : obj = parent.site
220
+ @parent = obj
221
+ end
231
222
 
232
- # See if there's a Watir DOM method for the class. If not, then
233
- # initialize using the default collection.
234
- if watir_class = Insite::CLASS_MAP.key(self.class)
235
- @target = watir_class.new(@parent.target, @args)
236
- # @target = watir_class.new(obj, @args)
237
- else
238
- @target = Watir::HTMLElement.new(@parent.target, @args)
239
- end
223
+ # See if there's a Watir DOM method for the class. If not, then
224
+ # initialize using the default HTML element.
225
+ watir_class = Insite::CLASS_MAP.key(self.class)
226
+ if watir_class && watir_class != Watir::HTMLElement
227
+ @target = watir_class.new(@parent.target, @args)
228
+ else
229
+ @target = Watir::HTMLElement.new(@parent.target, @args)
240
230
  end
241
231
 
242
232
  # New webdriver approach.
@@ -1,6 +1,6 @@
1
1
  module Insite
2
2
  class ComponentCollection
3
- attr_reader :args, :collection_member_type, :browser, :indentifiers, :site, :target
3
+ attr_reader :args, :collection_member_type, :browser, :indentifiers, :parent, :site, :target
4
4
  class_attribute :selector, default: {}
5
5
  self.selector = self.selector.clone
6
6
 
@@ -43,38 +43,36 @@ module Insite
43
43
  end
44
44
 
45
45
  def initialize(parent, *args)
46
- # Figure out the correct query scope.
47
- parent.respond_to?(:target) ? obj = parent : obj = parent.site
48
- @parent = obj
49
-
50
46
  @site = parent.class.ancestors.include?(Insite) ? parent : parent.site
51
47
  @browser = @site.browser
52
48
  @collection_member_type = self.class.instance_variable_get(:@collection_member_type)
53
49
  @selector = @collection_member_type.selector
54
50
 
55
- if args[0].is_a?(Insite::Element) || args[0].is_a?(Insite::ElementCollection)
51
+ if args[0].is_a?(Insite::Element) || args[0].is_a?(Watir::Element)
56
52
  @dom_type = nil
57
53
  @args = nil
58
54
  @target = args[0].target
59
- elsif args[0].is_a?(Watir::Element) || args[0].is_a?(Watir::ElementCollection)
55
+ elsif args[0].is_a?(Insite::ElementCollection) || args[0].is_a?(Watir::ElementCollection)
60
56
  @dom_type = nil
61
57
  @args = nil
62
58
  @target = args[0]
63
59
  else
64
- @args = parse_args(args)
60
+
61
+ @args = parse_args(args)
62
+ @selector = @args
63
+
64
+ @non_relative = @args.delete(:non_relative) || false
65
+ if @non_relative
66
+ @parent = parent.site
67
+ else
68
+ parent.respond_to?(:target) ? obj = parent : obj = parent.site
69
+ @parent = obj
70
+ end
65
71
 
66
72
  if watir_class = Insite::CLASS_MAP.key(self.class)
67
- if @parent.respond_to?(:target)
68
- @target = watir_class.new(@parent.target, @args)
69
- else
70
- @target = watir_class.new(@browser, @args)
71
- end
73
+ @target = watir_class.new(@parent.target, @args)
72
74
  else
73
- if @parent.respond_to?(:target)
74
- @target = Watir::HTMLElementCollection.new(@parent.target, @args)
75
- else
76
- @target = Watir::HTMLElementCollection.new(@browser, @args)
77
- end
75
+ @target = Watir::HTMLElementCollection.new(@parent.target, @args)
78
76
  end
79
77
  end
80
78
  end
@@ -41,11 +41,11 @@ module Insite
41
41
  @site = parent.class.ancestors.include?(Insite) ? parent : parent.site
42
42
  @browser = @site.browser
43
43
 
44
- if args[0].is_a?(Insite::Element) || args[0].is_a?(Insite::ElementCollection)
44
+ if args[0].is_a?(Insite::Element) || args[0].is_a?(Watir::Element)
45
45
  @target = args[0].target
46
46
  @selector = @target.selector.dup
47
47
  @args = @selector
48
- elsif args[0].is_a?(Watir::Element) || args[0].is_a?(Watir::ElementCollection)
48
+ elsif args[0].is_a?(Insite::ElementCollection) || args[0].is_a?(Watir::ElementCollection)
49
49
  @args = nil
50
50
  @selector = @target.instance_variable_get(:@selector).dup
51
51
  @args = @selector
@@ -61,6 +61,15 @@ module Insite
61
61
  else
62
62
  @args = parse_args(args.dup)
63
63
  end
64
+
65
+ # Figure out the correct query scope.
66
+ @non_relative = @args.delete(:non_relative) || false
67
+ if @non_relative
68
+ @parent = parent.site
69
+ else
70
+ parent.respond_to?(:target) ? obj = parent : obj = parent.site
71
+ @parent = obj
72
+ end
64
73
  @selector = @args
65
74
 
66
75
  if watir_class = Insite::CLASS_MAP.key(self.class)
@@ -38,11 +38,11 @@ module Insite
38
38
  @parent = obj
39
39
  @site = parent.class.ancestors.include?(Insite) ? parent : parent.site
40
40
  @browser = @site.browser
41
- if args[0].is_a?(Insite::Element) || args[0].is_a?(Insite::ElementCollection)
41
+ if args[0].is_a?(Insite::Element) || args[0].is_a?(Watir::Element)
42
42
  @target = args[0].target
43
43
  @args = @target.selector.dup
44
44
  @selector = @args
45
- elsif args[0].is_a?(Watir::Element) || args[0].is_a?(Watir::ElementCollection)
45
+ elsif args[0].is_a?(Insite::ElementCollection) || args[0].is_a?(Watir::ElementCollection)
46
46
  @target = args[0]
47
47
  @args = @target.instance_variable_get(:@selector).dup
48
48
  @selector = @args
@@ -50,12 +50,33 @@ module Insite
50
50
  if @collection_member_type == Insite::HTMLElement
51
51
  @args = parse_args(args)
52
52
  @selector = @args
53
+
54
+ # Figure out the correct query scope.
55
+ @non_relative = @args.delete(:non_relative) || false
56
+ if @non_relative
57
+ @parent = parent.site
58
+ else
59
+ parent.respond_to?(:target) ? obj = parent : obj = parent.site
60
+ @parent = obj
61
+ end
62
+
53
63
  @target = Watir::HTMLElementCollection.new(@parent.target, @args)
54
64
  else
55
65
  @args = parse_args(args).merge(
56
66
  tag_name: Insite.class_to_tag(@collection_member_type)
57
67
  )
58
68
  @selector = @args
69
+
70
+ # Figure out the correct query scope.
71
+ @non_relative = @args.delete(:non_relative) || false
72
+ if @non_relative
73
+ @parent = parent.site
74
+ else
75
+ parent.respond_to?(:target) ? obj = parent : obj = parent.site
76
+ @parent = obj
77
+ end
78
+ @selector = @args
79
+
59
80
  @target = Insite::CLASS_MAP.key(self.class).new(@parent.target, @args)
60
81
  end
61
82
  end
@@ -22,7 +22,7 @@ module Insite
22
22
  end
23
23
 
24
24
  def self.tag_to_class(tag)
25
- CLASS_MAP[Watir.tag_to_class[tag]] || Insite::HTMLElement
25
+ CLASS_MAP[Watir.tag_to_class[tag.to_sym]] || Insite::HTMLElement
26
26
  end
27
27
 
28
28
  # Automatically sets up a Page class when Insite is included. Probably overkill
@@ -190,7 +190,8 @@ module Insite
190
190
 
191
191
  # Duplicates Watir DOM element argument parsing for element methods.
192
192
  private
193
- def parse_args(args)
193
+ def parse_args(*args)
194
+ args = args.flatten if args.is_a?(Array)
194
195
  case args.length
195
196
  when 2
196
197
  return { args[0] => args[1] }
@@ -1,3 +1,3 @@
1
1
  module Insite
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.6'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: insite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Fitisoff
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-25 00:00:00.000000000 Z
11
+ date: 2018-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport