Class: AutoWindowFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/auto_window_finder.rb

Class Method Summary collapse

Class Method Details

.search_for_player_and_url_match(player_root_dir) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/auto_window_finder.rb', line 28

def self.search_for_player_and_url_match player_root_dir
  for filename in Dir[player_root_dir + '/*/*.txt']
    settings = YAML.load_file filename
    if regex = settings["window_title"] # assume regex :)
      p 'searching for player regex', regex
      if search_for_single_url_match regex # applies the regex X url
        return filename
      end
    end
  end
  nil
end

.search_for_single_url_match(regexp = /Chrome/) ⇒ Object

when they select a file, it contains a…url say… so look for that url, with “this” child window class [?] so basically, if a browser window is “open” to such and such a url and it is mentioned in a file it should find it



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/auto_window_finder.rb', line 12

def self.search_for_single_url_match regexp = /Chrome/
  EdlParser.find_single_edit_list_matching(true) {|parsed|
    if url = parsed["url"]
      window = RAutomation::Window.new(:title => regexp)
      if window.exist? 
        if window.text =~ Regexp.new(Regexp.escape url.gsub(/http(s|):\/\//, ""))
          p 'got match' + url
          true
        else
          false
        end
      end
    end
  }
end