2006-12-04 08:40:23 +00:00
|
|
|
require 'sass/tree/node'
|
|
|
|
require 'sass/tree/value_node'
|
|
|
|
require 'sass/tree/rule_node'
|
2007-03-17 23:34:26 +00:00
|
|
|
require 'sass/tree/comment_node'
|
|
|
|
require 'sass/tree/attr_node'
|
2007-08-12 10:54:35 +00:00
|
|
|
require 'sass/tree/directive_node'
|
2007-01-01 06:10:20 +00:00
|
|
|
require 'sass/constant'
|
2007-01-28 10:14:15 +00:00
|
|
|
require 'sass/error'
|
2007-03-25 08:20:33 +00:00
|
|
|
require 'haml/util'
|
2006-11-28 19:43:58 +00:00
|
|
|
|
|
|
|
module Sass
|
2006-12-17 16:45:07 +00:00
|
|
|
# This is the class where all the parsing and processing of the Sass
|
|
|
|
# template is done. It can be directly used by the user by creating a
|
|
|
|
# new instance and calling <tt>render</tt> to render the template. For example:
|
|
|
|
#
|
|
|
|
# template = File.load('stylesheets/sassy.sass')
|
|
|
|
# sass_engine = Sass::Engine.new(template)
|
|
|
|
# output = sass_engine.render
|
|
|
|
# puts output
|
2006-11-28 19:43:58 +00:00
|
|
|
class Engine
|
2006-12-04 08:40:23 +00:00
|
|
|
# The character that begins a CSS attribute.
|
2007-01-28 10:14:15 +00:00
|
|
|
ATTRIBUTE_CHAR = ?:
|
2007-05-03 08:46:02 +00:00
|
|
|
|
2006-12-22 06:22:15 +00:00
|
|
|
# The character that designates that
|
|
|
|
# an attribute should be assigned to the result of constant arithmetic.
|
2007-01-28 10:14:15 +00:00
|
|
|
SCRIPT_CHAR = ?=
|
2007-03-17 20:48:29 +00:00
|
|
|
|
|
|
|
# The character that designates the beginning of a comment,
|
|
|
|
# either Sass or CSS.
|
|
|
|
COMMENT_CHAR = ?/
|
|
|
|
|
2007-03-17 23:34:26 +00:00
|
|
|
# The character that follows the general COMMENT_CHAR and designates a Sass comment,
|
2007-03-17 20:48:29 +00:00
|
|
|
# which is not output as a CSS comment.
|
|
|
|
SASS_COMMENT_CHAR = ?/
|
2007-02-28 16:35:37 +00:00
|
|
|
|
2007-03-17 23:34:26 +00:00
|
|
|
# The character that follows the general COMMENT_CHAR and designates a CSS comment,
|
|
|
|
# which is embedded in the CSS document.
|
|
|
|
CSS_COMMENT_CHAR = ?*
|
2007-03-18 21:11:32 +00:00
|
|
|
|
|
|
|
# The character used to denote a compiler directive.
|
|
|
|
DIRECTIVE_CHAR = ?@
|
2007-12-11 10:36:40 +00:00
|
|
|
|
|
|
|
# Designates a non-parsed rule.
|
|
|
|
ESCAPE_CHAR = ?\\
|
2007-05-03 08:46:02 +00:00
|
|
|
|
2007-06-28 08:43:09 +00:00
|
|
|
# The regex that matches and extracts data from
|
|
|
|
# attributes of the form <tt>:name attr</tt>.
|
|
|
|
ATTRIBUTE = /^:([^\s=:]+)\s*(=?)(?:\s+|$)(.*)/
|
2007-05-03 08:46:02 +00:00
|
|
|
|
|
|
|
# The regex that matches attributes of the form <tt>name: attr</tt>.
|
2007-06-28 08:43:09 +00:00
|
|
|
ATTRIBUTE_ALTERNATE_MATCHER = /^[^\s:]+\s*[=:](\s|$)/
|
2007-05-03 08:46:02 +00:00
|
|
|
|
2007-06-28 08:43:09 +00:00
|
|
|
# The regex that matches and extracts data from
|
|
|
|
# attributes of the form <tt>name: attr</tt>.
|
|
|
|
ATTRIBUTE_ALTERNATE = /^([^\s=:]+)(\s*=|:)(?:\s+|$)(.*)/
|
2007-05-03 08:46:02 +00:00
|
|
|
|
2006-12-17 16:45:07 +00:00
|
|
|
# Creates a new instace of Sass::Engine that will compile the given
|
|
|
|
# template string when <tt>render</tt> is called.
|
2008-03-13 01:07:07 -07:00
|
|
|
# See README.rdoc for available options.
|
2006-12-17 16:45:07 +00:00
|
|
|
#
|
|
|
|
#--
|
|
|
|
#
|
2007-02-02 06:15:28 +00:00
|
|
|
# TODO: Add current options to REFRENCE. Remember :filename!
|
2006-12-17 16:45:07 +00:00
|
|
|
#
|
|
|
|
# When adding options, remember to add information about them
|
2008-03-13 01:07:07 -07:00
|
|
|
# to README.rdoc!
|
2006-12-17 16:45:07 +00:00
|
|
|
#++
|
|
|
|
#
|
2006-12-04 02:47:37 +00:00
|
|
|
def initialize(template, options={})
|
2007-02-06 01:58:23 +00:00
|
|
|
@options = {
|
2007-03-18 21:11:32 +00:00
|
|
|
:style => :nested,
|
|
|
|
:load_paths => ['.']
|
2007-02-06 01:58:23 +00:00
|
|
|
}.merge! options
|
2008-01-31 06:21:24 +00:00
|
|
|
@template = template.split(/\n?\r|\r?\n/)
|
2006-12-19 05:22:19 +00:00
|
|
|
@lines = []
|
2007-11-23 14:49:54 +00:00
|
|
|
@constants = {"important" => "!important"}
|
2006-11-28 20:33:22 +00:00
|
|
|
end
|
2007-05-03 08:46:02 +00:00
|
|
|
|
2006-12-17 16:45:07 +00:00
|
|
|
# Processes the template and returns the result as a string.
|
2006-12-04 02:47:37 +00:00
|
|
|
def render
|
2007-01-31 06:38:23 +00:00
|
|
|
begin
|
2007-03-18 21:11:32 +00:00
|
|
|
render_to_tree.to_s
|
2007-01-31 06:38:23 +00:00
|
|
|
rescue SyntaxError => err
|
2007-03-25 04:57:03 +00:00
|
|
|
unless err.sass_filename
|
|
|
|
err.add_backtrace_entry(@options[:filename])
|
|
|
|
end
|
2007-01-31 06:38:23 +00:00
|
|
|
raise err
|
|
|
|
end
|
2006-12-04 08:40:23 +00:00
|
|
|
end
|
2007-02-01 06:59:08 +00:00
|
|
|
|
|
|
|
alias_method :to_css, :render
|
2007-03-18 21:11:32 +00:00
|
|
|
|
|
|
|
protected
|
|
|
|
|
|
|
|
def constants
|
|
|
|
@constants
|
|
|
|
end
|
|
|
|
|
|
|
|
def render_to_tree
|
|
|
|
split_lines
|
2007-05-03 08:46:02 +00:00
|
|
|
|
2007-03-18 21:11:32 +00:00
|
|
|
root = Tree::Node.new(@options[:style])
|
|
|
|
index = 0
|
|
|
|
while @lines[index]
|
|
|
|
child, index = build_tree(index)
|
2007-05-03 08:46:02 +00:00
|
|
|
|
2007-03-18 21:11:32 +00:00
|
|
|
if child.is_a? Tree::Node
|
2007-05-03 08:46:02 +00:00
|
|
|
child.line = index
|
2007-03-18 21:11:32 +00:00
|
|
|
root << child
|
|
|
|
elsif child.is_a? Array
|
|
|
|
child.each do |c|
|
|
|
|
root << c
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
@line = nil
|
|
|
|
|
|
|
|
root
|
|
|
|
end
|
2007-05-03 08:46:02 +00:00
|
|
|
|
2006-12-04 08:40:23 +00:00
|
|
|
private
|
2007-05-03 08:46:02 +00:00
|
|
|
|
2006-12-19 05:22:19 +00:00
|
|
|
# Readies each line in the template for parsing,
|
|
|
|
# and computes the tabulation of the line.
|
|
|
|
def split_lines
|
2007-03-18 21:11:32 +00:00
|
|
|
@line = 0
|
2007-01-31 04:30:30 +00:00
|
|
|
old_tabs = 0
|
2007-01-28 10:14:15 +00:00
|
|
|
@template.each_with_index do |line, index|
|
2007-03-18 21:11:32 +00:00
|
|
|
@line += 1
|
|
|
|
|
2007-03-17 20:48:29 +00:00
|
|
|
tabs = count_tabs(line)
|
2007-05-03 08:46:02 +00:00
|
|
|
|
2007-03-18 21:11:32 +00:00
|
|
|
if line[0] == COMMENT_CHAR && line[1] == SASS_COMMENT_CHAR && tabs == 0
|
2007-03-17 20:48:29 +00:00
|
|
|
tabs = old_tabs
|
|
|
|
end
|
2007-01-31 04:30:30 +00:00
|
|
|
|
2007-03-17 20:48:29 +00:00
|
|
|
if tabs # if line isn't blank
|
|
|
|
if tabs - old_tabs > 1
|
2007-05-03 08:46:02 +00:00
|
|
|
raise SyntaxError.new("Illegal Indentation: Only two space characters are allowed as tabulation.", @line)
|
2006-12-19 05:22:19 +00:00
|
|
|
end
|
2008-03-27 17:18:38 +01:00
|
|
|
line.strip!
|
|
|
|
next_line = @template[index+1]
|
|
|
|
if next_line
|
|
|
|
next_tabs = count_tabs(next_line)
|
|
|
|
if line[-1] == ?, && tabs == next_tabs
|
|
|
|
@template[index+1] = "#{' '*tabs}#{line} #{next_line.strip}"
|
|
|
|
next
|
|
|
|
end
|
|
|
|
end
|
2007-03-17 20:48:29 +00:00
|
|
|
@lines << [line.strip, tabs]
|
2007-05-03 08:46:02 +00:00
|
|
|
|
2007-03-17 20:48:29 +00:00
|
|
|
old_tabs = tabs
|
2007-03-17 23:13:04 +00:00
|
|
|
else
|
|
|
|
@lines << ['//', old_tabs]
|
2006-11-28 19:43:58 +00:00
|
|
|
end
|
|
|
|
end
|
2007-03-17 20:48:29 +00:00
|
|
|
|
2007-01-28 10:14:15 +00:00
|
|
|
@line = nil
|
2006-12-04 08:40:23 +00:00
|
|
|
end
|
2007-05-03 08:46:02 +00:00
|
|
|
|
2006-12-19 05:22:19 +00:00
|
|
|
# Counts the tabulation of a line.
|
|
|
|
def count_tabs(line)
|
|
|
|
spaces = line.index(/[^ ]/)
|
2007-01-28 10:14:15 +00:00
|
|
|
if spaces
|
2007-01-31 04:30:30 +00:00
|
|
|
if spaces % 2 == 1 || line[spaces] == ?\t
|
2007-03-30 06:49:03 +00:00
|
|
|
# Make sure a line with just tabs isn't an error
|
|
|
|
return nil if line.strip.empty?
|
|
|
|
|
2007-05-03 08:46:02 +00:00
|
|
|
raise SyntaxError.new("Illegal Indentation: Only two space characters are allowed as tabulation.", @line)
|
2007-01-28 10:14:15 +00:00
|
|
|
end
|
|
|
|
spaces / 2
|
|
|
|
else
|
|
|
|
nil
|
|
|
|
end
|
2006-12-19 05:22:19 +00:00
|
|
|
end
|
2007-05-03 08:46:02 +00:00
|
|
|
|
2006-12-19 05:22:19 +00:00
|
|
|
def build_tree(index)
|
|
|
|
line, tabs = @lines[index]
|
|
|
|
index += 1
|
2007-02-02 06:15:28 +00:00
|
|
|
@line = index
|
2006-12-19 05:22:19 +00:00
|
|
|
node = parse_line(line)
|
2007-01-28 10:14:15 +00:00
|
|
|
|
2006-12-19 05:22:19 +00:00
|
|
|
has_children = has_children?(index, tabs)
|
2007-03-18 04:20:45 +00:00
|
|
|
|
|
|
|
# Node is a symbol if it's non-outputting, like a constant assignment
|
|
|
|
unless node.is_a? Tree::Node
|
2007-03-18 21:11:32 +00:00
|
|
|
if has_children
|
|
|
|
if node == :constant
|
|
|
|
raise SyntaxError.new("Illegal nesting: Nothing may be nested beneath constants.", @line)
|
|
|
|
elsif node.is_a? Array
|
|
|
|
raise SyntaxError.new("Illegal nesting: Nothing may be nested beneath import directives.", @line)
|
|
|
|
end
|
2007-03-18 04:20:45 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
return node, index
|
|
|
|
end
|
2007-03-18 04:52:16 +00:00
|
|
|
|
|
|
|
if node.is_a? Tree::CommentNode
|
|
|
|
while has_children
|
|
|
|
line, index = raw_next_line(index)
|
|
|
|
node << line
|
|
|
|
|
|
|
|
has_children = has_children?(index, tabs)
|
2007-02-05 00:41:05 +00:00
|
|
|
end
|
2007-03-18 04:52:16 +00:00
|
|
|
else
|
|
|
|
while has_children
|
|
|
|
child, index = build_tree(index)
|
2007-05-03 08:46:02 +00:00
|
|
|
|
2007-03-18 04:52:16 +00:00
|
|
|
if child == :constant
|
|
|
|
raise SyntaxError.new("Constants may only be declared at the root of a document.", @line)
|
2007-03-18 21:11:32 +00:00
|
|
|
elsif child.is_a? Array
|
2007-03-25 08:20:33 +00:00
|
|
|
raise SyntaxError.new("Import directives may only be used at the root of a document.", @line)
|
2007-03-18 04:52:16 +00:00
|
|
|
elsif child.is_a? Tree::Node
|
|
|
|
child.line = @line
|
|
|
|
node << child
|
|
|
|
end
|
2007-02-05 00:41:05 +00:00
|
|
|
|
2007-03-18 04:52:16 +00:00
|
|
|
has_children = has_children?(index, tabs)
|
|
|
|
end
|
2006-12-19 05:22:19 +00:00
|
|
|
end
|
2007-05-03 08:46:02 +00:00
|
|
|
|
2006-12-19 05:22:19 +00:00
|
|
|
return node, index
|
|
|
|
end
|
2007-05-03 08:46:02 +00:00
|
|
|
|
2006-12-19 05:22:19 +00:00
|
|
|
def has_children?(index, tabs)
|
2007-08-16 18:28:57 +00:00
|
|
|
next_line = ['//', 0]
|
|
|
|
while !next_line.nil? && next_line[0] == '//' && next_line[1] = 0
|
|
|
|
next_line = @lines[index]
|
|
|
|
index += 1
|
|
|
|
end
|
2006-12-19 05:22:19 +00:00
|
|
|
next_line && next_line[1] > tabs
|
2006-12-04 08:40:23 +00:00
|
|
|
end
|
2007-03-18 04:52:16 +00:00
|
|
|
|
|
|
|
def raw_next_line(index)
|
|
|
|
[@lines[index][0], index + 1]
|
|
|
|
end
|
2007-05-03 08:46:02 +00:00
|
|
|
|
2006-12-04 08:40:23 +00:00
|
|
|
def parse_line(line)
|
2007-06-28 08:43:09 +00:00
|
|
|
case line[0]
|
|
|
|
when ATTRIBUTE_CHAR
|
2007-05-03 08:46:02 +00:00
|
|
|
parse_attribute(line, ATTRIBUTE)
|
2007-06-28 08:43:09 +00:00
|
|
|
when Constant::CONSTANT_CHAR
|
|
|
|
parse_constant(line)
|
|
|
|
when COMMENT_CHAR
|
|
|
|
parse_comment(line)
|
|
|
|
when DIRECTIVE_CHAR
|
|
|
|
parse_directive(line)
|
2007-12-11 10:36:40 +00:00
|
|
|
when ESCAPE_CHAR
|
|
|
|
Tree::RuleNode.new(line[1..-1], @options[:style])
|
2007-03-17 20:48:29 +00:00
|
|
|
else
|
2007-06-28 08:43:09 +00:00
|
|
|
if line =~ ATTRIBUTE_ALTERNATE_MATCHER
|
|
|
|
parse_attribute(line, ATTRIBUTE_ALTERNATE)
|
2007-05-03 08:46:02 +00:00
|
|
|
else
|
|
|
|
Tree::RuleNode.new(line, @options[:style])
|
|
|
|
end
|
2006-12-22 01:52:45 +00:00
|
|
|
end
|
|
|
|
end
|
2007-05-03 08:46:02 +00:00
|
|
|
|
|
|
|
def parse_attribute(line, attribute_regx)
|
2007-08-11 23:13:43 +00:00
|
|
|
if @options[:attribute_syntax] == :normal &&
|
|
|
|
attribute_regx == ATTRIBUTE_ALTERNATE
|
|
|
|
raise SyntaxError.new("Illegal attribute syntax: can't use alternate syntax when :attribute_syntax => :normal is set.")
|
|
|
|
elsif @options[:attribute_syntax] == :alternate &&
|
|
|
|
attribute_regx == ATTRIBUTE
|
|
|
|
raise SyntaxError.new("Illegal attribute syntax: can't use normal syntax when :attribute_syntax => :alternate is set.")
|
|
|
|
end
|
|
|
|
|
2007-05-03 08:46:02 +00:00
|
|
|
name, eq, value = line.scan(attribute_regx)[0]
|
2007-01-28 10:14:15 +00:00
|
|
|
|
2007-02-28 16:35:37 +00:00
|
|
|
if name.nil? || value.nil?
|
2007-01-28 10:14:15 +00:00
|
|
|
raise SyntaxError.new("Invalid attribute: \"#{line}\"", @line)
|
|
|
|
end
|
2007-05-03 08:46:02 +00:00
|
|
|
|
2007-06-28 08:43:09 +00:00
|
|
|
if eq.strip[0] == SCRIPT_CHAR
|
2007-01-28 10:28:19 +00:00
|
|
|
value = Sass::Constant.parse(value, @constants, @line).to_s
|
2006-12-04 08:40:23 +00:00
|
|
|
end
|
2007-05-03 08:46:02 +00:00
|
|
|
|
2007-02-06 01:58:23 +00:00
|
|
|
Tree::AttrNode.new(name, value, @options[:style])
|
2006-12-22 01:52:45 +00:00
|
|
|
end
|
2007-05-03 08:46:02 +00:00
|
|
|
|
2006-12-22 01:52:45 +00:00
|
|
|
def parse_constant(line)
|
2008-02-29 13:18:52 -08:00
|
|
|
name, op, value = line.scan(Sass::Constant::MATCH)[0]
|
2007-01-28 10:14:15 +00:00
|
|
|
unless name && value
|
2007-01-31 04:30:30 +00:00
|
|
|
raise SyntaxError.new("Invalid constant: \"#{line}\"", @line)
|
2007-01-28 10:14:15 +00:00
|
|
|
end
|
2008-02-29 13:18:52 -08:00
|
|
|
|
|
|
|
constant = Sass::Constant.parse(value, @constants, @line)
|
|
|
|
if op == '||='
|
|
|
|
@constants[name] ||= constant
|
|
|
|
else
|
|
|
|
@constants[name] = constant
|
|
|
|
end
|
|
|
|
|
2007-03-17 20:48:29 +00:00
|
|
|
:constant
|
|
|
|
end
|
|
|
|
|
|
|
|
def parse_comment(line)
|
|
|
|
if line[1] == SASS_COMMENT_CHAR
|
|
|
|
:comment
|
2007-03-17 23:34:26 +00:00
|
|
|
elsif line[1] == CSS_COMMENT_CHAR
|
|
|
|
Tree::CommentNode.new(line, @options[:style])
|
2007-03-17 20:48:29 +00:00
|
|
|
else
|
|
|
|
Tree::RuleNode.new(line, @options[:style])
|
|
|
|
end
|
2006-12-04 08:40:23 +00:00
|
|
|
end
|
2007-03-18 21:11:32 +00:00
|
|
|
|
|
|
|
def parse_directive(line)
|
|
|
|
directive, value = line[1..-1].split(/\s+/, 2)
|
|
|
|
|
2008-02-29 22:38:01 -08:00
|
|
|
# If value begins with url( or ",
|
|
|
|
# it's a CSS @import rule and we don't want to touch it.
|
|
|
|
if directive == "import" && value !~ /^(url\(|")/
|
2007-03-18 21:11:32 +00:00
|
|
|
import(value)
|
|
|
|
else
|
2007-08-12 10:54:35 +00:00
|
|
|
Tree::DirectiveNode.new(line, @options[:style])
|
2007-03-18 21:11:32 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def import(files)
|
|
|
|
nodes = []
|
|
|
|
|
|
|
|
files.split(/,\s*/).each do |filename|
|
|
|
|
engine = nil
|
2007-09-02 01:48:25 +00:00
|
|
|
|
|
|
|
begin
|
|
|
|
filename = self.class.find_file_to_import(filename, @options[:load_paths])
|
|
|
|
rescue Exception => e
|
|
|
|
raise SyntaxError.new(e.message, @line)
|
|
|
|
end
|
|
|
|
|
2007-03-25 04:34:55 +00:00
|
|
|
if filename =~ /\.css$/
|
2007-11-18 00:36:39 +00:00
|
|
|
nodes << Tree::ValueNode.new("@import url(#{filename});", @options[:style])
|
2007-03-25 04:34:55 +00:00
|
|
|
else
|
|
|
|
File.open(filename) do |file|
|
2007-03-25 04:57:03 +00:00
|
|
|
new_options = @options.dup
|
|
|
|
new_options[:filename] = filename
|
2007-03-25 04:34:55 +00:00
|
|
|
engine = Sass::Engine.new(file.read, @options)
|
|
|
|
end
|
2007-03-18 21:11:32 +00:00
|
|
|
|
2007-03-25 08:20:33 +00:00
|
|
|
engine.constants.merge! @constants
|
|
|
|
|
2007-03-25 04:57:03 +00:00
|
|
|
begin
|
|
|
|
root = engine.render_to_tree
|
|
|
|
rescue Sass::SyntaxError => err
|
|
|
|
err.add_backtrace_entry(filename)
|
|
|
|
raise err
|
|
|
|
end
|
|
|
|
root.children.each do |child|
|
|
|
|
child.filename = filename
|
|
|
|
nodes << child
|
|
|
|
end
|
2007-03-25 08:20:33 +00:00
|
|
|
@constants = engine.constants
|
2007-03-25 04:34:55 +00:00
|
|
|
end
|
2007-03-18 21:11:32 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
nodes
|
|
|
|
end
|
|
|
|
|
2007-09-02 01:48:25 +00:00
|
|
|
def self.find_file_to_import(filename, load_paths)
|
2007-03-25 08:20:33 +00:00
|
|
|
was_sass = false
|
|
|
|
original_filename = filename
|
2007-03-18 21:11:32 +00:00
|
|
|
|
2007-03-25 08:20:33 +00:00
|
|
|
if filename[-5..-1] == ".sass"
|
|
|
|
filename = filename[0...-5]
|
|
|
|
was_sass = true
|
|
|
|
elsif filename[-4..-1] == ".css"
|
|
|
|
return filename
|
|
|
|
end
|
2007-03-18 21:11:32 +00:00
|
|
|
|
2007-09-02 01:48:25 +00:00
|
|
|
new_filename = find_full_path("#{filename}.sass", load_paths)
|
2007-03-18 21:11:32 +00:00
|
|
|
|
2007-03-25 08:20:33 +00:00
|
|
|
if new_filename.nil?
|
|
|
|
if was_sass
|
2007-09-02 01:48:25 +00:00
|
|
|
raise Exception.new("File to import not found or unreadable: #{original_filename}")
|
2007-03-25 08:20:33 +00:00
|
|
|
else
|
|
|
|
return filename + '.css'
|
|
|
|
end
|
|
|
|
else
|
|
|
|
new_filename
|
2007-03-18 21:11:32 +00:00
|
|
|
end
|
|
|
|
end
|
2007-08-28 05:33:57 +00:00
|
|
|
|
2007-09-02 01:48:25 +00:00
|
|
|
def self.find_full_path(filename, load_paths)
|
|
|
|
load_paths.each do |path|
|
2007-08-28 05:33:57 +00:00
|
|
|
["_#{filename}", filename].each do |name|
|
|
|
|
full_path = File.join(path, name)
|
|
|
|
if File.readable?(full_path)
|
|
|
|
return full_path
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
nil
|
|
|
|
end
|
2006-11-28 19:43:58 +00:00
|
|
|
end
|
|
|
|
end
|