class Screengrab::AndroidEnvironment
Attributes
android_home[R]
build_tools_version[R]
Public Class Methods
new(android_home, build_tools_version)
click to toggle source
android_home
- the String
path to the install location of the Android SDK build_tools_version
- the String
version of the Android build tools that should be used
# File screengrab/lib/screengrab/android_environment.rb, line 11 def initialize(android_home, build_tools_version) @android_home = android_home @build_tools_version = build_tools_version end
Public Instance Methods
aapt_path()
click to toggle source
# File screengrab/lib/screengrab/android_environment.rb, line 28 def aapt_path @aapt_path ||= find_aapt(build_tools_path) end
adb_path()
click to toggle source
# File screengrab/lib/screengrab/android_environment.rb, line 24 def adb_path @adb_path ||= find_adb(platform_tools_path) end
build_tools_path()
click to toggle source
# File screengrab/lib/screengrab/android_environment.rb, line 20 def build_tools_path @build_tools_path ||= find_build_tools(android_home, build_tools_version) end
platform_tools_path()
click to toggle source
# File screengrab/lib/screengrab/android_environment.rb, line 16 def platform_tools_path @platform_tools_path ||= find_platform_tools(android_home) end
Private Instance Methods
executable_command?(cmd_path)
click to toggle source
# File screengrab/lib/screengrab/android_environment.rb, line 87 def executable_command?(cmd_path) Helper.executable?(cmd_path) end
find_aapt(build_tools_path)
click to toggle source
# File screengrab/lib/screengrab/android_environment.rb, line 80 def find_aapt(build_tools_path) return FastlaneCore::CommandExecutor.which('aapt') unless build_tools_path aapt_path = File.join(build_tools_path, 'aapt') return executable_command?(aapt_path) ? aapt_path : nil end
find_adb(platform_tools_path)
click to toggle source
# File screengrab/lib/screengrab/android_environment.rb, line 73 def find_adb(platform_tools_path) return FastlaneCore::CommandExecutor.which('adb') unless platform_tools_path adb_path = File.join(platform_tools_path, 'adb') return executable_command?(adb_path) ? adb_path : nil end
find_build_tools(android_home, build_tools_version)
click to toggle source
# File screengrab/lib/screengrab/android_environment.rb, line 41 def find_build_tools(android_home, build_tools_version) return nil unless android_home build_tools_dir = File.join(android_home, 'build-tools') return nil unless build_tools_dir && File.directory?(build_tools_dir) return File.join(build_tools_dir, build_tools_version) if build_tools_version version = select_build_tools_version(build_tools_dir) return version ? File.join(build_tools_dir, version) : nil end
find_platform_tools(android_home)
click to toggle source
# File screengrab/lib/screengrab/android_environment.rb, line 34 def find_platform_tools(android_home) return nil unless android_home platform_tools_path = File.join(android_home, 'platform-tools') File.directory?(platform_tools_path) ? platform_tools_path : nil end
select_build_tools_version(build_tools_dir)
click to toggle source
# File screengrab/lib/screengrab/android_environment.rb, line 55 def select_build_tools_version(build_tools_dir) # Collect the sub-directories of the build_tools_dir, rejecting any that start with '.' to remove . and .. dir_names = Dir.entries(build_tools_dir).select { |e| !e.start_with?('.') && File.directory?(File.join(build_tools_dir, e)) } # Collect a sorted array of Version objects from the directory names, handling the possibility that some # entries may not be valid version names versions = dir_names.map do |d| begin Gem::Version.new(d) rescue nil end end.reject(&:nil?).sort # We'll take the last entry (highest version number) as the directory name we want versions.last.to_s end