xamarin-automators-calabash 0.1.1 → 0.1.2

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: 3043733165676ca0cd221b3dc405f74009b08d17
4
- data.tar.gz: f03186de8b994d30b65227f745616caa52bb66c6
3
+ metadata.gz: 337e9c7e621d4266d6168d47cf314d62f7a6399e
4
+ data.tar.gz: 60e11706822def97e8507a60ee0d523a92df704a
5
5
  SHA512:
6
- metadata.gz: bf42c0cd78f94491e5f265dafcfe3dfe26ec4012f49e9bf6b4a1dfd6a515239841220ec067bd23bbc321184d8c23ab7cd0403f2ce314f1ce217edf519c988f03
7
- data.tar.gz: 4b8324dd7c6f681a59f560b8b961d7bc2189453b50ae44cad55e369c9b5d23c5028bf2442b1162c80ce026bdda6f4a77d53eb0c69162ce4939bdaaf14d6baf28
6
+ metadata.gz: 63a85aabd91faa936506e1e65688360454bce0406b226bd8a5c6bc70aca818f08b010edf66bf237e094d244ec3a52a4b92e0148c6b3da0aef843edd77334e8a4
7
+ data.tar.gz: 6e0e44624e8b2a574540b041f956b80c62c0af056f94aacc9927bbfc81865d2380527c55d2f8ef31b2a4c5ea0a3c3b3a22dd7ad9481df581f6553240f57be346
@@ -1,40 +1,41 @@
1
1
  require 'awesome_print'
2
+ # print_tree calls print_tree_recurse with only index 0 and also hash of roots
3
+ #
2
4
 
3
- def get_root_indexes
4
- all_items = (query "*")
5
- all_items.map {|x| x.delete("description")}
6
- indexes = Array.new
7
- print "Found root(s) at: "
8
- first = true
9
- (0..(all_items).count-1).each do |i|
10
- parents_children = query("* index:#{i} parent * index:0 child *")
11
- parents_children.map {|x| x.delete("description")}
12
- unless parents_children.include? all_items[i]
13
- if first
14
- print "#{i}"
15
- first = false
16
- else
17
- print ", #{i}"
18
- end
19
- indexes.push i
20
- end
21
- end
22
- print "\n"
23
- return indexes
5
+ def get_roots
6
+ all_items = query "*"
7
+ all_items.map {|x| x.delete("description")}
8
+ roots = Hash.new
9
+ roots[0] = all_items[0]
10
+ print "Found root(s) at: 0"
11
+ (1..(all_items.count-1)).each do |i|
12
+ parents_children = query("* index:#{i} parent * index:0 child *")
13
+ parents_children.map {|x| x.delete("description")}
14
+ unless parents_children.include? all_items[i]
15
+ print ", #{i}"
16
+ parent = query("* index:#{i} parent * index:0").first
17
+ unless parent.nil?
18
+ parent.delete("description")
19
+ end
20
+ roots[i] = parent
21
+ end
22
+ end
23
+ print "\n"
24
+ return roots
24
25
  end
25
26
 
26
27
  def print_tree(show_class=false)
27
28
  puts "Finding roots..."
28
- roots = get_root_indexes
29
- @count = roots.count
30
- roots.each do |i|
31
- print_tree_recurse("* index:#{i}", (query "* index:#{i}").first, 0, show_class)
32
- end
33
- # print_tree_recurse("child * parent * index:0", (query "* index:0").first, 0, show_class)
34
- return "Number of nodes printed: #{@count}"
29
+ roots = get_roots
30
+ @count = 1
31
+ main_root = roots[0]
32
+ roots.delete(0)
33
+ print_tree_recurse("* index:0", (query "* index:0").first, 0, show_class, roots)
34
+ "Found #{@count} nodes"
35
35
  end
36
36
 
37
- def print_tree_recurse(query, node, indent, show_class)
37
+ def print_tree_recurse(query, node, indent, show_class, roots)
38
+ node.delete("description")
38
39
  indent.times { print " " }
39
40
  print "id: #{green(node["id"])} " unless node["id"].nil?
40
41
  print "text: #{cyan(node["text"])} " unless node["text"].nil?
@@ -44,17 +45,23 @@ def print_tree_recurse(query, node, indent, show_class)
44
45
  print "--" if (node["id"].nil? and node["text"].nil?)
45
46
  end
46
47
  print "\n"
47
- children = query "#{query} child *"
48
+ children = query("#{query} child *")
49
+ if roots.has_value?(node)
50
+ index = roots.key(node)
51
+ sub_root_query = "* index:#{index} child *"
52
+ sub_root_children = query(sub_root_query)
53
+ roots.delete(index)
54
+ (sub_root_children.size).times do |j|
55
+ @count += 1
56
+ print_tree_recurse(sub_root_query + " index:#{j}", sub_root_children[j], indent+1, show_class, roots)
57
+ end
58
+ end
48
59
  (children.size).times do |i|
49
60
  @count += 1
50
- print_tree_recurse("#{query} child * index:#{i}", children[i], indent+1, show_class)
61
+ print_tree_recurse("#{query} child * index:#{i}", children[i], indent+1, show_class, roots)
51
62
  end
52
63
  end
53
64
 
54
- def print_tree_partial(query, show_class=false)
55
- print_tree_recurse("#{query} index:0", (query "#{query} index:0").first, 0, show_class)
56
- end
57
-
58
65
  def colorize(text, color_code)
59
66
  "\e[#{color_code}m#{text}\e[0m"
60
67
  end
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.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Austin Roos