lib/lockdown.rb in lockdown-0.7.1 vs lib/lockdown.rb in lockdown-0.8.0
- old
+ new
@@ -1,67 +1,70 @@
require File.join(File.dirname(__FILE__), "lockdown", "helper")
module Lockdown
- # :stopdoc:
- VERSION = '0.7.1'
- LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
- PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
- # :startdoc:
-
- class << self
- include Lockdown::Helper
+ extend Lockdown::Helper
- # Returns the version string for the library.
- def version
- VERSION
- end
-
- # Returns the qualified path to the init file
- def init_file
- "#{Dir.pwd}/lib/lockdown/init.rb"
- end
+ VERSION = '0.8.0'
- # Mixin Lockdown code to the appropriate framework and ORM
- def mixin
- if mixin_resource?("frameworks")
- unless mixin_resource?("orms")
- raise NotImplementedError, "ORM unknown to Lockdown!"
- end
+ # Returns the version string for the library.
+ def self.version
+ VERSION
+ end
- if File.exists?(Lockdown.init_file)
- puts "=> Requiring Lockdown rules engine: #{Lockdown.init_file} \n"
- require Lockdown.init_file
- else
- puts "=> Note:: Lockdown couldn't find init file: #{Lockdown.init_file}\n"
- end
+ def self.major_version
+ version.split('.')[0].to_i
+ end
+
+ def self.minor_version
+ version.split('.')[1].to_i
+ end
+
+ def self.patch_version
+ version.split('.')[2].to_i
+ end
+
+ # Mixin Lockdown code to the appropriate framework and ORM
+ def self.mixin
+ if mixin_resource?("frameworks")
+ unless mixin_resource?("orms")
+ raise NotImplementedError, "ORM unknown to Lockdown!"
+ end
+
+ if File.exists?(Lockdown.init_file)
+ puts "=> Requiring Lockdown rules engine: #{Lockdown.init_file} \n"
+ require Lockdown.init_file
else
- puts "=> Note:: Lockdown cannot determine framework and therefore is not active.\n"
+ puts "=> Note:: Lockdown couldn't find init file: #{Lockdown.init_file}\n"
end
- end # mixin
+ else
+ puts "=> Note:: Lockdown cannot determine framework and therefore is not active.\n"
+ end
+ end # mixin
- # :stopdoc:
- private
+ private
- def mixin_resource?(str)
- wildcard_path = File.join( File.dirname(__FILE__), 'lockdown', str , '*.rb' )
- Dir[wildcard_path].each do |f|
- require f
- module_name = File.basename(f).split(".")[0]
- module_class = eval("Lockdown::#{str.capitalize}::#{Lockdown.camelize(module_name)}")
- if module_class.use_me?
- include module_class
- return true
- end
+ def self.mixin_resource?(str)
+ wildcard_path = File.join( File.dirname(__FILE__), 'lockdown', str , '*.rb' )
+ Dir[wildcard_path].each do |f|
+ require f
+ module_name = File.basename(f).split(".")[0]
+ module_class = eval("Lockdown::#{str.capitalize}::#{Lockdown.camelize(module_name)}")
+ if module_class.use_me?
+ include module_class
+ return true
end
- false
- end # mixin_resource?
- end # class block
+ end
+ false
+ end # mixin_resource?
end # Lockdown
-
-require File.join(File.dirname(__FILE__), "lockdown", "system")
-require File.join(File.dirname(__FILE__), "lockdown", "controller")
require File.join(File.dirname(__FILE__), "lockdown", "session")
+require File.join(File.dirname(__FILE__), "lockdown", "context")
+require File.join(File.dirname(__FILE__), "lockdown", "permission")
+require File.join(File.dirname(__FILE__), "lockdown", "database")
+require File.join(File.dirname(__FILE__), "lockdown", "rules")
+require File.join(File.dirname(__FILE__), "lockdown", "system")
puts "=> Mixing in Lockdown version: #{Lockdown.version} \n"
+
Lockdown.mixin