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.
13
14
15
16
17
|
# File 'lib/libcfenjin/cfp_translate.rb', line 13
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
94
95
96
97
|
# File 'lib/libcfenjin/cfp_translate.rb', line 94
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
# File 'lib/libcfenjin/cfp_translate.rb', line 67
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
34
35
36
|
# File 'lib/libcfenjin/cfp_translate.rb', line 34
def control line
@parser.form_control line
end
|
#copy(line) ⇒ Object
46
47
48
|
# File 'lib/libcfenjin/cfp_translate.rb', line 46
def copy line
@parser.form_copy line
end
|
#directories(line) ⇒ Object
58
59
60
|
# File 'lib/libcfenjin/cfp_translate.rb', line 58
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
22
23
24
25
26
27
28
|
# File 'lib/libcfenjin/cfp_translate.rb', line 22
def do_translate action,line
if action != 'initialize'
send(action,line)
else
line
end
end
|
#editfiles(line) ⇒ Object
54
55
56
|
# File 'lib/libcfenjin/cfp_translate.rb', line 54
def editfiles line
@parser.form_editfiles line
end
|
#files(line) ⇒ Object
38
39
40
|
# File 'lib/libcfenjin/cfp_translate.rb', line 38
def files line
@parser.form_files line
end
|
#groups(line) ⇒ Object
30
31
32
|
# File 'lib/libcfenjin/cfp_translate.rb', line 30
def groups line
@parser.form_groups line
end
|
#links(line) ⇒ Object
42
43
44
|
# File 'lib/libcfenjin/cfp_translate.rb', line 42
def links line
@parser.form_links line
end
|
#shellcommands(line) ⇒ Object
62
63
64
65
|
# File 'lib/libcfenjin/cfp_translate.rb', line 62
def shellcommands line
@parser.form_shellcommands line
end
|
#tidy(line) ⇒ Object
50
51
52
|
# File 'lib/libcfenjin/cfp_translate.rb', line 50
def tidy line
@parser.form_tidy line
end
|