Module: Rux

Defined in:
lib/rux.rb,
lib/rux/ast.rb,
lib/rux/lex.rb,
lib/rux/file.rb,
lib/rux/lexer.rb,
lib/rux/utils.rb,
lib/rux/buffer.rb,
lib/rux/parser.rb,
lib/rux/version.rb,
lib/rux/visitor.rb,
lib/rux/lex/state.rb,
lib/rux/rux_lexer.rb,
lib/rux/ruby_lexer.rb,
lib/rux/ast/tag_node.rb,
lib/rux/lex/patterns.rb,
lib/rux/ast/list_node.rb,
lib/rux/ast/ruby_node.rb,
lib/rux/ast/text_node.rb,
lib/rux/lex/transition.rb,
lib/rux/ast/string_node.rb,
lib/rux/default_visitor.rb,
lib/rux/default_tag_builder.rb

Defined Under Namespace

Modules: AST, Lex, Utils Classes: Buffer, DefaultTagBuilder, DefaultVisitor, File, Lexer, Parser, RubyLexer, RuxLexer, Visitor

Constant Summary collapse

VERSION =
'1.1.0'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.bufferObject

Returns the value of attribute buffer.



35
36
37
# File 'lib/rux.rb', line 35

def buffer
  @buffer
end

.tag_builderObject

Returns the value of attribute tag_builder.



35
36
37
# File 'lib/rux.rb', line 35

def tag_builder
  @tag_builder
end

Class Method Details

.create_bufferObject



62
63
64
# File 'lib/rux.rb', line 62

def create_buffer
  buffer.new
end

.default_bufferObject



54
55
56
# File 'lib/rux.rb', line 54

def default_buffer
  @default_buffer ||= Buffer
end

.default_tag_builderObject



50
51
52
# File 'lib/rux.rb', line 50

def default_tag_builder
  @default_tag_builder ||= DefaultTagBuilder.new
end

.default_visitorObject



46
47
48
# File 'lib/rux.rb', line 46

def default_visitor
  @default_visitor ||= DefaultVisitor.new
end

.library_pathsObject



66
67
68
# File 'lib/rux.rb', line 66

def library_paths
  @library_paths ||= []
end

.tag(tag_name, attributes = {}, &block) ⇒ Object



58
59
60
# File 'lib/rux.rb', line 58

def tag(tag_name, attributes = {}, &block)
  tag_builder.call(tag_name, attributes, &block)
end

.to_ruby(str, visitor: default_visitor, pretty: true) ⇒ Object



37
38
39
40
41
42
43
44
# File 'lib/rux.rb', line 37

def to_ruby(str, visitor: default_visitor, pretty: true)
  ruby_code = visitor.visit(Parser.parse(str))
  return ruby_code unless pretty

  ::Unparser.unparse(
    ::Parser::CurrentRuby.parse(ruby_code)
  )
end