gito 0.3.1 → 0.4.1

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: 4416faef1ce8a1f742961c8166aa3748191d61cd
4
- data.tar.gz: ed9a120d580ae5f28dd6ba95ad9786755146eadd
3
+ metadata.gz: 1cb2512c80d82e067bb3931c186b04a69b116e27
4
+ data.tar.gz: d91c38661f76eb28174dea15d630c5ed0e29d067
5
5
  SHA512:
6
- metadata.gz: 52da36d58def0e2b8bf201966118a247ff1904bf896354a75923850f3fe853d5b48a9dc579da6f49b9dd6aa3e69076483acc3985b2825c227ae996fb43747c88
7
- data.tar.gz: 69966fb5f99e3c5aac8a00de16a30b42f1ed5149dcef2256f8712b48c1d7b7d9205d13a0eafb5debedebbe9802901bad658f67795e4080a9f0dd659fbf326422
6
+ metadata.gz: a64134ef2dd4af7c3747323033a19d1b8847a2d917389d1481f8c69fef1c594cb9af9d54fb4d37b282558582c649631b3dcbc45a34923f054a26d9bfed164868
7
+ data.tar.gz: 702e6c5d7bb147910b3ec666974f6b8759509636e1fed4b7cc17f762bf73e9c270181d3408957f5d78e097e622c3fc72c01d2d644b7c6874ab729367c90c71ba
data/README.md CHANGED
@@ -30,6 +30,7 @@ Options
30
30
  -e, --edit Open the project on an editor
31
31
  -o, --open Open the project on Finder
32
32
  -d, --dryrun Does not install the dependencies
33
+ -t, --temp Clones the project into a temporary folder
33
34
  -h, --help Displays help
34
35
  -v, --version Displays the version
