documentize 1.1.3 → 1.1.4

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: e6cfd72a6925ca9b57ef544c89a68abeb7e46f38
4
- data.tar.gz: 863a91330cc7a3a16976c0add757bbfc791735c1
3
+ metadata.gz: c107d5efaa49836810823542cbb3adcd084cb8fd
4
+ data.tar.gz: b7f21383f2b4e82132ede4fbbe54bf437de0308c
5
5
  SHA512:
6
- metadata.gz: bc52b6625adc13de1354790016d0b3566d048b882f325af56df3a4d2f336ca4901a2cc637d8d0a422ed2c0c48142815edab96f24407e00601134b3e0524c37d1
7
- data.tar.gz: 1bf8be7d0ccb0bfec50d0374a8cbde65bccd7f2156214d146d10ff2d084038d78c38cde9647041b16250e5e4d2035f9c6283b7c5b7b59e5d5118479bd854b56c
6
+ metadata.gz: d37075b89ff739d19ec61ab9eb0e3744ec2cfe0c404af2c031db38d44379b737722facda40ac1ff3b24870d2c96686d2ac4dcc3f437ad2e8b9b7679d135b266b
7
+ data.tar.gz: b0968bfc1893ef45ce2208dcb62e3ed70e5cc0ef3a5f15174a733be12b2ec33ff15626e26b32f2aa90bd7450bee18fca7aca20d5f788cf80c2499404f01d4764
data/README.md CHANGED
@@ -12,7 +12,7 @@ run the following in your console:
12
12
 
13
13
  ## Usage
14
14
 
15
- Documentize takes any ruby file as an argument in the CLI, relative to you current working directory:
15
+ Documentize takes any ruby file as an argument in the CLI, relative to your current working directory:
16
16
 
17
17
  $ documentize my_ruby_file.rb
18
18
 
@@ -4,8 +4,6 @@ require "documentize/builder"
4
4
  require "documentize/collector"
5
5
  require "documentize/informator"
6
6
 
7
-
8
-
9
7
  module Documentize
10
8
  class Documentize
11
9
  REGEX = {
@@ -45,4 +43,4 @@ module Documentize
45
43
  end
46
44
  end
47
45
  end
48
- end
46
+ end
@@ -9,22 +9,14 @@ module Documentize
9
9
  flow: /^(if|unless|while|for).*?/
10
10
  }
11
11
 
12
- def make_private
13
- @private = true
14
- end
15
-
16
- def make_public
17
- @private = false
18
- end
19
-
20
- def build_docs(branch, indent = 0)
12
+ def build_docs(branch, level = 0)
21
13
  doc_str = ""
22
- doc_str << "#{' '*indent}# #{@private ? 'Private' : 'Public'}: #{branch[:desc]}\n#{' '*indent}#\n"
14
+ doc_str << "#{indent(level)}# #{@private ? 'Private' : 'Public'}: #{branch[:desc]}\n#{indent(level)}#\n"
23
15
  if branch[:args]
24
16
  branch[:args].each do |arg|
25
- doc_str << "#{' '*indent}# #{arg[:name]} - #{arg[:type]}: #{arg[:desc]}\n"
17
+ doc_str << "#{indent(level)}# #{arg[:name]} - #{arg[:type]}: #{arg[:desc]}\n"
26
18
  end
27
- doc_str << "#{' '*indent}# \n"
19
+ doc_str << "#{indent(level)}# \n"
28
20
  end
29
21
  doc_str
30
22
  end
@@ -41,11 +33,11 @@ module Documentize
41
33
  str << ")"
42
34
  end
43
35
 
44
- def build_code(code, indent = 0)
36
+ def build_code(code, level = 0)
45
37
  make_public if(code[:type] == "class")
46
38
  str = ""
47
- str << build_docs(code, indent) if code[:doc]
48
- str << " "*indent
39
+ str << build_docs(code, level) if code[:doc]
40
+ str << indent(level)
49
41
  str << "#{code[:type] == "method" ? "def" : code[:type]} #{code[:name]}"
50
42
  str << build_args(code[:args]) if code[:args]
51
43
  str << "\n\n"
@@ -53,25 +45,38 @@ module Documentize
53
45
  code[:content].each do |item|
54
46
  if item.is_a?(Hash)
55
47
 
56
- str << build_code(item, indent+1)
48
+ str << build_code(item, level+1)
57
49
 
58
50
  else
59
51
  make_private if(item =~ /private/)
60
- indent -= 1 if item =~ /end/ && item !~ REGEX[:bad]
52
+ level -= 1 if item =~ /end/ && item !~ REGEX[:bad]
61
53
 
62
- str << " "*(indent+1) + "#{item} \n"
54
+ str << indent(level+1) + "#{item} \n"
63
55
  str << "\n" if item =~ /end/ && item !~ REGEX[:bad]
64
56
 
65
- indent += 1 if (item =~ REGEX[:do_block] || item =~ REGEX[:flow]) && item !~ REGEX[:bad]
57
+ level += 1 if (item =~ REGEX[:do_block] || item =~ REGEX[:flow]) && item !~ REGEX[:bad]
66
58
 
67
59
  end
68
60
  end
69
61
 
70
- str << " " * indent
62
+ str << indent(level)
71
63
  str << "end\n"
72
- indent -= 1
64
+ level -= 1
73
65
  str << "\n"
74
66
  end
67
+
68
+ private
69
+ def make_private
70
+ @private = true
71
+ end
72
+
73
+ def make_public
74
+ @private = false
75
+ end
76
+
77
+ def indent(level)
78
+ ' ' * level
79
+ end
75
80
  end
76
81
  end
77
82
  end
@@ -1,8 +1,6 @@
1
1
  module Documentize
2
2
  class Informator
3
3
 
4
-
5
-
6
4
  def clear_screen
7
5
  system("cls") || system("tput reset") || system("clear") || puts("\e[H\e[2J")
8
6
  end
@@ -82,7 +80,7 @@ module Documentize
82
80
 
83
81
  end
84
82
 
85
-
83
+
86
84
 
87
85
  def line_break
88
86
  puts
@@ -90,4 +88,4 @@ module Documentize
90
88
  end
91
89
 
92
90
  end
93
- end
91
+ end
@@ -1,3 +1,3 @@
1
1
  module Documentize
2
- VERSION = "1.1.3"
2
+ VERSION = "1.1.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: documentize
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sampson Crowley
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-02-22 00:00:00.000000000 Z
11
+ date: 2017-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler