bewildr 0.1.2 → 0.1.3

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.
@@ -1,10 +1,11 @@
1
1
  #Copyright (c) 2010, Nathaniel Ritmeyer. All rights reserved.
2
2
 
3
- class ElementNotEnabled < StandardError; end
4
- class ElementDoesntExist < StandardError; end
5
- class PasswordFieldReadAttempt < StandardError; end
6
- class NoSuchItemInComboBox < StandardError; end
7
- class NoSuchItemInListBox < StandardError; end
8
- class NoSuchTab < StandardError; end
9
-
10
- class BewildrInternalError < StandardError; end
3
+ module Bewildr
4
+ class ElementNotEnabled < StandardError; end
5
+ class ElementDoesntExist < StandardError; end
6
+ class PasswordFieldReadAttempt < StandardError; end
7
+ class NoSuchItemInComboBox < StandardError; end
8
+ class NoSuchItemInListBox < StandardError; end
9
+ class NoSuchTab < StandardError; end
10
+ class InternalError < StandardError; end
11
+ end
@@ -1,66 +1,66 @@
1
- #Copyright (c) 2010, Nathaniel Ritmeyer. All rights reserved.
2
-
3
- module Bewildr
4
- class Finder
5
- extend Bewildr::BewildrHelpers
6
-
7
- class << self
8
- def condition_for(condition_hash)
9
- conditions = condition_hash.select {|key, value| [:id, :name, :type].include?(key) }
10
- conditions = Hash[*conditions.flatten]
11
- case
12
- when conditions.length == 0 then raise "Condition needs to include at least an :id, a :name or a :type"
13
- when conditions.length == 1 then return single_condition(conditions)
14
- when conditions.length > 1 then return multiple_conditions(conditions)
15
- end
16
- end
17
-
18
- def scope_for(condition_hash)
19
- case condition_hash[:scope]
20
- when :children then System::Windows::Automation::TreeScope.Children
21
- when :descendants, nil then System::Windows::Automation::TreeScope.Descendants
22
- end
23
- end
24
-
25
- #returns the method to call
26
- def how_many_for(condition_hash)
27
- case condition_hash[:how_many]
28
- when :first then :find_first
29
- when :all, nil then :find_all
30
- else raise "Invalid number of elements to look for. Use ':first' or ':all'"
31
- end
32
- end
33
-
34
- private
35
-
36
- def multiple_conditions(condition_hash)
37
- condition_array = []
38
- condition_hash.keys.each {|key| condition_array << single_condition({key => condition_hash[key]}) }
39
- System::Windows::Automation::AndCondition.new(r_array_to_cs_array_of_conditions(condition_array))
40
- end
41
-
42
- def single_condition(condition_hash)
43
- case condition_hash.keys.first
44
- when :id then id_condition(condition_hash)
45
- when :name then name_condition(condition_hash)
46
- when :type then type_condition(condition_hash)
47
- end
48
- end
49
-
50
- def id_condition(condition_hash)
51
- value = r_string_to_c_string(condition_hash[:id].to_s)
52
- System::Windows::Automation::PropertyCondition.new(System::Windows::Automation::AutomationElement.automation_id_property, value)
53
- end
54
-
55
- def name_condition(condition_hash)
56
- value = r_string_to_c_string(condition_hash[:name])
57
- System::Windows::Automation::PropertyCondition.new(System::Windows::Automation::AutomationElement.name_property, value)
58
- end
59
-
60
- def type_condition(condition_hash)
61
- value = Bewildr::ControlType.class_for_symbol(condition_hash[:type])
62
- System::Windows::Automation::PropertyCondition.new(System::Windows::Automation::AutomationElement.control_type_property, value)
63
- end
64
- end
65
- end
66
- end
1
+ #Copyright (c) 2010, Nathaniel Ritmeyer. All rights reserved.
2
+
3
+ module Bewildr
4
+ class Finder
5
+ extend Bewildr::BewildrHelpers
6
+
7
+ class << self
8
+ def condition_for(condition_hash)
9
+ conditions = condition_hash.select {|key, value| [:id, :name, :type].include?(key) }
10
+ conditions = Hash[*conditions.flatten]
11
+ case
12
+ when conditions.length == 0 then raise "Condition needs to include at least an :id, a :name or a :type"
13
+ when conditions.length == 1 then return single_condition(conditions)
14
+ when conditions.length > 1 then return multiple_conditions(conditions)
15
+ end
16
+ end
17
+
18
+ def scope_for(condition_hash)
19
+ case condition_hash[:scope]
20
+ when :children then System::Windows::Automation::TreeScope.Children
21
+ when :descendants, nil then System::Windows::Automation::TreeScope.Descendants
22
+ end
23
+ end
24
+
25
+ #returns the method to call
26
+ def how_many_for(condition_hash)
27
+ case condition_hash[:how_many]
28
+ when :first, nil then :find_first
29
+ when :all then :find_all
30
+ else raise "Invalid number of elements to look for. Use ':first' or ':all'"
31
+ end
32
+ end
33
+
34
+ private
35
+
36
+ def multiple_conditions(condition_hash)
37
+ condition_array = []
38
+ condition_hash.keys.each {|key| condition_array << single_condition({key => condition_hash[key]}) }
39
+ System::Windows::Automation::AndCondition.new(r_array_to_cs_array_of_conditions(condition_array))
40
+ end
41
+
42
+ def single_condition(condition_hash)
43
+ case condition_hash.keys.first
44
+ when :id then id_condition(condition_hash)
45
+ when :name then name_condition(condition_hash)
46
+ when :type then type_condition(condition_hash)
47
+ end
48
+ end
49
+
50
+ def id_condition(condition_hash)
51
+ value = r_string_to_c_string(condition_hash[:id].to_s)
52
+ System::Windows::Automation::PropertyCondition.new(System::Windows::Automation::AutomationElement.automation_id_property, value)
53
+ end
54
+
55
+ def name_condition(condition_hash)
56
+ value = r_string_to_c_string(condition_hash[:name])
57
+ System::Windows::Automation::PropertyCondition.new(System::Windows::Automation::AutomationElement.name_property, value)
58
+ end
59
+
60
+ def type_condition(condition_hash)
61
+ value = Bewildr::ControlType.class_for_symbol(condition_hash[:type])
62
+ System::Windows::Automation::PropertyCondition.new(System::Windows::Automation::AutomationElement.control_type_property, value)
63
+ end
64
+ end
65
+ end
66
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bewildr
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 2
10
- version: 0.1.2
9
+ - 3
10
+ version: 0.1.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Nat Ritmeyer
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-06-07 00:00:00 +01:00
18
+ date: 2010-07-05 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -40,6 +40,7 @@ files:
40
40
  - lib/bewildr/control_patterns/range_value_pattern.rb
41
41
  - lib/bewildr/control_patterns/selection_item_pattern.rb
42
42
  - lib/bewildr/control_patterns/selection_pattern.rb
43
+ - lib/bewildr/control_patterns/table_item_pattern.rb
43
44
  - lib/bewildr/control_patterns/table_pattern.rb
44
45
  - lib/bewildr/control_patterns/text_pattern.rb
45
46
  - lib/bewildr/control_patterns/toggle_pattern.rb