mobo 0.0.3 → 0.0.4

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: 9cb76d7425338870e1922afcda730786204c9881
4
- data.tar.gz: c212948730a6331afd4c35db61842e79c9f2655a
3
+ metadata.gz: ec492a01d8e2c5e073f564253929c3de1bea2e14
4
+ data.tar.gz: 847a8263a0f14aa1d8bbf6e36279788853d5d5c6
5
5
  SHA512:
6
- metadata.gz: cdf7ad5905136253b76e31e8e09c414a11ea76fb27b8156177363daac969d306c3d4d2c8db47637c908a6905b2fe353c464f325baea52f1f92172b6460e61e99
7
- data.tar.gz: 9565d3808d4f3ecf5d9a7a27ccfd7cf87ad6c4312d490b92125e62d7107a9374493ceba75ad9bd6da9e13b7233d900f7913cb7ce3e0673ff65da6789ade5d4f4
6
+ metadata.gz: 371938188360908000aa6eb0415c35b955c1a4be1495627a40804f65528eb068db216d668a3d832c29acdbd7c2aa7dea738dc475b4f6215231503349c10338a7
7
+ data.tar.gz: 343f1fb59c6b9ea4a68b1af77b3b530446c0c81fa97aa4dd92d9bec3c686f20cedc7aeae3a8c51aa3a6466055e2794c11a480bb012ef0d818b554ad1b5857434
data/lib/mobo/android.rb CHANGED
@@ -4,57 +4,44 @@ module Mobo
4
4
 
5
5
  class << self
6
6
  def exists?
7
- if Mobo.cmd("which android")
8
- return true
9
- # if exists? isn't true straight away, check if ANDROID_HOME is set, and try and
10
- # fix the issue
11
- elsif ENV['ANDROID_HOME'] and File.exists?(ENV['ANDROID_HOME'] + '/tools/android')
12
- add_to_path(ENV['ANDROID_HOME'])
13
- Mobo.cmd("which android")
7
+ if Dir.exists?(Mobo.home_dir) and not Dir["#{Mobo.home_dir}/**/tools/android"].empty?
8
+ add_to_path
14
9
  end
10
+ Mobo.cmd("which android | grep #{Mobo.home_dir}")
15
11
  end
16
12
 
13
+ # as a default, install in ~/.mobo
17
14
  def install
18
- if SystemCheck.ubuntu?
19
- Mobo.cmd("curl -O http://dl.google.com/android/android-sdk_r24.3.4-linux.tgz")
20
- Mobo.cmd("sudo tar -xf android-sdk_r24.3.4-linux.tgz -C /usr/local/")
21
- Mobo.cmd("sudo chown -R $(whoami) /usr/local/android-sdk-linux")
22
- add_to_path("/usr/local/android-sdk-linux")
23
- elsif SystemCheck.osx?
24
- Mobo.cmd("curl -O http://dl.google.com/android/android-sdk_r24.3.4-macosx.zip")
25
- Mobo.cmd("sudo unzip android-sdk_r24.3.4-macosx.zip -d /usr/local/")
26
- Mobo.cmd("sudo chown -R $(whoami) /usr/local/android-sdk-macosx")
27
- add_to_path("/usr/local/android-sdk-macosx")
28
- else
29
- Mobo.log.error("Platform not yet supported! Please raise a request with the project to support it.")
15
+ unless File.exists?(Mobo.android_home)
16
+ if SystemCheck.ubuntu?
17
+ Mobo.cmd("curl -o #{path}/android-sdk_r24.3.4-linux.tgz http://dl.google.com/android/android-sdk_r24.3.4-linux.tgz")
18
+ Mobo.cmd("tar -xf #{path}/android-sdk_r24.3.4-linux.tgz -C #{path}")
19
+ Mobo.cmd("mv #{path}/android-sdk-linux #{Mobo.android_home}")
20
+ elsif SystemCheck.osx?
21
+ Mobo.cmd("curl -o #{path}/android-sdk_r24.3.4-macosx.zip http://dl.google.com/android/android-sdk_r24.3.4-macosx.zip")
22
+ Mobo.cmd("unzip #{path}/android-sdk_r24.3.4-macosx.zip -d #{path}")
23
+ Mobo.cmd("mv #{path}/android-sdk-macosx #{Mobo.android_home}")
24
+ else
25
+ Mobo.log.error("Platform not yet supported! Please raise a request with the project to support it.")
26
+ end
30
27
  end
28
+ add_to_path
31
29
  end
32
30
 
