Skip to content

Commit

Permalink
fix for the new loader
Browse files Browse the repository at this point in the history
  • Loading branch information
triskweline committed May 9, 2010
1 parent 4dd8aae commit c70069d
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 51 deletions.
19 changes: 11 additions & 8 deletions aegis.gemspec
Expand Up @@ -5,11 +5,11 @@

Gem::Specification.new do |s|
s.name = %q{aegis}
s.version = "2.0.0"
s.version = "2.0.1"

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Henning Koch", "Tobias Kraze"]
s.date = %q{2010-05-02}
s.date = %q{2010-05-09}
s.description = %q{Aegis is an authorization solution for Ruby on Rails that supports roles and a RESTish, resource-style declaration of permission rules.}
s.email = %q{henning.koch@makandra.de}
s.extra_rdoc_files = [
Expand All @@ -27,6 +27,7 @@ Gem::Specification.new do |s|
"lib/aegis/action.rb",
"lib/aegis/compiler.rb",
"lib/aegis/has_role.rb",
"lib/aegis/loader.rb",
"lib/aegis/parser.rb",
"lib/aegis/permissions.rb",
"lib/aegis/resource.rb",
Expand Down Expand Up @@ -58,6 +59,7 @@ Gem::Specification.new do |s|
"spec/app_root/script/console",
"spec/controllers/reviews_controller_spec.rb",
"spec/has_role_spec.rb",
"spec/loader_spec.rb",
"spec/permissions_spec.rb",
"spec/rcov.opts",
"spec/spec.opts",
Expand All @@ -66,15 +68,15 @@ Gem::Specification.new do |s|
s.homepage = %q{http://github.com/makandra/aegis}
s.rdoc_options = ["--charset=UTF-8"]
s.require_paths = ["lib"]
s.rubygems_version = %q{1.3.5}
s.rubygems_version = %q{1.3.6}
s.summary = %q{Complete authorization solution for Rails}
s.test_files = [
"spec/app_root/app/models/user.rb",
"spec/app_root/app/controllers/application_controller.rb",
"spec/app_root/app/controllers/reviews_controller.rb",
"spec/app_root/app/models/permissions.rb",
"spec/app_root/app/models/property.rb",
"spec/app_root/app/models/review.rb",
"spec/app_root/app/models/permissions.rb",
"spec/app_root/app/controllers/application_controller.rb",
"spec/app_root/app/controllers/reviews_controller.rb",
"spec/app_root/app/models/user.rb",
"spec/app_root/config/boot.rb",
"spec/app_root/config/environment.rb",
"spec/app_root/config/environments/in_memory.rb",
Expand All @@ -88,10 +90,11 @@ Gem::Specification.new do |s|
"spec/app_root/db/migrate/003_create_reviews.rb",
"spec/app_root/lib/console_with_fixtures.rb",
"spec/action_controller_spec.rb",
"spec/controllers/reviews_controller_spec.rb",
"spec/has_role_spec.rb",
"spec/permissions_spec.rb",
"spec/spec_helper.rb",
"spec/controllers/reviews_controller_spec.rb"
"spec/loader_spec.rb"
]

if s.respond_to? :specification_version then
Expand Down
20 changes: 1 addition & 19 deletions lib/aegis.rb
@@ -1,20 +1,2 @@
require 'ostruct'

#for file in Dir["#{File.dirname(__FILE__)}/*/*.rb"]
# p file
#end

# Dir["#{File.dirname(__FILE__)}/**/*.rb"].each {|f| require f}

require 'aegis/loader'
require 'aegis/access_denied'
require 'aegis/action'
require 'aegis/compiler'
require 'aegis/has_role'
require 'aegis/parser'
require 'aegis/permissions'
require 'aegis/role'
require 'aegis/sieve'

require 'rails/action_controller'
require 'rails/active_record'
Aegis::Loader.load_paths
49 changes: 29 additions & 20 deletions lib/aegis/loader.rb
@@ -1,26 +1,35 @@
class Aegis::Loader
class << self
module Aegis
class Loader
class << self

def paths
[ 'aegis/access_denied',
'aegis/action',
'aegis/compiler',
'aegis/has_role',
'aegis/parser',
'aegis/permissions',
'aegis/resource',
'aegis/role',
'aegis/sieve',
def paths
[ 'ostruct',

'rails/action_controller',
'rails/active_record' ]
end
'aegis/access_denied',
'aegis/action',
'aegis/compiler',
'aegis/has_role',
'aegis/parser',
'aegis/permissions',
'aegis/resource',
'aegis/role',
'aegis/sieve',

'rails/action_controller',
'rails/active_record' ]
end

def load
for path in paths
require path
def load_paths
for path in paths
require path
end
@loaded = true
end

def loaded?
@loaded
end

end

end
end
end
15 changes: 11 additions & 4 deletions spec/loader_spec.rb
Expand Up @@ -7,12 +7,19 @@
it "should return all paths in the lib folder" do

root = "#{File.dirname(__FILE__)}/../lib/"
expected_paths = Dir["#{root}*/*.rb"].collect do |file|
file.sub(root, "").sub(/\.rb$/, "")
end - ['aegis/loader']
Dir["#{root}*/*.rb"].collect do |file|
path = file.sub(root, "").sub(/\.rb$/, "")
Aegis::Loader.paths.should include(path) unless path == 'aegis/loader'
end

Aegis::Loader.paths.should =~ expected_paths
end

end

describe 'loaded?' do

it "should be loaded" do
Aegis::Loader.should be_loaded
end

end
Expand Down

0 comments on commit c70069d

Please sign in to comment.