Class: Cfp_Translate
- Inherits:
-
Object
show all
- Defined in:
- lib/libcfenjin/cfp_translate.rb
Instance Method Summary
collapse
Constructor Details
#initialize(cf, parser = nil) ⇒ Cfp_Translate
Returns a new instance of Cfp_Translate.
9
10
11
12
13
|
# File 'lib/libcfenjin/cfp_translate.rb', line 9
def initialize cf,parser=nil
@cf = cf
@parser = parser
@parser = Cfruby::Parser.new(@cf) if @parser == nil
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(methId, line) ⇒ Object
This method is reached when an action does not exist (e.g. myshellcommands) - in this implementation it sends out a warning and comments out the code - so it will compile
90
91
92
93
|
# File 'lib/libcfenjin/cfp_translate.rb', line 90
def method_missing(methId,line)
Cfruby.controller.inform('verbose', "Warning: undefined user action #{methId} - #{line}") if line.strip != ''
'# Not recognised: '+line
end
|
Instance Method Details
#conditionals(code) ⇒ Object
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
# File 'lib/libcfenjin/cfp_translate.rb', line 63
def conditionals code
r = []
blocklist = [] code.each do | line, num |
if @parser.conditional? line
blocklist.push [ r.size, line.strip ] line = @parser.form_conditional line
end
r.push line
end
relpos = 0
if blocklist.size > 0
tmp,first = blocklist.shift blocklist.each do | num, s |
r.insert(num+relpos,' end # ---- '+s)
relpos += 1
end
r.push 'end # ---- '+first
end
r
end
|
#control(line) ⇒ Object
30
31
32
|
# File 'lib/libcfenjin/cfp_translate.rb', line 30
def control line
@parser.form_control line
end
|
#copy(line) ⇒ Object
42
43
44
|
# File 'lib/libcfenjin/cfp_translate.rb', line 42
def copy line
@parser.form_copy line
end
|
#directories(line) ⇒ Object
54
55
56
|
# File 'lib/libcfenjin/cfp_translate.rb', line 54
def directories line
@parser.form_directories line
end
|
#do_translate(action, line) ⇒ Object
Each executable Cfruby line comes through this method for parsing - returns the translated version - as related to the action
18
19
20
21
22
23
24
|
# File 'lib/libcfenjin/cfp_translate.rb', line 18
def do_translate action,line
if action != 'initialize'
send(action,line)
else
line
end
end
|
#editfiles(line) ⇒ Object
50
51
52
|
# File 'lib/libcfenjin/cfp_translate.rb', line 50
def editfiles line
@parser.form_editfiles line
end
|
#files(line) ⇒ Object
34
35
36
|
# File 'lib/libcfenjin/cfp_translate.rb', line 34
def files line
@parser.form_files line
end
|
#groups(line) ⇒ Object
26
27
28
|
# File 'lib/libcfenjin/cfp_translate.rb', line 26
def groups line
@parser.form_groups line
end
|
#links(line) ⇒ Object
38
39
40
|
# File 'lib/libcfenjin/cfp_translate.rb', line 38
def links line
@parser.form_links line
end
|
#shellcommands(line) ⇒ Object
58
59
60
61
|
# File 'lib/libcfenjin/cfp_translate.rb', line 58
def shellcommands line
@parser.form_shellcommands line
end
|
#tidy(line) ⇒ Object
46
47
48
|
# File 'lib/libcfenjin/cfp_translate.rb', line 46
def tidy line
@parser.form_tidy line
end
|