android_workstation 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in android_workstation.gemspec
4
+ gemspec
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "android_workstation/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "android_workstation"
7
+ s.version = AndroidWorkstation::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Carl-Gustaf Harroch"]
10
+ s.email = ["carl@novoda.com"]
11
+ s.homepage = "https://github.com/charroch/android_workstation"
12
+ s.summary = %q{Utility tools to help with android development}
13
+ s.description = %q{Android utilities to be executed within the android root project following a standard structure (apk in bin folder etc...)}
14
+
15
+ s.rubyforge_project = "android_workstation"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+ s.add_dependency "thor"
22
+ end
data/bin/amanage ADDED
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'rexml/document'
5
+ require 'thor'
6
+
7
+ include REXML
8
+
9
+ class AndroidLocalManage < Thor
10
+
11
+ desc "pull [FILE]", "pull from the current directory's project the file specified"
12
+ def pull(file)
13
+ begin
14
+ manifest = Document.new(File.new(options[:manifest]))
15
+ rescue Exception=>e
16
+ puts "Could not find AndroidManifest.xml, execute from root of your project or use -m option to specify the location of the manifest"
17
+ exit(0)
18
+ end
19
+ package = package(manifest)
20
+ exec "adb pull /data/data/#{package}/files/#{file} ."
21
+ end
22
+
23
+ desc "install", "installing the APK located in bin against all devices connected"
24
+ def install
25
+ output = ""
26
+ IO.popen("adb devices") do |readme|
27
+ readme.each do |line|
28
+ output << line unless line.start_with? "List"
29
+ end
30
+ end
31
+ devices = output.scan(/(\w+)\tdevice\n+/)
32
+ puts "no device found"; exit(0) if devices.empty?
33
+ puts "no apk found in bin"; exit(0) if Dir.glob("bin/*.apk").empty?
34
+ devices.each do |d|
35
+ puts "installing #{Dir.glob("bin/*.apk").first} onto device with serial #{d[0]}"
36
+ exec "adb -s #{d[0]} install -r #{Dir.glob("bin/*.apk").first}"
37
+ end
38
+ end
39
+
40
+ private
41
+ def package(manifest)
42
+ XPath.each(manifest, "//manifest@package").first.attribute("package").value
43
+ end
44
+ end
45
+
46
+ AndroidLocalManage.start
data/bin/asql ADDED
@@ -0,0 +1,93 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'rexml/document'
5
+ require 'thor'
6
+
7
+ include REXML
8
+
9
+ class AndroidLocalSQLite < Thor
10
+
11
+ desc "dump", "dump the database attached to this project"
12
+ method_option :manifest, :type => :string, :aliases => "-m", :default => "#{Dir.pwd}/AndroidManifest.xml", :desc => "location of the AndroidManifest.xml for the project"
13
+ method_option :database_name, :type => :string, :aliases => "-n", :desc => "Database name defaulted to package name with '.db' as suffix (i.e. com.test.db)"
14
+ def dump
15
+ begin
16
+ manifest = Document.new(File.new(options[:manifest]))
17
+ rescue Exception=>e
18
+ puts "Could not find AndroidManifest.xml, execute from root of your project or use -m option to specify the location of the manifest"
19
+ exit(0)
20
+ end
21
+ package = package(manifest)
22
+ dbname = options[:database_name]
23
+ dbname ||= package + ".db"
24
+ exec "adb shell sqlite3 /data/data/#{package}/databases/#{dbname} .dump"
25
+ end
26
+
27
+ desc "select", "select from the database attached to this project"
28
+ method_option :manifest, :type => :string, :aliases => "-m", :default => "#{Dir.pwd}/AndroidManifest.xml", :desc => "location of the AndroidManifest.xml for the project"
29
+ method_option :database_name, :type => :string, :aliases => "-n", :desc => "Database name defaulted to package name with '.db' as suffix (i.e. com.test.db)"
30
+ method_option :table_name, :type => :string, :aliases => "-t", :option => :required, :desc => "the table name being selected"
31
+ method_option :fields, :type => :array, :aliases => "-f", :desc => "the fields to select"
32
+ method_option :raw, :type => :string, :desc => "execute a raw select (omiting the select)"
33
+ method_option :where, :type => :string, :aliases => "-w", :desc => "add a where clause to the query"
34
+ def select
35
+ begin
36
+ manifest = Document.new(File.new(options[:manifest]))
37
+ rescue Exception=>e
38
+ puts "Could not find AndroidManifest.xml, execute from root of your project or use -m option to specify the location of the manifest"
39
+ exit(0)
40
+ end
41
+ package = package(manifest)
42
+ dbname = options[:database_name]
43
+ dbname ||= package + ".db"
44
+
45
+ if options.where
46
+ where = "where " + options[:where]
47
+ end
48
+
49
+ if options.raw
50
+ exec "adb shell sqlite3 /data/data/#{package}/databases/#{dbname} 'select #{options[:raw]};'"
51
+ else
52
+ fields = options[:fields].join"," unless options[:fields].nil?
53
+ fields ||= "*"
54
+ exec "adb shell sqlite3 /data/data/#{package}/databases/#{dbname} 'select #{fields} from #{options[:table_name]} #{where};'"
55
+ end
56
+ end
57
+
58
+ desc "pull [FILE]", "pull from the current directory's project the file specified"
59
+ def pull(file)
60
+ begin
61
+ manifest = Document.new(File.new(options[:manifest]))
62
+ rescue Exception=>e
63
+ puts "Could not find AndroidManifest.xml, execute from root of your project or use -m option to specify the location of the manifest"
64
+ exit(0)
65
+ end
66
+ package = package(manifest)
67
+ exec "adb pull /data/data/#{package}/files/#{file} ."
68
+ end
69
+
70
+ desc "install", "installing the APK located in bin against all devices connected"
71
+ def install
72
+ output = ""
73
+ IO.popen("adb devices") do |readme|
74
+ readme.each do |line|
75
+ output << line unless line.start_with? "List"
76
+ end
77
+ end
78
+ devices = output.scan(/(\w+)\tdevice\n+/)
79
+ puts "no device found"; exit(0) if devices.empty?
80
+ puts "no apk found in bin"; exit(0) if Dir.glob("bin/*.apk").empty?
81
+ devices.each do |d|
82
+ puts "installing #{Dir.glob("bin/*.apk").first} onto device with serial #{d[0]}"
83
+ exec "adb -s #{d[0]} install -r #{Dir.glob("bin/*.apk").first}"
84
+ end
85
+ end
86
+
87
+ private
88
+ def package(manifest)
89
+ XPath.each(manifest, "//manifest@package").first.attribute("package").value
90
+ end
91
+ end
92
+
93
+ AndroidLocalSQLite.start
@@ -0,0 +1,2 @@
1
+ module AndroidWorkstation
2
+ end
@@ -0,0 +1,3 @@
1
+ module AndroidWorkstation
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: android_workstation
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.1
6
+ platform: ruby
7
+ authors:
8
+ - Carl-Gustaf Harroch
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-02-22 00:00:00 +00:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: thor
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: "0"
25
+ type: :runtime
26
+ version_requirements: *id001
27
+ description: Android utilities to be executed within the android root project following a standard structure (apk in bin folder etc...)
28
+ email:
29
+ - carl@novoda.com
30
+ executables:
31
+ - amanage
32
+ - asql
33
+ extensions: []
34
+
35
+ extra_rdoc_files: []
36
+
37
+ files:
38
+ - .gitignore
39
+ - Gemfile
40
+ - Rakefile
41
+ - android_workstation.gemspec
42
+ - bin/amanage
43
+ - bin/asql
44
+ - lib/android_workstation.rb
45
+ - lib/android_workstation/version.rb
46
+ has_rdoc: true
47
+ homepage: https://github.com/charroch/android_workstation
48
+ licenses: []
49
+
50
+ post_install_message:
51
+ rdoc_options: []
52
+
53
+ require_paths:
54
+ - lib
55
+ required_ruby_version: !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: "0"
61
+ required_rubygems_version: !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: "0"
67
+ requirements: []
68
+
69
+ rubyforge_project: android_workstation
70
+ rubygems_version: 1.5.2
71
+ signing_key:
72
+ specification_version: 3
73
+ summary: Utility tools to help with android development
74
+ test_files: []
75
+