xamarin-automators-calabash 0.1.5 → 0.1.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: 937a48078b47858580c635a2e5d7a6012be28835
4
- data.tar.gz: 9fb63072c0f6674d7092f844e8b7adb626c390cc
3
+ metadata.gz: c77e00f95f9e3e4400957387dab965cdea0260d8
4
+ data.tar.gz: 981669929456226e1eb2dccb0ec8464606471b58
5
5
  SHA512:
6
- metadata.gz: 1eb4fe93deb96c386aa66d0b718f0c5286b800c34f794e5f7ec31d97acc2ee82064e1ce93f914a9dea22967fb87912dbda53587c664f9bb6533177df2e2836e5
7
- data.tar.gz: 494860226dc2ebf14a9badba730c5cd21156c950ed088812f1996b22e22666efad444fd5d7f64d91152a9b54db94a2af7422dc5d07545be69a4ef98f4bfe9d2d
6
+ metadata.gz: a5b695e4cba04c7c69c65b357a2e819fde7e6498b9f4069b317f6a15557b015f8deb198a74b300897eaeee9402b17352c8df39125569474e8b7a2787b32bb1ea
7
+ data.tar.gz: 1770ea36df57d1aab884cdbfa657f43f490611053c53f599af4d55907482477728171d30cf63685abeeb486bb1e54058e3fb505cd711fad942d07c7bc706ef91
@@ -3,15 +3,15 @@ require 'awesome_print'
3
3
  #
4
4
 
5
5
  def get_roots
6
- all_items = query "*"
7
- all_items.map {|x| x.delete("description")}
6
+ @all_items = query "*"
7
+ @all_items.map {|x| x.delete("description")}
8
8
  roots = Hash.new
9
- roots[0] = all_items[0]
9
+ roots[0] = @all_items[0]
10
10
  print "Found root(s) at: 0"
11
- (1..(all_items.count-1)).each do |i|
11
+ (1..(@all_items.count-1)).each do |i|
12
12
  parents_children = query("* index:#{i} parent * index:0 child *")
13
13
  parents_children.map {|x| x.delete("description")}
14
- unless parents_children.include? all_items[i]
14
+ unless parents_children.include? @all_items[i]
15
15
  print ", #{i}"
16
16
  parent = query("* index:#{i} parent * index:0").first
17
17
  unless parent.nil?
@@ -24,42 +24,54 @@ def get_roots
24
24
  return roots
25
25
  end
26
26
 
27
- def print_tree(show_class=false)
27
+ def print_tree(show_class=false, show_index=false)
28
28
  puts "Finding roots..."
29
29
  @roots = get_roots
30
30
  @count = 1
31
31
  main_root = @roots[0]
32
32
  @roots.delete(0)
33
- print_tree_recurse("* index:0", (query "* index:0").first, 0, show_class)
33
+ print_tree_recurse("* index:0", (query "* index:0").first, 0, show_class, show_index)
34
34
  @roots.each do |key, value|
35
35
  @count += 1
36
36
  puts "#{magenta("** Parent off of screen **")}"
37
- print_tree_recurse("* index:#{key}", (query "* index:#{key}").first, 0, show_class)
37
+ print_tree_recurse("* index:#{key}", (query "* index:#{key}").first, 0, show_class, show_index)
38
38
  end
39
39
  "Found #{@count} nodes"
40
40
  end
41
41
 
42
- def print_tree_recurse(query, node, indent, show_class)
43
- node.delete("description")
42
+ def roots_with_value(node)
43
+ return @roots.select {|k,v| v == node }
44
+ end
45
+
46
+ def print_tree_recurse(query, node, indent, show_class, show_index)
47
+ node.delete("description") unless node["description"].nil?
44
48
  indent.times { print " " }
45
49
  print "id: #{green(node["id"])} " unless node["id"].nil?
46
- print "text: #{cyan(node["text"])} " unless node["text"].nil?
50
+ print "text: '#{cyan(node["text"])}' " unless node["text"].nil?
47
51
  if show_class or (node["id"].nil? and node["text"].nil?)
48
- print "class: #{yellow(node["class"].split(/[$.]/).last)}"
52
+ print "class: #{yellow(node["class"].split(/[$.]/).last)} "
53
+ end
54
+ if show_index
55
+ index = @all_items.index(node)
56
+ print "index: #{magenta("#{index}")} "
49
57
  end
50
58
  print "\n"
51
59
  children = query("#{query} child *")
52
- if @roots.has_value?(node)
53
- index = @roots.key(node)
54
- sub_root_query = "* index:#{index}"
55
- sub_root = query(sub_root_query).first
56
- @roots.delete(index)
57
- @count += 1
58
- print_tree_recurse(sub_root_query, sub_root, indent+1, show_class)
60
+ roots = roots_with_value(node)
61
+ if roots.size != 0
62
+ roots.each do |k,v|
63
+ sub_root_query = "* index:#{k}"
64
+ sub_root = query(sub_root_query).first
65
+ @roots.delete(k)
66
+ @count += 1
67
+ (indent+1).times { print " " }
68
+ print "#{magenta("**")}\n"
69
+ print_tree_recurse(sub_root_query, sub_root, indent+2, show_class, show_index)
70
+ end
59
71
  end
60
72
  (children.size).times do |i|
61
73
  @count += 1
62
- print_tree_recurse("#{query} child * index:#{i}", children[i], indent+1, show_class)
74
+ print_tree_recurse("#{query} child * index:#{i}", children[i], indent+1, show_class, show_index)
63
75
  end
64
76
  end
65
77
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xamarin-automators-calabash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Austin Roos