Module: Ruboto::Util::Verify
- Included in:
- Commands::Base, Build, Emulator, Setup, XMLElement
- Defined in:
- lib/ruboto/util/verify.rb
Constant Summary collapse
- ON_TRAVIS =
TODO: (uwe) Maybe check “/dev/kvm” ?
ENV['TRAVIS'] == 'true'
Instance Method Summary collapse
- #project_api_level ⇒ Object
- #project_properties ⇒ Object
- #save_manifest ⇒ Object
- #save_ruboto_config ⇒ Object
- #save_test_manifest ⇒ Object
- #verify_activity ⇒ Object
- #verify_api ⇒ Object
-
#verify_manifest(reload: false) ⇒ Object
Verify the presence of important components.
- #verify_min_sdk ⇒ Object
- #verify_package ⇒ Object
- #verify_project_properties ⇒ Object
- #verify_ruboto_config ⇒ Object
- #verify_sdk_versions ⇒ Object
- #verify_strings ⇒ Object
- #verify_target_sdk ⇒ Object
- #verify_test_manifest ⇒ Object
Instance Method Details
#project_api_level ⇒ Object
105 106 107 108 109 110 111 |
# File 'lib/ruboto/util/verify.rb', line 105 def project_api_level begin return $1 if project_properties =~ /^target=(.*)$/ rescue # ignored end end |
#project_properties ⇒ Object
98 99 100 101 102 103 |
# File 'lib/ruboto/util/verify.rb', line 98 def project_properties return @project_properties if @project_properties properties_file_name = 'project.properties' return nil unless File.exists? properties_file_name @project_properties = File.read(properties_file_name) end |
#save_manifest ⇒ Object
22 23 24 25 26 27 |
# File 'lib/ruboto/util/verify.rb', line 22 def save_manifest File.open('AndroidManifest.xml', 'w') do |f| REXML::Formatters::OrderedAttributes.new(4).write(verify_manifest.document, f) f.puts end end |
#save_ruboto_config ⇒ Object
89 90 91 |
# File 'lib/ruboto/util/verify.rb', line 89 def save_ruboto_config File.open('ruboto.yml', 'w') {|f| f << YAML.dump(verify_ruboto_config)} end |
#save_test_manifest ⇒ Object
35 36 37 |
# File 'lib/ruboto/util/verify.rb', line 35 def save_test_manifest File.open('test/AndroidManifest.xml', 'w') {|f| verify_test_manifest.document.write(f, 4)} end |
#verify_activity ⇒ Object
44 45 46 47 |
# File 'lib/ruboto/util/verify.rb', line 44 def verify_activity verify_manifest @activity ||= @manifest.elements['application/activity'].attribute('android:name').value end |
#verify_api ⇒ Object
77 78 79 |
# File 'lib/ruboto/util/verify.rb', line 77 def verify_api Ruboto::API.api end |
#verify_manifest(reload: false) ⇒ Object
Verify the presence of important components
14 15 16 17 18 19 20 |
# File 'lib/ruboto/util/verify.rb', line 14 def verify_manifest(reload: false) return @manifest if @manifest && !reload unless File.exists? 'AndroidManifest.xml' abort "cannot find your AndroidManifest.xml to extract info from it. Make sure you're in the root directory of your app" end @manifest = REXML::Document.new(File.read('AndroidManifest.xml')).root end |
#verify_min_sdk ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/ruboto/util/verify.rb', line 56 def verify_min_sdk return @min_sdk if @min_sdk verify_sdk_versions min_sdk_attr = @uses_sdk.attribute('android:minSdkVersion').value abort "you must specify a minimum sdk level in the manifest (e.g., <uses-sdk android:minSdkVersion='3' android:targetSdkVersion='8' />)" unless min_sdk_attr @min_sdk = min_sdk_attr.to_i end |
#verify_package ⇒ Object
39 40 41 42 |
# File 'lib/ruboto/util/verify.rb', line 39 def verify_package verify_manifest @package ||= @manifest.attribute('package').value end |
#verify_project_properties ⇒ Object
93 94 95 96 |
# File 'lib/ruboto/util/verify.rb', line 93 def verify_project_properties return @project_properties if project_properties abort "cannot find your #{properties_file_name} to extract info from it. Make sure you're in the root directory of your app." unless File.exists? properties_file_name end |
#verify_ruboto_config ⇒ Object
81 82 83 84 85 86 87 |
# File 'lib/ruboto/util/verify.rb', line 81 def verify_ruboto_config if File.exists? 'ruboto.yml' @ruboto_config ||= (YAML::load_file('ruboto.yml') || {}) else @ruboto_config = {} end end |
#verify_sdk_versions ⇒ Object
49 50 51 52 53 54 |
# File 'lib/ruboto/util/verify.rb', line 49 def verify_sdk_versions verify_manifest @uses_sdk ||= @manifest.elements['uses-sdk'] abort "you must specify your sdk level in the manifest (e.g., <uses-sdk android:minSdkVersion='3' android:targetSdkVersion='8' />)" unless @uses_sdk @uses_sdk end |
#verify_strings ⇒ Object
72 73 74 75 |
# File 'lib/ruboto/util/verify.rb', line 72 def verify_strings abort "cannot find your strings.xml to extract info from it. Make sure you're in the root directory of your app" unless File.exists? 'res/values/strings.xml' @strings ||= REXML::Document.new(File.read('res/values/strings.xml')) end |
#verify_target_sdk ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/ruboto/util/verify.rb', line 64 def verify_target_sdk return @target_sdk if @target_sdk verify_sdk_versions target_sdk_attr = @uses_sdk.attribute('android:targetSdkVersion').value abort "you must specify a target sdk level in the manifest (e.g., <uses-sdk android:minSdkVersion='3' android:targetSdkVersion='8' />)" unless target_sdk_attr @target_sdk = target_sdk_attr.to_i end |
#verify_test_manifest ⇒ Object
29 30 31 32 33 |
# File 'lib/ruboto/util/verify.rb', line 29 def verify_test_manifest abort "cannot find your test AndroidManifest.xml to extract info from it. Make sure you're in the root directory of your app" \ unless File.exists? 'test/AndroidManifest.xml' @manifest ||= REXML::Document.new(File.read('test/AndroidManifest.xml')).root end |