gemx 0.1.0 → 0.2.0
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 +4 -4
- data/.rubocop.yml +6 -0
- data/.rubocop_todo.yml +1 -10
- data/VERSION +1 -0
- data/bin/gemx +4 -0
- data/gemx.gemspec +2 -5
- data/lib/gemx.rb +74 -7
- data/lib/gemx/version.rb +2 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cbc55303df14243474da3f5eefcfc219e5dffe15c7e6f1db67d20f839b9e1082
|
4
|
+
data.tar.gz: 3db245cc4fc12d4e9d5459c6a588d21caa946cb78a374a6ac6fee2328ed52d64
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c2839f4f755f927448056c687275fed3f80c15011ae7e9855d85c7fb0bb570b3e894b5be6428660b2ae798d0d90a387f1131dfedd05f3bb44762d01ffd7e4cb
|
7
|
+
data.tar.gz: ea6df1cbee98d7eef90d307823d82d8dbc14c44a8d37d1df85d8d6ce5db2bc8cdb3d609d88e263637c72f189f4705a112ba04afdd04c4e3794369c068045bd66
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -1,16 +1,7 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on
|
3
|
+
# on 2018-04-10 20:20:02 -0700 using RuboCop version 0.51.0.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
|
-
|
9
|
-
# Offense count: 2
|
10
|
-
Metrics/AbcSize:
|
11
|
-
Max: 38
|
12
|
-
|
13
|
-
# Offense count: 2
|
14
|
-
# Configuration parameters: CountComments.
|
15
|
-
Metrics/MethodLength:
|
16
|
-
Max: 25
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.2.0
|
data/bin/gemx
ADDED
data/gemx.gemspec
CHANGED
@@ -1,10 +1,7 @@
|
|
1
|
-
lib = File.expand_path('../lib', __FILE__)
|
2
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
-
require 'gemx/version'
|
4
|
-
|
5
1
|
Gem::Specification.new do |spec|
|
6
2
|
spec.name = 'gemx'
|
7
|
-
spec.version =
|
3
|
+
spec.version = File.read(File.expand_path('../VERSION', __FILE__))
|
4
|
+
.strip.freeze
|
8
5
|
spec.authors = ['Samuel Giddins']
|
9
6
|
spec.email = ['segiddins@segiddins.me']
|
10
7
|
|
data/lib/gemx.rb
CHANGED
@@ -5,7 +5,15 @@ require 'rubygems'
|
|
5
5
|
|
6
6
|
# Execute a command that comes from a gem
|
7
7
|
module GemX
|
8
|
-
X = Struct.new(
|
8
|
+
X = Struct.new(
|
9
|
+
:gem_name,
|
10
|
+
:requirements,
|
11
|
+
:executable,
|
12
|
+
:arguments,
|
13
|
+
:conservative,
|
14
|
+
:verbose
|
15
|
+
)
|
16
|
+
|
9
17
|
# The eXecutable part of this gem
|
10
18
|
class X
|
11
19
|
def install_if_needed
|
@@ -71,7 +79,7 @@ module GemX
|
|
71
79
|
opts.version = VERSION
|
72
80
|
opts.banner = 'Usage: gemx [options --] command'
|
73
81
|
|
74
|
-
opts.
|
82
|
+
opts.on_tail('-v', '--[no-]verbose', 'Run verbosely') do |v|
|
75
83
|
options.verbose = v
|
76
84
|
end
|
77
85
|
|
@@ -84,20 +92,53 @@ module GemX
|
|
84
92
|
'Run the gem with the given requirement') do |r|
|
85
93
|
options.requirements.concat [r]
|
86
94
|
end
|
95
|
+
|
96
|
+
opts.on('--pre',
|
97
|
+
'Allow resolving pre-release versions of the gem') do |_r|
|
98
|
+
options.requirements.concat ['>= 0.a']
|
99
|
+
end
|
100
|
+
|
101
|
+
opts.on('-c', '--[no-]conservative',
|
102
|
+
'Prefer the most recent installed version, ' \
|
103
|
+
'rather than the latest version overall') do |c|
|
104
|
+
options.conservative = c
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
opt_parse.order!(args) do |v|
|
109
|
+
# put the non-option back at the front of the list of arguments
|
110
|
+
args.unshift(v)
|
111
|
+
|
112
|
+
# stop parsing once we hit the first non-option,
|
113
|
+
# so you can call `gemx rails --version` and it prints the rails
|
114
|
+
# version rather than gemx's
|
115
|
+
break
|
87
116
|
end
|
88
|
-
|
117
|
+
|
89
118
|
abort(opt_parse.help) if args.empty?
|
119
|
+
|
90
120
|
options.executable = args.shift
|
91
121
|
options.gem_name ||= options.executable
|
92
122
|
options.arguments = args
|
123
|
+
options.requirements.requirements.tap(&:uniq).delete(['>=', Gem::Version.new('0')])
|
124
|
+
|
93
125
|
options
|
94
126
|
end
|
95
127
|
|
96
128
|
def self.run!(argv)
|
97
|
-
parse!(argv).
|
98
|
-
|
99
|
-
|
129
|
+
parse!(argv).run!
|
130
|
+
end
|
131
|
+
|
132
|
+
def run!
|
133
|
+
print_command if verbose
|
134
|
+
if conservative
|
135
|
+
install_if_needed
|
136
|
+
else
|
137
|
+
install
|
138
|
+
activate!
|
100
139
|
end
|
140
|
+
|
141
|
+
load!
|
101
142
|
end
|
102
143
|
|
103
144
|
private
|
@@ -115,10 +156,36 @@ module GemX
|
|
115
156
|
home = File.join(home, 'gemx')
|
116
157
|
Gem.use_paths(home, Gem.path + [home])
|
117
158
|
with_rubygems_config do
|
118
|
-
|
159
|
+
suppress_always_install do
|
160
|
+
Gem.install(gem_name, requirements)
|
161
|
+
end
|
119
162
|
end
|
120
163
|
rescue StandardError => e
|
121
164
|
abort "Installing #{dependency_to_s} failed:\n#{e.to_s.gsub(/^/, "\t")}"
|
122
165
|
end
|
166
|
+
|
167
|
+
def print_command
|
168
|
+
puts "running gemx with:\n"
|
169
|
+
opts = to_h.reject { |_, v| v.nil? }
|
170
|
+
max_length = opts.map { |k, _| k.size }.max
|
171
|
+
opts.each do |k, v|
|
172
|
+
next if v.nil?
|
173
|
+
puts "\t#{k.to_s.rjust(max_length)}: #{v} "
|
174
|
+
end
|
175
|
+
puts
|
176
|
+
end
|
177
|
+
|
178
|
+
def suppress_always_install
|
179
|
+
name = :always_install
|
180
|
+
cls = ::Gem::Resolver::InstallerSet
|
181
|
+
method = cls.instance_method(name)
|
182
|
+
cls.define_method(name) { [] }
|
183
|
+
|
184
|
+
begin
|
185
|
+
yield
|
186
|
+
ensure
|
187
|
+
cls.define_method(name, method)
|
188
|
+
end
|
189
|
+
end
|
123
190
|
end
|
124
191
|
end
|
data/lib/gemx/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gemx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Giddins
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-04-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -84,7 +84,9 @@ files:
|
|
84
84
|
- LICENSE.txt
|
85
85
|
- README.md
|
86
86
|
- Rakefile
|
87
|
+
- VERSION
|
87
88
|
- bin/console
|
89
|
+
- bin/gemx
|
88
90
|
- bin/rake
|
89
91
|
- bin/rspec
|
90
92
|
- bin/rubocop
|
@@ -113,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
113
115
|
version: 2.6.10
|
114
116
|
requirements: []
|
115
117
|
rubyforge_project:
|
116
|
-
rubygems_version: 2.7.
|
118
|
+
rubygems_version: 2.7.6
|
117
119
|
signing_key:
|
118
120
|
specification_version: 4
|
119
121
|
summary: Automagically execute commands that come in gem form
|