Module: Closer::Formatter::CloserHtml

Included in:
Html
Defined in:
lib/closer/formatter/closer_html.rb

Instance Method Summary collapse

Instance Method Details

#current_time_stringObject


51
52
53
# File 'lib/closer/formatter/closer_html.rb', line 51

def current_time_string
  ::Time.now.instance_eval{ '%s%03d' % [strftime('%Y%m%d%H%M%S'), (usec / 1000.0).round] }
end

#display_keyword(keyword) ⇒ Object


55
56
57
58
59
60
61
62
63
64
65
# File 'lib/closer/formatter/closer_html.rb', line 55

def display_keyword(keyword)
  if @in_background
    display_keyword = keyword.strip + ' '
  else
    if keyword.strip == '*'
      display_keyword = ''
    else
      display_keyword = keyword.strip + ' '
    end
  end
end

#feature_dir(feature, short = false) ⇒ Object


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/closer/formatter/closer_html.rb', line 22

def feature_dir(feature, short = false)
  ret = ''
  
  split = feature.file.split(File::SEPARATOR).reject{|dir| dir.empty? }
  split.reverse[1..-2].each_with_index do |dir, i|
    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


18
19
20
# File 'lib/closer/formatter/closer_html.rb', line 18

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

#gem_dirObject


14
15
16
# File 'lib/closer/formatter/closer_html.rb', line 14

def gem_dir
  ::File.join(Gem.dir, 'gems')
end

#indent_size(text) ⇒ Object


67
68
69
# File 'lib/closer/formatter/closer_html.rb', line 67

def indent_size(text)
  text.to_s[/\A */].size
end

#magic_comment?(comment_line) ⇒ Boolean

Returns:

  • (Boolean)

41
42
43
44
45
46
47
48
49
# File 'lib/closer/formatter/closer_html.rb', line 41

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

#ruby_version_dirObject


7
8
9
10
11
12
# File 'lib/closer/formatter/closer_html.rb', line 7

def ruby_version_dir
  unless @_ruby_version_dir
    @_ruby_version_dir = RUBY_VERSION.split('.')[0..1].join('.') + '.0'
  end
  @_ruby_version_dir
end