motion-accessibility 1.0.3 → 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
  SHA1:
3
- metadata.gz: e21cc5aefae606f8fe216ccc78d34391dd7f9acb
4
- data.tar.gz: f4403f5ea6cba4481adc565676a376bf0e585a1a
3
+ metadata.gz: 09dd0711b1a6ee53a0c7db8a88fd89c23ab1eb5a
4
+ data.tar.gz: 59df3af595dad1192d4315bb5b0feaeee73ac592
5
5
  SHA512:
6
- metadata.gz: 26fb160a63785a4b6c629e5cbca426cb93433a2245c05e64695cb50cc5ac47009929fb3cf9a8e18d2df099111b4def9e424e10a97f9e16a69a711c2eae5e1a86
7
- data.tar.gz: cfbffc6d828abce4299cc3a332e86e18fdb708c2ce79c30aa897a4d99d02214506ff5640d67e04cd1b8414db27368296d901df50a507e0ce48306b711f9e833f
6
+ metadata.gz: fc4269d468e95a783c2690e5adbab380fc8a271fbb3744c4781ce624161f531facd6d89f1f04c99b2470b9d0108caf73d3b3a19236bfe36c089aacd4c244afe0
7
+ data.tar.gz: b10596326aa2b79dbbcc05ecdcfe9322428cf843498ae0cb3cb36ba5753741eee8913282f5d657c3add4e7370206b6e04a04372b9b1fa6c0e3ad5bf0520c8936
data/README.md CHANGED
@@ -23,6 +23,31 @@ Or install it yourself as:
23
23
  $ gem install motion-accessibility
24
24
 
25
25
  ## Usage
26
+ ### The Accessibility Inspector
27
+
28
+ You can easily see the state of any of the following attributes and methods by using the accessibility inspector. Just call the `inspect_accessibility` method on any object.
29
+
30
+ ```
31
+ main)> label=UILabel.alloc.initWithFrame(CGRectMake(0, 0, 100, 100))
32
+ => #<UILabel:0xb062870>
33
+ (main)> label.text="Hello!"
34
+ => "Hello!"
35
+ (main)> label.inspect_accessibility
36
+ Accessibility label: "Hello!"
37
+ Accessibility hint: nil
38
+ Accessibility traits: Static text
39
+ Accessibility value: nil
40
+ Accessibility language: nil
41
+ Accessibility frame: x=0.0 y=0.0 width=100.0 height=100.0
42
+ Accessibility activation point: x=0.0 y=0.0
43
+ Accessibility view is modal: false
44
+ Should group accessibility children: false
45
+ Accessibility elements hidden: false
46
+ Is accessibility element: false
47
+ Accessibility identifier: nil
48
+ ```
49
+
50
+ By the way, `a11y` stands for `accessibility`, because it has a, then 11 letters, then y. Hence, you can use `inspect_a11y` as a shortcut. You can also use this abreviation when referring to the Accessibility class, for instance `A11y::Element`.
26
51
 
27
52
  ### UIAccessibility Informal Protocol
28
53
 
@@ -3,13 +3,12 @@ class Accessibility
3
3
  Data={}
4
4
 
