install_gem_local 0.1.4 → 0.1.5

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
  SHA256:
3
- metadata.gz: 9fb359829ea7f108b9cf5094f536cfe7e7928d298a2f5edca52db8b88275acff
4
- data.tar.gz: ede47929e4b46e1219b2bb1f75c4ac21071e2593423f207052efabf18df4ffe7
3
+ metadata.gz: ce714b8b79bf2a7a652e3818bf5ac12dfe571e49f81fcd29d0e305aeecd09b4c
4
+ data.tar.gz: a05c0d63842d2b3de5d0572e50481c7d0e3a2a4b3132c3fb886aa13fec7b9542
5
5
  SHA512:
6
- metadata.gz: 44e6b54d1af8983ed5402bfd9823bd474692109e14ce475c1069dee921fa30b977f3d066d8c07602fae4cd8f0db8040ac229b678eb628780e4e865877ea56be4
7
- data.tar.gz: 50c89d5f1271218077864b518be8913051f80b77a036ed9e294daf570dd374efc7a9e5cbf15c71ad5dee71a0285e7abf6c8aaa0653528b6f3b7ab2702f68156f
6
+ metadata.gz: bf3f7efac2d9259e68764f155b1ad1f8977d8709d86fa7fed5e55ce57e11af5164c37c0eea0824e9523c8ddda779a68a0f171b521162c8e1cfa5767edbce9823
7
+ data.tar.gz: 67da087919a77f45ef59f77da878e116310980ab9a313349e579097033eb46fb5fc656b4130633abd9005c3556df726e9d8be7baba95b9a9ab131143cd9385d9
data/Gemfile CHANGED
@@ -6,4 +6,4 @@ source 'https://rubygems.org'
6
6
  gemspec
7
7
 
8
8
  # cops
9
- gem 'rubocop'
9
+ gem 'rubocop'
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'thor'
3
4
  require 'downup'
4
5
  require 'awesome_print'
@@ -11,8 +12,6 @@ require 'install_gem_local/action'
11
12
  module InstallGemLocal
12
13
  class App < Thor
13
14
  desc 'usage', 'list all commands'
14
- def usage
15
-
16
- end
15
+ def usage; end
17
16
  end
18
17
  end
@@ -1,58 +1,99 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module InstallGemLocal
2
4
  class Action
3
5
  class << self
4
6
  def remove_gem
5
- cmd = TTY::Command.new
6
- file = cmd.run('find -type f -name "*.gem"')
7
- ap file_name = file.out.strip
8
- file_name.empty? ? ap('Gem not exist') : cmd.run("rm #{file_name}")
7
+ file_exists = file_names
8
+ if file_exists.count > 1
9
+ remove_file_from_path(multiple_version_selection)
10
+ elsif file_exists.count == 1
11
+ remove_file_from_path(file_exists.first)
12
+ else
13
+ ap 'Gem not exist'
14
+ end
15
+ end
16
+
17
+ def remove_file_from_path(file_name)
18
+ tty_command.run("rm #{file_name}")
9
19
  end
10
20
 
11
21
  def build_gem
12
22
  puts '-----------------------------'
13
23
  puts ''
14
- cmd = TTY::Command.new
15
- file = cmd.run('find -type f -name "*.gemspec"')
24
+ file = tty_command.run('find -type f -name "*.gemspec"')
16
25
  ap file_name = file.out.strip
17
- file_name.empty? ? ap('Gemspec not exist') : cmd.run("gem build #{file_name}")
26
+ file_name.empty? ? ap('Gemspec not exist') : tty_command.run("gem build #{file_name}")
18
27
  end
19
28
 
20
29
  def install_gem
21
30
  puts '-----------------------------'
22
31
  puts ''
23
- cmd = TTY::Command.new
24
- file = cmd.run('find -type f -name "*.gem"')
25
- ap file_name = file.out.strip
26
- file_name.empty? ? ap('Gem not exist') : cmd.run("gem install #{file_name}")
32
+ files_exists = file_names
33
+ if files_exists.count > 1
34
+ install_gem_from_path(multiple_version_selection)
35
+ elsif files_exists.count == 1
36
+ install_gem_from_path(files_exists.first)
37
+ else
38
+ ap 'Gem not exist'
39
+ end
27
40
  end
28
41
 
