documentize 1.1.2 → 1.1.3

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
  SHA1:
3
- metadata.gz: 36c3ea291baa8735c7b8bc3eb5888fb8907c016f
4
- data.tar.gz: 5b7c99220c8fd2d45dfa44066a72508fb78b117d
3
+ metadata.gz: e6cfd72a6925ca9b57ef544c89a68abeb7e46f38
4
+ data.tar.gz: 863a91330cc7a3a16976c0add757bbfc791735c1
5
5
  SHA512:
6
- metadata.gz: 7b4e5c4c8632b0ada05c9d49a1c620598ed84f30046d2aa0803e9ca58727750792257113613b511041720aae7cc9e2790e99234b16bc5fda98452fa7a702811d
7
- data.tar.gz: 024add8f810c2977ecadf7e4a178f01f4f71510d65b3d11be874c8b9ef8d43041bfbb87ff34a2dc7d37e5cab42825673e66905c279d97571858d4e9a599eb852
6
+ metadata.gz: bc52b6625adc13de1354790016d0b3566d048b882f325af56df3a4d2f336ca4901a2cc637d8d0a422ed2c0c48142815edab96f24407e00601134b3e0524c37d1
7
+ data.tar.gz: 1bf8be7d0ccb0bfec50d0374a8cbde65bccd7f2156214d146d10ff2d084038d78c38cde9647041b16250e5e4d2035f9c6283b7c5b7b59e5d5118479bd854b56c
@@ -1,65 +1,77 @@
1
1
  module Documentize
2
2
  class Builder
3
3
 
4
- REGEX = {
5
- bad_do_block: /\sdo.*?end/,
6
- do_block: /\sdo[\s\|.*]/,
7
- flow: /^(if|unless|while|for).*?/
8
- }
4
+ class << self
9
5
 
10
- def self.build_docs(branch, indent = 0)
11
- doc_str = ""
12
- doc_str << "#{' '*indent}# Public: #{branch[:desc]}\n#{' '*indent}#\n"
13
- if branch[:args]
14
- branch[:args].each do |arg|
15
- doc_str << "#{' '*indent}# #{arg[:name]} - #{arg[:type]}: #{arg[:desc]}\n"
16
- end
17
- doc_str << "#{' '*indent}# \n"
6
+ REGEX = {
7
+ bad_do_block: /\sdo.*?end/,
8
+ do_block: /\sdo[\s\|.*]/,
9
+ flow: /^(if|unless|while|for).*?/
10
+ }
11
+
12
+ def make_private
13
+ @private = true
18
14
  end
19
- doc_str
20
- end
21
15
 
16
+ def make_public
17
+ @private = false
18
+ end
22
19
 
23
- def self.build_args(args)
24
- str = ""
25
- str << "("
26
- args.each do |arg|
27
- str << "#{arg[:name]}"
28
- str << " = #{arg[:default]}" if arg[:default]
29
- str << ", " unless arg == args[-1]
20
+ def build_docs(branch, indent = 0)
21
+ doc_str = ""
22
+ doc_str << "#{' '*indent}# #{@private ? 'Private' : 'Public'}: #{branch[:desc]}\n#{' '*indent}#\n"
23
+ if branch[:args]
24
+ branch[:args].each do |arg|
25
+ doc_str << "#{' '*indent}# #{arg[:name]} - #{arg[:type]}: #{arg[:desc]}\n"
26
+ end
27
+ doc_str << "#{' '*indent}# \n"
28
+ end
29
+ doc_str
30
30
  end
31
- str << ")"
32
- end
33
31
 
34
- def self.build_code(code, indent = 0)
35
- str = ""
36
- str << build_docs(code, indent) if code[:doc]
37
- str << " "*indent
38
- str << "#{code[:type] == "method" ? "def" : code[:type]} #{code[:name]}"
39
- str << build_args(code[:args]) if code[:args]
40
- str << "\n\n"
41
32
 
42
- code[:content].each do |item|
43
- if item.is_a?(Hash)
33
+ def build_args(args)
34
+ str = ""
35
+ str << "("
36
+ args.each do |arg|
37
+ str << "#{arg[:name]}"
38
+ str << " = #{arg[:default]}" if arg[:default]
39
+ str << ", " unless arg == args[-1]
40
+ end
41
+ str << ")"
42
+ end
43
+
44
+ def build_code(code, indent = 0)
45
+ make_public if(code[:type] == "class")
46
+ str = ""
47
+ str << build_docs(code, indent) if code[:doc]
48
+ str << " "*indent
49
+ str << "#{code[:type] == "method" ? "def" : code[:type]} #{code[:name]}"
50
+ str << build_args(code[:args]) if code[:args]
51
+ str << "\n\n"
44
52
 
45
- str << build_code(item, indent+1)
53
+ code[:content].each do |item|
54
+ if item.is_a?(Hash)
46
55
 
47
- else
56
+ str << build_code(item, indent+1)
48
57
 
49
- indent -= 1 if item =~ /end/ && item !~ REGEX[:bad]
58
+ else
59
+ make_private if(item =~ /private/)
60
+ indent -= 1 if item =~ /end/ && item !~ REGEX[:bad]
50
61
 
51
- str << " "*(indent+1) + "#{item} \n"
52
- str << "\n" if item =~ /end/ && item !~ REGEX[:bad]
62
+ str << " "*(indent+1) + "#{item} \n"
63
+ str << "\n" if item =~ /end/ && item !~ REGEX[:bad]
53
64
 
54
- indent += 1 if (item =~ REGEX[:do_block] || item =~ REGEX[:flow]) && item !~ REGEX[:bad]
65
+ indent += 1 if (item =~ REGEX[:do_block] || item =~ REGEX[:flow]) && item !~ REGEX[:bad]
55
66
 
67
+ end
56
68
  end
57
- end
58
69
 
59
- str << " " * indent
60
- str << "end\n"
61
- indent -= 1
62
- str << "\n"
70
+ str << " " * indent
71
+ str << "end\n"
72
+ indent -= 1
73
+ str << "\n"
74
+ end
63
75
  end
64
76
  end
65
77
  end
@@ -1,3 +1,3 @@
1
1
  module Documentize
2
- VERSION = "1.1.2"
2
+ VERSION = "1.1.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: documentize
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sampson Crowley