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



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

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



6
7
8
# File 'lib/documentize/informator.rb', line 6

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

#display_branch(branch, parent = nil) ⇒ Object



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

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



38
39
40
41
42
43
# File 'lib/documentize/informator.rb', line 38

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



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

def gen_info(tree)

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

end

#get_args(branch) ⇒ Object



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

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



78
79
80
81
82
83
# File 'lib/documentize/informator.rb', line 78

def get_desc(type)

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

end

#line_breakObject



87
88
89
90
# File 'lib/documentize/informator.rb', line 87

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