33
- # setting env variables in the bash profile and trying to reload them isn't easy,
34
- # as the variables are only set in the sub process the bash_profile is executed in
35
- # so we can set env variables, which take effect here, and also set them in bash_profile
36
- # for the user to use later on
37
- def add_to_path(android_home)
38
- android_tools = android_home + '/tools'
39
- unless ENV['PATH'].match(/#{android_home}/)
40
- ENV['ANDROID_HOME'] = android_home
41
- ENV['PATH'] += ":#{android_tools}"
31
+ def add_to_path
32
+ unless ENV['PATH'].match(/^#{Mobo.android_home}\/tools/)
33
+ ENV['ANDROID_HOME'] = Mobo.android_home
34
+ ENV['PATH'] = "#{Mobo.android_home}/tools:#{ENV['PATH']}"
35
+ Mobo.log.debug("$PATH set to '#{ENV['PATH']}' to set up android")
42
36
  end
43
- unless Mobo.cmd("grep -i ANDROID_HOME ~/.bash_profile")
44
- Mobo.cmd("echo 'export ANDROID_HOME=#{android_home}' >> ~/.bash_profile")
45
- Mobo.cmd("echo 'export PATH=\$PATH:#{android_tools}' >> ~/.bash_profile")
46
- Mobo.log.info("ANDROID_HOME and PATH env variables have been updated.
47
- Start a new terminal session for them to take effect")
48
- end
49
- raise "Setting ANDROID_HOME and PATH failed" unless self.exists?
50
37
  end
51
38
 
52
39
  def package_exists?(package)
53
- Mobo.cmd("android list sdk --extended --no-ui --all | grep '\"#{package}\"'")
40
+ Mobo.cmd("android list sdk --extended --no-ui --all | grep '#{package}'")
54
41
  end
55
42
 
56
43
  def install_package(package)
57
- Mobo.cmd("echo y | android update sdk --no-ui --all --filter #{package} 2>&1 >> /dev/null")
44
+ Mobo.cmd("echo y | android update sdk --no-ui --all --filter #{package}")
58
45
  end
59
46
  end
60
47
 
@@ -70,6 +57,8 @@ module Mobo
70
57
  records.each do |record|
71
58
  return record if record.match(/#{target}/)
72
59
  end
60
+ # return empty string if nothing is found
61
+ return ""
73
62
  end
74
63
 
75
64
  def abi_package(target, abi)
@@ -111,21 +100,21 @@ module Mobo
111
100
  class << self
112
101
 
113
102
  def add_to_path
114
- if !ENV['PATH'].match(/platform-tools/)
115
- ENV['PATH'] += ":#{ENV['ANDROID_HOME']}/platform-tools"
116
- Mobo.cmd("echo 'export PATH=\$PATH:#{ENV['ANDROID_HOME']}/platform-tools' >> ~/.bash_profile")
117
- Mobo.log.debug("ENV['PATH'] set to #{ENV['PATH']}")
118
- Mobo.log.info("PATH env variables has been updated.
119
- Start a new terminal session for it to take effect")
103
+ if !ENV['PATH'].match(/#{Mobo.android_home}\/platform-tools/)
104
+ ENV['PATH'] = "#{Mobo.android_home}/platform-tools:#{ENV['PATH']}"
120
105
  end
106
+ Mobo.log.debug("$PATH set to #{ENV['PATH']}")
121
107
  end
122
108
 
123
109
  def exists?
124
- Mobo.cmd("which adb")
110
+ if Dir.exists?(Mobo.home_dir) and not Dir["#{Mobo.android_home}/platform-tools/adb"].empty?
111
+ add_to_path
112
+ end
113
+ Mobo.cmd("which adb | grep #{Mobo.home_dir}")
125
114
  end
126
115
 
127
116
  def install
128
- Mobo.cmd("echo yes | android update sdk --all --no-ui --filter platform-tools 2>&1 >> /dev/null")
117
+ Mobo.cmd("echo yes | android update sdk --all --no-ui --filter platform-tools")
129
118
  add_to_path
130
119
  raise "Installing adb failed" unless self.exists?
131
120
  end
@@ -8,6 +8,12 @@ module Mobo
8
8
  end
9
9
  end
10
10
 
11
+ def mobo
12
+ Mobo.home_dir = File.expand_path("~/.mobo")
13
+ Mobo.log.info("Using #{Mobo.home_dir} as home directory. Android will be installed here")
14
+ Dir.mkdir(Mobo.home_dir) unless File.exists?(Mobo.home_dir)
15
+ end
16
+
11
17
  end
12
18
  end
13
19
  end
data/lib/mobo.rb CHANGED
@@ -8,7 +8,7 @@ require_relative 'mobo/system_setup'
8
8
 
9
9
  module Mobo
10
10
  class << self
11
- attr_accessor :log, :data, :devices
11
+ attr_accessor :log, :data, :devices, :home_dir
12
12
 
13
13
  def log
14
14
  unless @log
@@ -18,6 +18,10 @@ module Mobo
18
18
  @log
19
19
  end
20
20
 
21
+ def android_home
22
+ @home_dir + '/android-sdk'
23
+ end
24
+
21
25
  def cmd(command)
22
26
  log.debug(command)
23
27
  system(command)
@@ -63,6 +67,7 @@ module Mobo
63
67
  end
64
68
 
65
69
  def system_checks
70
+ SystemSetup.mobo
66
71
  SystemSetup.base_libraries
67
72
  SystemCheck.android?
68
73
  SystemCheck.adb?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mobo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark O'Shea