class Smith::ACLParser

Public Class Methods

new() click to toggle source
Calls superclass method
# File lib/smith/acl_parser.rb, line 11
def initialize
  super()
  @class_stack         = []
  self.auto_shift_type = true
  self.reset
end

Public Instance Methods

class_name() click to toggle source

Returns the first class in the list, or :main

# File lib/smith/acl_parser.rb, line 31
def class_name
  if @class_stack.any?
    @class_stack.reverse
  else
    :main
  end
end
fully_qualified_classes() click to toggle source
# File lib/smith/acl_parser.rb, line 44
def fully_qualified_classes
  @classes.delete(:main)
  @classes.inject([]) do |a, class_method|
    a.tap do |acc|
      acc << class_method
    end
  end
end
go(ruby) click to toggle source
# File lib/smith/acl_parser.rb, line 18
def go(ruby)
  @parser = RubyParser.new
  process(@parser.process(ruby))
end
in_class(name) { || ... } click to toggle source

Adds name to the class stack, for the duration of the block

# File lib/smith/acl_parser.rb, line 24
def in_class(name)
  @class_stack.unshift(name)
  yield
  @class_stack.shift
end
process_class(exp) click to toggle source

Process Class method

# File lib/smith/acl_parser.rb, line 59
def process_class(exp)
  in_class(exp.shift) do
    process_until_empty exp
    @classes << class_name
  end
  s()
end
process_module(exp) click to toggle source
# File lib/smith/acl_parser.rb, line 67
def process_module(exp)
  in_class exp.shift do
    process_until_empty exp
  end
  s()
end
process_until_empty(exp) click to toggle source

Process each element of exp in turn.

# File lib/smith/acl_parser.rb, line 40
def process_until_empty(exp)
  process(exp.shift) until exp.empty?
end
reset() click to toggle source

Reset @classes data

# File lib/smith/acl_parser.rb, line 54
def reset
  @classes = Set.new
end