29
- def copy_gem
42
+ def install_gem_from_path(file_name)
43
+ tty_command.run("gem install #{file_name}")
44
+ end
45
+
46
+ def multiple_version_selection
47
+ options = {}
48
+ file_names.each_with_index do |file_name, index|
49
+ options[('a'..'z').to_a[index]] = { 'value' => file_name, 'display' => file_name }
50
+ end
51
+ options['/'] = { 'value' => 'exit', 'display' => 'Exit'}
52
+ Downup::Base.new(flash_message: 'Choose which version',
53
+ options: options).prompt
54
+ end
55
+
56
+ def file_names
57
+ file = tty_command.run('find -type f -name "*.gem"')
58
+ file.entries
59
+ end
60
+
61
+ def tty_command
62
+ @tty_command ||= TTY::Command.new
63
+ end
64
+
65
+ def choose_copy_folder
30
66
  options = {
31
- "a" => {"value" => 'desktop', "display" => 'Desktop'},
32
- "b" => {"value" => 'downloads', "display" => 'Downloads'},
33
- "c" => {"value" => 'documents', "display" => 'Documents'},
34
- "/" => {"value" => "exit", "display" => "Exit"}
67
+ 'a' => { 'value' => 'desktop', 'display' => 'Desktop' },
68
+ 'b' => { 'value' => 'downloads', 'display' => 'Downloads' },
69
+ 'c' => { 'value' => 'documents', 'display' => 'Documents' },
70
+ '/' => { 'value' => 'exit', 'display' => 'Exit' }
35
71
  }
36
72
 
37
- selection = Downup::Base.new(flash_message: 'Choose Folder To Copy',
38
- options: options).prompt
73
+ Downup::Base.new(flash_message: 'Choose Folder To Copy',
74
+ options: options).prompt
75
+ end
39
76
 
40
- ap selection
77
+ def copy_gem
78
+ files_exists = file_names
41
79
 
42
- cmd = TTY::Command.new
43
- file = cmd.run('find -type f -name "*.gem"')
44
- ap file_name = file.out.strip
45
- if file_name.empty?
46
- ap 'Gem not present in the current folder'
80
+ if files_exists.count > 1
81
+ copy_file_to_path(multiple_version_selection)
82
+ elsif files_exists.count == 1
83
+ copy_file_to_path(files_exists.first)
47
84
  else
48
- case selection
49
- when 'desktop'
50
- cmd.run("cp #{file_name} ~/Desktop")
51
- when 'downloads'
52
- cmd.run("cp #{file_name} ~/Downloads")
53
- when 'documents'
54
- cmd.run("cp #{file_name} ~/Documents")
55
- end
85
+ ap 'Gem not exist'
86
+ end
87
+ end
88
+
89
+ def copy_file_to_path(file_name)
90
+ case choose_copy_folder
91
+ when 'desktop'
92
+ tty_command.run("cp #{file_name} ~/Desktop")
93
+ when 'downloads'
94
+ tty_command.run("cp #{file_name} ~/Downloads")
95
+ when 'documents'
96
+ tty_command.run("cp #{file_name} ~/Documents")
56
97
  end
57
98
  end
58
99
 
@@ -68,4 +109,4 @@ module InstallGemLocal
68
109
  end
69
110
  end
70
111
  end
71
- end
112
+ end
@@ -1,15 +1,17 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module InstallGemLocal
2
4
  class Navigation
3
5
  class << self
4
6
  def start
5
7
  options = {
6
- "a" => {"value" => 'remove', "display" => 'Remove old version'},
7
- "b" => {"value" => 'build', "display" => 'Build new version'},
8
- "c" => {"value" => 'install', "display" => 'Install new version'},
9
- "d" => {"value" => 'copy_gem', "display" => 'Copy gem to folder'},
10
- "e" => {"value" => 'till_install', "display" => 'Remove old version, build and install the new version'},
11
- "f" => {"value" => 'till_copy', "display" => 'Remove old version, build, install and copy the new version'},
12
- "/" => {"value" => "exit", "display" => "Exit"}
8
+ 'a' => { 'value' => 'remove', 'display' => 'Remove old version' },
9
+ 'b' => { 'value' => 'build', 'display' => 'Build new version' },
10
+ 'c' => { 'value' => 'install', 'display' => 'Install new version' },
11
+ 'd' => { 'value' => 'copy_gem', 'display' => 'Copy gem to folder' },
12
+ 'e' => { 'value' => 'till_install', 'display' => 'Remove old version, build and install the new version' },
13
+ 'f' => { 'value' => 'till_copy', 'display' => 'Remove old version, build, install and copy the new version' },
14
+ '/' => { 'value' => 'exit', 'display' => 'Exit' }
13
15
  }
14
16
 
15
17
  selection = Downup::Base.new(flash_message: 'Select Action', options: options).prompt
@@ -30,11 +32,10 @@ module InstallGemLocal
30
32
  when 'till_copy'
31
33
  InstallGemLocal::Action.till_copy
32
34
  end
33
-
34
35
  rescue StandardError => e
35
36
  ap e
36
37
  ap 'Something Wrong! Try again!'
37
38
  end
38
39
  end
39
40
  end
40
- end
41
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module InstallGemLocal
4
- VERSION = '0.1.4'
4
+ VERSION = '0.1.5'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: install_gem_local
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dhanabal T
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-05-16 00:00:00.000000000 Z
11
+ date: 2019-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler