Class: Treebis::Task

Inherits:
Object
  • Object
show all
Includes:
PathUtils
Defined in:
lib/nandoc/support/treebis-extlib.rb

Defined Under Namespace

Classes: RunContext

Instance Method Summary collapse

Methods included from PathUtils

#path_from_full, #path_from_full_assert, #undot

Constructor Details

#initialize(*a, &b) ⇒ Task

Returns a new instance of Task.



43
44
45
46
47
48
# File 'lib/nandoc/support/treebis-extlib.rb', line 43

def initialize(*a,&b)
  initialize_orig(*a,&b)
  sexp = reflection_sexp
  props = sexp.select{|x| x.first == :prop }
  set_props(props) if props.any?
end

Instance Method Details

#erb_variable_namesObject



49
50
51
52
53
54
55
56
57
58
# File 'lib/nandoc/support/treebis-extlib.rb', line 49

def erb_variable_names
  sexp = reflection_sexp
  filenames = sexp.select{ |x| x.first == :erb }
  names = []
  filenames.each do |node|
    path = path_from_full_assert(node[1])
    names |= erb_variable_names_in_file(path)
  end
  names
end

#erb_variable_names_in_file(path) ⇒ Object



59
60
61
62
63
64
# File 'lib/nandoc/support/treebis-extlib.rb', line 59

def erb_variable_names_in_file path
  content = File.read(path)
  names = content.scan(/<%= *([_a-z0-9]+) *%>/).map{ |x| x[0] }
  names = names.uniq
  names
end

#initialize_origObject



42
# File 'lib/nandoc/support/treebis-extlib.rb', line 42

alias_method :initialize_orig, :initialize

#prop(*a) ⇒ Object



65
66
# File 'lib/nandoc/support/treebis-extlib.rb', line 65

def prop *a
end

#reflection_sexpObject



67
68
69
# File 'lib/nandoc/support/treebis-extlib.rb', line 67

def reflection_sexp
  BlockProbe.new(&@block).sexp
end