Class: Documentize::Informator

Inherits:
Object
  • Object
show all
Defined in:
lib/documentize/informator.rb

Instance Method Summary collapse

Instance Method Details

#branch_info(branch, parent = nil) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/documentize/informator.rb', line 8

def branch_info(branch, parent = nil)

  display_branch(branch, parent)

  branch[:desc] = get_desc(branch[:type])

  get_args(branch) if branch[:args]

  branch[:content].each do |item|
    branch_info(item, [branch[:name], branch[:type]]) if item.is_a?(Hash)
  end

end

#clear_screenObject



4
5
6
# File 'lib/documentize/informator.rb', line 4

def clear_screen
  system("cls") || system("tput reset") || system("clear") || puts("\e[H\e[2J")
end

#display_branch(branch, parent = nil) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/documentize/informator.rb', line 22

def display_branch(branch, parent = nil)
  clear_screen unless parent

  puts line_break

  print "Describing: #{branch[:name]} #{branch[:type]}"
  print " of #{parent[0]} #{parent[1]}" if parent
  puts

  puts line_break

  puts Builder.build_code(branch)
end

#gen_doc(branch) ⇒ Object



36
37
38
39
40
41
# File 'lib/documentize/informator.rb', line 36

def gen_doc(branch)
  branch[:content].each do |item|
    gen_doc(item) if item.is_a?(Hash)
  end
  branch[:doc] = Builder.build_docs(branch)
end

#gen_info(tree) ⇒ Object



43
44
45
46
47
48
49
50
# File 'lib/documentize/informator.rb', line 43

def gen_info(tree)

  tree.each do |branch|
    branch_info(branch)
    gen_doc(branch)
  end

end

#get_args(branch) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/documentize/informator.rb', line 52

def get_args(branch)

  print "#{branch[:type]} #{branch[:name]}"
  print Builder.build_args(branch[:args])
  puts

  branch[:args].each do |arg|

    puts "Please enter a brief description of argument: #{arg[:name]}"
    arg[:desc] = gets.strip

    puts "What input Type should be entered for agument: #{arg[:name]}"
    arg[:type] = gets.strip

    if arg[:default] == nil
      puts "Please enter a default 'testing' value for Rspec:"
      arg[:test] = gets.strip
    end

  end

  branch[:args]
end

#get_desc(type) ⇒ Object



76
77
78
79
80
81
# File 'lib/documentize/informator.rb', line 76

def get_desc(type)

  puts "please enter a description of the above #{type}\n\n"
  gets.strip

end

#line_breakObject



85
86
87
88
# File 'lib/documentize/informator.rb', line 85

def line_break
  puts
  puts "--------------------------------------------------"
end