module Haml
def self.init_rails(binding)
so we can change the initialization behavior
We use it rather than putting stuff straight into init.rb
which is run by Rails on startup.
This method is called by init.rb,
def self.init_rails(binding) # No &method here for Rails 2.1 compatibility %w[haml/template sass sass/plugin].each {|f| require f} end
def self.scope(file) # :nodoc:
Returns the path of file relative to the Haml root.
def self.scope(file) # :nodoc: File.join(File.dirname(__FILE__), '..', file) end
def self.version
If Haml is checked out from Git,
The :string key contains a human-readable string representation of the version.
The :major, :minor, and :teeny keys have their respective numbers.
Returns a hash representing the version of Haml.
def self.version return @@version if defined?(@@version) numbers = File.read(scope('VERSION')).strip.split('.').map { |n| n.to_i } @@version = { :major => numbers[0], :minor => numbers[1], :teeny => numbers[2] } @@version[:string] = [:major, :minor, :teeny].map { |comp| @@version[comp] }.compact.join('.') if File.exists?(scope('REVISION')) rev = File.read(scope('REVISION')).strip rev = nil if rev !~ /[a-f0-9]+/ end if rev.nil? && File.exists?(scope('.git/HEAD')) rev = File.read(scope('.git/HEAD')).strip if rev =~ /^ref: (.*)$/ rev = File.read(scope(".git/#{$1}")).strip end end if rev @@version[:rev] = rev @@version[:string] << "." << rev[0...7] end @@version end