watir-webdriver 0.6.9 → 0.6.10

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.
@@ -13,7 +13,7 @@ module Watir
13
13
  #
14
14
  # @see https://www.w3.org/Bugs/Public/show_bug.cgi?id=23192
15
15
  #
16
- attributes :string => [:href]
16
+ attribute String, :href, :href
17
17
 
18
18
  end # Anchor
19
19
  end # Watir
@@ -3,14 +3,12 @@ module Watir
3
3
  # @private
4
4
  attr_writer :locator_class
5
5
 
6
+ alias_method :colspan, :col_span
7
+ alias_method :rowspan, :row_span
8
+
6
9
  def locator_class
7
10
  @locator_class || super
8
11
  end
9
-
10
- def colspan
11
- value = attribute_value :colspan
12
- value ? Integer(value) : 1
13
- end
14
12
  end # TableCell
15
13
 
16
14
  class TableCellCollection < ElementCollection
@@ -3,7 +3,7 @@ module Watir
3
3
  class TextField < Input
4
4
  include UserEditable
5
5
 
6
- attributes Watir::TextArea.typed_attributes
6
+ inherit_attributes_from Watir::TextArea
7
7
  remove_method :type # we want Input#type here, which was overriden by TextArea's attributes
8
8
 
9
9
  private
@@ -4,6 +4,8 @@ module Watir
4
4
  module HTML
5
5
  class Generator
6
6
 
7
+ IGNORED_ATTRIBUTES = %w(cells elements hash rows span text)
8
+
7
9
  def generate(spec_url, io = StringIO.new)
8
10
  @spec_url, @io = spec_url, io
9
11
 
@@ -47,6 +49,11 @@ module Watir
47
49
  @sorted_interfaces.reject! { |intf| intf.name == "HTMLLinkElement" }
48
50
  # frame is implemented manually, see https://github.com/watir/watir-webdriver/issues/204
49
51
  @sorted_interfaces.reject! { |intf| intf.name == "HTMLFrameElement" }
52
+
53
+ # cleanup attributes
54
+ @sorted_interfaces.each do |intf|
55
+ intf.members.delete_if { |member| IGNORED_ATTRIBUTES.include?(member.name) }
56
+ end
50
57
  end
51
58
 
52
59
  def write_header
@@ -56,11 +63,16 @@ module Watir
56
63
 
57
64
  def write_class_defs
58
65
  @sorted_interfaces.each do |interface|
59
- @io.puts indent(generator.generate(interface))
66
+ interface = generator.generate(interface)
67
+ unless interface.empty?
68
+ interface.gsub!(/^\s+\n/, '') # remove empty lines
69
+ @io.puts indent(interface)
70
+ end
60
71
  end
61
72
  end
62
73
 
63
74
  def write_container_methods
75
+ @io.puts "\n\n"
64
76
  @io.puts indent("module Container")
65
77
 
66
78
  @tag2interfaces.sort.each do |tag, interfaces|
@@ -74,6 +86,7 @@ module Watir
74
86
 
75
87
  # visitor.visit_tag(tag, interfaces.first.name) !?
76
88
  @io.puts indent(<<-CODE, 3)
89
+
77
90
  #
78
91
  # @return [#{element_class}]
79
92
  #
@@ -103,7 +116,7 @@ CODE
103
116
  end
104
117
 
105
118
  def indent(code, indent = 1)
106
- indent_string = " "*indent
119
+ indent_string = " " * indent
107
120
  code.split("\n").map { |line| line.empty? ? line : indent_string + line }.join("\n")
108
121
  end
109
122
 
@@ -40,7 +40,7 @@ module Watir
40
40
  def print_node(node, indent = 0)
41
41
  return if @visited.include?(node)
42
42
  @visited << node
43
- puts " "*indent + node
43
+ puts " " * indent + node
44
44
  tsort_each_child(node) { |child| print_node(child, indent + 2)}
45
45
  end
46
46
 
@@ -33,8 +33,8 @@ module Watir
33
33
  process if @interfaces.nil?
34
34
 
35
35
  sorter.sort.map { |name|
36
- @interfaces_by_name[name] or puts "ignoring interface: #{name}"
37
- }.flatten.compact
36
+ @interfaces.find { |i| i.name == name } or puts "ignoring interface: #{name}"
37
+ }.compact
38
38
  end
39
39
 
40
40
  def print_hierarchy
