network-utility 1.1.42 → 1.1.43

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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/document/document.rb +71 -1
  3. data/network.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d91f268f69c1aa7a91c1736cc4691583a28051d97ec9852d992498157f42c66b
4
- data.tar.gz: 3525f6054ddf2053b69c4147c10b34ed25f05c8883efbb36087528d95400b9a8
3
+ metadata.gz: efefda6c8d40e86b6cbf5721bce9069fc335e2593e7bc53245538738fac87643
4
+ data.tar.gz: f5e98f9ada324bdcb1df2bb108bb5bb2cd59408d7b5ab4cd31631c1eefc27a8b
5
5
  SHA512:
6
- metadata.gz: 33d4d3b7ddca7f8d7ffc8c111b21e437101e9e3cc8deecfe6515a8f272dca272836678f077801e517da3be76fc51211eafb7be6dbde69b50f06df0320de80583
7
- data.tar.gz: '09db809ee1f704e5c2fb6a26872864710e2e48d469296e442ba0afa443daf02c2f820e54c888649ec70a40f44248d7a0d5f2612dce34c067a8d4e2fd1bd899e8'
6
+ metadata.gz: 5b590eb785a6bbf02cf5b7b7011f2f80e23210ff855e52ad241f2ef4a955c23a3a8eaf38998f58042a34ecd153a95cc1488a9741efc665b0dddaa9c418fe86d4
7
+ data.tar.gz: 298bf7e8f4da077a4fbb3643cbb0dafd802173d435457c3f462058cc62c87956d5f074cc370d4d194ed25baa742850fccf17ae62e939bdb00cf190f39a87c45a
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.43'
26
26
  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.43
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt