lib/dryrun/android_project.rb in dryrun-0.6.4 vs lib/dryrun/android_project.rb in dryrun-0.6.5

- old
+ new

@@ -34,22 +34,26 @@ def remove_local_properties Dir.chdir @base_path file_name = 'local.properties' File.delete(file_name) if File.exist?(file_name) - - DryrunUtils.execute("touch #{file_name}") + if !Gem.win_platform? + DryrunUtils.execute("touch #{file_name}") + end end def remove_application_id # Open temporary file tmp = Tempfile.new("extract") file = "#{@path_to_sample}/build.gradle" # Write good lines to temporary file - open(file, 'r').each { |l| tmp << l unless l.include? 'applicationId' } + File.open(file, 'r') do |file| + file.each do |l| tmp << l unless l.include? 'applicationId' + end + end tmp.close # Move temp file to origin FileUtils.mv(tmp.path, file) end @@ -83,12 +87,13 @@ builder = "gradle" if File.exist?('gradlew') if !Gem.win_platform? DryrunUtils.execute('chmod +x gradlew') + else + DryrunUtils.execute("icacls gradlew /T") end - builder = './gradlew' end # Generate the gradle/ folder DryrunUtils.execute('gradle wrap') if File.exist?('gradlew') and !is_gradle_wrapped @@ -151,11 +156,11 @@ def uninstall_application DryrunUtils.execute(get_uninstall_command) # > /dev/null 2>&1") end def get_execution_line_command(path_to_sample) - manifest_file = get_manifest(path_to_sample) + manifest_file = get_manifest(path_to_sample) if manifest_file.nil? return false end @@ -188,21 +193,21 @@ full_path_to_launcher = "#{@package}#{@launcher_activity.gsub(@package,'')}" "#{@package}/#{full_path_to_launcher}" end def get_package(doc) - doc.xpath("//manifest").attr('package').first.value - end + doc.xpath("//manifest").attr('package').first.value + end - def get_launcher_activity(doc) - activities = doc.css('activity') - activities.each do |child| - intent_filter = child.css('intent-filter') + def get_launcher_activity(doc) + activities = doc.css('activity') + activities.each do |child| + intent_filter = child.css('intent-filter') - if intent_filter != nil and intent_filter.length != 0 - return child.attr("android:name").value - end + if intent_filter != nil and intent_filter.length != 0 + return child.attr("android:name").value end - false end + false end +end end