35
36
  ```
@@ -42,11 +43,14 @@ gito cesarferreira/dryrun
42
43
  # git clone, install, open and edit the project
43
44
  gito cesarferreira/dryrun --edit --open
44
45
 
46
+ # git clone on a operating system /temp/ folder, install, and edit the project
47
+ gito cesarferreira/dryrun --edit --temp
48
+
45
49
  # set the editor to be 'subl' from now on
46
50
  gito cesarferreira/dryrun -s subl
47
51
 
48
- # git clone, install, open and edit the project from github
49
- gito https://github.com/cesarferreira/dryrun -e -o
52
+ # git clone, install, open and edit the project from github on a temp folder
53
+ gito https://github.com/cesarferreira/dryrun -e -o -t
50
54
 
51
55
  # git clone, install from another git source
52
56
  gito https://bitbucket.org/username/project
@@ -7,6 +7,7 @@ require 'gito/config_manager'
7
7
  require 'openssl'
8
8
  require 'open3'
9
9
  require 'optparse'
10
+ require 'tempfile'
10
11
 
11
12
  class MainApp
12
13
  def initialize(arguments)
@@ -14,12 +15,14 @@ class MainApp
14
15
  @url = %w(-h --help -v --version).include?(arguments.first) ? nil : arguments.shift
15
16
 
16
17
  # defaults
17
- @app_path = nil
18
- @should_edit = false
19
- @should_open = false
20
- @dryrun = false
21
- @editor = nil
22
- @setting_up = false
18
+ @options = {}
19
+ @options[:app_path] = nil
20
+ @options[:should_edit] = false
21
+ @options[:should_open] = false
22
+ @options[:dryrun] = false
23
+ @options[:editor] = nil
24
+ @options[:setting_up] = false
25
+ @options[:is_temp] = false
23
26
 
24
27
  # Parse Options
25
28
  create_options_parser(arguments)
@@ -32,20 +35,24 @@ class MainApp
32
35
  opts.separator 'Options'
33
36
 
34
37
  opts.on('-s EDITOR', '--set-editor EDITOR', 'Set a custom editor to open the project (e.g. "atom", "subl", "vim", etc.') do |editor|
35
- @editor = editor.nil? ? nil : editor
36
- @setting_up = true
38
+ @options[:editor] = editor.nil? ? nil : editor
39
+ @options[:setting_up] = true
37
40
  end
38
41
 
39
42
  opts.on('-e', '--edit', 'Open the project on an editor') do |editor|
40
- @should_edit = true
43
+ @options[:should_edit] = true
41
44
  end
42
45
 
43
46
  opts.on('-o', '--open', 'Open the project on Finder') do |edit|
44
- @should_open = true
47
+ @options[:should_open] = true
45
48
  end
46
49
 
47
50
  opts.on('-d', '--dryrun', 'Doesn\'t install the dependencies') do |dryrun|
48
- @dryrun = true
51
+ @options[:dryrun] = true
52
+ end
53
+
54
+ opts.on('-t', '--temp', 'Clones the project into a temporary folder') do |is_temp|
55
+ @options[:is_temp] = true
49
56
  end
50
57
 
51
58
  opts.on('-h', '--help', 'Displays help') do
@@ -66,21 +73,21 @@ class MainApp
66
73
  config_manager = ConfigManager.new
67
74
  app_config = config_manager.get
68
75
 
69
- if @editor.nil?
70
- @editor = app_config[:editor]
76
+ if @options[:editor].nil?
77
+ @options[:editor] = app_config[:editor]
71
78
  else
72
- config_manager.write_editor @editor
79
+ config_manager.write_editor @options[:editor]
73
80
  end
74
81
  end
75
82
 
76
83
  def call
77
84
 
78
- if @setting_up
79
- if @editor.nil?
85
+ if @options[:setting_up]
86
+ if @options[:editor].nil?
80
87
  puts 'New new editor can\'t be empty'.red
81
88
  else
82
89
  update_configuration
83
- puts 'Updated the editor to: ' + @editor.yellow
90
+ puts 'Updated the editor to: ' + @options[:editor].yellow
84
91
  end
85
92
  exit 1
86
93
  end
@@ -96,20 +103,20 @@ class MainApp
96
103
  project = Project.new(@url)
97
104
 
98
105
  # Clone the repository
99
- project.clone
106
+ project.clone(@options[:is_temp])
100
107
 
101
108
  # Open in editor
102
- if @should_edit
109
+ if @options[:should_edit]
103
110
  # binding.pry
104
- project.open_editor @editor
111
+ project.open_editor @options[:editor]
105
112
  end
106
113
 
107
114
  # Open in Finder
108
- if @should_open
115
+ if @options[:should_open]
109
116
  project.open_folder
110
117
  end
111
118
 
112
- unless @dryrun
119
+ unless @options[:dryrun]
113
120
  # Install dependencies
114
121
  project.install_dependencies
115
122
  end
@@ -91,13 +91,19 @@ class Project
91
91
  ##
92
92
  ## CLONE THE REPOSITORY
93
93
  ##
94
- def clone
94
+ def clone(is_temp_folder=false)
95
95
  cloneable = cloneable_url
96
96
 
97
- @destination_dir = Dir.pwd + "/#{@destination}"
97
+ unless is_temp_folder
98
+ prefix = Dir.pwd + '/'
99
+ else
100
+ prefix = Dir.tmpdir + '/gito/'
101
+ end
102
+
103
+ @destination_dir = prefix + "#{@destination}"
98
104
 
99
105
  if File.directory?(@destination_dir)
100
- puts 'The folder is not empty...'.yellow
106
+ puts "The folder #{@destination_dir.green} is not empty..."
101
107
  else
102
108
  AppUtils.execute("git clone --depth 1 #{cloneable} #{@destination_dir}")
103
109
  end
@@ -1,3 +1,3 @@
1
1
  module Gito
2
- VERSION = '0.3.1'
2
+ VERSION = '0.4.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gito
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - cesar ferreira