Class: Buhos::Reflection::Authorizations

Inherits:
Object
  • Object
show all
Defined in:
lib/buhos/reflection.rb

Overview

Class to explore authorizations

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Authorizations

Returns a new instance of Authorizations.

Parameters:



38
39
40
41
42
43
44
45
46
# File 'lib/buhos/reflection.rb', line 38

def initialize(app)
  @app=app
  @files={}
  @permits=[]
  get_auth_from_ruby_files
  get_auth_from_haml
  @permits.flatten!.uniq!.sort!
  @current_route=nil
end

Instance Attribute Details

#filesObject (readonly)

Returns the value of attribute files.



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

def files
  @files
end

#permitsObject (readonly)

Returns the value of attribute permits.



36
37
38
# File 'lib/buhos/reflection.rb', line 36

def permits
  @permits
end

Instance Method Details

#get_auth_from_hamlObject



63
64
65
66
67
68
69
70
71
72
73
# File 'lib/buhos/reflection.rb', line 63

def get_auth_from_haml
  Dir.glob("#{@app.dir_base}/views/*.haml").each do |v|
    File.open(v,"rb") do |fp|
      filename=v.gsub(@app.dir_base,"")
      @files[filename]={:nil=>[]}
      fp.each_line do |line|
        process_haml_line(filename, line)
      end
    end
  end
end

#get_auth_from_ruby_filesObject



47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/buhos/reflection.rb', line 47

def get_auth_from_ruby_files
  Dir.glob("#{@app.dir_base}/**/*.rb").each do |v|
    @auth=[]
    next if v=~/\/spec\// or v=~/installer.rb/
    File.open(v,"rb") do |fp|
      filename=v.gsub(@app.dir_base,"")
      @files[filename]={}
      fp.each_line do |line|
        process_line_ruby_file(filename, line)
      end
    end
  end
end