@@ -67,8 +67,9 @@ module Watir
67
67
  end
68
68
  end
69
69
 
70
- @interfaces_by_name = @interfaces.group_by { |i| i.name }
70
+ @interfaces_by_name = @interfaces.group_by(&:name)
71
71
  apply_implements(implements)
72
+ merge_interfaces
72
73
  end
73
74
 
74
75
  def extract_interface_map
@@ -136,6 +137,19 @@ module Watir
136
137
  end
137
138
  end
138
139
 
140
+ def merge_interfaces
141
+ non_duplicates = @interfaces.uniq(&:name)
142
+ duplicates = @interfaces - non_duplicates
143
+
144
+ duplicates.each do |intf|
145
+ final = non_duplicates.find { |i| i.name == intf.name }
146
+ final.members += intf.members
147
+ final.extended_attributes += intf.extended_attributes
148
+ end
149
+
150
+ @interfaces = non_duplicates
151
+ end
152
+
139
153
  def idl_parser
140
154
  @idl_parser ||= WebIDL::Parser::IDLParser.new
141
155
  end
@@ -83,9 +83,7 @@ module Watir
83
83
 
84
84
  def element_class(name, attributes, parent)
85
85
  [:class, Util.classify(name), [:const, Util.classify(parent)],
86
- [:scope,
87
- [:block, attributes_call(attributes)]
88
- ]
86
+ *attribute_calls(attributes)
89
87
  ]
90
88
  end
91
89
 
@@ -113,77 +111,51 @@ module Watir
113
111
  ]
114
112
  end
115
113
 
116
- def attributes_call(attributes)
117
- return if attributes.empty?
118
-
119
- attrs = Hash.new { |hash, key| hash[key] = [] }
120
- attributes.sort_by { |a| a.name }.each do |a|
121
- type = ruby_type_for(a.type)
122
- attrs[type] << ruby_attribute_for(type, a.name)
114
+ def attribute_calls(attributes)
115
+ attributes.map do |attribute|
116
+ call(:attribute, [
117
+ [:lit, ruby_type_for(attribute.type)],
118
+ [:lit, ruby_method_name_for(attribute)],
119
+ [:lit, attribute.name.to_sym]
120
+ ])
123
121
  end
122
+ end
124
123
 
125
- call :attributes, [literal_hash(attrs)]
124
+ def call(name, args)
125
+ [:call, nil, name.to_sym, [:arglist] + args]
126
126
  end
127
127
 
128
- def ruby_attribute_for(type, str)
129
- str = str.snake_case
128
+ def ruby_method_name_for(attribute)
129
+ str = attribute.name.snake_case
130
130
 
131
- if str =~ /^is_(.+)/ && type == :bool
132
- str = $1
131
+ if attribute.type.name == :Boolean
132
+ str = $1 if str =~ /^is_(.+)/
133
+ str << '?'
133
134
  end
134
135
 
135
- str.to_sym
136
- end
136
+ str = 'for' if str == 'html_for'
137
137
 
138
- def literal_hash(hash)
139
- [:hash] + hash.map { |k, v| [[:lit, k.to_sym], [:lit, v]] }.flatten(1)
140
- end
141
-
142
- def literal_array(arr)
143
- [:array] + arr.map { |e| [:lit, e.to_sym] }
144
- end
145
-
146
- def call(name, args)
147
- [:call, nil, name.to_sym, [:arglist] + args]
138
+ str.to_sym
148
139
  end
149
140
 
150
141
  def ruby_type_for(type)
151
142
  case type.name.to_s
152
143
  when 'DOMString', 'any'
153
- :string
144
+ String
154
145
  when 'UnsignedLong', 'Long', 'Integer', 'Short', 'UnsignedShort'
155
- :int
146
+ Fixnum
156
147
  when 'Float', /.*Double$/
157
- :float
158
- when 'Function', /.*EventHandler$/
159
- :function
148
+ Float
160
149
  when 'Boolean'
161
- :bool
162
- when 'Document', 'DocumentFragment'
163
- :document
164
- when 'DOMTokenList', 'DOMSettableTokenList'
165
- :token_list
166
- when 'DOMStringMap'
167
- :string_map
168
- when 'HTMLPropertiesCollection'
169
- :properties_collection
170
- when /HTML(.*)Element/
171
- :html_element
172
- when /HTML(.*)Collection/
173
- :html_collection
174
- when 'CSSStyleDeclaration'
175
- :style
176
- when /.+List$/
177
- :list
178
- when 'Date'
179
- :date
180
- when 'Element'
181
- :element
150
+ 'Boolean'
182
151
  when 'WindowProxy', 'ValidityState', 'MediaError', 'TimeRanges', 'Location',
