un 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/Gemfile +10 -0
- data/LICENSE.txt +22 -0
- data/README.md +48 -0
- data/Rakefile +12 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/un.rb +394 -0
- data/un.gemspec +24 -0
- metadata +55 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 570bbaaa3fd83fed605b117c23c1a1b6a8ca94579bdbfa716f1116186c80b8be
|
4
|
+
data.tar.gz: 5a4b7ebda1ce0472dcfe36cc0901849382d1c3e9e9a39023e6413e5022cadc6f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ef5c05b6d7b732d21b2892f6e962db79b028353da5631f5be8b5e4515a491a73b3f9c3aae7bd4fd73b1909eaf8ef5ad4640203a246dedf5be4904837dc61d314
|
7
|
+
data.tar.gz: c31d629139e8714c81fc000d286c387d93910a8f6ee69c360703ed9ed79ddd6889583527bd51cda392c6e08841970ff82f0697f3fbd64be4e2411641da53d501
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (C) 1993-2013 Yukihiro Matsumoto. All rights reserved.
|
2
|
+
|
3
|
+
Redistribution and use in source and binary forms, with or without
|
4
|
+
modification, are permitted provided that the following conditions
|
5
|
+
are met:
|
6
|
+
1. Redistributions of source code must retain the above copyright
|
7
|
+
notice, this list of conditions and the following disclaimer.
|
8
|
+
2. Redistributions in binary form must reproduce the above copyright
|
9
|
+
notice, this list of conditions and the following disclaimer in the
|
10
|
+
documentation and/or other materials provided with the distribution.
|
11
|
+
|
12
|
+
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
13
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
14
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
15
|
+
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
16
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
17
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
18
|
+
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
19
|
+
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
20
|
+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
21
|
+
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
22
|
+
SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# un.rb
|
2
|
+
|
3
|
+
Utilities to replace common UNIX commands in Makefiles etc.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'un'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle install
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install un
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
```
|
24
|
+
ruby -run -e cp -- [OPTION] SOURCE DEST
|
25
|
+
ruby -run -e ln -- [OPTION] TARGET LINK_NAME
|
26
|
+
ruby -run -e mv -- [OPTION] SOURCE DEST
|
27
|
+
ruby -run -e rm -- [OPTION] FILE
|
28
|
+
ruby -run -e mkdir -- [OPTION] DIRS
|
29
|
+
ruby -run -e rmdir -- [OPTION] DIRS
|
30
|
+
ruby -run -e install -- [OPTION] SOURCE DEST
|
31
|
+
ruby -run -e chmod -- [OPTION] OCTAL-MODE FILE
|
32
|
+
ruby -run -e touch -- [OPTION] FILE
|
33
|
+
ruby -run -e wait_writable -- [OPTION] FILE
|
34
|
+
ruby -run -e mkmf -- [OPTION] EXTNAME [OPTION]
|
35
|
+
ruby -run -e httpd -- [OPTION] [DocumentRoot]
|
36
|
+
ruby -run -e help [COMMAND]
|
37
|
+
```
|
38
|
+
|
39
|
+
## Development
|
40
|
+
|
41
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
42
|
+
|
43
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
44
|
+
|
45
|
+
## Contributing
|
46
|
+
|
47
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/ruby/un.
|
48
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "un"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/un.rb
ADDED
@@ -0,0 +1,394 @@
|
|
1
|
+
# frozen_string_literal: false
|
2
|
+
#
|
3
|
+
# = un.rb
|
4
|
+
#
|
5
|
+
# Copyright (c) 2003 WATANABE Hirofumi <eban@ruby-lang.org>
|
6
|
+
#
|
7
|
+
# This program is free software.
|
8
|
+
# You can distribute/modify this program under the same terms of Ruby.
|
9
|
+
#
|
10
|
+
# == Utilities to replace common UNIX commands in Makefiles etc
|
11
|
+
#
|
12
|
+
# == SYNOPSIS
|
13
|
+
#
|
14
|
+
# ruby -run -e cp -- [OPTION] SOURCE DEST
|
15
|
+
# ruby -run -e ln -- [OPTION] TARGET LINK_NAME
|
16
|
+
# ruby -run -e mv -- [OPTION] SOURCE DEST
|
17
|
+
# ruby -run -e rm -- [OPTION] FILE
|
18
|
+
# ruby -run -e mkdir -- [OPTION] DIRS
|
19
|
+
# ruby -run -e rmdir -- [OPTION] DIRS
|
20
|
+
# ruby -run -e install -- [OPTION] SOURCE DEST
|
21
|
+
# ruby -run -e chmod -- [OPTION] OCTAL-MODE FILE
|
22
|
+
# ruby -run -e touch -- [OPTION] FILE
|
23
|
+
# ruby -run -e wait_writable -- [OPTION] FILE
|
24
|
+
# ruby -run -e mkmf -- [OPTION] EXTNAME [OPTION]
|
25
|
+
# ruby -run -e httpd -- [OPTION] [DocumentRoot]
|
26
|
+
# ruby -run -e help [COMMAND]
|
27
|
+
|
28
|
+
require "fileutils"
|
29
|
+
require "optparse"
|
30
|
+
|
31
|
+
module FileUtils
|
32
|
+
# @fileutils_label = ""
|
33
|
+
@fileutils_output = $stdout
|
34
|
+
end
|
35
|
+
|
36
|
+
# :nodoc:
|
37
|
+
def setup(options = "", *long_options)
|
38
|
+
caller = caller_locations(1, 1)[0].label
|
39
|
+
opt_hash = {}
|
40
|
+
argv = []
|
41
|
+
OptionParser.new do |o|
|
42
|
+
options.scan(/.:?/) do |s|
|
43
|
+
opt_name = s.delete(":").intern
|
44
|
+
o.on("-" + s.tr(":", " ")) do |val|
|
45
|
+
opt_hash[opt_name] = val
|
46
|
+
end
|
47
|
+
end
|
48
|
+
long_options.each do |s|
|
49
|
+
opt_name, arg_name = s.split(/(?=[\s=])/, 2)
|
50
|
+
opt_name.delete_prefix!('--')
|
51
|
+
s = "--#{opt_name.gsub(/([A-Z]+|[a-z])([A-Z])/, '\1-\2').downcase}#{arg_name}"
|
52
|
+
puts "#{opt_name}=>#{s}" if $DEBUG
|
53
|
+
opt_name = opt_name.intern
|
54
|
+
o.on(s) do |val|
|
55
|
+
opt_hash[opt_name] = val
|
56
|
+
end
|
57
|
+
end
|
58
|
+
o.on("-v") do opt_hash[:verbose] = true end
|
59
|
+
o.on("--help") do
|
60
|
+
UN.help([caller])
|
61
|
+
exit
|
62
|
+
end
|
63
|
+
o.order!(ARGV) do |x|
|
64
|
+
if /[*?\[{]/ =~ x
|
65
|
+
argv.concat(Dir[x])
|
66
|
+
else
|
67
|
+
argv << x
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
yield argv, opt_hash
|
72
|
+
end
|
73
|
+
|
74
|
+
##
|
75
|
+
# Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY
|
76
|
+
#
|
77
|
+
# ruby -run -e cp -- [OPTION] SOURCE DEST
|
78
|
+
#
|
79
|
+
# -p preserve file attributes if possible
|
80
|
+
# -r copy recursively
|
81
|
+
# -v verbose
|
82
|
+
#
|
83
|
+
|
84
|
+
def cp
|
85
|
+
setup("pr") do |argv, options|
|
86
|
+
cmd = "cp"
|
87
|
+
cmd += "_r" if options.delete :r
|
88
|
+
options[:preserve] = true if options.delete :p
|
89
|
+
dest = argv.pop
|
90
|
+
argv = argv[0] if argv.size == 1
|
91
|
+
FileUtils.__send__ cmd, argv, dest, **options
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
##
|
96
|
+
# Create a link to the specified TARGET with LINK_NAME.
|
97
|
+
#
|
98
|
+
# ruby -run -e ln -- [OPTION] TARGET LINK_NAME
|
99
|
+
#
|
100
|
+
# -s make symbolic links instead of hard links
|
101
|
+
# -f remove existing destination files
|
102
|
+
# -v verbose
|
103
|
+
#
|
104
|
+
|
105
|
+
def ln
|
106
|
+
setup("sf") do |argv, options|
|
107
|
+
cmd = "ln"
|
108
|
+
cmd += "_s" if options.delete :s
|
109
|
+
options[:force] = true if options.delete :f
|
110
|
+
dest = argv.pop
|
111
|
+
argv = argv[0] if argv.size == 1
|
112
|
+
FileUtils.__send__ cmd, argv, dest, **options
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
##
|
117
|
+
# Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.
|
118
|
+
#
|
119
|
+
# ruby -run -e mv -- [OPTION] SOURCE DEST
|
120
|
+
#
|
121
|
+
# -v verbose
|
122
|
+
#
|
123
|
+
|
124
|
+
def mv
|
125
|
+
setup do |argv, options|
|
126
|
+
dest = argv.pop
|
127
|
+
argv = argv[0] if argv.size == 1
|
128
|
+
FileUtils.mv argv, dest, **options
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
##
|
133
|
+
# Remove the FILE
|
134
|
+
#
|
135
|
+
# ruby -run -e rm -- [OPTION] FILE
|
136
|
+
#
|
137
|
+
# -f ignore nonexistent files
|
138
|
+
# -r remove the contents of directories recursively
|
139
|
+
# -v verbose
|
140
|
+
#
|
141
|
+
|
142
|
+
def rm
|
143
|
+
setup("fr") do |argv, options|
|
144
|
+
cmd = "rm"
|
145
|
+
cmd += "_r" if options.delete :r
|
146
|
+
options[:force] = true if options.delete :f
|
147
|
+
FileUtils.__send__ cmd, argv, **options
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
##
|
152
|
+
# Create the DIR, if they do not already exist.
|
153
|
+
#
|
154
|
+
# ruby -run -e mkdir -- [OPTION] DIR
|
155
|
+
#
|
156
|
+
# -p no error if existing, make parent directories as needed
|
157
|
+
# -v verbose
|
158
|
+
#
|
159
|
+
|
160
|
+
def mkdir
|
161
|
+
setup("p") do |argv, options|
|
162
|
+
cmd = "mkdir"
|
163
|
+
cmd += "_p" if options.delete :p
|
164
|
+
FileUtils.__send__ cmd, argv, **options
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
##
|
169
|
+
# Remove the DIR.
|
170
|
+
#
|
171
|
+
# ruby -run -e rmdir -- [OPTION] DIR
|
172
|
+
#
|
173
|
+
# -p remove DIRECTORY and its ancestors.
|
174
|
+
# -v verbose
|
175
|
+
#
|
176
|
+
|
177
|
+
def rmdir
|
178
|
+
setup("p") do |argv, options|
|
179
|
+
options[:parents] = true if options.delete :p
|
180
|
+
FileUtils.rmdir argv, **options
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
##
|
185
|
+
# Copy SOURCE to DEST.
|
186
|
+
#
|
187
|
+
# ruby -run -e install -- [OPTION] SOURCE DEST
|
188
|
+
#
|
189
|
+
# -p apply access/modification times of SOURCE files to
|
190
|
+
# corresponding destination files
|
191
|
+
# -m set permission mode (as in chmod), instead of 0755
|
192
|
+
# -o set owner user id, instead of the current owner
|
193
|
+
# -g set owner group id, instead of the current group
|
194
|
+
# -v verbose
|
195
|
+
#
|
196
|
+
|
197
|
+
def install
|
198
|
+
setup("pm:o:g:") do |argv, options|
|
199
|
+
(mode = options.delete :m) and options[:mode] = /\A\d/ =~ mode ? mode.oct : mode
|
200
|
+
options[:preserve] = true if options.delete :p
|
201
|
+
(owner = options.delete :o) and options[:owner] = owner
|
202
|
+
(group = options.delete :g) and options[:group] = group
|
203
|
+
dest = argv.pop
|
204
|
+
argv = argv[0] if argv.size == 1
|
205
|
+
FileUtils.install argv, dest, **options
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
##
|
210
|
+
# Change the mode of each FILE to OCTAL-MODE.
|
211
|
+
#
|
212
|
+
# ruby -run -e chmod -- [OPTION] OCTAL-MODE FILE
|
213
|
+
#
|
214
|
+
# -v verbose
|
215
|
+
#
|
216
|
+
|
217
|
+
def chmod
|
218
|
+
setup do |argv, options|
|
219
|
+
mode = argv.shift
|
220
|
+
mode = /\A\d/ =~ mode ? mode.oct : mode
|
221
|
+
FileUtils.chmod mode, argv, **options
|
222
|
+
end
|
223
|
+
end
|
224
|
+
|
225
|
+
##
|
226
|
+
# Update the access and modification times of each FILE to the current time.
|
227
|
+
#
|
228
|
+
# ruby -run -e touch -- [OPTION] FILE
|
229
|
+
#
|
230
|
+
# -v verbose
|
231
|
+
#
|
232
|
+
|
233
|
+
def touch
|
234
|
+
setup do |argv, options|
|
235
|
+
FileUtils.touch argv, **options
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
##
|
240
|
+
# Wait until the file becomes writable.
|
241
|
+
#
|
242
|
+
# ruby -run -e wait_writable -- [OPTION] FILE
|
243
|
+
#
|
244
|
+
# -n RETRY count to retry
|
245
|
+
# -w SEC each wait time in seconds
|
246
|
+
# -v verbose
|
247
|
+
#
|
248
|
+
|
249
|
+
def wait_writable
|
250
|
+
setup("n:w:v") do |argv, options|
|
251
|
+
verbose = options[:verbose]
|
252
|
+
n = options[:n] and n = Integer(n)
|
253
|
+
wait = (wait = options[:w]) ? Float(wait) : 0.2
|
254
|
+
argv.each do |file|
|
255
|
+
begin
|
256
|
+
open(file, "r+b")
|
257
|
+
rescue Errno::ENOENT
|
258
|
+
break
|
259
|
+
rescue Errno::EACCES => e
|
260
|
+
raise if n and (n -= 1) <= 0
|
261
|
+
if verbose
|
262
|
+
puts e
|
263
|
+
STDOUT.flush
|
264
|
+
end
|
265
|
+
sleep wait
|
266
|
+
retry
|
267
|
+
end
|
268
|
+
end
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
##
|
273
|
+
# Create makefile using mkmf.
|
274
|
+
#
|
275
|
+
# ruby -run -e mkmf -- [OPTION] EXTNAME [OPTION]
|
276
|
+
#
|
277
|
+
# -d ARGS run dir_config
|
278
|
+
# -h ARGS run have_header
|
279
|
+
# -l ARGS run have_library
|
280
|
+
# -f ARGS run have_func
|
281
|
+
# -v ARGS run have_var
|
282
|
+
# -t ARGS run have_type
|
283
|
+
# -m ARGS run have_macro
|
284
|
+
# -c ARGS run have_const
|
285
|
+
# --vendor install to vendor_ruby
|
286
|
+
#
|
287
|
+
|
288
|
+
def mkmf
|
289
|
+
setup("d:h:l:f:v:t:m:c:", "vendor") do |argv, options|
|
290
|
+
require 'mkmf'
|
291
|
+
opt = options[:d] and opt.split(/:/).each {|n| dir_config(*n.split(/,/))}
|
292
|
+
opt = options[:h] and opt.split(/:/).each {|n| have_header(*n.split(/,/))}
|
293
|
+
opt = options[:l] and opt.split(/:/).each {|n| have_library(*n.split(/,/))}
|
294
|
+
opt = options[:f] and opt.split(/:/).each {|n| have_func(*n.split(/,/))}
|
295
|
+
opt = options[:v] and opt.split(/:/).each {|n| have_var(*n.split(/,/))}
|
296
|
+
opt = options[:t] and opt.split(/:/).each {|n| have_type(*n.split(/,/))}
|
297
|
+
opt = options[:m] and opt.split(/:/).each {|n| have_macro(*n.split(/,/))}
|
298
|
+
opt = options[:c] and opt.split(/:/).each {|n| have_const(*n.split(/,/))}
|
299
|
+
$configure_args["--vendor"] = true if options[:vendor]
|
300
|
+
create_makefile(*argv)
|
301
|
+
end
|
302
|
+
end
|
303
|
+
|
304
|
+
##
|
305
|
+
# Run WEBrick HTTP server.
|
306
|
+
#
|
307
|
+
# ruby -run -e httpd -- [OPTION] [DocumentRoot]
|
308
|
+
#
|
309
|
+
# --bind-address=ADDR address to bind
|
310
|
+
# --port=NUM listening port number
|
311
|
+
# --max-clients=MAX max number of simultaneous clients
|
312
|
+
# --temp-dir=DIR temporary directory
|
313
|
+
# --do-not-reverse-lookup disable reverse lookup
|
314
|
+
# --request-timeout=SECOND request timeout in seconds
|
315
|
+
# --http-version=VERSION HTTP version
|
316
|
+
# --server-name=NAME name of the server host
|
317
|
+
# --server-software=NAME name and version of the server
|
318
|
+
# --ssl-certificate=CERT The SSL certificate file for the server
|
319
|
+
# --ssl-private-key=KEY The SSL private key file for the server certificate
|
320
|
+
# -v verbose
|
321
|
+
#
|
322
|
+
|
323
|
+
def httpd
|
324
|
+
setup("", "BindAddress=ADDR", "Port=PORT", "MaxClients=NUM", "TempDir=DIR",
|
325
|
+
"DoNotReverseLookup", "RequestTimeout=SECOND", "HTTPVersion=VERSION",
|
326
|
+
"ServerName=NAME", "ServerSoftware=NAME",
|
327
|
+
"SSLCertificate=CERT", "SSLPrivateKey=KEY") do
|
328
|
+
|argv, options|
|
329
|
+
require 'webrick'
|
330
|
+
opt = options[:RequestTimeout] and options[:RequestTimeout] = opt.to_i
|
331
|
+
[:Port, :MaxClients].each do |name|
|
332
|
+
opt = options[name] and (options[name] = Integer(opt)) rescue nil
|
333
|
+
end
|
334
|
+
if cert = options[:SSLCertificate]
|
335
|
+
key = options[:SSLPrivateKey] or
|
336
|
+
raise "--ssl-private-key option must also be given"
|
337
|
+
require 'webrick/https'
|
338
|
+
options[:SSLEnable] = true
|
339
|
+
options[:SSLCertificate] = OpenSSL::X509::Certificate.new(File.read(cert))
|
340
|
+
options[:SSLPrivateKey] = OpenSSL::PKey.read(File.read(key))
|
341
|
+
options[:Port] ||= 8443 # HTTPS Alternate
|
342
|
+
end
|
343
|
+
options[:Port] ||= 8080 # HTTP Alternate
|
344
|
+
options[:DocumentRoot] = argv.shift || '.'
|
345
|
+
s = WEBrick::HTTPServer.new(options)
|
346
|
+
shut = proc {s.shutdown}
|
347
|
+
siglist = %w"TERM QUIT"
|
348
|
+
siglist.concat(%w"HUP INT") if STDIN.tty?
|
349
|
+
siglist &= Signal.list.keys
|
350
|
+
siglist.each do |sig|
|
351
|
+
Signal.trap(sig, shut)
|
352
|
+
end
|
353
|
+
s.start
|
354
|
+
end
|
355
|
+
end
|
356
|
+
|
357
|
+
##
|
358
|
+
# Display help message.
|
359
|
+
#
|
360
|
+
# ruby -run -e help [COMMAND]
|
361
|
+
#
|
362
|
+
|
363
|
+
def help
|
364
|
+
setup do |argv,|
|
365
|
+
UN.help(argv)
|
366
|
+
end
|
367
|
+
end
|
368
|
+
|
369
|
+
module UN # :nodoc:
|
370
|
+
module_function
|
371
|
+
def help(argv, output: $stdout)
|
372
|
+
all = argv.empty?
|
373
|
+
cmd = nil
|
374
|
+
if all
|
375
|
+
store = proc {|msg| output << msg}
|
376
|
+
else
|
377
|
+
messages = {}
|
378
|
+
store = proc {|msg| messages[cmd] = msg}
|
379
|
+
end
|
380
|
+
open(__FILE__) do |me|
|
381
|
+
while me.gets("##\n")
|
382
|
+
if help = me.gets("\n\n")
|
383
|
+
if all or argv.include?(cmd = help[/^#\s*ruby\s.*-e\s+(\w+)/, 1])
|
384
|
+
store[help.gsub(/^# ?/, "")]
|
385
|
+
break unless all or argv.size > messages.size
|
386
|
+
end
|
387
|
+
end
|
388
|
+
end
|
389
|
+
end
|
390
|
+
if messages
|
391
|
+
argv.each {|arg| output << messages[arg]}
|
392
|
+
end
|
393
|
+
end
|
394
|
+
end
|
data/un.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "un"
|
5
|
+
spec.version = "0.1.0"
|
6
|
+
spec.authors = ["WATANABE Hirofumi"]
|
7
|
+
spec.email = ["eban@ruby-lang.org"]
|
8
|
+
|
9
|
+
spec.summary = "Utilities to replace common UNIX commands"
|
10
|
+
spec.description = spec.summary
|
11
|
+
spec.homepage = "https://github.com/ruby/un"
|
12
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
13
|
+
spec.licenses = ["Ruby", "BSD-2-Clause"]
|
14
|
+
|
15
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
16
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
17
|
+
|
18
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
19
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
20
|
+
end
|
21
|
+
spec.bindir = "exe"
|
22
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
23
|
+
spec.require_paths = ["lib"]
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: un
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- WATANABE Hirofumi
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-12-03 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Utilities to replace common UNIX commands
|
14
|
+
email:
|
15
|
+
- eban@ruby-lang.org
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- ".gitignore"
|
21
|
+
- Gemfile
|
22
|
+
- LICENSE.txt
|
23
|
+
- README.md
|
24
|
+
- Rakefile
|
25
|
+
- bin/console
|
26
|
+
- bin/setup
|
27
|
+
- lib/un.rb
|
28
|
+
- un.gemspec
|
29
|
+
homepage: https://github.com/ruby/un
|
30
|
+
licenses:
|
31
|
+
- Ruby
|
32
|
+
- BSD-2-Clause
|
33
|
+
metadata:
|
34
|
+
homepage_uri: https://github.com/ruby/un
|
35
|
+
source_code_uri: https://github.com/ruby/un
|
36
|
+
post_install_message:
|
37
|
+
rdoc_options: []
|
38
|
+
require_paths:
|
39
|
+
- lib
|
40
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: 2.3.0
|
45
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
requirements: []
|
51
|
+
rubygems_version: 3.2.0.rc.2
|
52
|
+
signing_key:
|
53
|
+
specification_version: 4
|
54
|
+
summary: Utilities to replace common UNIX commands
|
55
|
+
test_files: []
|