un 0.1.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/lib/un.rb +49 -4
- data/un.gemspec +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8c8d915490e45125d7b38a47b0aeb67b28b9ab530c7fba21839a05f8343e34d
|
4
|
+
data.tar.gz: 7017890ba253218048086124b79a493885bcc6bc6441023faf1a58ec82e32075
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f579ec63b6cbc2c69a29df7b4d90c897b44384a807f13714895f7505696dbe742aee8825602010e3a0aefe1a4a53cad5b2480c4e31d43c2081ea6425d1262e3f
|
7
|
+
data.tar.gz: efd61b8e25c638735bd9349eec4098ab0d5aed956b1ec6ca5fa9847a63ac9fc6625f97bc661d1d44b2ab546362c759514caa3dde6ea227cb461ccb284b7d512e
|
data/README.md
CHANGED
data/lib/un.rb
CHANGED
@@ -23,6 +23,7 @@
|
|
23
23
|
# ruby -run -e wait_writable -- [OPTION] FILE
|
24
24
|
# ruby -run -e mkmf -- [OPTION] EXTNAME [OPTION]
|
25
25
|
# ruby -run -e httpd -- [OPTION] [DocumentRoot]
|
26
|
+
# ruby -run -e colorize -- [FILE]
|
26
27
|
# ruby -run -e help [COMMAND]
|
27
28
|
|
28
29
|
require "fileutils"
|
@@ -78,13 +79,15 @@ end
|
|
78
79
|
#
|
79
80
|
# -p preserve file attributes if possible
|
80
81
|
# -r copy recursively
|
82
|
+
# -l make hard link instead of copying (implies -r)
|
81
83
|
# -v verbose
|
82
84
|
#
|
83
85
|
|
84
86
|
def cp
|
85
|
-
setup("
|
87
|
+
setup("prl") do |argv, options|
|
86
88
|
cmd = "cp"
|
87
89
|
cmd += "_r" if options.delete :r
|
90
|
+
cmd = "cp_lr" if options.delete :l
|
88
91
|
options[:preserve] = true if options.delete :p
|
89
92
|
dest = argv.pop
|
90
93
|
argv = argv[0] if argv.size == 1
|
@@ -253,7 +256,7 @@ def wait_writable
|
|
253
256
|
wait = (wait = options[:w]) ? Float(wait) : 0.2
|
254
257
|
argv.each do |file|
|
255
258
|
begin
|
256
|
-
open(file, "r+b")
|
259
|
+
File.open(file, "r+b") {}
|
257
260
|
rescue Errno::ENOENT
|
258
261
|
break
|
259
262
|
rescue Errno::EACCES => e
|
@@ -326,7 +329,11 @@ def httpd
|
|
326
329
|
"ServerName=NAME", "ServerSoftware=NAME",
|
327
330
|
"SSLCertificate=CERT", "SSLPrivateKey=KEY") do
|
328
331
|
|argv, options|
|
329
|
-
|
332
|
+
begin
|
333
|
+
require 'webrick'
|
334
|
+
rescue LoadError
|
335
|
+
abort "webrick is not found. You may need to `gem install webrick` to install webrick."
|
336
|
+
end
|
330
337
|
opt = options[:RequestTimeout] and options[:RequestTimeout] = opt.to_i
|
331
338
|
[:Port, :MaxClients].each do |name|
|
332
339
|
opt = options[name] and (options[name] = Integer(opt)) rescue nil
|
@@ -342,6 +349,21 @@ def httpd
|
|
342
349
|
end
|
343
350
|
options[:Port] ||= 8080 # HTTP Alternate
|
344
351
|
options[:DocumentRoot] = argv.shift || '.'
|
352
|
+
s = nil
|
353
|
+
options[:StartCallback] = proc {
|
354
|
+
logger = s.logger
|
355
|
+
logger.info("To access this server, open this URL in a browser:")
|
356
|
+
s.listeners.each do |listener|
|
357
|
+
if options[:SSLEnable]
|
358
|
+
addr = listener.addr
|
359
|
+
addr[3] = "127.0.0.1" if addr[3] == "0.0.0.0"
|
360
|
+
addr[3] = "::1" if addr[3] == "::"
|
361
|
+
logger.info(" https://#{Addrinfo.new(addr).inspect_sockaddr}")
|
362
|
+
else
|
363
|
+
logger.info(" http://#{listener.connect_address.inspect_sockaddr}")
|
364
|
+
end
|
365
|
+
end
|
366
|
+
}
|
345
367
|
s = WEBrick::HTTPServer.new(options)
|
346
368
|
shut = proc {s.shutdown}
|
347
369
|
siglist = %w"TERM QUIT"
|
@@ -354,6 +376,29 @@ def httpd
|
|
354
376
|
end
|
355
377
|
end
|
356
378
|
|
379
|
+
##
|
380
|
+
# Colorize ruby code.
|
381
|
+
#
|
382
|
+
# ruby -run -e colorize -- [FILE]
|
383
|
+
#
|
384
|
+
|
385
|
+
def colorize
|
386
|
+
begin
|
387
|
+
require "irb/color"
|
388
|
+
rescue LoadError
|
389
|
+
raise "colorize requires irb 1.1.0 or later"
|
390
|
+
end
|
391
|
+
setup do |argv, |
|
392
|
+
if argv.empty?
|
393
|
+
puts IRB::Color.colorize_code STDIN.read
|
394
|
+
return
|
395
|
+
end
|
396
|
+
argv.each do |file|
|
397
|
+
puts IRB::Color.colorize_code File.read(file)
|
398
|
+
end
|
399
|
+
end
|
400
|
+
end
|
401
|
+
|
357
402
|
##
|
358
403
|
# Display help message.
|
359
404
|
#
|
@@ -377,7 +422,7 @@ module UN # :nodoc:
|
|
377
422
|
messages = {}
|
378
423
|
store = proc {|msg| messages[cmd] = msg}
|
379
424
|
end
|
380
|
-
open(__FILE__) do |me|
|
425
|
+
File.open(__FILE__) do |me|
|
381
426
|
while me.gets("##\n")
|
382
427
|
if help = me.gets("\n\n")
|
383
428
|
if all or argv.include?(cmd = help[/^#\s*ruby\s.*-e\s+(\w+)/, 1])
|
data/un.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "un"
|
5
|
-
spec.version = "0.1
|
5
|
+
spec.version = "0.2.1"
|
6
6
|
spec.authors = ["WATANABE Hirofumi"]
|
7
7
|
spec.email = ["eban@ruby-lang.org"]
|
8
8
|
|
@@ -19,6 +19,6 @@ Gem::Specification.new do |spec|
|
|
19
19
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
20
20
|
end
|
21
21
|
spec.bindir = "exe"
|
22
|
-
spec.executables =
|
22
|
+
spec.executables = []
|
23
23
|
spec.require_paths = ["lib"]
|
24
24
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: un
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- WATANABE Hirofumi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Utilities to replace common UNIX commands
|
14
14
|
email:
|
@@ -48,7 +48,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
48
48
|
- !ruby/object:Gem::Version
|
49
49
|
version: '0'
|
50
50
|
requirements: []
|
51
|
-
rubygems_version: 3.
|
51
|
+
rubygems_version: 3.4.0.dev
|
52
52
|
signing_key:
|
53
53
|
specification_version: 4
|
54
54
|
summary: Utilities to replace common UNIX commands
|