Module: Daddy::Formatter::DaddyHtml

Included in:
Html
Defined in:
lib/daddy/formatter/daddy_html.rb

Instance Method Summary collapse

Instance Method Details

#after_menuObject



24
25
26
27
28
29
# File 'lib/daddy/formatter/daddy_html.rb', line 24

def after_menu
  if ENV['PUBLISH']
    @builder << '</div>'
    @builder << '</div>'
  end
end

#before_menuObject



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/daddy/formatter/daddy_html.rb', line 12

def before_menu
  if ENV['PUBLISH']
    @builder << "<div>"

    @builder.div(:id => 'menu') do
        @builder << make_menu_for_publish
    end

    @builder << "<div class='contents'>"
  end
end

#feature_dir(feature, short = false) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/daddy/formatter/daddy_html.rb', line 42

def feature_dir(feature, short = false)
  ret = ''
  
  split = feature.file.split(File::SEPARATOR)
  split.reverse[1..-2].each_with_index do |dir, i|
    break if dir == '仕様書' or dir == '開発日記'

    if i == 0
      if short
        ret = dir.split('.').first + '.'
      else
        ret = dir
      end
    else
      ret = dir.split('.').first + '.' + ret
    end
  end

  ret
end

#feature_idObject



38
39
40
# File 'lib/daddy/formatter/daddy_html.rb', line 38

def feature_id
  @feature.file.gsub(/(\/|\.|\\)/, '_')
end

#magic_comment?(comment_line) ⇒ Boolean

Returns:

  • (Boolean)


67
68
69
70
71
72
73
74
75
# File 'lib/daddy/formatter/daddy_html.rb', line 67

def magic_comment?(comment_line)
  comment = comment_line.to_s

  ['language', 'format'].each do |magic|
    return true if /#\s*#{magic}\s*:.*/ =~ comment
  end
  
  false
end

#make_menu_for_publishObject



31
32
33
34
35
36
# File 'lib/daddy/formatter/daddy_html.rb', line 31

def make_menu_for_publish
  FileUtils.mkdir_p('tmp')
  menu = File.join('tmp', 'menu.html')
  system("erb -T - #{File.dirname(__FILE__)}/menu.html.erb > #{menu}")
  File.read(menu)
end

#should_expandObject



63
64
65
# File 'lib/daddy/formatter/daddy_html.rb', line 63

def should_expand
  ['t', 'true'].include?(ENV['EXPAND'].to_s.downcase)
end

#titleObject



5
6
7
8
9
10
# File 'lib/daddy/formatter/daddy_html.rb', line 5

def title
  ret = ENV['TITLE']
  ret ||= Daddy.config.cucumber.title if Daddy.config.cucumber.title?
  ret ||= 'Daddy'
  ret
end