Class: Vocco::Generator::SourceFile

Inherits:
Object
  • Object
show all
Defined in:
lib/vocco/generator/source_file.rb

Constant Summary collapse

NOTE_FORMATS =
'.{textile,md,mkd,markdown,rdoc}'
HTML_TEMPLATE =
<<-'__YOU_ARE_SPECIAL__'
_buf = [] ; _temple_pre_tags = /<pre|<textarea/ ; _buf << ("<div class=\"nav\"><div class=\"wrapper\"><div class=\"area\"><h3><strong>") ; 
 ; 
 ; 
 ; 
 ; 
 ; if @gen.site ; 
 ; _buf << ("<a href=\"#{@gen.site}\">#{@gen.name}"\
"</a>") ; else ; 
 ; _buf << (@gen.name) ; 
 ; end ; _buf << ("</strong><span>#{' : '}"\
"</span><span>#{basename}"\
""\
"</span></h3>") ; if @gen.files.size > 1 ; 
 ; _buf << ("<p class=\"autohide\">") ; 
 ; @gen.files.each do |file| ; 
 ; _buf << ("#{file.short_dirname == '.' ? '' : file.short_dirname + '/'}"\
"<a href=\"#{file.doc_link}\">#{file.basename}"\
"</a><br>"\
""\
"") ; end ; _buf << ("</p>") ; end ; _buf << ("</div>") ; if notes.any? ; 
 ; _buf << ("<div class=\"notes area\">") ; 
 ; notes.each do |note| ; 
 ; _buf << (note) ; 
 ; 
 ; end ; _buf << ("</div>") ; end ; _buf << ("<div class=\"area\"><table><tr><th>Generated:</th><td>"\
""\
""\
""\
"#{Time.now.to_s}"\
"</td></tr></table></div></div></div>") ; _buf = _buf.join
__YOU_ARE_SPECIAL__

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file, generator) ⇒ SourceFile

Returns a new instance of SourceFile.



9
10
11
12
# File 'lib/vocco/generator/source_file.rb', line 9

def initialize(file, generator)
  @file       = file
  @gen        = generator
end

Instance Attribute Details

#fileObject (readonly)

full file path



14
15
16
# File 'lib/vocco/generator/source_file.rb', line 14

def file
  @file
end

Instance Method Details

#basenameObject



21
22
23
# File 'lib/vocco/generator/source_file.rb', line 21

def basename
  File.basename(@file)
end

#dirnameObject

full dirname



17
18
19
# File 'lib/vocco/generator/source_file.rb', line 17

def dirname
  File.dirname(@file)
end

#doc_basenameObject

corresponding doc file basename



36
37
38
# File 'lib/vocco/generator/source_file.rb', line 36

def doc_basename
  doc_scope + basename + '.html'
end

relative link to doc



46
47
48
# File 'lib/vocco/generator/source_file.rb', line 46

def doc_link
  './' + doc_basename
end

#doc_pathObject

corresponding doc file path



41
42
43
# File 'lib/vocco/generator/source_file.rb', line 41

def doc_path
  File.join(@gen.out, doc_basename)
end

#notesObject



50
51
52
53
54
# File 'lib/vocco/generator/source_file.rb', line 50

def notes
  @notes ||= Dir[note_glob].map do |path|
    Tilt.new(path).render
  end
end

#short_dirnameObject

dirname of the above



31
32
33
# File 'lib/vocco/generator/source_file.rb', line 31

def short_dirname
  File.dirname(short_path).sub(/^\.\//, '')
end

#short_pathObject

file path with glob dir scope trimmed off



26
27
28
# File 'lib/vocco/generator/source_file.rb', line 26

def short_path
  @short_path ||= @file.sub(@gen.glob_regex, '')
end