183
152
  'Any', 'TimedTrackArray', 'TimedTrack', 'TextTrackArray', 'TextTrack',
184
- 'MediaController', 'TextTrackKind'
153
+ 'MediaController', 'TextTrackKind', 'Function', /.*EventHandler$/,
154
+ 'Document', 'DocumentFragment', 'DOMTokenList', 'DOMSettableTokenList',
155
+ 'DOMStringMap', 'HTMLPropertiesCollection', /HTML(.*)Element/, /HTML(.*)Collection/,
156
+ 'CSSStyleDeclaration', /.+List$/, 'Date', 'Element'
185
157
  # probably completely wrong.
186
- :string
158
+ String
187
159
  else
188
160
  raise "unknown type: #{type.name}"
189
161
  end
@@ -216,9 +216,6 @@ module Watir
216
216
  [:class, what]
217
217
  when :caption
218
218
  [:text, what]
219
- when :for
220
- assert_valid_as_attribute :html_for
221
- [how, what]
222
219
  else
223
220
  assert_valid_as_attribute how
224
221
  [how, what]
@@ -1,3 +1,3 @@
1
1
  module Watir
2
- VERSION = "0.6.9"
2
+ VERSION = "0.6.10"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: watir-webdriver
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.9
4
+ version: 0.6.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jari Bakken
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-13 00:00:00.000000000 Z
11
+ date: 2014-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: selenium-webdriver
@@ -175,7 +175,6 @@ files:
175
175
  - .gitignore
176
176
  - .gitmodules
177
177
  - .travis.yml
178
- - .yardopts
179
178
  - CHANGES.md
180
179
  - Gemfile
181
180
  - LICENSE
@@ -246,7 +245,6 @@ files:
246
245
  - lib/watir-webdriver/wait/timer.rb
247
246
  - lib/watir-webdriver/window.rb
248
247
  - lib/watir-webdriver/xpath_support.rb
249
- - lib/yard/handlers/watir.rb
250
248
  - spec/browser_spec.rb
251
249
  - spec/click_spec.rb
252
250
  - spec/container_spec.rb
@@ -305,3 +303,4 @@ test_files:
305
303
  - spec/locator_spec_helper.rb
306
304
  - spec/spec_helper.rb
307
305
  - spec/special_chars_spec.rb
306
+ has_rdoc:
data/.yardopts DELETED
@@ -1 +0,0 @@
1
- --load ./lib/yard/handlers/watir.rb
@@ -1,55 +0,0 @@
1
- module YARD
2
- module Handlers
3
- module Watir
4
- #
5
- # @private
6
- #
7
-
8
- class AttributesHandler < YARD::Handlers::Ruby::Base
9
- handles method_call(:attributes)
10
-
11
- TYPES = {
12
- :string => "String",
13
- :bool => "Boolean",
14
- :int => "Integer"
15
- }
16
-
17
- def process
18
- attributes = try_eval
19
-
20
- if attributes.nil?
21
- p :ignoring => statement.source, :in => namespace.to_s if $DEBUG
22
- return
23
- end
24
-
25
- TYPES.each do |type, return_type|
26
- if attributes.member? type
27
- create_attributes attributes[type], return_type
28
- end
29
- end
30
- end
31
-
32
- private
33
-
34
- def create_attributes(names, return_type)
35
- names.each do |attribute_name|
36
- p :adding => "#{namespace}##{attribute_name}" if $DEBUG
37
- attribute_name = "#{attribute_name}?".to_sym if return_type == "Boolean"
38
- register MethodObject.new(namespace, attribute_name, scope) do |o|
39
- o.visibility = :public
40
- o.explicit = false
41
- o.docstring.add_tag YARD::Tags::Tag.new(:return, "", return_type)
42
- end
43
- end
44
- end
45
-
46
- def try_eval
47
- eval "{#{statement.parameters.source}}"
48
- rescue SyntaxError, StandardError
49
- nil
50
- end
51
-
52
- end # AttributesHandler
53
- end # Watir
54
- end # Handlers
55
- end # YARD