network-utility 1.1.42 → 1.1.44

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: d91f268f69c1aa7a91c1736cc4691583a28051d97ec9852d992498157f42c66b
4
- data.tar.gz: 3525f6054ddf2053b69c4147c10b34ed25f05c8883efbb36087528d95400b9a8
3
+ metadata.gz: c4ccc5a9ed9d02063837b9114fb98342726aaff01b5f8a3b76c1012eaade0991
4
+ data.tar.gz: b9e331486a5e504937dcf3253969ee62b12d6cab6f1693d964213b81cfa254de
5
5
  SHA512:
6
- metadata.gz: 33d4d3b7ddca7f8d7ffc8c111b21e437101e9e3cc8deecfe6515a8f272dca272836678f077801e517da3be76fc51211eafb7be6dbde69b50f06df0320de80583
7
- data.tar.gz: '09db809ee1f704e5c2fb6a26872864710e2e48d469296e442ba0afa443daf02c2f820e54c888649ec70a40f44248d7a0d5f2612dce34c067a8d4e2fd1bd899e8'
6
+ metadata.gz: 32b3c3678b9a31c2abb2361f5d0beb9f5060f80fbf70c785e75ff1e86812c187c4a45f886f244c30327c0a175d8eeecb2b7f3d76ac8a8b3dc76b6945a7574285
7
+ data.tar.gz: b449e0463c5c037cd1811a1e08f61c8302d1612870d8f53d9c14265923f6b738842a7992068c53be1c7eb28a021a06d6d924c0b8da28f7dc0e327786619b01b4
data/document/document.rb CHANGED
@@ -24,4 +24,74 @@ class Array
24
24
  proc.call code
25
25
  end
26
26
  end
27
- end
27
+ end
28
+
29
+ module Doc
30
+ module_function
31
+ def build paths, option={}
32
+ # custom: :active, runtime: :runtime|:static, select: @sign
33
+ params = {custom: nil, runtime: :runtime, dir: nil}.merge(option)
34
+ custom = params[:custom] # if custom then {custom: :active} else do nothing
35
+ runtime = params[:runtime] # if runtime then {runtime: :runtime} else {runtime: :static}
36
+ build = ""
37
+ @sign = []
38
+ paths.each do|path|
39
+ codes = path.refine(custom)
40
+ codes.run{|code|eval(code)} if runtime==:runtime
41
+ codes.map{|code|build<<code+"\n\n"} if runtime==:static
42
+ if params[:dir] && runtime==:static
43
+ Dir.mkdir('document') unless File.exist?('document')
44
+ File.write path.gsub('.md','.rb'), codes.join("\n\n")
45
+ end
46
+ end
47
+ warning = $VERBOSE
48
+ $VERBOSE = nil
49
+ @sign.map{|ms|(eval "::#{ms[0].gsub('-','_')} = #{ms[0].gsub('-','_')}")}
50
+ $VERBOSE = warning
51
+ File.write "build.rb", build if !params[:dir] && runtime==:static
52
+ return @sign
53
+ end
54
+
55
+ def load paths
56
+ File.write "_@sign_.rb","@sign = []"
57
+ require './_@sign_'
58
+ File.delete "./_@sign_.rb"
59
+ Kernel.instance_variable_set(:@sign,[])
60
+ if paths.is_a?(Array)
61
+ paths.each{|path|require "./"+path.gsub('.md','.rb')}
62
+ else
63
+ require "./"+paths.gsub('.md','.rb')
64
+ end
65
+ return @sign
66
+ end
67
+
68
+ def reload option={
69
+ # runtime: :static, if use runtime: :runtime, wont make doc files
70
+ # config: 'document.txt', each line is a path of reference module file
71
+ # document: [], path set of original module files
72
+ # expansion: [], path set of extension module files
73
+ }
74
+ parameters = {runtime: :static, config: 'document.txt'}.merge(option)
75
+ if File.exist?(parameters[:config])
76
+ paths = File.read(parameters[:config]).split("\n")
77
+ Doc.build paths, runtime: :static, dir: :yes
78
+ Doc.load paths
79
+ end
80
+ if File.exist?(parameters[:document])
81
+ paths = parameters[:document]
82
+ Doc.build paths, runtime: :static, dir: :yes
83
+ Doc.load paths
84
+ end
85
+ if parameters[:expansion]
86
+ paths = parameters[:expansion]
87
+ Doc.build paths, custom: :active, runtime: :static, dir: :yes
88
+ Doc.load paths
89
+ end
90
+ end
91
+
92
+ def path
93
+ Dir["#{$_DOC_PATH_}/document/*.md"].map{|d|d.split('/')[-2..-1].join("/")}
94
+ end
95
+ end
96
+
97
+ $_DOC_PATH_ = Pathname.new(__FILE__).realpath.join('..', '..')
data/network.rb CHANGED
@@ -22,5 +22,5 @@
22
22
  ].each{|mod|require mod}
23
23
 
24
24
  module Network
25
- VERSION = '1.1.42'
25
+ VERSION = '1.1.44'
26
26
  end
@@ -281,7 +281,9 @@ class IPv4Mask
281
281
  end
282
282
 
283
283
  module IP
284
- def self.v4 string
284
+ module_function
285
+
286
+ def v4 string
285
287
  ip,msk = string.split("/")
286
288
  unless msk
287
289
  return IPv4.new(ip)
@@ -290,4 +292,19 @@ module IP
290
292
  return IPv4.new(ip),mask
291
293
  end
292
294
  end
295
+
296
+ def range addr
297
+ if addr.include?('.')
298
+ gateway, netmask = IP.v4(addr)
299
+ elsif addr.include?(':')
300
+ gateway, netmask = IP.v6(addr)
301
+ end
302
+ if netmask
303
+ network = gateway.network_with(netmask)
304
+ start, finish = network.range_with(netmask)
305
+ return [start, finish]
306
+ else
307
+ return [gateway, gateway]
308
+ end
309
+ end
293
310
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: network-utility
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.42
4
+ version: 1.1.44
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt