ash-adb 0.0.0 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 977e5624b787d52220a19bda174b819105536901
4
- data.tar.gz: 60a023c09f7c27a3cdcd7730e37bfe09e433a933
3
+ metadata.gz: 189ce0215b54ce1e81fd908a40ced6ddb63a2f20
4
+ data.tar.gz: 769770d1547881b0b3ba63c6a7c4d7c48992c039
5
5
  SHA512:
6
- metadata.gz: ab86b06b20cee3a5ccf381a99f5eb345c398bcad8de51665ff432c836ffa33273db263393abfe3d017651f3f6685c0a91a1c064fa6355fc72efe14cb19ca3fe9
7
- data.tar.gz: e79fd865b9db8d7cebd8384880d76f7e43601dacd8fd795ab346680f001e497c619bc63c3f747e13179435cab663a56a90c813c4a6b72488b846bb561f191c69
6
+ metadata.gz: 6ead681b5facab5f685c613fda8ed87d3eb82b6490043cc5aafe2af3b1ad2d0863226ed7d2c6e38b484b1d4a275afdae935616c19776c77e2fcf91fe45b2bc3f
7
+ data.tar.gz: e903f6f24a6a5e358a1aae40a23e42a62f58dec65347b3c2f94c97ea858227a35079a2a3c4dc4f40e4e621db2ae94f6bd06e36cb54e80dbfdfe4aaf06588655f
data/README.md CHANGED
@@ -22,7 +22,20 @@ Or install it yourself as:
22
22
 
23
23
  ## Usage
24
24
 
25
- TODO: Write usage instructions here
25
+ ### Listing Devices
26
+
27
+ ```ruby
28
+ client = Ash::Adb::Client.new
29
+ devices = client.devices
30
+
31
+ devices.first.serial_number
32
+ => "emulator-5554"
33
+ ```
34
+
35
+ ### List Packages for a Device
36
+
37
+ TODO
38
+
26
39
 
27
40
  ## Development
28
41
 
@@ -0,0 +1,42 @@
1
+ module Ash::Adb
2
+ class Client
3
+ def devices
4
+ devices = []
5
+
6
+ devices_output = run('adb devices -l')
7
+
8
+ # Device output is newline seperated and we also want to drop the first
9
+ # line which is the "List of devices attached" string
10
+ device_strings = devices_output.split("\n").drop(1)
11
+
12
+ device_strings.each do |device_string|
13
+ # At this point a qualified device_string might look something like:
14
+ #
15
+ # "emulator-5554 device product:sdk_google_phone_x86 model:Android_SDK_built_for_x86 device:generic_x86"
16
+ #
17
+ # So we'll want to split this up and parse it accordingly
18
+ attributes = device_string.split
19
+
20
+ # Now attributes might look like:
21
+ # ["emulator-5554", "device", "product:sdk_google_phone_x86", "model:Android_SDK_built_for_x86", "device:generic_x86"]
22
+ serial_number = attributes.shift
23
+ state = attributes.shift
24
+ qualifiers = attributes
25
+
26
+ devices << Device.new(serial_number, state, qualifiers)
27
+ end
28
+
29
+ devices
30
+ end
31
+
32
+ private
33
+
34
+ def run(cmd)
35
+ output, errors, status = Open3.capture3(cmd)
36
+
37
+ raise "Error running #{ cmd }: #{ errors.inspect }" unless errors.empty?
38
+
39
+ return output
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,11 @@
1
+ module Ash::Adb
2
+ class Device
3
+ attr_reader :serial_number, :state, :qualifiers
4
+
5
+ def initialize(serial_number, state, qualifiers=nil)
6
+ @serial_number = serial_number
7
+ @state = state
8
+ @qualifiers = qualifiers
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,5 @@
1
+ module Ash::Adb
2
+ class Package
3
+
4
+ end
5
+ end
@@ -1,5 +1,5 @@
1
1
  module Ash
2
2
  module Adb
3
- VERSION = "0.0.0"
3
+ VERSION = "0.0.1"
4
4
  end
5
5
  end
data/lib/ash/adb.rb CHANGED
@@ -1,7 +1,14 @@
1
+ require "pry"
2
+ require 'open3'
3
+
4
+
5
+ require "ash/adb/client"
6
+ require "ash/adb/device"
7
+ require "ash/adb/package"
8
+
1
9
  require "ash/adb/version"
2
10
 
3
11
  module Ash
4
12
  module Adb
5
- # Your code goes here...
6
13
  end
7
14
  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.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomek Rabczak
@@ -84,6 +84,9 @@ files:
84
84
  - bin/console
85
85
  - bin/setup
86
86
  - lib/ash/adb.rb
87
+ - lib/ash/adb/client.rb
88
+ - lib/ash/adb/device.rb
89
+ - lib/ash/adb/package.rb
87
90
  - lib/ash/adb/version.rb
88
91
  homepage: ''
89
92
  licenses: []