Module: RAutomation::Adapter::Helper

Extended by:
Helper
Included in:
Helper, Window
Defined in:
lib/rautomation/adapter/helper.rb

Instance Method Summary collapse

Instance Method Details

#build_solution(ext)



34
35
36
37
38
39
# File 'lib/rautomation/adapter/helper.rb', line 34

def build_solution(ext)
  return if ext =~ /RAutomation.UIA.dll/ # skip this since its built in UiaDll.sln

  name = File.basename(ext, File.extname(ext))
  msbuild_solution(name)
end

#find_missing_externals(externals)



26
27
28
29
30
31
32
# File 'lib/rautomation/adapter/helper.rb', line 26

def find_missing_externals(externals)
  externals.select do |ext|
    path = "#{Dir.pwd}/#{File.dirname(ext)}"
    file = File.basename(ext)
    !Dir.exist?(path) && !File.exist?("#{path}/#{file}")
  end
end

#move_adapter_dlls(externals, architecture)

Raises:

  • (ArgumentError)


48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/rautomation/adapter/helper.rb', line 48

def move_adapter_dlls(externals, architecture)
  raise ArgumentError, "Invalid platform #{architecture}" unless %w[x86 x64].any? { |arch| arch == architecture }
  puts "Moving #{architecture} dll's into 'Release' folder.."

  externals.each do |dest_path|
    next if dest_path =~ /WindowsForms/
    dll_path = dest_path.gsub('Release', "#{architecture}Release")
    dest_dir = File.dirname(dest_path)
    FileUtils.mkdir_p(dest_dir) unless Dir.exist?(dest_dir)
    FileUtils.cp(dll_path, dest_path)
  end

  externals
end

#msbuild_solution(name)



41
42
43
44
45
46
# File 'lib/rautomation/adapter/helper.rb', line 41

def msbuild_solution(name)
  cmd = "msbuild /p:Configuration=Release ext\\#{name}\\#{name}.sln"
  cmd += " && #{cmd} /p:Platform=x64" unless name == 'WindowsForms'
  system(cmd) or raise StandardError, "An error occurred when trying to build solution #{name}. " +
                                      "Make sure msbuild binary is in your PATH and the project is configured correctly"
end

#supported_for_current_platform?(adapter) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/rautomation/adapter/helper.rb', line 22

def supported_for_current_platform?(adapter)
  Platform.is_x86? || adapter == :win_32
end