dryrun 0.4.5 → 0.5.0
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 +4 -4
- data/.ruby-version +1 -1
- data/README.md +28 -2
- data/bin/dryrun +1 -7
- data/lib/dryrun.rb +42 -11
- data/lib/dryrun/android_project.rb +66 -49
- data/lib/dryrun/version.rb +1 -1
- metadata +22 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d3f3a98a45ab58ac45426e6c806a5b6bd773cc9
|
4
|
+
data.tar.gz: 04cacfaa410713424d3c67e570e79864ab30f6a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56e0f7b045e2ab959a96f007016ae362d8d97a62be4b583989e313bceafbb77623aca311df3db72381f5b8f117a782a1623591043e16b6f56cc283c8678dd9c4
|
7
|
+
data.tar.gz: 65f34a5ef5c2d48fab4a841431876d60694597b777fe616bdcb376ca63607a9a811f74c257909ef1f8af772bb9a4f92d97b259308709833e7a2df0310699b6f0
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.2.3
|
data/README.md
CHANGED
@@ -11,11 +11,29 @@
|
|
11
11
|
|
12
12
|
|
13
13
|
## Usage
|
14
|
-
|
15
|
-
|
14
|
+
```shell
|
15
|
+
dryrun https://github.com/cesarferreira/android-helloworld
|
16
|
+
```
|
16
17
|
|
17
18
|
Wait a few seconds... and `voilà`! The app is opened on your phone :smiley:
|
18
19
|
|
20
|
+
|
21
|
+
#### From a custom repository folder:
|
22
|
+
```shell
|
23
|
+
dryrun repository_url -p custom/path/to/gradle_application
|
24
|
+
```
|
25
|
+
|
26
|
+
#### A custom module
|
27
|
+
```shell
|
28
|
+
dryrun repository_url -m custom_application_module
|
29
|
+
```
|
30
|
+
|
31
|
+
#### Help at any time:
|
32
|
+
```shell
|
33
|
+
dryrun -h
|
34
|
+
```
|
35
|
+
|
36
|
+
|
19
37
|
### Goodies
|
20
38
|
|
21
39
|
- Private repos can be tested too :smiley:
|
@@ -57,3 +75,11 @@ Wait a few seconds... and `voilà`! The app is opened on your phone :smiley:
|
|
57
75
|
## Contributing
|
58
76
|
|
59
77
|
Bug reports and pull requests are welcome on GitHub at https://github.com/cesarferreira/dryrun.
|
78
|
+
|
79
|
+
To install gem as local you can use this:
|
80
|
+
```shell
|
81
|
+
# In the project folder:
|
82
|
+
rake install
|
83
|
+
# Next in the any gemset or place:
|
84
|
+
gem install --local path_to_dryrun/pkg/dryrun-<builded_version>.gem
|
85
|
+
```
|
data/bin/dryrun
CHANGED
data/lib/dryrun.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'optparse'
|
1
2
|
require 'colorize'
|
2
3
|
require 'tmpdir'
|
3
4
|
require 'fileutils'
|
@@ -5,47 +6,77 @@ require 'dryrun/github'
|
|
5
6
|
require 'dryrun/android_project'
|
6
7
|
|
7
8
|
module DryRun
|
8
|
-
|
9
9
|
class MainApp
|
10
|
+
def initialize(arguments)
|
11
|
+
create_options_parser
|
12
|
+
@url = ['-h', '--help'].include?(arguments.first) ? nil : arguments.shift
|
13
|
+
@app_path = nil
|
14
|
+
@custom_module = nil
|
15
|
+
@opt_parser.parse!(arguments)
|
10
16
|
|
11
|
-
|
12
|
-
|
13
|
-
|
17
|
+
unless @url
|
18
|
+
puts @opt_parser.help
|
19
|
+
exit
|
20
|
+
end
|
14
21
|
end
|
15
22
|
|
23
|
+
def create_options_parser
|
24
|
+
@opt_parser = OptionParser.new do |opts|
|
25
|
+
opts.banner = "Usage: dryrun GITHUB_URL [OPTIONS]"
|
26
|
+
opts.separator ''
|
27
|
+
opts.separator "Options"
|
28
|
+
|
29
|
+
opts.on('-m MODULE_NAME', '--module MODULE_NAME', 'Custom module to run') do |custom_module|
|
30
|
+
@custom_module = custom_module
|
31
|
+
end
|
32
|
+
opts.on('-p PATH', '--path PATH', 'Custom path to android project') do |app_path|
|
33
|
+
@app_path = app_path
|
34
|
+
end
|
35
|
+
opts.on('-h', '--help', 'Displays help') do
|
36
|
+
puts opts.help
|
37
|
+
exit
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
16
41
|
|
17
|
-
def
|
42
|
+
def android_home_is_defined
|
43
|
+
sdk = `echo $ANDROID_HOME`.gsub("\n",'')
|
44
|
+
!sdk.empty?
|
45
|
+
end
|
18
46
|
|
19
|
-
|
47
|
+
def call
|
48
|
+
unless android_home_is_defined
|
20
49
|
puts "\nWARNING: your #{'$ANDROID_HOME'.yellow} is not defined\n"
|
21
50
|
puts "\nhint: in your #{'~/.bashrc'.yellow} add:\n #{"export ANDROID_HOME=\"/Users/cesarferreira/Library/Android/sdk/\"".yellow}"
|
22
51
|
puts "\nNow type #{'source ~/.bashrc'.yellow}\n\n"
|
23
52
|
exit 1
|
24
53
|
end
|
25
54
|
|
26
|
-
github = Github.new(url)
|
55
|
+
github = Github.new(@url)
|
27
56
|
|
28
57
|
unless github.is_valid
|
29
|
-
puts "#{url.red} is not a valid github url"
|
58
|
+
puts "#{@url.red} is not a valid github @url"
|
30
59
|
exit 1
|
31
60
|
end
|
32
61
|
|
33
62
|
# clone the repository
|
34
63
|
repository_path = github.clone
|
35
64
|
|
36
|
-
android_project = AndroidProject.new(repository_path)
|
65
|
+
android_project = AndroidProject.new(repository_path, @app_path, @custom_module)
|
37
66
|
|
38
67
|
# is a valid android project?
|
39
68
|
unless android_project.is_valid
|
40
|
-
puts "#{url.red} is not a valid android project"
|
69
|
+
puts "#{@url.red} is not a valid android project"
|
41
70
|
exit 1
|
42
71
|
end
|
43
72
|
|
73
|
+
puts "Using custom app folder: #{@app_path.green}" if @app_path
|
74
|
+
puts "Using custom module: #{@custom_module.green}" if @custom_module
|
75
|
+
|
44
76
|
# clean and install the apk
|
45
77
|
android_project.install
|
46
78
|
|
47
79
|
puts "\n> If you want to remove the app you just installed, execute:\n#{android_project.get_uninstall_command.yellow}\n\n"
|
48
|
-
|
49
80
|
end
|
50
81
|
end
|
51
82
|
end
|
@@ -3,22 +3,34 @@ require 'fileutils'
|
|
3
3
|
require 'tempfile'
|
4
4
|
|
5
5
|
module DryRun
|
6
|
-
|
7
6
|
class AndroidProject
|
8
|
-
|
9
|
-
|
7
|
+
def initialize(path, custom_app_path, custom_module)
|
8
|
+
@custom_app_path = custom_app_path
|
9
|
+
@custom_module = custom_module
|
10
10
|
@base_path = path
|
11
|
-
@settings_gradle_path =
|
11
|
+
@settings_gradle_path = settings_gradle_file
|
12
|
+
|
13
|
+
check_custom_app_path
|
14
|
+
|
12
15
|
@modules = find_modules
|
13
16
|
end
|
14
17
|
|
18
|
+
def check_custom_app_path
|
19
|
+
return unless @custom_app_path
|
20
|
+
|
21
|
+
full_custom_path = File.join(@base_path, @custom_app_path)
|
22
|
+
settings_path = settings_gradle_file(full_custom_path)
|
23
|
+
return unless is_valid(settings_path)
|
24
|
+
|
25
|
+
@settings_gradle_path = settings_path
|
26
|
+
@base_path = full_custom_path
|
27
|
+
end
|
28
|
+
|
15
29
|
def remove_local_properties
|
16
30
|
Dir.chdir @base_path
|
17
31
|
file_name = 'local.properties'
|
18
32
|
|
19
|
-
if File.exist?(file_name)
|
20
|
-
File.remove(file_name)
|
21
|
-
end
|
33
|
+
File.delete(file_name) if File.exist?(file_name)
|
22
34
|
|
23
35
|
system("touch #{file_name}")
|
24
36
|
end
|
@@ -35,34 +47,30 @@ module DryRun
|
|
35
47
|
|
36
48
|
# Move temp file to origin
|
37
49
|
FileUtils.mv(tmp.path, file)
|
38
|
-
|
39
50
|
end
|
40
51
|
|
41
|
-
def
|
42
|
-
|
52
|
+
def settings_gradle_file(path = @base_path)
|
53
|
+
File.join(path, 'settings.gradle')
|
43
54
|
end
|
44
55
|
|
45
|
-
def is_valid
|
46
|
-
File.exist?(
|
56
|
+
def is_valid(settings_path = @settings_gradle_path)
|
57
|
+
File.exist?(settings_path)
|
47
58
|
end
|
48
59
|
|
49
60
|
def find_modules
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
return []
|
56
|
-
end
|
61
|
+
return [] unless is_valid
|
62
|
+
|
63
|
+
content = File.open(@settings_gradle_path, "rb").read
|
64
|
+
modules = content.scan(/'([^']*)'/)
|
65
|
+
modules.each {|replacement| replacement.first.gsub!(':', '/')}
|
57
66
|
end
|
58
67
|
|
59
68
|
def install
|
60
|
-
|
61
69
|
Dir.chdir @base_path
|
62
70
|
|
63
|
-
path, execute_line =
|
71
|
+
path, execute_line = sample_project
|
64
72
|
|
65
|
-
if path == false and execute_line==false
|
73
|
+
if path == false and execute_line == false
|
66
74
|
puts "Couldn't open the sample project, sorry!".red
|
67
75
|
exit 1
|
68
76
|
end
|
@@ -76,60 +84,72 @@ module DryRun
|
|
76
84
|
end
|
77
85
|
|
78
86
|
# Generate the gradle/ folder
|
79
|
-
if File.exist?('gradlew') and !is_gradle_wrapped
|
80
|
-
|
81
|
-
|
87
|
+
system('gradle wrap') if File.exist?('gradlew') and !is_gradle_wrapped
|
88
|
+
|
89
|
+
remove_application_id
|
90
|
+
remove_local_properties
|
82
91
|
|
83
|
-
|
84
|
-
|
85
|
-
|
92
|
+
if @custom_module
|
93
|
+
system("#{builder} clean :#{@custom_module}:installDebug")
|
94
|
+
else
|
95
|
+
system("#{builder} clean installDebug")
|
96
|
+
end
|
86
97
|
|
87
|
-
|
98
|
+
clear_app_data
|
88
99
|
|
89
100
|
puts "Installing #{@package.green}...\n"
|
90
101
|
puts "executing: #{execute_line.green}\n\n"
|
102
|
+
|
91
103
|
system(execute_line)
|
92
104
|
|
93
105
|
end
|
94
106
|
|
95
107
|
def is_gradle_wrapped
|
96
|
-
|
97
|
-
if !File.directory?('gradle/')
|
98
|
-
return false
|
99
|
-
end
|
108
|
+
return false if !File.directory?('gradle/')
|
100
109
|
|
101
110
|
File.exist?('gradle/wrapper/gradle-wrapper.properties') and File.exist?('gradle/wrapper/gradle-wrapper.jar')
|
102
111
|
end
|
103
112
|
|
104
113
|
def sample_project
|
114
|
+
if @custom_module && @modules.any? { |m| m.first == "/#{@custom_module}" }
|
115
|
+
@path_to_sample = File.join(@base_path, "/#{@custom_module}")
|
116
|
+
return @path_to_sample, get_execution_line_command(@path_to_sample)
|
117
|
+
else
|
118
|
+
@modules.each do |child|
|
119
|
+
full_path = File.join(@base_path, child.first)
|
120
|
+
@path_to_sample = full_path
|
105
121
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
execute_line = get_execute_line("#{full_path}/src/main/AndroidManifest.xml")
|
111
|
-
return full_path, execute_line if execute_line
|
112
|
-
|
122
|
+
execution_line_command = get_execution_line_command(full_path)
|
123
|
+
return full_path, execution_line_command if execution_line_command
|
124
|
+
end
|
113
125
|
end
|
114
|
-
|
126
|
+
[false, false]
|
127
|
+
end
|
128
|
+
|
129
|
+
def get_clear_app_command
|
130
|
+
"adb shell pm clear #{@package}"
|
115
131
|
end
|
116
132
|
|
117
133
|
def get_uninstall_command
|
118
134
|
"adb uninstall #{@package}"
|
119
135
|
end
|
120
136
|
|
121
|
-
def
|
122
|
-
system(
|
137
|
+
def clear_app_data
|
138
|
+
system(get_clear_app_command)
|
123
139
|
end
|
124
140
|
|
141
|
+
def uninstall_application
|
142
|
+
system(get_uninstall_command) # > /dev/null 2>&1")
|
143
|
+
end
|
125
144
|
|
126
|
-
def
|
145
|
+
def get_execution_line_command(path_to_sample)
|
146
|
+
path_to_manifest = File.join(path_to_sample, 'src/main/AndroidManifest.xml')
|
127
147
|
|
128
|
-
if !File.exist?(
|
148
|
+
if !File.exist?(path_to_manifest)
|
129
149
|
return false
|
130
150
|
end
|
131
151
|
|
132
|
-
f = File.open(
|
152
|
+
f = File.open(path_to_manifest)
|
133
153
|
doc = Nokogiri::XML(f)
|
134
154
|
|
135
155
|
@package = get_package(doc)
|
@@ -142,7 +162,6 @@ module DryRun
|
|
142
162
|
f.close
|
143
163
|
|
144
164
|
"adb shell am start -n \"#{get_launchable_activity}\" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER"
|
145
|
-
|
146
165
|
end
|
147
166
|
|
148
167
|
def get_launchable_activity
|
@@ -164,7 +183,5 @@ module DryRun
|
|
164
183
|
end
|
165
184
|
false
|
166
185
|
end
|
167
|
-
|
168
186
|
end
|
169
|
-
|
170
187
|
end
|
data/lib/dryrun/version.rb
CHANGED
metadata
CHANGED
@@ -1,97 +1,97 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dryrun
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- cesar ferreira
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '10.0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '10.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: pry-byebug
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '3.1'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '3.1'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '1.7'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - ~>
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '1.7'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: colorize
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - ~>
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0.7'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - ~>
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0.7'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: nokogiri
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - ~>
|
87
|
+
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: 1.6.6.2
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - ~>
|
94
|
+
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: 1.6.6.2
|
97
97
|
description: Tool which allows to quickly try the demo project of any Android Library
|
@@ -102,11 +102,11 @@ executables:
|
|
102
102
|
extensions: []
|
103
103
|
extra_rdoc_files: []
|
104
104
|
files:
|
105
|
-
- .gitignore
|
106
|
-
- .rspec
|
107
|
-
- .ruby-gemset
|
108
|
-
- .ruby-version
|
109
|
-
- .travis.yml
|
105
|
+
- ".gitignore"
|
106
|
+
- ".rspec"
|
107
|
+
- ".ruby-gemset"
|
108
|
+
- ".ruby-version"
|
109
|
+
- ".travis.yml"
|
110
110
|
- Gemfile
|
111
111
|
- LICENSE
|
112
112
|
- README.md
|
@@ -129,17 +129,17 @@ require_paths:
|
|
129
129
|
- lib
|
130
130
|
required_ruby_version: !ruby/object:Gem::Requirement
|
131
131
|
requirements:
|
132
|
-
- -
|
132
|
+
- - ">="
|
133
133
|
- !ruby/object:Gem::Version
|
134
134
|
version: 2.0.0
|
135
135
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
136
|
requirements:
|
137
|
-
- -
|
137
|
+
- - ">="
|
138
138
|
- !ruby/object:Gem::Version
|
139
139
|
version: '0'
|
140
140
|
requirements: []
|
141
141
|
rubyforge_project:
|
142
|
-
rubygems_version: 2.4.
|
142
|
+
rubygems_version: 2.4.8
|
143
143
|
signing_key:
|
144
144
|
specification_version: 4
|
145
145
|
summary: Tool which allows to quickly try the demo project of any Android Library
|