5
5
  Attributes = {
6
- :accessibility_identifier => :accessibilityIdentifier,
7
- :accessibility_identifier= => :setAccessibilityIdentifier,
8
6
  :accessibility_label => :accessibilityLabel,
9
7
  :accessibility_label= => :setAccessibilityLabel,
10
8
  :accessibility_hint => :accessibilityHint,
11
9
  :accessibility_hint= => :setAccessibilityHint,
12
10
  :accessibility_traits => :accessibilityTraits,
11
+ :accessibility_traits= => :setAccessibilityTraits,
13
12
  :accessibility_value => :accessibilityValue,
14
13
  :accessibility_value= => :setAccessibilityValue,
15
14
  :accessibility_language => :accessibilityLanguage,
@@ -33,7 +32,9 @@ Attributes = {
33
32
  :accessibility_element_focused? => :accessibilityElementIsFocused,
34
33
  :accessibility_element? => :isAccessibilityElement,
35
34
  :is_accessibility_element => :isAccessibilityElement,
36
- :is_accessibility_element= => :isAccessibilityElement=
35
+ :is_accessibility_element= => :setIsAccessibilityElement,
36
+ :accessibility_identifier => :accessibilityIdentifier,
37
+ :accessibility_identifier= => :setAccessibilityIdentifier
37
38
  }
38
39
 
39
40
  Element_Attributes = {
@@ -85,13 +86,13 @@ PickerView_Attributes = {
85
86
  }
86
87
 
87
88
  Container_Attributes = {
88
- :accessibility_element_at_index => :accessibilityElementAtIndex,
89
89
  :accessibility_element_count => :accessibilityElementCount,
90
+ :accessibility_element_at_index => :accessibilityElementAtIndex,
90
91
  :index_of_accessibility_element => :indexOfAccessibilityElement
91
92
  }
92
93
 
93
94
  Reading_Content = {
94
- accessibility_content_for_line_number: :accessibbilityContentForLineNumber,
95
+ accessibility_content_for_line_number: :accessibilityContentForLineNumber,
95
96
  accessibility_frame_for_line_number: :accessibilityFrameForLineNumber,
96
97
  accessibility_line_number_for_point: :accessibilityLineNumberForPoint,
97
98
  accessibility_page_content: :accessibilityPageContent
@@ -145,6 +146,67 @@ Zoom = {
145
146
  :announcement_key_was_successful => UIAccessibilityAnnouncementKeyWasSuccessful
146
147
  }
147
148
 
149
+ Attribute_Types = {
150
+ :accessibilityIdentifier =>:string,
151
+ :accessibilityLabel => :string,
152
+ :accessibilityHint => :string,
153
+ :accessibilityTraits => :fixnum,
154
+ :accessibilityValue=>:string,
155
+ :accessibilityLanguage=>:string,
156
+ :accessibilityFrame=>:cgrect,
157
+ :accessibilityActivationPoint=>:cgpoint,
158
+ :accessibilityViewIsModal=>:boolean,
159
+ :shouldGroupAccessibilityChildren=>:boolean,
160
+ :accessibilityElementsHidden=>:boolean,
161
+ :isAccessibilityElement=>:boolean
162
+ }
163
+
164
+ Default_Type_Values = {
165
+ :string => "Testing",
166
+ :boolean => true,
167
+ :fixnum => 23,
168
+ :cgrect=>CGRectMake(0,0,100,100),
169
+ :cgpoint=>CGPointMake(100,100)
170
+ }
171
+
172
+ def self.attribute_type(attribute)
173
+ Attribute_Types[attribute]||nil
174
+ end
175
+
176
+ Defined_Attributes=Hash.new
177
+
178
+ def self.defined_attribute(class_name, attribute)
179
+ Defined_Attributes[class_name]||=Array.new
180
+ Defined_Attributes[class_name]<<attribute
181
+ end
182
+
183
+ def self.defined_attribute?(class_name, attribute)
184
+ attributes=Defined_Attributes[class_name]
185
+ return false if attributes.nil?
186
+ attributes.member?(attribute)
187
+ end
188
+
189
+ Touchable_Types = ["UITextField", "UIButton", "UIPickerView", "UIDatePicker",
190
+ "UISegmentedControl", "UISlider", "UIStepper", "UISwitch"]
191
+
192
+ private
193
+ def compile_attributes
194
+ # Needed just to include these
195
+ view=UIView.new
196
+ view.accessibilityActivationPoint=CGPoint.new(100,100)
197
+ view.accessibilityViewIsModal=true
198
+ view.shouldGroupAccessibilityChildren=true
199
+ view.accessibilityElementsHidden=true
200
+ view.isAccessibilityElement=true
201
+ view.accessibilityTraits==0
202
+ view.accessibilityActivationPoint==nil
203
+ view.accessibilityViewIsModal==nil
204
+ view.shouldGroupAccessibilityChildren==nil
205
+ view.accessibilityElementsHidden==nil
206
+ view.isAccessibilityElement==true
207
+ view.indexOfAccessibilityElement(0)
208
+ end
209
+
148
210
  end
149
211
 
150
212
  class Symbol
@@ -166,3 +228,5 @@ Accessibility::Zoom[self]||(raise("Unknown zoom type #{self}"))
166
228
  end
167
229
 
168
230
  end
231
+
232
+ A11y=Accessibility unless defined?(A11y)
@@ -0,0 +1,48 @@
1
+ # Accessibility Inspector
2
+
3
+ class Object
4
+
5
+ def inspect_accessibility
6
+ displayed=[]
7
+ attributes=Accessibility::All_Attributes.dup
8
+ attributes.merge(Accessibility::PickerView_Attributes) if self.class==UIPickerView
9
+ puts self.inspect
10
+ attributes.each do |ruby,ios|
11
+ next if ios=~/^set/
12
+ next if displayed.member?(ios)
13
+ self.inspect_accessibility_attribute(ios)
14
+ displayed<<ios
15
+ end
16
+ nil
17
+ end
18
+
19
+ alias :inspect_a11y :inspect_accessibility
20
+
21
+ protected
22
+
23
+ def inspect_accessibility_attribute(attribute)
24
+ name=attribute.gsub(/(.)([A-Z])/,'\1 \2').capitalize
25
+ if Accessibility::Attribute_Types.member?(attribute)
26
+ begin
27
+ case attribute
28
+ when :accessibilityTraits then value=inspect_accessibility_traits
29
+ else
30
+ value=self.send(attribute).inspect
31
+ end
32
+ case Accessibility.attribute_type(attribute)
33
+ when :boolean
34
+ value=true if value==1
35
+ value=false if value==0||value.nil?
36
+ when :cgrect then value="x=#{self.origin.x} y=#{self.origin.y} width=#{self.size.width} height=#{self.size.height}"
37
+ when :cgpoint then value="x=#{self.origin.x} y=#{self.origin.y}"
38
+ end
39
+ rescue
40
+ value="Error: #{$!}"
41
+ end
42
+ puts "#{name}: #{value}"
43
+ elsif Accessibility.defined_attribute?(self.class,attribute)
44
+ puts "#{name}: Defined"
45
+ end
46
+ end
47
+
48
+ end
@@ -1,23 +1,25 @@
1
+
1
2
  class NSObject
2
3
 
3
4
  Accessibility::Attributes.each do |ruby, ios|
4
5
  next if ruby==:accessibility_traits=
5
6
  if ruby=~/=$/
6
7
  define_method(ruby) {|value| self.send(ios,value)}
7
- elsif(ruby=~/^is_|\?$/)
8
+ else
8
9
  define_method(ruby) do
9
10
  result=self.send(ios)
11
+ case Accessibility.attribute_type(ios)
12
+ when :boolean
10
13
  result=true if result==1
11
- result=false if result==0
14
+ result=false if result==0||result.nil?
15
+ end
12
16
  result
13
17
  end
14
- else
15
- define_method(ruby) {self.send(ios)}
16
18
  end
17
19
  end
18
20
 
19
21
  Accessibility::Container_Attributes.each do |ruby, ios|
20
- if ruby=="accessibility_element_count"
22
+ if ruby==:accessibility_element_count
21
23
  define_method(ruby) {self.send(ios)}
22
24
  else
23
25
  define_method(ruby) {|n| self.send(ios,n)}
@@ -38,6 +40,19 @@ else
38
40
  raise "Pass a bitmask, a symbol, or an array to accessibility_traits="
39
41
  end
40
42
  self.accessibilityTraits=bits
43
+ self
44
+ end
45
+
46
+ def inspect_accessibility_traits
47
+ traits=[]
48
+ Accessibility::Traits.each do |trait, bitmask|
49
+ if self.accessibility_traits&bitmask>0
50
+ name=trait.gsub(/_/,' ').capitalize
51
+ traits<<name
52
+ end
53
+ end
54
+ traits=["None"] if traits.empty?
55
+ traits.join(', ')
41
56
  end
42
57
 
43
58
  if self.respond_to?(:method_added)
@@ -63,6 +78,7 @@ ios=name
63
78
  ruby=attributes.rassoc(name).first
64
79
  define_method(ruby) { self.send(ios)}
65
80
  end
81
+ Accessibility.defined_attribute(self,ios)
66
82
  end
67
83
 
68
84
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motion-accessibility
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: '1.1'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Austin Seraphin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-04 00:00:00.000000000 Z
11
+ date: 2013-07-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -35,7 +35,7 @@ files:
35
35
  - lib/motion-accessibility.rb
36
36
  - lib/project/constants.rb
37
37
  - lib/project/element.rb
38
- - lib/project/motion-accessibility.rb
38
+ - lib/project/inspector.rb
39
39
  - lib/project/object.rb
40
40
  - lib/project/picker.rb
41
41
  - lib/project/status.rb
@@ -1,6 +0,0 @@
1
- class Motion
2
- class Accessibility
3
-
4
- end
5
- end
6
-