rgversion 1.1.6 → 1.1.7.beta1

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
  SHA256:
3
- metadata.gz: 3f76e582fd0d2c41465e1766f3e6e6b4b4e744d9977ed8bb71d61126e7ce8d6e
4
- data.tar.gz: 074b9a9c140d35b533b6fc3595bb46e95767aeedcbcabc914ef55964f9e372f9
3
+ metadata.gz: a425e7138abec6028f4141d2b83749336db732bfdafe0e59a517910058b77ff2
4
+ data.tar.gz: 5fe10e6b1c337b7116dff69d83252456487459b21113dcf6120f37ff177cc22f
5
5
  SHA512:
6
- metadata.gz: 9ed51a0aae922f7f1b2f905bb8e2651188613d2b13976e0e81529e3724ed3fcedba52972b0633cf3ff57e9c4d99d687a137df117aba5f340f726da6262bdff14
7
- data.tar.gz: 477a06660ffff8ae2589b35151be58367500e133e4a21b8eb423995bf7aa4171b1ec7123b1a5989a1400941aa70ac8fb0b4226eb4da4344c5415c3c24f2dfd62
6
+ metadata.gz: 11e6af8cad947bcf6bab957d3cf850a7d185f704cb5a46a80fce3e1096f7ad079f7aab99603e0514f815c937936b95c94b7dc8f3caaeb6014100d32b0d8fb64c
7
+ data.tar.gz: 9c8e874e26b7d7f59e923463b8ad882f9ef378180ffd92a89868f69f2feebc31d1140434a8dfac7fddaead74505b33b7d8c25ab8d79e7aa00d1245bb3ef67cd2
data/exe/rgversion CHANGED
@@ -2,5 +2,5 @@
2
2
 
3
3
  require "rgversion"
4
4
 
5
- app = Rgversion::Application.new(ARGV, Rgversion::SELECTOR)
5
+ app = Rgversion::Application.new(ARGV, Rgversion::Settings::SELECTOR)
6
6
  app.run
@@ -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
@@ -0,0 +1,5 @@
1
+ module Rgversion
2
+ module Settings
3
+ SELECTOR = "#gemfile_text".freeze
4
+ end
5
+ end
@@ -12,12 +12,8 @@ module Rgversion
12
12
 
13
13
  def copy_to_clipboard
14
14
  return if @output.blank?
15
- if command_exists?
16
- system("echo \"#{@output}\" | #{clarified_command}")
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
@@ -1,4 +1,4 @@
1
1
  module Rgversion
2
- VERSION = "1.1.6".freeze
3
- PREVIOUS_VERSION = "1.1.5".freeze
2
+ VERSION = "1.1.7.beta1".freeze
3
+ PREVIOUS_VERSION = "1.1.6".freeze
4
4
  end
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
- SELECTOR = "#gemfile_text".freeze
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.6
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-31 00:00:00.000000000 Z
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: '0'
175
+ version: 1.3.1
173
176
  requirements: []
174
177
  rubyforge_project:
175
178
  rubygems_version: 2.7.3