dryrun 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +34 -0
- data/Rakefile +1 -0
- data/bin/dryrun +11 -0
- data/dryrun.gemspec +33 -0
- data/lib/dryrun.rb +52 -0
- data/lib/dryrun/android_project.rb +120 -0
- data/lib/dryrun/github.rb +55 -0
- data/lib/dryrun/version.rb +3 -0
- metadata +126 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c3cdc84537a50f2e39bff50364c75e9e4344e155
|
4
|
+
data.tar.gz: f028864c95b061bf1d536a9cb29b3e484818796d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6ea1733c6aeccb2a5f7e23e90f6aba22a095f5dddb9d877caf541b9833ac221832db990b3f891a4ed175808fcfccf0f4bf8928906ecda7ae99d78bd18f3ed06c
|
7
|
+
data.tar.gz: b2debe338fcd62eb7ed250893076cc2accc74aefa43649787ffb51f9e81e696d0f0624fea8792940ebeba0414538c026f681c118d1404661b2788bc06eb33434
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 César Ferreira
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# dryrun
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/dryrun.svg)](http://badge.fury.io/rb/dryrun)
|
3
|
+
|
4
|
+
**Try** an **android** library on your **smartphone** **directly** from the **command line**
|
5
|
+
|
6
|
+
## Typical scenario
|
7
|
+
|
8
|
+
1. Find the github url (lets say `https://github.com/cesarferreira/colorize`)
|
9
|
+
2. Click the `download zip`
|
10
|
+
3. Extract the `zipfile`
|
11
|
+
4. Open Android Studio
|
12
|
+
5. Import the project you just downloaded
|
13
|
+
6. Sync gradle
|
14
|
+
7. Run the project
|
15
|
+
8. Choose the device you want to run
|
16
|
+
|
17
|
+
... or you can use `dryrun`:
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
> dryrun https://github.com/cesarferreira/colorize
|
22
|
+
|
23
|
+
Wait a few seconds... `et voilà !`
|
24
|
+
The app is installed on your phone :smiley:
|
25
|
+
|
26
|
+
|
27
|
+
## Installation
|
28
|
+
|
29
|
+
$ gem install dryrun
|
30
|
+
|
31
|
+
|
32
|
+
## Contributing
|
33
|
+
|
34
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/cesarferreira/dryrun.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/dryrun
ADDED
data/dryrun.gemspec
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'dryrun/version'
|
5
|
+
|
6
|
+
#rake build # Build dryrun-0.0.1.gem into the pkg directory
|
7
|
+
#rake install # Build and install dryrun-0.0.1.gem into system gems
|
8
|
+
#rake release # Create tag v0.0.1 and build and push dryrun-0.0.1.gem t...
|
9
|
+
#rake spec # Run RSpec code examples
|
10
|
+
|
11
|
+
Gem::Specification.new do |spec|
|
12
|
+
spec.name = "dryrun"
|
13
|
+
spec.version = DryRun::VERSION
|
14
|
+
spec.authors = ["cesar ferreira"]
|
15
|
+
spec.email = ["cesar.manuel.ferreira@gmail.com"]
|
16
|
+
|
17
|
+
spec.summary = %q{try an android library directly from the command line}
|
18
|
+
spec.description = %q{try an android library directly from the command line}
|
19
|
+
spec.homepage = "https://github.com/cesarferreira/dryrun"
|
20
|
+
|
21
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
22
|
+
spec.bindir = "bin"
|
23
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
24
|
+
spec.require_paths = ["lib"]
|
25
|
+
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
27
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
28
|
+
spec.add_development_dependency 'pry-byebug', '~> 3.1'
|
29
|
+
|
30
|
+
spec.add_dependency 'colorize', '~> 0.7'
|
31
|
+
spec.add_dependency 'nokogiri', '~> 1.6.6.2'
|
32
|
+
|
33
|
+
end
|
data/lib/dryrun.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'colorize'
|
2
|
+
require 'tmpdir'
|
3
|
+
require 'fileutils'
|
4
|
+
require 'dryrun/github'
|
5
|
+
require 'dryrun/android_project'
|
6
|
+
|
7
|
+
module DryRun
|
8
|
+
|
9
|
+
class MainApp
|
10
|
+
|
11
|
+
def self.is_ANDROID_HOME_defined
|
12
|
+
return true
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
def self.initialize(url)
|
17
|
+
|
18
|
+
if !is_ANDROID_HOME_defined
|
19
|
+
# TODO missing warning
|
20
|
+
end
|
21
|
+
|
22
|
+
github = Github.new(url)
|
23
|
+
|
24
|
+
if !github.is_valid
|
25
|
+
puts "#{url.red} is not a valid github url"
|
26
|
+
exit 1
|
27
|
+
end
|
28
|
+
|
29
|
+
puts "\nLets work this one out: #{url.green}\n\n"
|
30
|
+
|
31
|
+
# clone the repository
|
32
|
+
clonable = github.clonable_url
|
33
|
+
puts "git clone #{clonable.yellow}.....\n\n"
|
34
|
+
|
35
|
+
repository = github.clone
|
36
|
+
|
37
|
+
project = AndroidProject.new(repository)
|
38
|
+
|
39
|
+
# is a valid android project?
|
40
|
+
if !project.is_valid
|
41
|
+
puts "#{url.red} is not a valid android project"
|
42
|
+
exit 1
|
43
|
+
end
|
44
|
+
|
45
|
+
project.clean_install
|
46
|
+
|
47
|
+
|
48
|
+
puts "\nOpened #{url.green}!\n"
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
|
3
|
+
module DryRun
|
4
|
+
|
5
|
+
class AndroidProject
|
6
|
+
|
7
|
+
def initialize(path)
|
8
|
+
@base_path = path
|
9
|
+
@settings_gradle_path = settings_gradle
|
10
|
+
@modules = find_modules
|
11
|
+
end
|
12
|
+
|
13
|
+
def settings_gradle
|
14
|
+
"#{@base_path}/settings.gradle"
|
15
|
+
end
|
16
|
+
|
17
|
+
def is_valid
|
18
|
+
File.exist?(@settings_gradle_path)
|
19
|
+
end
|
20
|
+
|
21
|
+
def find_modules
|
22
|
+
if self.is_valid
|
23
|
+
content = File.open(@settings_gradle_path, "rb").read
|
24
|
+
modules = content.scan(/'([^']*)'/)
|
25
|
+
modules.each {|replacement| replacement.first.gsub!(':', '/')}
|
26
|
+
else
|
27
|
+
return []
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# ./gradlew clean installDebug
|
32
|
+
def clean_install
|
33
|
+
|
34
|
+
path, execute_line = self.sample_project
|
35
|
+
|
36
|
+
|
37
|
+
if path == false and execute_line==false
|
38
|
+
puts "Couldn't open, sorry!".red
|
39
|
+
return ''
|
40
|
+
end
|
41
|
+
|
42
|
+
Dir.chdir @base_path
|
43
|
+
|
44
|
+
self.uninstall
|
45
|
+
|
46
|
+
# clean assemble and install
|
47
|
+
system("./gradlew clean assembleDebug installDebug")
|
48
|
+
|
49
|
+
|
50
|
+
puts "Installing #{@package.green}...\n"
|
51
|
+
puts "executing: #{execute_line}"
|
52
|
+
system(execute_line)
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
def sample_project
|
57
|
+
|
58
|
+
@modules.each do |child|
|
59
|
+
full_path = "#{@base_path}#{child.first}"
|
60
|
+
|
61
|
+
execute_line = get_execute_line("#{full_path}/src/main/AndroidManifest.xml")
|
62
|
+
|
63
|
+
if execute_line
|
64
|
+
puts "\nTHE SAMPLE IS HERE #{full_path.green}:\n"
|
65
|
+
|
66
|
+
system("tree #{full_path}")
|
67
|
+
|
68
|
+
return full_path, execute_line
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
return false, false
|
73
|
+
end
|
74
|
+
|
75
|
+
def uninstall
|
76
|
+
system("adb uninstall #{@package}")
|
77
|
+
end
|
78
|
+
|
79
|
+
|
80
|
+
def get_execute_line(path_to_sample)
|
81
|
+
|
82
|
+
if !File.exist?(path_to_sample)
|
83
|
+
return false
|
84
|
+
end
|
85
|
+
|
86
|
+
f = File.open(path_to_sample)
|
87
|
+
doc = Nokogiri::XML(f)
|
88
|
+
|
89
|
+
@package = get_package(doc)
|
90
|
+
@launcher_activity = get_launcher_activity(doc)
|
91
|
+
|
92
|
+
if !@launcher_activity
|
93
|
+
return false
|
94
|
+
end
|
95
|
+
|
96
|
+
f.close
|
97
|
+
|
98
|
+
"adb shell am start -n #{@package}/#{@launcher_activity}"
|
99
|
+
|
100
|
+
end
|
101
|
+
|
102
|
+
|
103
|
+
def get_package(doc)
|
104
|
+
doc.xpath("//manifest").attr('package').value
|
105
|
+
end
|
106
|
+
|
107
|
+
def get_launcher_activity(doc)
|
108
|
+
activities = doc.css('activity')
|
109
|
+
activities.each do |child|
|
110
|
+
intent_filter = child.css('intent-filter')
|
111
|
+
if intent_filter != nil and intent_filter.length != 0
|
112
|
+
return child.attr('android:name')
|
113
|
+
end
|
114
|
+
end
|
115
|
+
false
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'tmpdir'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'uri'
|
4
|
+
require 'colorize'
|
5
|
+
|
6
|
+
module DryRun
|
7
|
+
|
8
|
+
class Github
|
9
|
+
def initialize(url)
|
10
|
+
@base_url = url
|
11
|
+
|
12
|
+
begin
|
13
|
+
@resource = URI.parse(url)
|
14
|
+
rescue Exception => e
|
15
|
+
puts "Invalid github url".red
|
16
|
+
puts "Valid example: #{'https://github.com/cesarferreira/colorize'.green}"
|
17
|
+
exit 1
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def path
|
22
|
+
@resource.path
|
23
|
+
end
|
24
|
+
|
25
|
+
def is_valid
|
26
|
+
return true
|
27
|
+
end
|
28
|
+
|
29
|
+
def clonable_url
|
30
|
+
# if @base_url.split(//).last(4).join.eql? ".git" or @base_url.split(//).first(4).join.eql? "git@"
|
31
|
+
# @base_url
|
32
|
+
# else
|
33
|
+
"#{@base_url}.git"
|
34
|
+
# end
|
35
|
+
end
|
36
|
+
|
37
|
+
##
|
38
|
+
## CLONE THE REPOSITORY
|
39
|
+
##
|
40
|
+
def clone
|
41
|
+
clonable = self.clonable_url
|
42
|
+
|
43
|
+
tmpdir = Dir.tmpdir+"#{path}"
|
44
|
+
FileUtils.rm_rf(tmpdir)
|
45
|
+
|
46
|
+
system("git clone #{clonable} #{tmpdir}")
|
47
|
+
|
48
|
+
Dir.chdir tmpdir
|
49
|
+
|
50
|
+
tmpdir
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
metadata
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dryrun
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- cesar ferreira
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-08-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry-byebug
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.1'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.1'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: colorize
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.7'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.7'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: nokogiri
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.6.6.2
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.6.6.2
|
83
|
+
description: try an android library directly from the command line
|
84
|
+
email:
|
85
|
+
- cesar.manuel.ferreira@gmail.com
|
86
|
+
executables:
|
87
|
+
- dryrun
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- ".gitignore"
|
92
|
+
- ".travis.yml"
|
93
|
+
- Gemfile
|
94
|
+
- LICENSE
|
95
|
+
- README.md
|
96
|
+
- Rakefile
|
97
|
+
- bin/dryrun
|
98
|
+
- dryrun.gemspec
|
99
|
+
- lib/dryrun.rb
|
100
|
+
- lib/dryrun/android_project.rb
|
101
|
+
- lib/dryrun/github.rb
|
102
|
+
- lib/dryrun/version.rb
|
103
|
+
homepage: https://github.com/cesarferreira/dryrun
|
104
|
+
licenses: []
|
105
|
+
metadata: {}
|
106
|
+
post_install_message:
|
107
|
+
rdoc_options: []
|
108
|
+
require_paths:
|
109
|
+
- lib
|
110
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: '0'
|
120
|
+
requirements: []
|
121
|
+
rubyforge_project:
|
122
|
+
rubygems_version: 2.4.8
|
123
|
+
signing_key:
|
124
|
+
specification_version: 4
|
125
|
+
summary: try an android library directly from the command line
|
126
|
+
test_files: []
|