File tree 13 files changed +150
-29
lines changed
13 files changed +150
-29
lines changed Original file line number Diff line number Diff line change
1
+ --require spec_helper
2
+ --tty
3
+ --color
4
+ --format documentation
5
+ --format html -o " tmp/rspec_result.html"
Original file line number Diff line number Diff line change 1
1
language : ruby
2
2
rvm :
3
+ - 1.9.3
3
4
- 2.2.1
4
- before_install : gem install bundler -v 1.10.6
Original file line number Diff line number Diff line change 1
1
# dryrun
2
- [ ![ Gem Version] ( https://badge.fury.io/rb/dryrun.svg )] ( http://badge.fury.io/rb/dryrun )
2
+ ![ Header ] ( https://travis-ci.org/cesarferreira/dryrun.svg?branch=master ) [ ![ Gem Version] ( https://badge.fury.io/rb/dryrun.svg )] ( http://badge.fury.io/rb/dryrun )
3
3
4
4
** Try** an ** android** library on your ** smartphone** ** directly** from the ** command line**
5
5
Original file line number Diff line number Diff line change 1
1
require "bundler/gem_tasks"
2
+
3
+ require 'rspec/core/rake_task'
4
+
5
+ # Default directory to look in is `/specs`
6
+ # Run with `rake spec`
7
+ RSpec ::Core ::RakeTask . new ( :spec ) do |task |
8
+ task . rspec_opts = [ '--color' , '--format' , 'nested' ]
9
+ end
10
+
11
+ task :default => :spec
Original file line number Diff line number Diff line change @@ -14,8 +14,8 @@ Gem::Specification.new do |spec|
14
14
spec . authors = [ "cesar ferreira" ]
15
15
spec . email = [ "[email protected] " ]
16
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 }
17
+ spec . summary = %q{Tool which allows to quickly try the demo project of an Android Library }
18
+ spec . description = %q{Tool which allows to quickly try the demo project of an Android Library }
19
19
spec . homepage = "https://github.com/cesarferreira/dryrun"
20
20
21
21
spec . files = `git ls-files -z` . split ( "\x0 " ) . reject { |f | f . match ( %r{^(test|spec|features)/} ) }
@@ -26,6 +26,10 @@ Gem::Specification.new do |spec|
26
26
spec . add_development_dependency "bundler" , "~> 1.10"
27
27
spec . add_development_dependency "rake" , "~> 10.0"
28
28
spec . add_development_dependency 'pry-byebug' , '~> 3.1'
29
+ spec . add_development_dependency "rspec"
30
+ spec . add_development_dependency "rspec-nc"
31
+ spec . add_development_dependency "guard"
32
+ spec . add_development_dependency "guard-rspec"
29
33
30
34
spec . add_dependency 'colorize' , '~> 0.7'
31
35
spec . add_dependency 'nokogiri' , '~> 1.6.6.2'
Original file line number Diff line number Diff line change @@ -41,8 +41,11 @@ def self.initialize(url)
41
41
exit 1
42
42
end
43
43
44
+ # clean and install the apk
44
45
project . clean_install
45
46
47
+ puts "\n > If you want to remove the app you just installed, execute:\n #{ project . get_uninstall_command . yellow } \n \n "
48
+
46
49
end
47
50
end
48
51
end
Original file line number Diff line number Diff line change @@ -51,7 +51,6 @@ def clean_install
51
51
52
52
system ( "#{ builder } clean assembleDebug installDebug" )
53
53
54
-
55
54
puts "Installing #{ @package . green } ...\n "
56
55
puts "executing: #{ execute_line } "
57
56
system ( execute_line )
@@ -64,19 +63,18 @@ def sample_project
64
63
full_path = "#{ @base_path } #{ child . first } "
65
64
66
65
execute_line = get_execute_line ( "#{ full_path } /src/main/AndroidManifest.xml" )
67
-
68
- if execute_line
69
- #puts "\nTHE SAMPLE IS HERE #{full_path.green}:\n"
70
- #system("tree #{full_path}")
71
- return full_path , execute_line
72
- end
66
+ return full_path , execute_line if execute_line
73
67
74
68
end
75
69
return false , false
76
70
end
77
71
72
+ def get_uninstall_command
73
+ "adb uninstall #{ @package } "
74
+ end
75
+
78
76
def uninstall
79
- system ( "adb uninstall #{ @package } " )
77
+ system ( "#{ self . get_uninstall_command } > /dev/null 2>&1 " )
80
78
end
81
79
82
80
Original file line number Diff line number Diff line change 1
1
require 'tmpdir'
2
2
require 'fileutils'
3
3
require 'uri'
4
- require 'colorize '
4
+ require 'pry '
5
5
6
6
module DryRun
7
7
8
8
class Github
9
9
def initialize ( url )
10
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
11
+ @destination = get_destination
19
12
end
20
13
21
- def path
22
- @resource . path
14
+ def get_destination
15
+ destiny = @base_url . gsub ( '.git' , '' )
16
+ destiny = destiny . split ( '/' )
17
+ "#{ destiny . last ( 2 ) . join ( '/' ) } "
23
18
end
24
19
25
20
def is_valid
26
21
return true
27
22
end
28
23
29
24
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"
25
+ starts_with_git = @base_url . split ( // ) . first ( 4 ) . join . eql? "git@"
26
+ ends_with_git = @base_url . split ( // ) . last ( 4 ) . join . eql? ".git"
27
+
28
+ # ends with git but doesnt start with git
29
+ if ends_with_git and !starts_with_git
30
+ return @base_url
31
+ end
32
+
33
+ # ends with git but doesnt start with git
34
+ if !ends_with_git and !starts_with_git
35
+ return "#{ @base_url } .git"
36
+ end
37
+
38
+ @base_url
39
+
34
40
# end
35
41
end
36
42
@@ -40,7 +46,7 @@ def clonable_url
40
46
def clone
41
47
clonable = self . clonable_url
42
48
43
- tmpdir = Dir . tmpdir +"#{ path } "
49
+ tmpdir = Dir . tmpdir +"dryrun/ #{ @destination } "
44
50
FileUtils . rm_rf ( tmpdir )
45
51
46
52
system ( "git clone #{ clonable } #{ tmpdir } " )
Original file line number Diff line number Diff line change 1
1
module DryRun
2
- VERSION = "0.2.2 "
2
+ VERSION = "0.3.1 "
3
3
end
Original file line number Diff line number Diff line change
1
+ require 'spec_helper'
2
+ require 'pry'
3
+ require 'dryrun/android_project'
4
+
5
+
6
+ # RSpec.describe "something" do
7
+ # context "in one context" do
8
+ # it "does one thing" do
9
+ # end
10
+ # end
11
+ # context "in another context" do
12
+ # it "does another thing" do
13
+ # end
14
+ # end
15
+ # end
Original file line number Diff line number Diff line change
1
+ require 'spec_helper'
Original file line number Diff line number Diff line change
1
+ require 'spec_helper'
2
+ require 'pry'
3
+ require 'dryrun/github'
4
+
5
+
6
+ describe '#github' do
7
+
8
+ context 'when given github url\'s' do
9
+
10
+ it 'is a regular url' do
11
+ url = "https://github.com/cesarferreira/android-helloworld"
12
+ github = DryRun ::Github . new ( url )
13
+ expected = "https://github.com/cesarferreira/android-helloworld.git"
14
+ expect ( github . clonable_url == expected ) . to be true
15
+ end
16
+
17
+
18
+ it 'ends in .git' do
19
+ url = 'https://github.com/googlesamples/google-services.git'
20
+ github = DryRun ::Github . new ( url )
21
+ expected = 'https://github.com/googlesamples/google-services.git'
22
+ expect ( github . clonable_url == expected ) . to be true
23
+ end
24
+
25
+
26
+ it 'is from ssh' do
27
+ url = '[email protected] :cesarferreira/android-helloworld.git'
28
+ github = DryRun ::Github . new ( url )
29
+ expected = '[email protected] :cesarferreira/android-helloworld.git'
30
+ expect ( github . clonable_url == expected ) . to be true
31
+ end
32
+ end
33
+
34
+
35
+ context 'when needing a destination to clone the project' do
36
+ it 'is 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 . get_destination == expected ) . to be true
41
+ end
42
+
43
+ it '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 . get_destination == expected ) . to be true
48
+ end
49
+ end
50
+
51
+
52
+ end
Original file line number Diff line number Diff line change
1
+ require 'dryrun'
2
+
3
+ RSpec . configure do |config |
4
+ # rspec-expectations config goes here. You can use an alternate
5
+ # assertion/expectation library such as wrong or the stdlib/minitest
6
+ # assertions if you prefer.
7
+ config . expect_with :rspec do |expectations |
8
+ # This option will default to `true` in RSpec 4. It makes the `description`
9
+ # and `failure_message` of custom matchers include text for helper methods
10
+ # defined using `chain`, e.g.:
11
+ # be_bigger_than(2).and_smaller_than(4).description
12
+ # # => "be bigger than 2 and smaller than 4"
13
+ # ...rather than:
14
+ # # => "be bigger than 2"
15
+ expectations . include_chain_clauses_in_custom_matcher_descriptions = true
16
+ end
17
+
18
+ # rspec-mocks config goes here. You can use an alternate test double
19
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
20
+ config . mock_with :rspec do |mocks |
21
+ # Prevents you from mocking or stubbing a method that does not exist on
22
+ # a real object. This is generally recommended, and will default to
23
+ # `true` in RSpec 4.
24
+ mocks . verify_partial_doubles = true
25
+ end
26
+
27
+ end
You can’t perform that action at this time.
0 commit comments