rgversion 1.1.6 → 1.1.7.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/rgversion +1 -1
- data/lib/rgversion/clipboard.rb +42 -0
- data/lib/rgversion/instruction.rb +18 -0
- data/lib/rgversion/settings.rb +5 -0
- data/lib/rgversion/terminal.rb +2 -38
- data/lib/rgversion/version.rb +2 -2
- data/lib/rgversion.rb +12 -6
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a425e7138abec6028f4141d2b83749336db732bfdafe0e59a517910058b77ff2
|
4
|
+
data.tar.gz: 5fe10e6b1c337b7116dff69d83252456487459b21113dcf6120f37ff177cc22f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11e6af8cad947bcf6bab957d3cf850a7d185f704cb5a46a80fce3e1096f7ad079f7aab99603e0514f815c937936b95c94b7dc8f3caaeb6014100d32b0d8fb64c
|
7
|
+
data.tar.gz: 9c8e874e26b7d7f59e923463b8ad882f9ef378180ffd92a89868f69f2feebc31d1140434a8dfac7fddaead74505b33b7d8c25ab8d79e7aa00d1245bb3ef67cd2
|
data/exe/rgversion
CHANGED
@@ -0,0 +1,42 @@
|
|
1
|
+
module Rgversion
|
2
|
+
class Clipboard
|
3
|
+
def initialize(command)
|
4
|
+
@command = command
|
5
|
+
end
|
6
|
+
|
7
|
+
def copy
|
8
|
+
if command_exists?
|
9
|
+
system("echo \"#{@output}\" | #{clarified_command}")
|
10
|
+
puts "\nCopied to your clipboard!".green
|
11
|
+
else
|
12
|
+
instruction = Instruction.new(@command)
|
13
|
+
instruction.render
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def clarified_command
|
20
|
+
return "#{@command} -selection clipboard" if OS.linux?
|
21
|
+
@command
|
22
|
+
end
|
23
|
+
|
24
|
+
def command_exists?
|
25
|
+
return false if which(@command.to_s).nil?
|
26
|
+
true
|
27
|
+
end
|
28
|
+
|
29
|
+
# based on https://stackoverflow.com/a/5471032
|
30
|
+
# let's avoid find_executable from mkmf because in this case we need to supress logs
|
31
|
+
def which(cmd)
|
32
|
+
exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
|
33
|
+
ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
|
34
|
+
exts.each do |ext|
|
35
|
+
exe = File.join(path, "#{cmd}#{ext}")
|
36
|
+
return exe if File.executable?(exe) && !File.directory?(exe)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
nil
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Rgversion
|
2
|
+
class Instruction
|
3
|
+
def initialize(command)
|
4
|
+
@command = command
|
5
|
+
end
|
6
|
+
|
7
|
+
def render
|
8
|
+
if @command.nil?
|
9
|
+
puts "\nWarning: at this moment rgversion doesn't support copy to clipboard feature if your OS isn't macOS or Linux."
|
10
|
+
puts "You can manually copy output above."
|
11
|
+
elsif @command == :xclip
|
12
|
+
puts "\nWarning: unable to copy to clipboard because #{@command} is missed."
|
13
|
+
puts "Try the command below if you are on Ubuntu/Debian:"
|
14
|
+
puts "sudo apt-get install #{@command}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/rgversion/terminal.rb
CHANGED
@@ -12,12 +12,8 @@ module Rgversion
|
|
12
12
|
|
13
13
|
def copy_to_clipboard
|
14
14
|
return if @output.blank?
|
15
|
-
|
16
|
-
|
17
|
-
puts "\nCopied to your clipboard!".green
|
18
|
-
else
|
19
|
-
render_instructions
|
20
|
-
end
|
15
|
+
clipboard = Clipboard.new(@command)
|
16
|
+
clipboard.copy
|
21
17
|
end
|
22
18
|
|
23
19
|
private
|
@@ -33,37 +29,5 @@ module Rgversion
|
|
33
29
|
@output = @results[:gems].join("\n")
|
34
30
|
puts @output
|
35
31
|
end
|
36
|
-
|
37
|
-
def clarified_command
|
38
|
-
return "#{@command} -selection clipboard" if OS.linux?
|
39
|
-
@command
|
40
|
-
end
|
41
|
-
|
42
|
-
def command_exists?
|
43
|
-
return false if which(@command.to_s).nil?
|
44
|
-
true
|
45
|
-
end
|
46
|
-
|
47
|
-
# based on https://stackoverflow.com/a/5471032
|
48
|
-
# let's avoid find_executable from mkmf because in this case we need to supress logs
|
49
|
-
def which(cmd)
|
50
|
-
exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
|
51
|
-
ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
|
52
|
-
exts.each do |ext|
|
53
|
-
exe = File.join(path, "#{cmd}#{ext}")
|
54
|
-
return exe if File.executable?(exe) && !File.directory?(exe)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
nil
|
58
|
-
end
|
59
|
-
|
60
|
-
def render_instructions
|
61
|
-
if @command.nil?
|
62
|
-
puts "\nRgversion doesn't support copy to clipboard feature if your OS isn't macOS or Linux. You can manually copy output above."
|
63
|
-
else
|
64
|
-
puts "\nUnable to copy to clipboard because #{@command} is missed.\nTry the command below if you are on Ubuntu/Debian:"
|
65
|
-
puts "sudo apt-get install #{@command}"
|
66
|
-
end
|
67
|
-
end
|
68
32
|
end
|
69
33
|
end
|
data/lib/rgversion/version.rb
CHANGED
data/lib/rgversion.rb
CHANGED
@@ -1,12 +1,18 @@
|
|
1
1
|
require "active_support/core_ext/object/blank"
|
2
|
+
require "active_support/dependencies/autoload"
|
2
3
|
require "awesome_print"
|
3
4
|
require "os"
|
4
|
-
require "rgversion/application"
|
5
|
-
require "rgversion/exceptions"
|
6
|
-
require "rgversion/spider"
|
7
|
-
require "rgversion/terminal"
|
8
|
-
require "rgversion/version"
|
9
5
|
|
10
6
|
module Rgversion
|
11
|
-
|
7
|
+
extend ActiveSupport::Autoload
|
8
|
+
|
9
|
+
autoload :Application
|
10
|
+
autoload :Clipboard
|
11
|
+
autoload :Instruction
|
12
|
+
autoload :Settings
|
13
|
+
autoload :Spider
|
14
|
+
autoload :Terminal
|
12
15
|
end
|
16
|
+
|
17
|
+
require_relative "rgversion/exceptions"
|
18
|
+
require_relative "rgversion/version"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rgversion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.7.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- vavgustov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01
|
11
|
+
date: 2018-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -147,7 +147,10 @@ files:
|
|
147
147
|
- exe/rgversion
|
148
148
|
- lib/rgversion.rb
|
149
149
|
- lib/rgversion/application.rb
|
150
|
+
- lib/rgversion/clipboard.rb
|
150
151
|
- lib/rgversion/exceptions.rb
|
152
|
+
- lib/rgversion/instruction.rb
|
153
|
+
- lib/rgversion/settings.rb
|
151
154
|
- lib/rgversion/spider.rb
|
152
155
|
- lib/rgversion/terminal.rb
|
153
156
|
- lib/rgversion/version.rb
|
@@ -167,9 +170,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
167
170
|
version: 2.1.0
|
168
171
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
169
172
|
requirements:
|
170
|
-
- - "
|
173
|
+
- - ">"
|
171
174
|
- !ruby/object:Gem::Version
|
172
|
-
version:
|
175
|
+
version: 1.3.1
|
173
176
|
requirements: []
|
174
177
|
rubyforge_project:
|
175
178
|
rubygems_version: 2.7.3
|