un 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/README.md +1 -0
- data/lib/un.rb +44 -1
- 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: d078bdacd95fd4ec259a706d8bfb3ce83778ca8b1982f58f803c31f86143035a
|
4
|
+
data.tar.gz: 9e6bcbe036e2868c42fd7887ee8877115139f107d1d4ecf8103360176cb34cc6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc9b3b8c54478d2e04cd18042458c4d3382b6ed263ada916239591814d73f12c341ca72fb978310693b83b9dc084211fc7a772bb5636be1f938b95de2417138b
|
7
|
+
data.tar.gz: c8f31f13962e5f0abc6804183fe331067553c8980866dac9e4a9dd651c3c8f43cf2584761b25f4092a901a380b534131b57675f6d4341ba1f055968de6d0e060
|
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"
|
@@ -326,7 +327,11 @@ def httpd
|
|
326
327
|
"ServerName=NAME", "ServerSoftware=NAME",
|
327
328
|
"SSLCertificate=CERT", "SSLPrivateKey=KEY") do
|
328
329
|
|argv, options|
|
329
|
-
|
330
|
+
begin
|
331
|
+
require 'webrick'
|
332
|
+
rescue LoadError
|
333
|
+
abort "webrick is not found. You may need to `gem install webrick` to install webrick."
|
334
|
+
end
|
330
335
|
opt = options[:RequestTimeout] and options[:RequestTimeout] = opt.to_i
|
331
336
|
[:Port, :MaxClients].each do |name|
|
332
337
|
opt = options[name] and (options[name] = Integer(opt)) rescue nil
|
@@ -342,6 +347,21 @@ def httpd
|
|
342
347
|
end
|
343
348
|
options[:Port] ||= 8080 # HTTP Alternate
|
344
349
|
options[:DocumentRoot] = argv.shift || '.'
|
350
|
+
s = nil
|
351
|
+
options[:StartCallback] = proc {
|
352
|
+
logger = s.logger
|
353
|
+
logger.info("To access this server, open this URL in a browser:")
|
354
|
+
s.listeners.each do |listener|
|
355
|
+
if options[:SSLEnable]
|
356
|
+
addr = listener.addr
|
357
|
+
addr[3] = "127.0.0.1" if addr[3] == "0.0.0.0"
|
358
|
+
addr[3] = "::1" if addr[3] == "::"
|
359
|
+
logger.info(" https://#{Addrinfo.new(addr).inspect_sockaddr}")
|
360
|
+
else
|
361
|
+
logger.info(" http://#{listener.connect_address.inspect_sockaddr}")
|
362
|
+
end
|
363
|
+
end
|
364
|
+
}
|
345
365
|
s = WEBrick::HTTPServer.new(options)
|
346
366
|
shut = proc {s.shutdown}
|
347
367
|
siglist = %w"TERM QUIT"
|
@@ -354,6 +374,29 @@ def httpd
|
|
354
374
|
end
|
355
375
|
end
|
356
376
|
|
377
|
+
##
|
378
|
+
# Colorize ruby code.
|
379
|
+
#
|
380
|
+
# ruby -run -e colorize -- [FILE]
|
381
|
+
#
|
382
|
+
|
383
|
+
def colorize
|
384
|
+
begin
|
385
|
+
require "irb/color"
|
386
|
+
rescue LoadError
|
387
|
+
raise "colorize requires irb 1.1.0 or later"
|
388
|
+
end
|
389
|
+
setup do |argv, |
|
390
|
+
if argv.empty?
|
391
|
+
puts IRB::Color.colorize_code STDIN.read
|
392
|
+
return
|
393
|
+
end
|
394
|
+
argv.each do |file|
|
395
|
+
puts IRB::Color.colorize_code File.read(file)
|
396
|
+
end
|
397
|
+
end
|
398
|
+
end
|
399
|
+
|
357
400
|
##
|
358
401
|
# Display help message.
|
359
402
|
#
|
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.
|
5
|
+
spec.version = "0.2.0"
|
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.
|
4
|
+
version: 0.2.0
|
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: 2021-09-24 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.2.
|
51
|
+
rubygems_version: 3.2.22
|
52
52
|
signing_key:
|
53
53
|
specification_version: 4
|
54
54
|
summary: Utilities to replace common UNIX commands
|