ash-adb 0.0.1 → 0.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 189ce0215b54ce1e81fd908a40ced6ddb63a2f20
4
- data.tar.gz: 769770d1547881b0b3ba63c6a7c4d7c48992c039
3
+ metadata.gz: fb51d22bdfcb4d9ac01e9574861286c5460d76e6
4
+ data.tar.gz: bbe60abb07c74961cfe707cba27d9f5273d22d61
5
5
  SHA512:
6
- metadata.gz: 6ead681b5facab5f685c613fda8ed87d3eb82b6490043cc5aafe2af3b1ad2d0863226ed7d2c6e38b484b1d4a275afdae935616c19776c77e2fcf91fe45b2bc3f
7
- data.tar.gz: e903f6f24a6a5e358a1aae40a23e42a62f58dec65347b3c2f94c97ea858227a35079a2a3c4dc4f40e4e621db2ae94f6bd06e36cb54e80dbfdfe4aaf06588655f
6
+ metadata.gz: ccf3ef6f6c2837f49e19e114205d48ffa7f19971e056f6547c293339ff5e1b327cf8002ddcab5dbbff14486b4dc0dc463c3c6499058fa64a3944623e0c3c5c2f
7
+ data.tar.gz: 0e802534e869a224ed752b87f2b2d41f0d65c993313f88e28ec61fb6430f3e6e8de6068780dfb6a0cc8c7c97663debe07228e4c09c7658a55ba02580462eff8a
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ *.swp
data/README.md CHANGED
@@ -25,18 +25,22 @@ Or install it yourself as:
25
25
  ### Listing Devices
26
26
 
27
27
  ```ruby
28
- client = Ash::Adb::Client.new
29
- devices = client.devices
28
+ require 'ash/adb'
30
29
 
30
+ devices = Ash::Adb::Client.devices
31
+
32
+ # listing devices
31
33
  devices.first.serial_number
32
- => "emulator-5554"
34
+ # => "emulator-5554"
35
+
36
+ # listing packages
37
+ devices.first.packages
38
+ devices.first.packages.first.package_name
39
+ # => "com.android.gallery3d"
40
+ devices.first.packages.first_package_path
41
+ # => "/system/app/Gallery2/Gallery2.apk"
33
42
  ```
34
43
 
35
- ### List Packages for a Device
36
-
37
- TODO
38
-
39
-
40
44
  ## Development
41
45
 
42
46
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -1,11 +1,11 @@
1
1
  module Ash::Adb
2
- class Client
3
- def devices
2
+ module Client
3
+ def self.devices
4
4
  devices = []
5
5
 
6
6
  devices_output = run('adb devices -l')
7
7
 
8
- # Device output is newline seperated and we also want to drop the first
8
+ # Device output is newline separated and we also want to drop the first
9
9
  # line which is the "List of devices attached" string
10
10
  device_strings = devices_output.split("\n").drop(1)
11
11
 
@@ -29,14 +29,13 @@ module Ash::Adb
29
29
  devices
30
30
  end
31
31
 
32
- private
33
32
 
34
- def run(cmd)
35
- output, errors, status = Open3.capture3(cmd)
33
+ def self.run(cmd)
34
+ output, errors, status = Open3.capture3(cmd)
36
35
 
37
- raise "Error running #{ cmd }: #{ errors.inspect }" unless errors.empty?
36
+ raise "Error running #{ cmd }: #{ errors.inspect }" unless errors.empty?
38
37
 
39
- return output
40
- end
38
+ return output
39
+ end
41
40
  end
42
41
  end
@@ -1,11 +1,21 @@
1
1
  module Ash::Adb
2
2
  class Device
3
- attr_reader :serial_number, :state, :qualifiers
3
+ attr_reader :serial_number, :state, :qualifiers, :packages
4
4
 
5
5
  def initialize(serial_number, state, qualifiers=nil)
6
6
  @serial_number = serial_number
7
7
  @state = state
8
8
  @qualifiers = qualifiers
9
+ @packages = parse_device_package_list
10
+ end
11
+
12
+ def parse_device_package_list
13
+ Ash::Adb::Client.run("adb -s #{@serial_number} shell pm list packages -f").split("\r\n").map do |package_line|
14
+ package_line = package_line.split(":").last.split("=")
15
+ package_path = package_line.first
16
+ package_name = package_line.last
17
+ Ash::Adb::Package.new(package_path, package_name)
18
+ end
9
19
  end
10
20
  end
11
21
  end
@@ -1,5 +1,10 @@
1
1
  module Ash::Adb
2
2
  class Package
3
+ attr_reader :package_path, :package_name
3
4
 
5
+ def initialize(package_path, package_name)
6
+ @package_path = package_path
7
+ @package_name = package_name
8
+ end
4
9
  end
5
10
  end
@@ -1,5 +1,5 @@
1
1
  module Ash
2
2
  module Adb
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ash-adb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomek Rabczak
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2015-12-01 00:00:00.000000000 Z
12
+ date: 2015-12-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler