class Tilt::DynCliTemplate

Attributes

content[R]

Public Class Methods

engine_initialized?() click to toggle source
# File lib/dyndoc/srv/tilt.rb, line 51
def self.engine_initialized?
  defined? ::DynDoc
end
init(libs=nil) click to toggle source
# File lib/dyndoc/srv/tilt.rb, line 16
def DynCliTemplate.init(libs=nil)
end

Public Instance Methods

decode_cmd(res) click to toggle source
# File lib/dyndoc/srv/tilt.rb, line 45
def decode_cmd(res)
  if res =~ /^__send_cmd__\[\[([a-zA-Z0-9_]*)\]\]__([\s\S]*)/m
      return {cmd: $1, content: $2}
  end
end
evaluate(scope, locals, &block) click to toggle source
# File lib/dyndoc/srv/tilt.rb, line 67
def evaluate(scope, locals, &block)
  if locals.keys.include? :reinit and locals[:reinit]
    ## The layout needs to be reintailized for new dyndoc file but not for the layout (of course)!
    @dyndoc_cmd="dyndoc"
    @dyndoc_cmd += "_with_tag_tmpl" if locals[:reinit].include? :dyndoc_tag_tmpl
    @dyndoc_cmd += "_with_libs_reinit" if locals[:reinit].include? :dyndoc_libs
    @dyndoc_cmd += "_with_layout_reinit" if locals[:reinit].include? :dyndoc_layout
    locals.delete :reinit
  end

    @output=prepare_output
    #puts @output
    #@output
end
initialize_engine() click to toggle source
# File lib/dyndoc/srv/tilt.rb, line 55
def initialize_engine
    DynCliTemplate.init
end
prepare() click to toggle source
# File lib/dyndoc/srv/tilt.rb, line 59
def prepare; end
prepare_output() click to toggle source
# File lib/dyndoc/srv/tilt.rb, line 62
def prepare_output
  send_dyndoc(data)
              return @content
end
send_dyndoc(code) click to toggle source

reinit is an array

# File lib/dyndoc/srv/tilt.rb, line 21
                def send_dyndoc(code)

      addr,port="127.0.0.1",7777


#p [:addr,@addr]
                        Socket.tcp(addr, port) {|sock|
                                        msg='__send_cmd__[['+@dyndoc_cmd+']]__' + code + @@end_token
                                        #p msg
                                sock.print msg
                                        #sleep 1
                                sock.close_write
                                @result=sock.read
                        }

                        data=@result.split(@@end_token,-1)
                        last=data.pop
                        resCmd=decode_cmd(data.join(""))
                        ##p [:resCmd,resCmd]
                        if resCmd and resCmd[:cmd] != "windows_platform"
                                @content=resCmd[:content]
                        end
                end