Module: Stark

Defined in:
lib/stark.rb,
lib/stark/ruby.rb,
lib/stark/client.rb,
lib/stark/parser.rb,
lib/stark/struct.rb,
lib/stark/exception.rb,
lib/stark/processor.rb,
lib/stark/log_transport.rb,
lib/stark/protocol_helpers.rb

Defined Under Namespace

Modules: ProtocolHelpers Classes: Client, Exception, LogTransport, Parser, Processor, Ruby, Struct

Constant Summary collapse

VERSION =
'0.9.3'

Class Method Summary collapse

Class Method Details

.loggerObject



7
8
9
# File 'lib/stark.rb', line 7

def self.logger
  @logger ||= ::Logger.new($stdout)
end

.logger=(logger) ⇒ Object



11
12
13
# File 'lib/stark.rb', line 11

def self.logger=(logger)
  @logger = logger
end

.materialize(file, namespace = Object) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/stark.rb', line 25

def self.materialize(file, namespace=Object)
  require 'stark/parser'
  require 'stark/ruby'
  require 'stringio'

  begin
    contents = Stark::Parser.read_file(file)
    ast = Stark::Parser.ast contents
  rescue => e
    raise e, e.message + " while processing #{file} -\n#{e.backtrace.join("\n")}"
  end

  stream = StringIO.new

  ruby = Stark::Ruby.new stream
  ruby.run ast

  if ENV['STARK_DEBUG']
    puts stream.string
  end

  namespace.module_eval stream.string
end

.pipe_transportObject



15
16
17
18
19
20
21
22
23
# File 'lib/stark.rb', line 15

def self.pipe_transport
  cr, cw = IO.pipe
  sr, sw = IO.pipe

  client_t = Thrift::IOStreamTransport.new sr, cw
  server_t = Thrift::IOStreamTransport.new cr, sw

  [client_t, server_t]
end