dryrun 0.8.1 → 0.9.0

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: 005bfb7f37647f9971b214b8830b486c565ecc12
4
- data.tar.gz: ad829eaf19861597354b3566004c62232c374696
3
+ metadata.gz: 759a2e5820edc02f75551a4f9750e3687cfd916d
4
+ data.tar.gz: 052d76dbdfbc28eb887378e9be865a338560860d
5
5
  SHA512:
6
- metadata.gz: a085e052f943535a1f368ef88b37092a4031570873c18b7be6fa823be6d31fdecc526c4780c4c3dd9ac0e2a5bc8b259fe087c03361479da947a7eeb3f5ec1611
7
- data.tar.gz: 1868495c41a7a841480858ece8966288ff81ef8891917c6835721c3ebd9211317671abb72f98812f684e46df47951aec34c16a8efb18ca2245db67dc637db669
6
+ metadata.gz: 30cb25425f1dfe5dce055886a9c521fa32ded7c74643a8304f94ff1b6bd637a5d6c6775eeae5f9c0842f81ea801afac580b85649b6fc2a376e5008653612df30
7
+ data.tar.gz: 22ff88af77ebcf96de7055970c214087e63387095a545e1d4c8bb0482dabbaec295df8fa07edff1ad535fbe228655372a17ead8eda5d86a0f97d129aecb2e195
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ .idea/
data/README.md CHANGED
@@ -11,7 +11,7 @@
11
11
 
12
12
  ### Show some :heart:
13
13
  [![GitHub stars](https://img.shields.io/github/stars/cesarferreira/dryrun.svg?style=social&label=Star)](https://github.com/cesarferreira/dryrun)
14
- [![GitHub forks](https://img.shields.io/github/forks/cesarferreira/dryrun.svg?style=social&label=Fork)](https://github.com/cesarferreira/dryrun/fork) [![GitHub watchers](https://img.shields.io/github/watchers/cesarferreira/dryrun.svg?style=social&label=Watch)](https://github.com/cesarferreira/dryrun) [![GitHub followers](https://img.shields.io/github/followers/cesarferreira.svg?style=social&label=Follow)](https://github.com/cesarferreira/dryrun)
14
+ [![GitHub forks](https://img.shields.io/github/forks/cesarferreira/dryrun.svg?style=social&label=Fork)](https://github.com/cesarferreira/dryrun/fork) [![GitHub watchers](https://img.shields.io/github/watchers/cesarferreira/dryrun.svg?style=social&label=Watch)](https://github.com/cesarferreira/dryrun) [![GitHub followers](https://img.shields.io/github/followers/cesarferreira.svg?style=social&label=Follow)](https://github.com/cesarferreira/dryrun)
15
15
  [![Twitter Follow](https://img.shields.io/twitter/follow/cesarmcferreira.svg?style=social)](https://twitter.com/cesarmcferreira)
16
16
 
17
17
 
@@ -27,7 +27,7 @@ Wait a few seconds and the app is now opened on your phone :smiley:
27
27
 
28
28
  ### Advanced usage
29
29
  ```bash
30
- $ dryrun -h
30
+ $ dryrun -h
31
31
  Usage: dryrun GIT_URL [OPTIONS]
32
32
 
33
33
  Options
@@ -57,6 +57,18 @@ Options
57
57
 
58
58
  - No need to wait for **Android Studio** to load.
59
59
 
60
+
61
+ ## Notes
62
+
63
+ Behaware that ANDROID_HOME needs to be set with the adb path:
64
+ - MAC -> ```ANDROID_HOME=/usr/local/opt/android-sdk```
65
+ - Linux -> ```ANDROID_HOME=/usr/local/opt/android-sdk```
66
+ - Windows -> ```ANDROID_HOME="...sdk"```
67
+ In windows this ANDROID_HOME is not automatically created, see more in [here](https://facebook.github.io/react-native/releases/0.21/docs/android-setup.html#define-the-android-home-environment-variable)
68
+
69
+ Additionally, on windows in order to use git commands, the following path should be on the environment variable
70
+ - ```...\Git\cmd ```
71
+
60
72
  ## Alternative scenario (if you don't use `dryrun`)
61
73
 
62
74
  1. Find the github's repository url
@@ -76,7 +88,7 @@ I welcome and encourage all pull requests. It usually will take me within 24-48
76
88
  2. If its a feature, bugfix, or anything please only change code to what you specify.
77
89
  3. Please keep PR titles easy to read and descriptive of changes, this will make them easier to merge :)
78
90
  4. Pull requests _must_ be made against `develop` branch. Any other branch (unless specified by the maintainers) will get rejected.
79
- 5. Check for existing [issues](https://github.com/cesarferreira/dryrun/issues) first, before filing an issue.
91
+ 5. Check for existing [issues](https://github.com/cesarferreira/dryrun/issues) first, before filing an issue.
80
92
  6. Have fun!
81
93
 
82
94
  ### Created & Maintained By
data/bin/dryrun CHANGED
@@ -1,4 +1,5 @@
1
- #!/usr/bin/env ruby
1
+ #!/usr/bin/env ruby
2
+
2
3
  require 'bundler/setup'
3
4
  require 'dryrun'
4
5
 
data/dryrun.gemspec CHANGED
@@ -1,38 +1,37 @@
1
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'
2
+ require File.join([File.dirname(__FILE__), 'lib', 'dryrun', 'version.rb'])
5
3
 
6
4
  # rake build # Build dryrun-0.0.1.gem into the pkg directory
7
5
  # rake install # Build and install dryrun-0.0.1.gem into system gems
8
6
  # rake release # Create tag v0.0.1 and build and push dryrun-0.0.1.gem t...
9
7
  # rake spec # Run RSpec code examples
10
8
 
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']
9
+ Gem::Specification.new do |s|
10
+ s.name = 'dryrun'
11
+ s.version = Dryrun::VERSION
12
+ s.authors = ['cesar ferreira']
13
+ s.email = ['cesar.manuel.ferreira@gmail.com']
16
14
 
17
- spec.summary = 'Tool to try any android library hosted online directly from the command line'
18
- spec.description = 'Tool to try any android library hosted online directly from the command line'
19
- spec.homepage = 'https://github.com/cesarferreira/dryrun'
20
- spec.license = 'MIT'
15
+ s.summary = 'Tool to try any android library hosted online directly from the command line'
16
+ s.homepage = 'http://cesarferreira.com'
17
+ s.license = 'MIT'
18
+ s.platform = Gem::Platform::RUBY
21
19
 
22
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
23
- spec.bindir = 'bin'
24
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
25
- spec.require_paths = ['lib']
20
+ s.files = `git ls-files`.split("
21
+ ")
22
+ s.bindir = 'bin'
23
+ s.require_paths << 'lib'
24
+ s.executables << 'dryrun'
26
25
 
27
- spec.required_ruby_version = '>= 2.0.0'
26
+ s.required_ruby_version = '>= 2.0.0'
28
27
 
29
- spec.add_development_dependency 'rake', '~> 10.0'
30
- spec.add_development_dependency 'pry-byebug', '~> 3.2'
31
- spec.add_development_dependency 'rspec'
28
+ s.add_development_dependency 'rake', '~> 10.0'
29
+ s.add_development_dependency 'pry-byebug', '~> 3.2'
30
+ s.add_development_dependency 'rspec'
32
31
 
33
- spec.add_dependency 'bundler', '~> 1.7'
34
- spec.add_dependency 'colorize', '~> 0.7'
35
- spec.add_dependency 'oga', '~> 1.3.1'
36
- spec.add_dependency 'highline', '~> 1.7'
37
- spec.add_dependency 'rjb', '>= 1.5.4'
32
+ s.add_dependency 'bundler', '~> 1.7'
33
+ s.add_dependency 'colorize', '~> 0.7'
34
+ s.add_dependency 'oga', '~> 1.3.1'
35
+ s.add_dependency 'highline', '~> 1.7'
36
+ s.add_dependency 'rjb', '>= 1.5.4'
38
37
  end
data/lib/dryrun.rb CHANGED
@@ -4,10 +4,10 @@ require 'fileutils'
4
4
  require 'dryrun/github'
5
5
  require 'dryrun/version'
6
6
  require 'dryrun/android_project'
7
+ require 'dryrun/device'
7
8
  require 'highline/import'
8
9
  require 'openssl'
9
10
  require 'open3'
10
- require_relative 'dryrun/device'
11
11
  require 'optparse'
12
12
 
13
13
  module Dryrun
@@ -33,8 +33,8 @@ module Dryrun
33
33
  def create_options_parser(args)
34
34
  args.options do |opts|
35
35
  opts.banner = 'Usage: dryrun GIT_URL [OPTIONS]'
36
- opts.separator ''
37
- opts.separator 'Options'
36
+ opts.separator ''
37
+ opts.separator 'Options'
38
38
 
39
39
  opts.on('-m MODULE_NAME', '--module MODULE_NAME', 'Custom module to run') do |custom_module|
40
40
  @custom_module = custom_module
@@ -107,11 +107,11 @@ module Dryrun
107
107
 
108
108
  @devices = DryrunUtils.run_adb('devices')
109
109
 
110
- if @devices.nil? || @devices.empty?
111
- puts 'Killing adb, there might be an issue with it...'
112
- DryrunUtils.run_adb('kill-server')
113
- @devices = DryrunUtils.run_adb('devices')
114
- end
110
+ # if @devices.nil? || @devices.empty?
111
+ # puts 'Killing adb, there might be an issue with it...'
112
+ # DryrunUtils.run_adb('kill-server')
113
+ # @devices = DryrunUtils.run_adb('devices')
114
+ # end
115
115
 
116
116
  puts 'No devices attached, but I\'ll run anyway' if @devices.empty?
117
117
 
@@ -161,24 +161,30 @@ module Dryrun
161
161
  end
162
162
 
163
163
  if @url.nil?
164
- puts 'You need to insert a valid GIT URL'
164
+ puts 'You need to insert a valid GIT URL/folder'
165
165
  exit 1
166
166
  end
167
167
 
168
- @url = @url.split('?').first
169
- @url.chop! if @url.end_with? '/'
170
-
171
168
  pick_device
172
169
 
173
- github = Github.new(@url)
170
+ if DryrunUtils::is_folder? (@url)
171
+ repository_path = File.expand_path @url
172
+ else
174
173
 
175
- unless github.valid?
176
- puts "#{@url.red} is not a valid git @url"
177
- exit 1
178
- end
174
+ @url = @url.split('?').first
175
+ @url.chop! if @url.end_with? '/'
179
176
 
180
- # clone the repository
181
- repository_path = github.clone(@branch, @tag, @cleanup)
177
+ github = Github.new(@url)
178
+
179
+ unless github.valid?
180
+ puts "#{@url.red} is not a valid git @url"
181
+ exit 1
182
+ end
183
+
184
+ # clone the repository
185
+ repository_path = github.clone(@branch, @tag, @cleanup)
186
+
187
+ end
182
188
 
183
189
  android_project = AndroidProject.new(repository_path, @app_path, @custom_module, @flavour, @device)
184
190
 
@@ -183,21 +183,23 @@ module Dryrun
183
183
 
184
184
  manifest_file.close
185
185
 
186
- "am start -n \"#{launchable_activity}\" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER"
186
+ "am start -n \"#{launcheable_activity}\" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER"
187
187
  end
188
188
 
189
189
  def get_manifest(path_to_sample)
190
190
  default_path = File.join(path_to_sample, 'src/main/AndroidManifest.xml')
191
+
191
192
  if File.exist?(default_path)
192
- return File.open(default_path)
193
+ File.open(default_path)
193
194
  else
195
+ puts path_to_sample
194
196
  Find.find(path_to_sample) do |path|
195
197
  return File.open(path) if path =~ /.*AndroidManifest.xml$/
196
198
  end
197
199
  end
198
200
  end
199
201
 
200
- def launchable_activity
202
+ def launcheable_activity
201
203
  full_path_to_launcher = "#{@package}#{@launcher_activity.gsub(@package, '')}"
202
204
  "#{@package}/#{full_path_to_launcher}"
203
205
  end
data/lib/dryrun/device.rb CHANGED
@@ -1,4 +1,4 @@
1
- module AdbDevice
1
+ module Dryrun
2
2
  class Device
3
3
  attr_accessor :name, :id
4
4
 
@@ -46,6 +46,10 @@ module Dryrun
46
46
  run(path)
47
47
  end
48
48
 
49
+ def self.is_folder? (path)
50
+ File.directory?(path)
51
+ end
52
+
49
53
  def self.run(path)
50
54
  Open3.popen3(path) do |_stdin, stdout, _stderr|
51
55
  devices = []
@@ -53,7 +57,7 @@ module Dryrun
53
57
  line = line.strip
54
58
  if !line.empty? && line !~ /^List of devices/ && !line.start_with?('adb') && !line.start_with?('*')
55
59
  parts = line.split
56
- devices << AdbDevice::Device.new(parts[0], parts[1])
60
+ devices << Dryrun::Device.new(parts[0], parts[1])
57
61
  end
58
62
  end
59
63
  devices
data/lib/dryrun/github.rb CHANGED
@@ -13,7 +13,7 @@ module Dryrun
13
13
  def sanitize_url(url)
14
14
  url = url.split('?').first
15
15
  url.chop! if url.end_with? '/'
16
- return url
16
+ url
17
17
  end
18
18
 
19
19
  def destination
@@ -25,7 +25,7 @@ module Dryrun
25
25
  stripped_url = stripped_url.gsub('.git', '')
26
26
  stripped_url = stripped_url.gsub('git@github.com:', '')
27
27
  stripped_url = stripped_url.gsub('https://github.com/', '')
28
- stripped_url = stripped_url.gsub('http://github.com/', '')
28
+ stripped_url.gsub('http://github.com/', '')
29
29
  end
30
30
 
31
31
  def valid?
@@ -36,7 +36,7 @@ module Dryrun
36
36
  (starts_with_git || starts_with_https || starts_with_http)
37
37
  end
38
38
 
39
- def clonable_url
39
+ def cloneable_url
40
40
  starts_with_git = @base_url.split(//).first(4).join.eql? 'git@'
41
41
  ends_with_git = @base_url.split(//).last(4).join.eql? '.git'
42
42
 
@@ -53,7 +53,7 @@ module Dryrun
53
53
  ## CLONE THE REPOSITORY
54
54
  ##
55
55
  def clone(branch, tag, cleanup)
56
- clonable = clonable_url
56
+ cloneable = cloneable_url
57
57
 
58
58
  tmpdir = Dir.tmpdir + "/dryrun/#{@destination}"
59
59
 
@@ -72,7 +72,7 @@ module Dryrun
72
72
 
73
73
  if !is_git_repo
74
74
  FileUtils.rm_rf(tmpdir)
75
- DryrunUtils.execute("git clone --depth 1 #{clonable} #{tmpdir}")
75
+ DryrunUtils.execute("git clone --depth 1 #{cloneable} #{tmpdir}")
76
76
  DryrunUtils.execute("git checkout #{branch}")
77
77
  else
78
78
  puts "Found project in #{tmpdir.green}..."
@@ -82,7 +82,7 @@ module Dryrun
82
82
  DryrunUtils.execute("git pull origin #{branch}")
83
83
  end
84
84
  else
85
- DryrunUtils.execute("git clone --depth 1 #{clonable} #{tmpdir}")
85
+ DryrunUtils.execute("git clone --depth 1 #{cloneable} #{tmpdir}")
86
86
  end
87
87
 
88
88
  if tag
@@ -1,3 +1,3 @@
1
1
  module Dryrun
2
- VERSION = '0.8.1'.freeze
2
+ VERSION = '0.9.0'.freeze
3
3
  end
@@ -0,0 +1 @@
1
+ require 'spec_helper'
@@ -0,0 +1,64 @@
1
+ require 'spec_helper'
2
+ require 'dryrun/github'
3
+
4
+ describe '# Github' do
5
+
6
+ context 'URL validity' do
7
+ it 'URL should be valid' do
8
+ url = 'https://github.com/cesarferreira/android-helloworld'
9
+ github = Dryrun::Github.new(url)
10
+ expected = 'https://github.com/cesarferreira/android-helloworld.git'
11
+ expect(github.cloneable_url).to eq(expected)
12
+ end
13
+
14
+ it 'URL that ends in .git should be valid' do
15
+ url = 'https://github.com/googlesamples/google-services.git'
16
+ github = Dryrun::Github.new(url)
17
+ expected = 'https://github.com/googlesamples/google-services.git'
18
+ expect(github.cloneable_url).to eq(expected)
19
+ end
20
+
21
+ it 'SSH URL should be valid' do
22
+ url = 'git@github.com:cesarferreira/android-helloworld.git'
23
+ github = Dryrun::Github.new(url)
24
+ expected = 'git@github.com:cesarferreira/android-helloworld.git'
25
+ expect(github.cloneable_url).to eq(expected)
26
+ end
27
+
28
+ it 'URL should not be valid' do
29
+ url = 'asdasdas'
30
+ github = Dryrun::Github.new(url)
31
+ expect(github.valid?).to be false
32
+ end
33
+ end
34
+
35
+ context 'URL destination folders' do
36
+ it 'Given a regular url' do
37
+ url = 'https://github.com/cesarferreira/android-helloworld'
38
+ github = Dryrun::Github.new(url)
39
+ expected = 'cesarferreira/android-helloworld'
40
+ expect(github.destination).to eq(expected)
41
+ end
42
+
43
+ it 'Given a URL that ends in .git' do
44
+ url = 'https://github.com/googlesamples/google-services.git'
45
+ github = Dryrun::Github.new(url)
46
+ expected = 'googlesamples/google-services'
47
+ expect(github.destination).to eq(expected)
48
+ end
49
+
50
+ it 'Given a SSH URL' do
51
+ url = 'git@github.com:cesarferreira/android-helloworld.git'
52
+ github = Dryrun::Github.new(url)
53
+ expected = 'cesarferreira/android-helloworld'
54
+ expect(github.destination).to eq(expected)
55
+ end
56
+
57
+ it 'Given a non Github URL' do
58
+ url = 'git@bitbucket.org:RyanBis/another-android-library.git'
59
+ github = Dryrun::Github.new(url)
60
+ expected = '2ef4153951350a0521cd8e02e4b629072dd515637610f0b48fe17a1a89a2c51a'
61
+ expect(github.destination).to eq(expected)
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,25 @@
1
+ require 'dryrun'
2
+ RSpec.configure do |config|
3
+ # rspec-expectations config goes here. You can use an alternate
4
+ # assertion/expectation library such as wrong or the stdlib/minitest
5
+ # assertions if you prefer.
6
+ config.expect_with :rspec do |expectations|
7
+ # This option will default to `true` in RSpec 4. It makes the `description`
8
+ # and `failure_message` of custom matchers include text for helper methods
9
+ # defined using `chain`, e.g.:
10
+ # be_bigger_than(2).and_smaller_than(4).description
11
+ # # => "be bigger than 2 and smaller than 4"
12
+ # ...rather than:
13
+ # # => "be bigger than 2"
14
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
15
+ end
16
+
17
+ # rspec-mocks config goes here. You can use an alternate test double
18
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
19
+ config.mock_with :rspec do |mocks|
20
+ # Prevents you from mocking or stubbing a method that does not exist on
21
+ # a real object. This is generally recommended, and will default to
22
+ # `true` in RSpec 4.
23
+ mocks.verify_partial_doubles = true
24
+ end
25
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dryrun
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.9.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: 2016-11-11 00:00:00.000000000 Z
11
+ date: 2016-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -122,8 +122,7 @@ dependencies:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: 1.5.4
125
- description: Tool to try any android library hosted online directly from the command
126
- line
125
+ description:
127
126
  email:
128
127
  - cesar.manuel.ferreira@gmail.com
129
128
  executables:
@@ -153,7 +152,10 @@ files:
153
152
  - lib/dryrun/dryrun_utils.rb
154
153
  - lib/dryrun/github.rb
155
154
  - lib/dryrun/version.rb
156
- homepage: https://github.com/cesarferreira/dryrun
155
+ - spec/dryrun_spec.rb
156
+ - spec/github_spec.rb
157
+ - spec/spec_helper.rb
158
+ homepage: http://cesarferreira.com
157
159
  licenses:
158
160
  - MIT
159
161
  metadata: {}
@@ -161,6 +163,7 @@ post_install_message:
161
163
  rdoc_options: []
162
164
  require_paths:
163
165
  - lib
166
+ - lib
164
167
  required_ruby_version: !ruby/object:Gem::Requirement
165
168
  requirements:
166
169
  - - ">="
@@ -173,7 +176,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
173
176
  version: '0'
174
177
  requirements: []
175
178
  rubyforge_project:
176
- rubygems_version: 2.5.1
179
+ rubygems_version: 2.5.2
177
180
  signing_key:
178
181
  specification_version: 4
179
182
  summary: Tool to try any android library hosted online directly from the command line