Top Level Namespace

Defined Under Namespace

Modules: Asciibuild

Instance Method Summary collapse

Instance Method Details

#get_lang(lang) ⇒ Object



23
24
25
26
27
28
29
30
31
32
# File 'lib/asciibuild/extensions.rb', line 23

def get_lang lang
  case lang
  when 'pyspark'
    'python'
  when 'spark-shell'
    'scala'
  else
    lang
  end
end

#include_section?(parent, attrs) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/asciibuild/extensions.rb', line 6

def include_section? parent, attrs
  sections = if parent.document.attributes["sections"]
    parent.document.attributes["sections"].split(/,[ ]*/)
  else
    []
  end

  incl_sect = sections.empty?
  sections.each do |s|
    if not incl_sect and Regexp.new(s) =~ parent.title
      incl_sect = true
    end
  end

  incl_sect or (not parent.document.attributes["error"] and (/^Before/ =~ parent.title or /^After/ =~ parent.title))
end

#write_file(attrs, default_name, body) ⇒ Object



34
35
36
37
38
39
40
# File 'lib/asciibuild/extensions.rb', line 34

def write_file attrs, default_name, body
  name = if attrs['file'] then attrs['file'] else default_name end
  mode = if attrs['overwrite'] == 'false' then File::WRONLY|File::CREAT|File::EXCL else 'w' end
  open(name, mode) do |f|
    f.write(body + "\n")
  end
end