id int32 0 24.9k | repo stringlengths 5 58 | path stringlengths 9 168 | func_name stringlengths 9 130 | original_string stringlengths 66 10.5k | language stringclasses 1
value | code stringlengths 66 10.5k | code_tokens list | docstring stringlengths 8 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 94 266 |
|---|---|---|---|---|---|---|---|---|---|---|---|
15,000 | sass/ruby-sass | lib/sass/script/tree/funcall.rb | Sass::Script::Tree.Funcall._perform | def _perform(environment)
args = @args.each_with_index.
map {|a, i| perform_arg(a, environment, signature && signature.args[i])}
keywords = Sass::Util.map_hash(@keywords) do |k, v|
[k, perform_arg(v, environment, k.tr('-', '_'))]
end
splat = Sass::Tree::Visitors::Perform.perform_... | ruby | def _perform(environment)
args = @args.each_with_index.
map {|a, i| perform_arg(a, environment, signature && signature.args[i])}
keywords = Sass::Util.map_hash(@keywords) do |k, v|
[k, perform_arg(v, environment, k.tr('-', '_'))]
end
splat = Sass::Tree::Visitors::Perform.perform_... | [
"def",
"_perform",
"(",
"environment",
")",
"args",
"=",
"@args",
".",
"each_with_index",
".",
"map",
"{",
"|",
"a",
",",
"i",
"|",
"perform_arg",
"(",
"a",
",",
"environment",
",",
"signature",
"&&",
"signature",
".",
"args",
"[",
"i",
"]",
")",
"}"... | Evaluates the function call.
@param environment [Sass::Environment] The environment in which to evaluate the SassScript
@return [Sass::Script::Value] The SassScript object that is the value of the function call
@raise [Sass::SyntaxError] if the function call raises an ArgumentError | [
"Evaluates",
"the",
"function",
"call",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/script/tree/funcall.rb#L127-L159 |
15,001 | sass/ruby-sass | lib/sass/environment.rb | Sass.ReadOnlyEnvironment.caller | def caller
return @caller if @caller
env = super
@caller ||= env.is_a?(ReadOnlyEnvironment) ? env : ReadOnlyEnvironment.new(env, env.options)
end | ruby | def caller
return @caller if @caller
env = super
@caller ||= env.is_a?(ReadOnlyEnvironment) ? env : ReadOnlyEnvironment.new(env, env.options)
end | [
"def",
"caller",
"return",
"@caller",
"if",
"@caller",
"env",
"=",
"super",
"@caller",
"||=",
"env",
".",
"is_a?",
"(",
"ReadOnlyEnvironment",
")",
"?",
"env",
":",
"ReadOnlyEnvironment",
".",
"new",
"(",
"env",
",",
"env",
".",
"options",
")",
"end"
] | The read-only environment of the caller of this environment's mixin or function.
@see BaseEnvironment#caller
@return {ReadOnlyEnvironment} | [
"The",
"read",
"-",
"only",
"environment",
"of",
"the",
"caller",
"of",
"this",
"environment",
"s",
"mixin",
"or",
"function",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/environment.rb#L186-L190 |
15,002 | sass/ruby-sass | lib/sass/environment.rb | Sass.ReadOnlyEnvironment.content | def content
# Return the cached content from a previous invocation if any
return @content if @content_cached
# get the content with a read-write environment from the superclass
read_write_content = super
if read_write_content
tree, env = read_write_content
# make the conten... | ruby | def content
# Return the cached content from a previous invocation if any
return @content if @content_cached
# get the content with a read-write environment from the superclass
read_write_content = super
if read_write_content
tree, env = read_write_content
# make the conten... | [
"def",
"content",
"# Return the cached content from a previous invocation if any",
"return",
"@content",
"if",
"@content_cached",
"# get the content with a read-write environment from the superclass",
"read_write_content",
"=",
"super",
"if",
"read_write_content",
"tree",
",",
"env",
... | The content passed to this environment. If the content's environment isn't already
read-only, it's made read-only.
@see BaseEnvironment#content
@return {[Array<Sass::Tree::Node>, ReadOnlyEnvironment]?} The content nodes and
the lexical environment of the content block.
Returns `nil` when there is no content ... | [
"The",
"content",
"passed",
"to",
"this",
"environment",
".",
"If",
"the",
"content",
"s",
"environment",
"isn",
"t",
"already",
"read",
"-",
"only",
"it",
"s",
"made",
"read",
"-",
"only",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/environment.rb#L200-L217 |
15,003 | sass/ruby-sass | lib/sass/script/tree/interpolation.rb | Sass::Script::Tree.Interpolation.to_string_interpolation | def to_string_interpolation(node_or_interp)
unless node_or_interp.is_a?(Interpolation)
node = node_or_interp
return string_literal(node.value.to_s) if node.is_a?(Literal)
if node.is_a?(StringInterpolation)
return concat(string_literal(node.quote), concat(node, string_literal(node... | ruby | def to_string_interpolation(node_or_interp)
unless node_or_interp.is_a?(Interpolation)
node = node_or_interp
return string_literal(node.value.to_s) if node.is_a?(Literal)
if node.is_a?(StringInterpolation)
return concat(string_literal(node.quote), concat(node, string_literal(node... | [
"def",
"to_string_interpolation",
"(",
"node_or_interp",
")",
"unless",
"node_or_interp",
".",
"is_a?",
"(",
"Interpolation",
")",
"node",
"=",
"node_or_interp",
"return",
"string_literal",
"(",
"node",
".",
"value",
".",
"to_s",
")",
"if",
"node",
".",
"is_a?",... | Converts a script node into a corresponding string interpolation
expression.
@param node_or_interp [Sass::Script::Tree::Node]
@return [Sass::Script::Tree::StringInterpolation] | [
"Converts",
"a",
"script",
"node",
"into",
"a",
"corresponding",
"string",
"interpolation",
"expression",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/script/tree/interpolation.rb#L119-L153 |
15,004 | sass/ruby-sass | lib/sass/script/tree/interpolation.rb | Sass::Script::Tree.Interpolation.concat | def concat(string_or_interp1, string_or_interp2)
if string_or_interp1.is_a?(Literal) && string_or_interp2.is_a?(Literal)
return string_literal(string_or_interp1.value.value + string_or_interp2.value.value)
end
if string_or_interp1.is_a?(Literal)
string = string_or_interp1
inte... | ruby | def concat(string_or_interp1, string_or_interp2)
if string_or_interp1.is_a?(Literal) && string_or_interp2.is_a?(Literal)
return string_literal(string_or_interp1.value.value + string_or_interp2.value.value)
end
if string_or_interp1.is_a?(Literal)
string = string_or_interp1
inte... | [
"def",
"concat",
"(",
"string_or_interp1",
",",
"string_or_interp2",
")",
"if",
"string_or_interp1",
".",
"is_a?",
"(",
"Literal",
")",
"&&",
"string_or_interp2",
".",
"is_a?",
"(",
"Literal",
")",
"return",
"string_literal",
"(",
"string_or_interp1",
".",
"value"... | Concatenates two string literals or string interpolation expressions.
@param string_or_interp1 [Sass::Script::Tree::Literal|Sass::Script::Tree::StringInterpolation]
@param string_or_interp2 [Sass::Script::Tree::Literal|Sass::Script::Tree::StringInterpolation]
@return [Sass::Script::Tree::StringInterpolation] | [
"Concatenates",
"two",
"string",
"literals",
"or",
"string",
"interpolation",
"expressions",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/script/tree/interpolation.rb#L194-L210 |
15,005 | sass/ruby-sass | lib/sass/script/tree/interpolation.rb | Sass::Script::Tree.Interpolation.string_literal | def string_literal(string)
Literal.new(Sass::Script::Value::String.new(string, :string))
end | ruby | def string_literal(string)
Literal.new(Sass::Script::Value::String.new(string, :string))
end | [
"def",
"string_literal",
"(",
"string",
")",
"Literal",
".",
"new",
"(",
"Sass",
"::",
"Script",
"::",
"Value",
"::",
"String",
".",
"new",
"(",
"string",
",",
":string",
")",
")",
"end"
] | Returns a string literal with the given contents.
@param string [String]
@return string [Sass::Script::Tree::Literal] | [
"Returns",
"a",
"string",
"literal",
"with",
"the",
"given",
"contents",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/script/tree/interpolation.rb#L216-L218 |
15,006 | sass/ruby-sass | lib/sass/exec/sass_scss.rb | Sass::Exec.SassScss.process_result | def process_result
require 'sass'
if !@options[:update] && !@options[:watch] &&
@args.first && colon_path?(@args.first)
if @args.size == 1
@args = split_colon_path(@args.first)
else
@fake_update = true
@options[:update] = true
end
end
... | ruby | def process_result
require 'sass'
if !@options[:update] && !@options[:watch] &&
@args.first && colon_path?(@args.first)
if @args.size == 1
@args = split_colon_path(@args.first)
else
@fake_update = true
@options[:update] = true
end
end
... | [
"def",
"process_result",
"require",
"'sass'",
"if",
"!",
"@options",
"[",
":update",
"]",
"&&",
"!",
"@options",
"[",
":watch",
"]",
"&&",
"@args",
".",
"first",
"&&",
"colon_path?",
"(",
"@args",
".",
"first",
")",
"if",
"@args",
".",
"size",
"==",
"1... | Processes the options set by the command-line arguments,
and runs the Sass compiler appropriately. | [
"Processes",
"the",
"options",
"set",
"by",
"the",
"command",
"-",
"line",
"arguments",
"and",
"runs",
"the",
"Sass",
"compiler",
"appropriately",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/exec/sass_scss.rb#L37-L64 |
15,007 | sass/ruby-sass | lib/sass/deprecation.rb | Sass.Deprecation.warn | def warn(filename, line, column_or_message, message = nil)
return if !@@allow_double_warnings && @seen.add?([filename, line]).nil?
if message
column = column_or_message
else
message = column_or_message
end
location = "line #{line}"
location << ", column #{column}" if... | ruby | def warn(filename, line, column_or_message, message = nil)
return if !@@allow_double_warnings && @seen.add?([filename, line]).nil?
if message
column = column_or_message
else
message = column_or_message
end
location = "line #{line}"
location << ", column #{column}" if... | [
"def",
"warn",
"(",
"filename",
",",
"line",
",",
"column_or_message",
",",
"message",
"=",
"nil",
")",
"return",
"if",
"!",
"@@allow_double_warnings",
"&&",
"@seen",
".",
"add?",
"(",
"[",
"filename",
",",
"line",
"]",
")",
".",
"nil?",
"if",
"message",... | Prints `message` as a deprecation warning associated with `filename`,
`line`, and optionally `column`.
This ensures that only one message will be printed for each line of a
given file.
@overload warn(filename, line, message)
@param filename [String, nil]
@param line [Number]
@param message [String]
@ove... | [
"Prints",
"message",
"as",
"a",
"deprecation",
"warning",
"associated",
"with",
"filename",
"line",
"and",
"optionally",
"column",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/deprecation.rb#L40-L53 |
15,008 | sass/ruby-sass | lib/sass/plugin/compiler.rb | Sass::Plugin.Compiler.update_stylesheets | def update_stylesheets(individual_files = [])
Sass::Plugin.checked_for_updates = true
staleness_checker = StalenessChecker.new(engine_options)
files = file_list(individual_files)
run_updating_stylesheets(files)
updated_stylesheets = []
files.each do |file, css, sourcemap|
#... | ruby | def update_stylesheets(individual_files = [])
Sass::Plugin.checked_for_updates = true
staleness_checker = StalenessChecker.new(engine_options)
files = file_list(individual_files)
run_updating_stylesheets(files)
updated_stylesheets = []
files.each do |file, css, sourcemap|
#... | [
"def",
"update_stylesheets",
"(",
"individual_files",
"=",
"[",
"]",
")",
"Sass",
"::",
"Plugin",
".",
"checked_for_updates",
"=",
"true",
"staleness_checker",
"=",
"StalenessChecker",
".",
"new",
"(",
"engine_options",
")",
"files",
"=",
"file_list",
"(",
"indi... | Updates out-of-date stylesheets.
Checks each Sass/SCSS file in
{file:SASS_REFERENCE.md#template_location-option `:template_location`}
to see if it's been modified more recently than the corresponding CSS file
in {file:SASS_REFERENCE.md#css_location-option `:css_location`}.
If it has, it updates the CSS file.
@p... | [
"Updates",
"out",
"-",
"of",
"-",
"date",
"stylesheets",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/plugin/compiler.rb#L201-L221 |
15,009 | sass/ruby-sass | lib/sass/plugin/compiler.rb | Sass::Plugin.Compiler.file_list | def file_list(individual_files = [])
files = individual_files.map do |tuple|
if engine_options[:sourcemap] == :none
tuple[0..1]
elsif tuple.size < 3
[tuple[0], tuple[1], Sass::Util.sourcemap_name(tuple[1])]
else
tuple.dup
end
end
template_... | ruby | def file_list(individual_files = [])
files = individual_files.map do |tuple|
if engine_options[:sourcemap] == :none
tuple[0..1]
elsif tuple.size < 3
[tuple[0], tuple[1], Sass::Util.sourcemap_name(tuple[1])]
else
tuple.dup
end
end
template_... | [
"def",
"file_list",
"(",
"individual_files",
"=",
"[",
"]",
")",
"files",
"=",
"individual_files",
".",
"map",
"do",
"|",
"tuple",
"|",
"if",
"engine_options",
"[",
":sourcemap",
"]",
"==",
":none",
"tuple",
"[",
"0",
"..",
"1",
"]",
"elsif",
"tuple",
... | Construct a list of files that might need to be compiled
from the provided individual_files and the template_locations.
Note: this method does not cache the results as they can change
across invocations when sass files are added or removed.
@param individual_files [Array<(String, String[, String])>]
A list of ... | [
"Construct",
"a",
"list",
"of",
"files",
"that",
"might",
"need",
"to",
"be",
"compiled",
"from",
"the",
"provided",
"individual_files",
"and",
"the",
"template_locations",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/plugin/compiler.rb#L240-L261 |
15,010 | sass/ruby-sass | lib/sass/plugin/compiler.rb | Sass::Plugin.Compiler.clean | def clean(individual_files = [])
file_list(individual_files).each do |(_, css_file, sourcemap_file)|
if File.exist?(css_file)
run_deleting_css css_file
File.delete(css_file)
end
if sourcemap_file && File.exist?(sourcemap_file)
run_deleting_sourcemap sourcemap_... | ruby | def clean(individual_files = [])
file_list(individual_files).each do |(_, css_file, sourcemap_file)|
if File.exist?(css_file)
run_deleting_css css_file
File.delete(css_file)
end
if sourcemap_file && File.exist?(sourcemap_file)
run_deleting_sourcemap sourcemap_... | [
"def",
"clean",
"(",
"individual_files",
"=",
"[",
"]",
")",
"file_list",
"(",
"individual_files",
")",
".",
"each",
"do",
"|",
"(",
"_",
",",
"css_file",
",",
"sourcemap_file",
")",
"|",
"if",
"File",
".",
"exist?",
"(",
"css_file",
")",
"run_deleting_c... | Remove all output files that would be created by calling update_stylesheets, if they exist.
This method runs the deleting_css and deleting_sourcemap callbacks for
the files that are deleted.
@param individual_files [Array<(String, String[, String])>]
A list of files to check for updates
**in addition to thos... | [
"Remove",
"all",
"output",
"files",
"that",
"would",
"be",
"created",
"by",
"calling",
"update_stylesheets",
"if",
"they",
"exist",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/plugin/compiler.rb#L362-L374 |
15,011 | sass/ruby-sass | lib/sass/script/value/color.rb | Sass::Script::Value.Color.with | def with(attrs)
attrs = attrs.reject {|_k, v| v.nil?}
hsl = !([:hue, :saturation, :lightness] & attrs.keys).empty?
rgb = !([:red, :green, :blue] & attrs.keys).empty?
if hsl && rgb
raise ArgumentError.new("Cannot specify HSL and RGB values for a color at the same time")
end
i... | ruby | def with(attrs)
attrs = attrs.reject {|_k, v| v.nil?}
hsl = !([:hue, :saturation, :lightness] & attrs.keys).empty?
rgb = !([:red, :green, :blue] & attrs.keys).empty?
if hsl && rgb
raise ArgumentError.new("Cannot specify HSL and RGB values for a color at the same time")
end
i... | [
"def",
"with",
"(",
"attrs",
")",
"attrs",
"=",
"attrs",
".",
"reject",
"{",
"|",
"_k",
",",
"v",
"|",
"v",
".",
"nil?",
"}",
"hsl",
"=",
"!",
"(",
"[",
":hue",
",",
":saturation",
",",
":lightness",
"]",
"&",
"attrs",
".",
"keys",
")",
".",
... | Returns a copy of this color with one or more channels changed.
RGB or HSL colors may be changed, but not both at once.
For example:
Color.new([10, 20, 30]).with(:blue => 40)
#=> rgb(10, 40, 30)
Color.new([126, 126, 126]).with(:red => 0, :green => 255)
#=> rgb(0, 255, 126)
Color.new([25... | [
"Returns",
"a",
"copy",
"of",
"this",
"color",
"with",
"one",
"or",
"more",
"channels",
"changed",
".",
"RGB",
"or",
"HSL",
"colors",
"may",
"be",
"changed",
"but",
"not",
"both",
"at",
"once",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/script/value/color.rb#L426-L446 |
15,012 | sass/ruby-sass | lib/sass/script/value/color.rb | Sass::Script::Value.Color.to_s | def to_s(opts = {})
return smallest if options[:style] == :compressed
return representation if representation
# IE10 doesn't properly support the color name "transparent", so we emit
# generated transparent colors as rgba(0, 0, 0, 0) in favor of that. See
# #1782.
return rgba_str if... | ruby | def to_s(opts = {})
return smallest if options[:style] == :compressed
return representation if representation
# IE10 doesn't properly support the color name "transparent", so we emit
# generated transparent colors as rgba(0, 0, 0, 0) in favor of that. See
# #1782.
return rgba_str if... | [
"def",
"to_s",
"(",
"opts",
"=",
"{",
"}",
")",
"return",
"smallest",
"if",
"options",
"[",
":style",
"]",
"==",
":compressed",
"return",
"representation",
"if",
"representation",
"# IE10 doesn't properly support the color name \"transparent\", so we emit",
"# generated t... | Returns a string representation of the color.
This is usually the color's hex value,
but if the color has a name that's used instead.
@return [String] The string representation | [
"Returns",
"a",
"string",
"representation",
"of",
"the",
"color",
".",
"This",
"is",
"usually",
"the",
"color",
"s",
"hex",
"value",
"but",
"if",
"the",
"color",
"has",
"a",
"name",
"that",
"s",
"used",
"instead",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/script/value/color.rb#L564-L574 |
15,013 | sass/ruby-sass | lib/sass/source/map.rb | Sass::Source.Map.shift_output_lines | def shift_output_lines(delta)
return if delta == 0
@data.each do |m|
m.output.start_pos.line += delta
m.output.end_pos.line += delta
end
end | ruby | def shift_output_lines(delta)
return if delta == 0
@data.each do |m|
m.output.start_pos.line += delta
m.output.end_pos.line += delta
end
end | [
"def",
"shift_output_lines",
"(",
"delta",
")",
"return",
"if",
"delta",
"==",
"0",
"@data",
".",
"each",
"do",
"|",
"m",
"|",
"m",
".",
"output",
".",
"start_pos",
".",
"line",
"+=",
"delta",
"m",
".",
"output",
".",
"end_pos",
".",
"line",
"+=",
... | Shifts all output source ranges forward one or more lines.
@param delta [Integer] The number of lines to shift the ranges forward. | [
"Shifts",
"all",
"output",
"source",
"ranges",
"forward",
"one",
"or",
"more",
"lines",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/source/map.rb#L41-L47 |
15,014 | sass/ruby-sass | lib/sass/source/map.rb | Sass::Source.Map.shift_output_offsets | def shift_output_offsets(delta)
return if delta == 0
@data.each do |m|
break if m.output.start_pos.line > 1
m.output.start_pos.offset += delta
m.output.end_pos.offset += delta if m.output.end_pos.line > 1
end
end | ruby | def shift_output_offsets(delta)
return if delta == 0
@data.each do |m|
break if m.output.start_pos.line > 1
m.output.start_pos.offset += delta
m.output.end_pos.offset += delta if m.output.end_pos.line > 1
end
end | [
"def",
"shift_output_offsets",
"(",
"delta",
")",
"return",
"if",
"delta",
"==",
"0",
"@data",
".",
"each",
"do",
"|",
"m",
"|",
"break",
"if",
"m",
".",
"output",
".",
"start_pos",
".",
"line",
">",
"1",
"m",
".",
"output",
".",
"start_pos",
".",
... | Shifts any output source ranges that lie on the first line forward one or
more characters on that line.
@param delta [Integer] The number of characters to shift the ranges
forward. | [
"Shifts",
"any",
"output",
"source",
"ranges",
"that",
"lie",
"on",
"the",
"first",
"line",
"forward",
"one",
"or",
"more",
"characters",
"on",
"that",
"line",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/source/map.rb#L54-L61 |
15,015 | sass/ruby-sass | lib/sass/tree/comment_node.rb | Sass::Tree.CommentNode.lines | def lines
@value.inject(0) do |s, e|
next s + e.count("\n") if e.is_a?(String)
next s
end
end | ruby | def lines
@value.inject(0) do |s, e|
next s + e.count("\n") if e.is_a?(String)
next s
end
end | [
"def",
"lines",
"@value",
".",
"inject",
"(",
"0",
")",
"do",
"|",
"s",
",",
"e",
"|",
"next",
"s",
"+",
"e",
".",
"count",
"(",
"\"\\n\"",
")",
"if",
"e",
".",
"is_a?",
"(",
"String",
")",
"next",
"s",
"end",
"end"
] | Returns the number of lines in the comment.
@return [Integer] | [
"Returns",
"the",
"number",
"of",
"lines",
"in",
"the",
"comment",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/tree/comment_node.rb#L63-L68 |
15,016 | sass/ruby-sass | lib/sass/plugin.rb | Sass.Plugin.force_update_stylesheets | def force_update_stylesheets(individual_files = [])
Compiler.new(
options.dup.merge(
:never_update => false,
:always_update => true,
:cache => false)).update_stylesheets(individual_files)
end | ruby | def force_update_stylesheets(individual_files = [])
Compiler.new(
options.dup.merge(
:never_update => false,
:always_update => true,
:cache => false)).update_stylesheets(individual_files)
end | [
"def",
"force_update_stylesheets",
"(",
"individual_files",
"=",
"[",
"]",
")",
"Compiler",
".",
"new",
"(",
"options",
".",
"dup",
".",
"merge",
"(",
":never_update",
"=>",
"false",
",",
":always_update",
"=>",
"true",
",",
":cache",
"=>",
"false",
")",
"... | Updates all stylesheets, even those that aren't out-of-date.
Ignores the cache.
@param individual_files [Array<(String, String)>]
A list of files to check for updates
**in addition to those specified by the
{file:SASS_REFERENCE.md#template_location-option `:template_location` option}.**
The first string ... | [
"Updates",
"all",
"stylesheets",
"even",
"those",
"that",
"aren",
"t",
"out",
"-",
"of",
"-",
"date",
".",
"Ignores",
"the",
"cache",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/plugin.rb#L95-L101 |
15,017 | sass/ruby-sass | lib/sass/script/functions.rb | Sass::Script.Functions.ie_hex_str | def ie_hex_str(color)
assert_type color, :Color, :color
alpha = Sass::Util.round(color.alpha * 255).to_s(16).rjust(2, '0')
identifier("##{alpha}#{color.send(:hex_str)[1..-1]}".upcase)
end | ruby | def ie_hex_str(color)
assert_type color, :Color, :color
alpha = Sass::Util.round(color.alpha * 255).to_s(16).rjust(2, '0')
identifier("##{alpha}#{color.send(:hex_str)[1..-1]}".upcase)
end | [
"def",
"ie_hex_str",
"(",
"color",
")",
"assert_type",
"color",
",",
":Color",
",",
":color",
"alpha",
"=",
"Sass",
"::",
"Util",
".",
"round",
"(",
"color",
".",
"alpha",
"*",
"255",
")",
".",
"to_s",
"(",
"16",
")",
".",
"rjust",
"(",
"2",
",",
... | Converts a color into the format understood by IE filters.
@example
ie-hex-str(#abc) => #FFAABBCC
ie-hex-str(#3322BB) => #FF3322BB
ie-hex-str(rgba(0, 255, 0, 0.5)) => #8000FF00
@overload ie_hex_str($color)
@param $color [Sass::Script::Value::Color]
@return [Sass::Script::Value::String] The IE-formatted ... | [
"Converts",
"a",
"color",
"into",
"the",
"format",
"understood",
"by",
"IE",
"filters",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/script/functions.rb#L1155-L1159 |
15,018 | sass/ruby-sass | lib/sass/script/functions.rb | Sass::Script.Functions.adjust_color | def adjust_color(color, kwargs)
assert_type color, :Color, :color
with = Sass::Util.map_hash(
"red" => [-255..255, ""],
"green" => [-255..255, ""],
"blue" => [-255..255, ""],
"hue" => nil,
"saturation" => [-100..100, "%"],
"lightness" => [-100..100, "%"],
... | ruby | def adjust_color(color, kwargs)
assert_type color, :Color, :color
with = Sass::Util.map_hash(
"red" => [-255..255, ""],
"green" => [-255..255, ""],
"blue" => [-255..255, ""],
"hue" => nil,
"saturation" => [-100..100, "%"],
"lightness" => [-100..100, "%"],
... | [
"def",
"adjust_color",
"(",
"color",
",",
"kwargs",
")",
"assert_type",
"color",
",",
":Color",
",",
":color",
"with",
"=",
"Sass",
"::",
"Util",
".",
"map_hash",
"(",
"\"red\"",
"=>",
"[",
"-",
"255",
"..",
"255",
",",
"\"\"",
"]",
",",
"\"green\"",
... | Increases or decreases one or more properties of a color. This can change
the red, green, blue, hue, saturation, value, and alpha properties. The
properties are specified as keyword arguments, and are added to or
subtracted from the color's current value for that property.
All properties are optional. You can't sp... | [
"Increases",
"or",
"decreases",
"one",
"or",
"more",
"properties",
"of",
"a",
"color",
".",
"This",
"can",
"change",
"the",
"red",
"green",
"blue",
"hue",
"saturation",
"value",
"and",
"alpha",
"properties",
".",
"The",
"properties",
"are",
"specified",
"as"... | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/script/functions.rb#L1195-L1221 |
15,019 | sass/ruby-sass | lib/sass/script/functions.rb | Sass::Script.Functions.change_color | def change_color(color, kwargs)
assert_type color, :Color, :color
with = Sass::Util.map_hash(
'red' => ['Red value', 0..255],
'green' => ['Green value', 0..255],
'blue' => ['Blue value', 0..255],
'hue' => [],
'saturation' => ['Saturation', 0..100, '%'],
'light... | ruby | def change_color(color, kwargs)
assert_type color, :Color, :color
with = Sass::Util.map_hash(
'red' => ['Red value', 0..255],
'green' => ['Green value', 0..255],
'blue' => ['Blue value', 0..255],
'hue' => [],
'saturation' => ['Saturation', 0..100, '%'],
'light... | [
"def",
"change_color",
"(",
"color",
",",
"kwargs",
")",
"assert_type",
"color",
",",
":Color",
",",
":color",
"with",
"=",
"Sass",
"::",
"Util",
".",
"map_hash",
"(",
"'red'",
"=>",
"[",
"'Red value'",
",",
"0",
"..",
"255",
"]",
",",
"'green'",
"=>",... | Changes one or more properties of a color. This can change the red, green,
blue, hue, saturation, value, and alpha properties. The properties are
specified as keyword arguments, and replace the color's current value for
that property.
All properties are optional. You can't specify both RGB properties
(`$red`, `$g... | [
"Changes",
"one",
"or",
"more",
"properties",
"of",
"a",
"color",
".",
"This",
"can",
"change",
"the",
"red",
"green",
"blue",
"hue",
"saturation",
"value",
"and",
"alpha",
"properties",
".",
"The",
"properties",
"are",
"specified",
"as",
"keyword",
"argumen... | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/script/functions.rb#L1327-L1357 |
15,020 | sass/ruby-sass | lib/sass/script/functions.rb | Sass::Script.Functions.mix | def mix(color1, color2, weight = number(50))
assert_type color1, :Color, :color1
assert_type color2, :Color, :color2
assert_type weight, :Number, :weight
Sass::Util.check_range("Weight", 0..100, weight, '%')
# This algorithm factors in both the user-provided weight (w) and the
# di... | ruby | def mix(color1, color2, weight = number(50))
assert_type color1, :Color, :color1
assert_type color2, :Color, :color2
assert_type weight, :Number, :weight
Sass::Util.check_range("Weight", 0..100, weight, '%')
# This algorithm factors in both the user-provided weight (w) and the
# di... | [
"def",
"mix",
"(",
"color1",
",",
"color2",
",",
"weight",
"=",
"number",
"(",
"50",
")",
")",
"assert_type",
"color1",
",",
":Color",
",",
":color1",
"assert_type",
"color2",
",",
":Color",
",",
":color2",
"assert_type",
"weight",
",",
":Number",
",",
"... | Mixes two colors together. Specifically, takes the average of each of the
RGB components, optionally weighted by the given percentage. The opacity
of the colors is also considered when weighting the components.
The weight specifies the amount of the first color that should be included
in the returned color. The de... | [
"Mixes",
"two",
"colors",
"together",
".",
"Specifically",
"takes",
"the",
"average",
"of",
"each",
"of",
"the",
"RGB",
"components",
"optionally",
"weighted",
"by",
"the",
"given",
"percentage",
".",
"The",
"opacity",
"of",
"the",
"colors",
"is",
"also",
"c... | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/script/functions.rb#L1382-L1418 |
15,021 | sass/ruby-sass | lib/sass/script/functions.rb | Sass::Script.Functions.quote | def quote(string)
assert_type string, :String, :string
if string.type != :string
quoted_string(string.value)
else
string
end
end | ruby | def quote(string)
assert_type string, :String, :string
if string.type != :string
quoted_string(string.value)
else
string
end
end | [
"def",
"quote",
"(",
"string",
")",
"assert_type",
"string",
",",
":String",
",",
":string",
"if",
"string",
".",
"type",
"!=",
":string",
"quoted_string",
"(",
"string",
".",
"value",
")",
"else",
"string",
"end",
"end"
] | Add quotes to a string if the string isn't quoted,
or returns the same string if it is.
@see #unquote
@example
quote("foo") => "foo"
quote(foo) => "foo"
@overload quote($string)
@param $string [Sass::Script::Value::String]
@return [Sass::Script::Value::String]
@raise [ArgumentError] if `$string` isn't a... | [
"Add",
"quotes",
"to",
"a",
"string",
"if",
"the",
"string",
"isn",
"t",
"quoted",
"or",
"returns",
"the",
"same",
"string",
"if",
"it",
"is",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/script/functions.rb#L1524-L1531 |
15,022 | sass/ruby-sass | lib/sass/script/functions.rb | Sass::Script.Functions.to_upper_case | def to_upper_case(string)
assert_type string, :String, :string
Sass::Script::Value::String.new(Sass::Util.upcase(string.value), string.type)
end | ruby | def to_upper_case(string)
assert_type string, :String, :string
Sass::Script::Value::String.new(Sass::Util.upcase(string.value), string.type)
end | [
"def",
"to_upper_case",
"(",
"string",
")",
"assert_type",
"string",
",",
":String",
",",
":string",
"Sass",
"::",
"Script",
"::",
"Value",
"::",
"String",
".",
"new",
"(",
"Sass",
"::",
"Util",
".",
"upcase",
"(",
"string",
".",
"value",
")",
",",
"st... | Converts a string to upper case.
@example
to-upper-case(abcd) => ABCD
@overload to_upper_case($string)
@param $string [Sass::Script::Value::String]
@return [Sass::Script::Value::String]
@raise [ArgumentError] if `$string` isn't a string | [
"Converts",
"a",
"string",
"to",
"upper",
"case",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/script/functions.rb#L1659-L1662 |
15,023 | sass/ruby-sass | lib/sass/script/functions.rb | Sass::Script.Functions.to_lower_case | def to_lower_case(string)
assert_type string, :String, :string
Sass::Script::Value::String.new(Sass::Util.downcase(string.value), string.type)
end | ruby | def to_lower_case(string)
assert_type string, :String, :string
Sass::Script::Value::String.new(Sass::Util.downcase(string.value), string.type)
end | [
"def",
"to_lower_case",
"(",
"string",
")",
"assert_type",
"string",
",",
":String",
",",
":string",
"Sass",
"::",
"Script",
"::",
"Value",
"::",
"String",
".",
"new",
"(",
"Sass",
"::",
"Util",
".",
"downcase",
"(",
"string",
".",
"value",
")",
",",
"... | Convert a string to lower case,
@example
to-lower-case(ABCD) => abcd
@overload to_lower_case($string)
@param $string [Sass::Script::Value::String]
@return [Sass::Script::Value::String]
@raise [ArgumentError] if `$string` isn't a string | [
"Convert",
"a",
"string",
"to",
"lower",
"case"
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/script/functions.rb#L1674-L1677 |
15,024 | sass/ruby-sass | lib/sass/script/functions.rb | Sass::Script.Functions.type_of | def type_of(value)
value.check_deprecated_interp if value.is_a?(Sass::Script::Value::String)
identifier(value.class.name.gsub(/Sass::Script::Value::/, '').downcase)
end | ruby | def type_of(value)
value.check_deprecated_interp if value.is_a?(Sass::Script::Value::String)
identifier(value.class.name.gsub(/Sass::Script::Value::/, '').downcase)
end | [
"def",
"type_of",
"(",
"value",
")",
"value",
".",
"check_deprecated_interp",
"if",
"value",
".",
"is_a?",
"(",
"Sass",
"::",
"Script",
"::",
"Value",
"::",
"String",
")",
"identifier",
"(",
"value",
".",
"class",
".",
"name",
".",
"gsub",
"(",
"/",
"/... | Returns the type of a value.
@example
type-of(100px) => number
type-of(asdf) => string
type-of("asdf") => string
type-of(true) => bool
type-of(#fff) => color
type-of(blue) => color
type-of(null) => null
type-of(a b c) => list
type-of((a: 1, b: 2)) => map
type-of(get-function(... | [
"Returns",
"the",
"type",
"of",
"a",
"value",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/script/functions.rb#L1698-L1701 |
15,025 | sass/ruby-sass | lib/sass/script/functions.rb | Sass::Script.Functions.comparable | def comparable(number1, number2)
assert_type number1, :Number, :number1
assert_type number2, :Number, :number2
bool(number1.comparable_to?(number2))
end | ruby | def comparable(number1, number2)
assert_type number1, :Number, :number1
assert_type number2, :Number, :number2
bool(number1.comparable_to?(number2))
end | [
"def",
"comparable",
"(",
"number1",
",",
"number2",
")",
"assert_type",
"number1",
",",
":Number",
",",
":number1",
"assert_type",
"number2",
",",
":Number",
",",
":number2",
"bool",
"(",
"number1",
".",
"comparable_to?",
"(",
"number2",
")",
")",
"end"
] | Returns whether two numbers can added, subtracted, or compared.
@example
comparable(2px, 1px) => true
comparable(100px, 3em) => false
comparable(10cm, 3mm) => true
@overload comparable($number1, $number2)
@param $number1 [Sass::Script::Value::Number]
@param $number2 [Sass::Script::Value::Number]
@ret... | [
"Returns",
"whether",
"two",
"numbers",
"can",
"added",
"subtracted",
"or",
"compared",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/script/functions.rb#L1836-L1840 |
15,026 | sass/ruby-sass | lib/sass/script/functions.rb | Sass::Script.Functions.percentage | def percentage(number)
unless number.is_a?(Sass::Script::Value::Number) && number.unitless?
raise ArgumentError.new("$number: #{number.inspect} is not a unitless number")
end
number(number.value * 100, '%')
end | ruby | def percentage(number)
unless number.is_a?(Sass::Script::Value::Number) && number.unitless?
raise ArgumentError.new("$number: #{number.inspect} is not a unitless number")
end
number(number.value * 100, '%')
end | [
"def",
"percentage",
"(",
"number",
")",
"unless",
"number",
".",
"is_a?",
"(",
"Sass",
"::",
"Script",
"::",
"Value",
"::",
"Number",
")",
"&&",
"number",
".",
"unitless?",
"raise",
"ArgumentError",
".",
"new",
"(",
"\"$number: #{number.inspect} is not a unitle... | Converts a unitless number to a percentage.
@example
percentage(0.2) => 20%
percentage(100px / 50px) => 200%
@overload percentage($number)
@param $number [Sass::Script::Value::Number]
@return [Sass::Script::Value::Number]
@raise [ArgumentError] if `$number` isn't a unitless number | [
"Converts",
"a",
"unitless",
"number",
"to",
"a",
"percentage",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/script/functions.rb#L1852-L1857 |
15,027 | sass/ruby-sass | lib/sass/script/functions.rb | Sass::Script.Functions.min | def min(*numbers)
numbers.each {|n| assert_type n, :Number}
numbers.inject {|min, num| min.lt(num).to_bool ? min : num}
end | ruby | def min(*numbers)
numbers.each {|n| assert_type n, :Number}
numbers.inject {|min, num| min.lt(num).to_bool ? min : num}
end | [
"def",
"min",
"(",
"*",
"numbers",
")",
"numbers",
".",
"each",
"{",
"|",
"n",
"|",
"assert_type",
"n",
",",
":Number",
"}",
"numbers",
".",
"inject",
"{",
"|",
"min",
",",
"num",
"|",
"min",
".",
"lt",
"(",
"num",
")",
".",
"to_bool",
"?",
"mi... | Finds the minimum of several numbers. This function takes any number of
arguments.
@example
min(1px, 4px) => 1px
min(5em, 3em, 4em) => 3em
@overload min($numbers...)
@param $numbers [[Sass::Script::Value::Number]]
@return [Sass::Script::Value::Number]
@raise [ArgumentError] if any argument isn't a number... | [
"Finds",
"the",
"minimum",
"of",
"several",
"numbers",
".",
"This",
"function",
"takes",
"any",
"number",
"of",
"arguments",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/script/functions.rb#L1927-L1930 |
15,028 | sass/ruby-sass | lib/sass/script/functions.rb | Sass::Script.Functions.max | def max(*values)
values.each {|v| assert_type v, :Number}
values.inject {|max, val| max.gt(val).to_bool ? max : val}
end | ruby | def max(*values)
values.each {|v| assert_type v, :Number}
values.inject {|max, val| max.gt(val).to_bool ? max : val}
end | [
"def",
"max",
"(",
"*",
"values",
")",
"values",
".",
"each",
"{",
"|",
"v",
"|",
"assert_type",
"v",
",",
":Number",
"}",
"values",
".",
"inject",
"{",
"|",
"max",
",",
"val",
"|",
"max",
".",
"gt",
"(",
"val",
")",
".",
"to_bool",
"?",
"max",... | Finds the maximum of several numbers. This function takes any number of
arguments.
@example
max(1px, 4px) => 4px
max(5em, 3em, 4em) => 5em
@overload max($numbers...)
@param $numbers [[Sass::Script::Value::Number]]
@return [Sass::Script::Value::Number]
@raise [ArgumentError] if any argument isn't a number... | [
"Finds",
"the",
"maximum",
"of",
"several",
"numbers",
".",
"This",
"function",
"takes",
"any",
"number",
"of",
"arguments",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/script/functions.rb#L1944-L1947 |
15,029 | sass/ruby-sass | lib/sass/script/functions.rb | Sass::Script.Functions.set_nth | def set_nth(list, n, value)
assert_type n, :Number, :n
Sass::Script::Value::List.assert_valid_index(list, n)
index = n.to_i > 0 ? n.to_i - 1 : n.to_i
new_list = list.to_a.dup
new_list[index] = value
list.with_contents(new_list)
end | ruby | def set_nth(list, n, value)
assert_type n, :Number, :n
Sass::Script::Value::List.assert_valid_index(list, n)
index = n.to_i > 0 ? n.to_i - 1 : n.to_i
new_list = list.to_a.dup
new_list[index] = value
list.with_contents(new_list)
end | [
"def",
"set_nth",
"(",
"list",
",",
"n",
",",
"value",
")",
"assert_type",
"n",
",",
":Number",
",",
":n",
"Sass",
"::",
"Script",
"::",
"Value",
"::",
"List",
".",
"assert_valid_index",
"(",
"list",
",",
"n",
")",
"index",
"=",
"n",
".",
"to_i",
"... | Return a new list, based on the list provided, but with the nth
element changed to the value given.
Note that unlike some languages, the first item in a Sass list is number
1, the second number 2, and so forth.
Negative index values address elements in reverse order, starting with the last element
in the list.
... | [
"Return",
"a",
"new",
"list",
"based",
"on",
"the",
"list",
"provided",
"but",
"with",
"the",
"nth",
"element",
"changed",
"to",
"the",
"value",
"given",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/script/functions.rb#L1986-L1993 |
15,030 | sass/ruby-sass | lib/sass/script/functions.rb | Sass::Script.Functions.nth | def nth(list, n)
assert_type n, :Number, :n
Sass::Script::Value::List.assert_valid_index(list, n)
index = n.to_i > 0 ? n.to_i - 1 : n.to_i
list.to_a[index]
end | ruby | def nth(list, n)
assert_type n, :Number, :n
Sass::Script::Value::List.assert_valid_index(list, n)
index = n.to_i > 0 ? n.to_i - 1 : n.to_i
list.to_a[index]
end | [
"def",
"nth",
"(",
"list",
",",
"n",
")",
"assert_type",
"n",
",",
":Number",
",",
":n",
"Sass",
"::",
"Script",
"::",
"Value",
"::",
"List",
".",
"assert_valid_index",
"(",
"list",
",",
"n",
")",
"index",
"=",
"n",
".",
"to_i",
">",
"0",
"?",
"n... | Gets the nth item in a list.
Note that unlike some languages, the first item in a Sass list is number
1, the second number 2, and so forth.
This can return the nth pair in a map as well.
Negative index values address elements in reverse order, starting with the last element in
the list.
@example
nth(10px 2... | [
"Gets",
"the",
"nth",
"item",
"in",
"a",
"list",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/script/functions.rb#L2017-L2023 |
15,031 | sass/ruby-sass | lib/sass/script/functions.rb | Sass::Script.Functions.join | def join(list1, list2,
separator = identifier("auto"), bracketed = identifier("auto"),
kwargs = nil, *rest)
if separator.is_a?(Hash)
kwargs = separator
separator = identifier("auto")
elsif bracketed.is_a?(Hash)
kwargs = bracketed
bracketed = identifi... | ruby | def join(list1, list2,
separator = identifier("auto"), bracketed = identifier("auto"),
kwargs = nil, *rest)
if separator.is_a?(Hash)
kwargs = separator
separator = identifier("auto")
elsif bracketed.is_a?(Hash)
kwargs = bracketed
bracketed = identifi... | [
"def",
"join",
"(",
"list1",
",",
"list2",
",",
"separator",
"=",
"identifier",
"(",
"\"auto\"",
")",
",",
"bracketed",
"=",
"identifier",
"(",
"\"auto\"",
")",
",",
"kwargs",
"=",
"nil",
",",
"*",
"rest",
")",
"if",
"separator",
".",
"is_a?",
"(",
"... | Joins together two lists into one.
Unless `$separator` is passed, if one list is comma-separated and one is
space-separated, the first parameter's separator is used for the resulting
list. If both lists have fewer than two items, spaces are used for the
resulting list.
Unless `$bracketed` is passed, the resultin... | [
"Joins",
"together",
"two",
"lists",
"into",
"one",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/script/functions.rb#L2056-L2104 |
15,032 | sass/ruby-sass | lib/sass/script/functions.rb | Sass::Script.Functions.append | def append(list, val, separator = identifier("auto"))
assert_type separator, :String, :separator
unless %w(auto space comma).include?(separator.value)
raise ArgumentError.new("Separator name must be space, comma, or auto")
end
list.with_contents(list.to_a + [val],
separator:
... | ruby | def append(list, val, separator = identifier("auto"))
assert_type separator, :String, :separator
unless %w(auto space comma).include?(separator.value)
raise ArgumentError.new("Separator name must be space, comma, or auto")
end
list.with_contents(list.to_a + [val],
separator:
... | [
"def",
"append",
"(",
"list",
",",
"val",
",",
"separator",
"=",
"identifier",
"(",
"\"auto\"",
")",
")",
"assert_type",
"separator",
",",
":String",
",",
":separator",
"unless",
"%w(",
"auto",
"space",
"comma",
")",
".",
"include?",
"(",
"separator",
".",... | Appends a single value onto the end of a list.
Unless the `$separator` argument is passed, if the list had only one item,
the resulting list will be space-separated.
Like all list functions, `append()` returns a new list rather than
modifying its argument in place.
@example
append(10px 20px, 30px) => 10px 20... | [
"Appends",
"a",
"single",
"value",
"onto",
"the",
"end",
"of",
"a",
"list",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/script/functions.rb#L2131-L2143 |
15,033 | sass/ruby-sass | lib/sass/script/functions.rb | Sass::Script.Functions.zip | def zip(*lists)
length = nil
values = []
lists.each do |list|
array = list.to_a
values << array.dup
length = length.nil? ? array.length : [length, array.length].min
end
values.each do |value|
value.slice!(length)
end
new_list_value = values.first... | ruby | def zip(*lists)
length = nil
values = []
lists.each do |list|
array = list.to_a
values << array.dup
length = length.nil? ? array.length : [length, array.length].min
end
values.each do |value|
value.slice!(length)
end
new_list_value = values.first... | [
"def",
"zip",
"(",
"*",
"lists",
")",
"length",
"=",
"nil",
"values",
"=",
"[",
"]",
"lists",
".",
"each",
"do",
"|",
"list",
"|",
"array",
"=",
"list",
".",
"to_a",
"values",
"<<",
"array",
".",
"dup",
"length",
"=",
"length",
".",
"nil?",
"?",
... | Combines several lists into a single multidimensional list. The nth value
of the resulting list is a space separated list of the source lists' nth
values.
The length of the resulting list is the length of the
shortest list.
@example
zip(1px 1px 3px, solid dashed solid, red green blue)
=> 1px solid red, 1px... | [
"Combines",
"several",
"lists",
"into",
"a",
"single",
"multidimensional",
"list",
".",
"The",
"nth",
"value",
"of",
"the",
"resulting",
"list",
"is",
"a",
"space",
"separated",
"list",
"of",
"the",
"source",
"lists",
"nth",
"values",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/script/functions.rb#L2160-L2173 |
15,034 | sass/ruby-sass | lib/sass/script/functions.rb | Sass::Script.Functions.index | def index(list, value)
index = list.to_a.index {|e| e.eq(value).to_bool}
index ? number(index + 1) : null
end | ruby | def index(list, value)
index = list.to_a.index {|e| e.eq(value).to_bool}
index ? number(index + 1) : null
end | [
"def",
"index",
"(",
"list",
",",
"value",
")",
"index",
"=",
"list",
".",
"to_a",
".",
"index",
"{",
"|",
"e",
"|",
"e",
".",
"eq",
"(",
"value",
")",
".",
"to_bool",
"}",
"index",
"?",
"number",
"(",
"index",
"+",
"1",
")",
":",
"null",
"en... | Returns the position of a value within a list. If the value isn't found,
returns `null` instead.
Note that unlike some languages, the first item in a Sass list is number
1, the second number 2, and so forth.
This can return the position of a pair in a map as well.
@example
index(1px solid red, solid) => 2
... | [
"Returns",
"the",
"position",
"of",
"a",
"value",
"within",
"a",
"list",
".",
"If",
"the",
"value",
"isn",
"t",
"found",
"returns",
"null",
"instead",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/script/functions.rb#L2193-L2196 |
15,035 | sass/ruby-sass | lib/sass/script/functions.rb | Sass::Script.Functions.map_remove | def map_remove(map, *keys)
assert_type map, :Map, :map
hash = map.to_h.dup
hash.delete_if {|key, _| keys.include?(key)}
map(hash)
end | ruby | def map_remove(map, *keys)
assert_type map, :Map, :map
hash = map.to_h.dup
hash.delete_if {|key, _| keys.include?(key)}
map(hash)
end | [
"def",
"map_remove",
"(",
"map",
",",
"*",
"keys",
")",
"assert_type",
"map",
",",
":Map",
",",
":map",
"hash",
"=",
"map",
".",
"to_h",
".",
"dup",
"hash",
".",
"delete_if",
"{",
"|",
"key",
",",
"_",
"|",
"keys",
".",
"include?",
"(",
"key",
")... | Returns a new map with keys removed.
Like all map functions, `map-merge()` returns a new map rather than
modifying its arguments in place.
@example
map-remove(("foo": 1, "bar": 2), "bar") => ("foo": 1)
map-remove(("foo": 1, "bar": 2, "baz": 3), "bar", "baz") => ("foo": 1)
map-remove(("foo": 1, "bar": 2), ... | [
"Returns",
"a",
"new",
"map",
"with",
"keys",
"removed",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/script/functions.rb#L2287-L2292 |
15,036 | sass/ruby-sass | lib/sass/script/functions.rb | Sass::Script.Functions.map_has_key | def map_has_key(map, key)
assert_type map, :Map, :map
bool(map.to_h.has_key?(key))
end | ruby | def map_has_key(map, key)
assert_type map, :Map, :map
bool(map.to_h.has_key?(key))
end | [
"def",
"map_has_key",
"(",
"map",
",",
"key",
")",
"assert_type",
"map",
",",
":Map",
",",
":map",
"bool",
"(",
"map",
".",
"to_h",
".",
"has_key?",
"(",
"key",
")",
")",
"end"
] | Returns whether a map has a value associated with a given key.
@example
map-has-key(("foo": 1, "bar": 2), "foo") => true
map-has-key(("foo": 1, "bar": 2), "baz") => false
@overload map_has_key($map, $key)
@param $map [Sass::Script::Value::Map]
@param $key [Sass::Script::Value::Base]
@return [Sass::Scrip... | [
"Returns",
"whether",
"a",
"map",
"has",
"a",
"value",
"associated",
"with",
"a",
"given",
"key",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/script/functions.rb#L2335-L2338 |
15,037 | sass/ruby-sass | lib/sass/script/functions.rb | Sass::Script.Functions.unique_id | def unique_id
generator = Sass::Script::Functions.random_number_generator
Thread.current[:sass_last_unique_id] ||= generator.rand(36**8)
# avoid the temptation of trying to guess the next unique value.
value = (Thread.current[:sass_last_unique_id] += (generator.rand(10) + 1))
# the u makes... | ruby | def unique_id
generator = Sass::Script::Functions.random_number_generator
Thread.current[:sass_last_unique_id] ||= generator.rand(36**8)
# avoid the temptation of trying to guess the next unique value.
value = (Thread.current[:sass_last_unique_id] += (generator.rand(10) + 1))
# the u makes... | [
"def",
"unique_id",
"generator",
"=",
"Sass",
"::",
"Script",
"::",
"Functions",
".",
"random_number_generator",
"Thread",
".",
"current",
"[",
":sass_last_unique_id",
"]",
"||=",
"generator",
".",
"rand",
"(",
"36",
"**",
"8",
")",
"# avoid the temptation of tryi... | Returns a unique CSS identifier. The identifier is returned as an unquoted
string. The identifier returned is only guaranteed to be unique within the
scope of a single Sass run.
@overload unique_id()
@return [Sass::Script::Value::String] | [
"Returns",
"a",
"unique",
"CSS",
"identifier",
".",
"The",
"identifier",
"is",
"returned",
"as",
"an",
"unquoted",
"string",
".",
"The",
"identifier",
"returned",
"is",
"only",
"guaranteed",
"to",
"be",
"unique",
"within",
"the",
"scope",
"of",
"a",
"single"... | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/script/functions.rb#L2389-L2396 |
15,038 | sass/ruby-sass | lib/sass/script/functions.rb | Sass::Script.Functions.variable_exists | def variable_exists(name)
assert_type name, :String, :name
bool(environment.caller.var(name.value))
end | ruby | def variable_exists(name)
assert_type name, :String, :name
bool(environment.caller.var(name.value))
end | [
"def",
"variable_exists",
"(",
"name",
")",
"assert_type",
"name",
",",
":String",
",",
":name",
"bool",
"(",
"environment",
".",
"caller",
".",
"var",
"(",
"name",
".",
"value",
")",
")",
"end"
] | Check whether a variable with the given name exists in the current
scope or in the global scope.
@example
$a-false-value: false;
variable-exists(a-false-value) => true
variable-exists(a-null-value) => true
variable-exists(nonexistent) => false
@overload variable_exists($name)
@param $name [Sass::Sc... | [
"Check",
"whether",
"a",
"variable",
"with",
"the",
"given",
"name",
"exists",
"in",
"the",
"current",
"scope",
"or",
"in",
"the",
"global",
"scope",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/script/functions.rb#L2486-L2489 |
15,039 | sass/ruby-sass | lib/sass/script/functions.rb | Sass::Script.Functions.function_exists | def function_exists(name)
assert_type name, :String, :name
exists = Sass::Script::Functions.callable?(name.value.tr("-", "_"))
exists ||= environment.caller.function(name.value)
bool(exists)
end | ruby | def function_exists(name)
assert_type name, :String, :name
exists = Sass::Script::Functions.callable?(name.value.tr("-", "_"))
exists ||= environment.caller.function(name.value)
bool(exists)
end | [
"def",
"function_exists",
"(",
"name",
")",
"assert_type",
"name",
",",
":String",
",",
":name",
"exists",
"=",
"Sass",
"::",
"Script",
"::",
"Functions",
".",
"callable?",
"(",
"name",
".",
"value",
".",
"tr",
"(",
"\"-\"",
",",
"\"_\"",
")",
")",
"ex... | Check whether a function with the given name exists.
@example
function-exists(lighten) => true
@function myfunc { @return "something"; }
function-exists(myfunc) => true
@overload function_exists($name)
@param name [Sass::Script::Value::String] The name of the function to
check or a function refere... | [
"Check",
"whether",
"a",
"function",
"with",
"the",
"given",
"name",
"exists",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/script/functions.rb#L2528-L2533 |
15,040 | sass/ruby-sass | lib/sass/script/functions.rb | Sass::Script.Functions.content_exists | def content_exists
# frames.last is the stack frame for this function,
# so we use frames[-2] to get the frame before that.
mixin_frame = environment.stack.frames[-2]
unless mixin_frame && mixin_frame.type == :mixin
raise Sass::SyntaxError.new("Cannot call content-exists() except within ... | ruby | def content_exists
# frames.last is the stack frame for this function,
# so we use frames[-2] to get the frame before that.
mixin_frame = environment.stack.frames[-2]
unless mixin_frame && mixin_frame.type == :mixin
raise Sass::SyntaxError.new("Cannot call content-exists() except within ... | [
"def",
"content_exists",
"# frames.last is the stack frame for this function,",
"# so we use frames[-2] to get the frame before that.",
"mixin_frame",
"=",
"environment",
".",
"stack",
".",
"frames",
"[",
"-",
"2",
"]",
"unless",
"mixin_frame",
"&&",
"mixin_frame",
".",
"type... | Check whether a mixin was passed a content block.
Unless `content-exists()` is called directly from a mixin, an error will be raised.
@example
@mixin needs-content {
@if not content-exists() {
@error "You must pass a content block!"
}
@content;
}
@overload content_exists()
@return [Sa... | [
"Check",
"whether",
"a",
"mixin",
"was",
"passed",
"a",
"content",
"block",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/script/functions.rb#L2568-L2576 |
15,041 | sass/ruby-sass | lib/sass/script/functions.rb | Sass::Script.Functions.inspect | def inspect(value)
value.check_deprecated_interp if value.is_a?(Sass::Script::Value::String)
unquoted_string(value.to_sass)
end | ruby | def inspect(value)
value.check_deprecated_interp if value.is_a?(Sass::Script::Value::String)
unquoted_string(value.to_sass)
end | [
"def",
"inspect",
"(",
"value",
")",
"value",
".",
"check_deprecated_interp",
"if",
"value",
".",
"is_a?",
"(",
"Sass",
"::",
"Script",
"::",
"Value",
"::",
"String",
")",
"unquoted_string",
"(",
"value",
".",
"to_sass",
")",
"end"
] | Return a string containing the value as its Sass representation.
@overload inspect($value)
@param $value [Sass::Script::Value::Base] The value to inspect.
@return [Sass::Script::Value::String] A representation of the value as
it would be written in Sass. | [
"Return",
"a",
"string",
"containing",
"the",
"value",
"as",
"its",
"Sass",
"representation",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/script/functions.rb#L2585-L2588 |
15,042 | sass/ruby-sass | lib/sass/script/functions.rb | Sass::Script.Functions.selector_unify | def selector_unify(selector1, selector2)
selector1 = parse_selector(selector1, :selector1)
selector2 = parse_selector(selector2, :selector2)
return null unless (unified = selector1.unify(selector2))
unified.to_sass_script
end | ruby | def selector_unify(selector1, selector2)
selector1 = parse_selector(selector1, :selector1)
selector2 = parse_selector(selector2, :selector2)
return null unless (unified = selector1.unify(selector2))
unified.to_sass_script
end | [
"def",
"selector_unify",
"(",
"selector1",
",",
"selector2",
")",
"selector1",
"=",
"parse_selector",
"(",
"selector1",
",",
":selector1",
")",
"selector2",
"=",
"parse_selector",
"(",
"selector2",
",",
":selector2",
")",
"return",
"null",
"unless",
"(",
"unifie... | Unifies two selectors into a single selector that matches only
elements matched by both input selectors. Returns `null` if
there is no such selector.
Like the selector unification done for `@extend`, this doesn't
guarantee that the output selector will match *all* elements
matched by both input selectors. For exa... | [
"Unifies",
"two",
"selectors",
"into",
"a",
"single",
"selector",
"that",
"matches",
"only",
"elements",
"matched",
"by",
"both",
"input",
"selectors",
".",
"Returns",
"null",
"if",
"there",
"is",
"no",
"such",
"selector",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/script/functions.rb#L2830-L2835 |
15,043 | sass/ruby-sass | lib/sass/script/functions.rb | Sass::Script.Functions.numeric_transformation | def numeric_transformation(value)
assert_type value, :Number, :value
Sass::Script::Value::Number.new(
yield(value.value), value.numerator_units, value.denominator_units)
end | ruby | def numeric_transformation(value)
assert_type value, :Number, :value
Sass::Script::Value::Number.new(
yield(value.value), value.numerator_units, value.denominator_units)
end | [
"def",
"numeric_transformation",
"(",
"value",
")",
"assert_type",
"value",
",",
":Number",
",",
":value",
"Sass",
"::",
"Script",
"::",
"Value",
"::",
"Number",
".",
"new",
"(",
"yield",
"(",
"value",
".",
"value",
")",
",",
"value",
".",
"numerator_units... | This method implements the pattern of transforming a numeric value into
another numeric value with the same units.
It yields a number to a block to perform the operation and return a number | [
"This",
"method",
"implements",
"the",
"pattern",
"of",
"transforming",
"a",
"numeric",
"value",
"into",
"another",
"numeric",
"value",
"with",
"the",
"same",
"units",
".",
"It",
"yields",
"a",
"number",
"to",
"a",
"block",
"to",
"perform",
"the",
"operation... | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/script/functions.rb#L2895-L2899 |
15,044 | sass/ruby-sass | lib/sass/media.rb | Sass::Media.Query.merge | def merge(other)
m1, t1 = resolved_modifier.downcase, resolved_type.downcase
m2, t2 = other.resolved_modifier.downcase, other.resolved_type.downcase
t1 = t2 if t1.empty?
t2 = t1 if t2.empty?
if (m1 == 'not') ^ (m2 == 'not')
return if t1 == t2
type = m1 == 'not' ? t2 : t1
... | ruby | def merge(other)
m1, t1 = resolved_modifier.downcase, resolved_type.downcase
m2, t2 = other.resolved_modifier.downcase, other.resolved_type.downcase
t1 = t2 if t1.empty?
t2 = t1 if t2.empty?
if (m1 == 'not') ^ (m2 == 'not')
return if t1 == t2
type = m1 == 'not' ? t2 : t1
... | [
"def",
"merge",
"(",
"other",
")",
"m1",
",",
"t1",
"=",
"resolved_modifier",
".",
"downcase",
",",
"resolved_type",
".",
"downcase",
"m2",
",",
"t2",
"=",
"other",
".",
"resolved_modifier",
".",
"downcase",
",",
"other",
".",
"resolved_type",
".",
"downca... | Merges this query with another. The returned query queries for
the intersection between the two inputs.
Both queries should be resolved.
@param other [Query]
@return [Query?] The merged query, or nil if there is no intersection. | [
"Merges",
"this",
"query",
"with",
"another",
".",
"The",
"returned",
"query",
"queries",
"for",
"the",
"intersection",
"between",
"the",
"two",
"inputs",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/media.rb#L123-L144 |
15,045 | sass/ruby-sass | lib/sass/media.rb | Sass::Media.Query.to_css | def to_css
css = ''
css << resolved_modifier
css << ' ' unless resolved_modifier.empty?
css << resolved_type
css << ' and ' unless resolved_type.empty? || expressions.empty?
css << expressions.map do |e|
# It's possible for there to be script nodes in Expressions even when
... | ruby | def to_css
css = ''
css << resolved_modifier
css << ' ' unless resolved_modifier.empty?
css << resolved_type
css << ' and ' unless resolved_type.empty? || expressions.empty?
css << expressions.map do |e|
# It's possible for there to be script nodes in Expressions even when
... | [
"def",
"to_css",
"css",
"=",
"''",
"css",
"<<",
"resolved_modifier",
"css",
"<<",
"' '",
"unless",
"resolved_modifier",
".",
"empty?",
"css",
"<<",
"resolved_type",
"css",
"<<",
"' and '",
"unless",
"resolved_type",
".",
"empty?",
"||",
"expressions",
".",
"em... | Returns the CSS for the media query.
@return [String] | [
"Returns",
"the",
"CSS",
"for",
"the",
"media",
"query",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/media.rb#L149-L162 |
15,046 | sass/ruby-sass | lib/sass/media.rb | Sass::Media.Query.deep_copy | def deep_copy
Query.new(
modifier.map {|c| c.is_a?(Sass::Script::Tree::Node) ? c.deep_copy : c},
type.map {|c| c.is_a?(Sass::Script::Tree::Node) ? c.deep_copy : c},
expressions.map {|e| e.map {|c| c.is_a?(Sass::Script::Tree::Node) ? c.deep_copy : c}})
end | ruby | def deep_copy
Query.new(
modifier.map {|c| c.is_a?(Sass::Script::Tree::Node) ? c.deep_copy : c},
type.map {|c| c.is_a?(Sass::Script::Tree::Node) ? c.deep_copy : c},
expressions.map {|e| e.map {|c| c.is_a?(Sass::Script::Tree::Node) ? c.deep_copy : c}})
end | [
"def",
"deep_copy",
"Query",
".",
"new",
"(",
"modifier",
".",
"map",
"{",
"|",
"c",
"|",
"c",
".",
"is_a?",
"(",
"Sass",
"::",
"Script",
"::",
"Tree",
"::",
"Node",
")",
"?",
"c",
".",
"deep_copy",
":",
"c",
"}",
",",
"type",
".",
"map",
"{",
... | Returns a deep copy of this query and all its children.
@return [Query] | [
"Returns",
"a",
"deep",
"copy",
"of",
"this",
"query",
"and",
"all",
"its",
"children",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/media.rb#L194-L199 |
15,047 | sass/ruby-sass | lib/sass/script/tree/list_literal.rb | Sass::Script::Tree.ListLiteral.element_needs_parens? | def element_needs_parens?(element)
if element.is_a?(ListLiteral)
return false if element.elements.length < 2
return false if element.bracketed
return Sass::Script::Parser.precedence_of(element.separator || :space) <=
Sass::Script::Parser.precedence_of(separator || :space)
... | ruby | def element_needs_parens?(element)
if element.is_a?(ListLiteral)
return false if element.elements.length < 2
return false if element.bracketed
return Sass::Script::Parser.precedence_of(element.separator || :space) <=
Sass::Script::Parser.precedence_of(separator || :space)
... | [
"def",
"element_needs_parens?",
"(",
"element",
")",
"if",
"element",
".",
"is_a?",
"(",
"ListLiteral",
")",
"return",
"false",
"if",
"element",
".",
"elements",
".",
"length",
"<",
"2",
"return",
"false",
"if",
"element",
".",
"bracketed",
"return",
"Sass",... | Returns whether an element in the list should be wrapped in parentheses
when serialized to Sass. | [
"Returns",
"whether",
"an",
"element",
"in",
"the",
"list",
"should",
"be",
"wrapped",
"in",
"parentheses",
"when",
"serialized",
"to",
"Sass",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/script/tree/list_literal.rb#L87-L104 |
15,048 | sass/ruby-sass | lib/sass/script/tree/list_literal.rb | Sass::Script::Tree.ListLiteral.is_literal_number? | def is_literal_number?(value)
value.is_a?(Literal) &&
value.value.is_a?((Sass::Script::Value::Number)) &&
!value.value.original.nil?
end | ruby | def is_literal_number?(value)
value.is_a?(Literal) &&
value.value.is_a?((Sass::Script::Value::Number)) &&
!value.value.original.nil?
end | [
"def",
"is_literal_number?",
"(",
"value",
")",
"value",
".",
"is_a?",
"(",
"Literal",
")",
"&&",
"value",
".",
"value",
".",
"is_a?",
"(",
"(",
"Sass",
"::",
"Script",
"::",
"Value",
"::",
"Number",
")",
")",
"&&",
"!",
"value",
".",
"value",
".",
... | Returns whether a value is a number literal that shouldn't be divided. | [
"Returns",
"whether",
"a",
"value",
"is",
"a",
"number",
"literal",
"that",
"shouldn",
"t",
"be",
"divided",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/script/tree/list_literal.rb#L107-L111 |
15,049 | sass/ruby-sass | lib/sass/css.rb | Sass.CSS.build_tree | def build_tree
root = Sass::SCSS::CssParser.new(@template, @options[:filename], nil).parse
parse_selectors(root)
expand_commas(root)
nest_seqs(root)
parent_ref_rules(root)
flatten_rules(root)
bubble_subject(root)
fold_commas(root)
dump_selectors(root)
root
... | ruby | def build_tree
root = Sass::SCSS::CssParser.new(@template, @options[:filename], nil).parse
parse_selectors(root)
expand_commas(root)
nest_seqs(root)
parent_ref_rules(root)
flatten_rules(root)
bubble_subject(root)
fold_commas(root)
dump_selectors(root)
root
... | [
"def",
"build_tree",
"root",
"=",
"Sass",
"::",
"SCSS",
"::",
"CssParser",
".",
"new",
"(",
"@template",
",",
"@options",
"[",
":filename",
"]",
",",
"nil",
")",
".",
"parse",
"parse_selectors",
"(",
"root",
")",
"expand_commas",
"(",
"root",
")",
"nest_... | Parses the CSS template and applies various transformations
@return [Tree::Node] The root node of the parsed tree | [
"Parses",
"the",
"CSS",
"template",
"and",
"applies",
"various",
"transformations"
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/css.rb#L76-L87 |
15,050 | sass/ruby-sass | lib/sass/css.rb | Sass.CSS.nest_seqs | def nest_seqs(root)
current_rule = nil
root.children.map! do |child|
unless child.is_a?(Tree::RuleNode)
nest_seqs(child) if child.is_a?(Tree::DirectiveNode)
next child
end
seq = first_seq(child)
seq.members.reject! {|sseq| sseq == "\n"}
first, res... | ruby | def nest_seqs(root)
current_rule = nil
root.children.map! do |child|
unless child.is_a?(Tree::RuleNode)
nest_seqs(child) if child.is_a?(Tree::DirectiveNode)
next child
end
seq = first_seq(child)
seq.members.reject! {|sseq| sseq == "\n"}
first, res... | [
"def",
"nest_seqs",
"(",
"root",
")",
"current_rule",
"=",
"nil",
"root",
".",
"children",
".",
"map!",
"do",
"|",
"child",
"|",
"unless",
"child",
".",
"is_a?",
"(",
"Tree",
"::",
"RuleNode",
")",
"nest_seqs",
"(",
"child",
")",
"if",
"child",
".",
... | Make rules use nesting so that
foo
color: green
foo bar
color: red
foo baz
color: blue
becomes
foo
color: green
bar
color: red
baz
color: blue
@param root [Tree::Node] The parent node | [
"Make",
"rules",
"use",
"nesting",
"so",
"that"
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/css.rb#L153-L183 |
15,051 | sass/ruby-sass | lib/sass/css.rb | Sass.CSS.parent_ref_rules | def parent_ref_rules(root)
current_rule = nil
root.children.map! do |child|
unless child.is_a?(Tree::RuleNode)
parent_ref_rules(child) if child.is_a?(Tree::DirectiveNode)
next child
end
sseq = first_sseq(child)
next child unless sseq.is_a?(Sass::Selector:... | ruby | def parent_ref_rules(root)
current_rule = nil
root.children.map! do |child|
unless child.is_a?(Tree::RuleNode)
parent_ref_rules(child) if child.is_a?(Tree::DirectiveNode)
next child
end
sseq = first_sseq(child)
next child unless sseq.is_a?(Sass::Selector:... | [
"def",
"parent_ref_rules",
"(",
"root",
")",
"current_rule",
"=",
"nil",
"root",
".",
"children",
".",
"map!",
"do",
"|",
"child",
"|",
"unless",
"child",
".",
"is_a?",
"(",
"Tree",
"::",
"RuleNode",
")",
"parent_ref_rules",
"(",
"child",
")",
"if",
"chi... | Make rules use parent refs so that
foo
color: green
foo.bar
color: blue
becomes
foo
color: green
&.bar
color: blue
@param root [Tree::Node] The parent node | [
"Make",
"rules",
"use",
"parent",
"refs",
"so",
"that"
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/css.rb#L200-L235 |
15,052 | sass/ruby-sass | lib/sass/css.rb | Sass.CSS.flatten_rules | def flatten_rules(root)
root.children.each do |child|
case child
when Tree::RuleNode
flatten_rule(child)
when Tree::DirectiveNode
flatten_rules(child)
end
end
end | ruby | def flatten_rules(root)
root.children.each do |child|
case child
when Tree::RuleNode
flatten_rule(child)
when Tree::DirectiveNode
flatten_rules(child)
end
end
end | [
"def",
"flatten_rules",
"(",
"root",
")",
"root",
".",
"children",
".",
"each",
"do",
"|",
"child",
"|",
"case",
"child",
"when",
"Tree",
"::",
"RuleNode",
"flatten_rule",
"(",
"child",
")",
"when",
"Tree",
"::",
"DirectiveNode",
"flatten_rules",
"(",
"chi... | Flatten rules so that
foo
bar
color: red
becomes
foo bar
color: red
and
foo
&.bar
color: blue
becomes
foo.bar
color: blue
@param root [Tree::Node] The parent node | [
"Flatten",
"rules",
"so",
"that"
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/css.rb#L260-L269 |
15,053 | sass/ruby-sass | lib/sass/css.rb | Sass.CSS.flatten_rule | def flatten_rule(rule)
while rule.children.size == 1 && rule.children.first.is_a?(Tree::RuleNode)
child = rule.children.first
if first_simple_sel(child).is_a?(Sass::Selector::Parent)
rule.parsed_rules = child.parsed_rules.resolve_parent_refs(rule.parsed_rules)
else
rul... | ruby | def flatten_rule(rule)
while rule.children.size == 1 && rule.children.first.is_a?(Tree::RuleNode)
child = rule.children.first
if first_simple_sel(child).is_a?(Sass::Selector::Parent)
rule.parsed_rules = child.parsed_rules.resolve_parent_refs(rule.parsed_rules)
else
rul... | [
"def",
"flatten_rule",
"(",
"rule",
")",
"while",
"rule",
".",
"children",
".",
"size",
"==",
"1",
"&&",
"rule",
".",
"children",
".",
"first",
".",
"is_a?",
"(",
"Tree",
"::",
"RuleNode",
")",
"child",
"=",
"rule",
".",
"children",
".",
"first",
"if... | Flattens a single rule.
@param rule [Tree::RuleNode] The candidate for flattening
@see #flatten_rules | [
"Flattens",
"a",
"single",
"rule",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/css.rb#L275-L289 |
15,054 | sass/ruby-sass | lib/sass/tree/visitors/base.rb | Sass::Tree::Visitors.Base.visit | def visit(node)
if respond_to?(node.class.visit_method, true)
send(node.class.visit_method, node) {visit_children(node)}
else
visit_children(node)
end
end | ruby | def visit(node)
if respond_to?(node.class.visit_method, true)
send(node.class.visit_method, node) {visit_children(node)}
else
visit_children(node)
end
end | [
"def",
"visit",
"(",
"node",
")",
"if",
"respond_to?",
"(",
"node",
".",
"class",
".",
"visit_method",
",",
"true",
")",
"send",
"(",
"node",
".",
"class",
".",
"visit_method",
",",
"node",
")",
"{",
"visit_children",
"(",
"node",
")",
"}",
"else",
"... | Runs the visitor on the given node.
This can be overridden by subclasses that need to do something for each node.
@param node [Tree::Node] The node to visit.
@return [Object] The return value of the `visit_*` method for this node. | [
"Runs",
"the",
"visitor",
"on",
"the",
"given",
"node",
".",
"This",
"can",
"be",
"overridden",
"by",
"subclasses",
"that",
"need",
"to",
"do",
"something",
"for",
"each",
"node",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/tree/visitors/base.rb#L34-L40 |
15,055 | sass/ruby-sass | lib/sass/exec/sass_convert.rb | Sass::Exec.SassConvert.process_result | def process_result
require 'sass'
if @options[:recursive]
process_directory
return
end
super
input = @options[:input]
if File.directory?(input)
raise "Error: '#{input.path}' is a directory (did you mean to use --recursive?)"
end
output = @options... | ruby | def process_result
require 'sass'
if @options[:recursive]
process_directory
return
end
super
input = @options[:input]
if File.directory?(input)
raise "Error: '#{input.path}' is a directory (did you mean to use --recursive?)"
end
output = @options... | [
"def",
"process_result",
"require",
"'sass'",
"if",
"@options",
"[",
":recursive",
"]",
"process_directory",
"return",
"end",
"super",
"input",
"=",
"@options",
"[",
":input",
"]",
"if",
"File",
".",
"directory?",
"(",
"input",
")",
"raise",
"\"Error: '#{input.p... | Processes the options set by the command-line arguments,
and runs the CSS compiler appropriately. | [
"Processes",
"the",
"options",
"set",
"by",
"the",
"command",
"-",
"line",
"arguments",
"and",
"runs",
"the",
"CSS",
"compiler",
"appropriately",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/exec/sass_convert.rb#L36-L52 |
15,056 | sass/ruby-sass | lib/sass/script/value/number.rb | Sass::Script::Value.Number.mod | def mod(other)
if other.is_a?(Number)
return Number.new(Float::NAN) if other.value == 0
operate(other, :%)
else
raise NoMethodError.new(nil, :mod)
end
end | ruby | def mod(other)
if other.is_a?(Number)
return Number.new(Float::NAN) if other.value == 0
operate(other, :%)
else
raise NoMethodError.new(nil, :mod)
end
end | [
"def",
"mod",
"(",
"other",
")",
"if",
"other",
".",
"is_a?",
"(",
"Number",
")",
"return",
"Number",
".",
"new",
"(",
"Float",
"::",
"NAN",
")",
"if",
"other",
".",
"value",
"==",
"0",
"operate",
"(",
"other",
",",
":%",
")",
"else",
"raise",
"N... | The SassScript `%` operation.
@param other [Number] The right-hand side of the operator
@return [Number] This number modulo the other
@raise [NoMethodError] if `other` is an invalid type
@raise [Sass::UnitConversionError] if `other` has incompatible units | [
"The",
"SassScript",
"%",
"operation",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/script/value/number.rb#L190-L197 |
15,057 | sass/ruby-sass | lib/sass/script/value/number.rb | Sass::Script::Value.Number.eq | def eq(other)
return Bool::FALSE unless other.is_a?(Sass::Script::Value::Number)
this = self
begin
if unitless?
this = this.coerce(other.numerator_units, other.denominator_units)
else
other = other.coerce(@numerator_units, @denominator_units)
end
rescu... | ruby | def eq(other)
return Bool::FALSE unless other.is_a?(Sass::Script::Value::Number)
this = self
begin
if unitless?
this = this.coerce(other.numerator_units, other.denominator_units)
else
other = other.coerce(@numerator_units, @denominator_units)
end
rescu... | [
"def",
"eq",
"(",
"other",
")",
"return",
"Bool",
"::",
"FALSE",
"unless",
"other",
".",
"is_a?",
"(",
"Sass",
"::",
"Script",
"::",
"Value",
"::",
"Number",
")",
"this",
"=",
"self",
"begin",
"if",
"unitless?",
"this",
"=",
"this",
".",
"coerce",
"(... | The SassScript `==` operation.
@param other [Value] The right-hand side of the operator
@return [Boolean] Whether this number is equal to the other object | [
"The",
"SassScript",
"==",
"operation",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/script/value/number.rb#L203-L216 |
15,058 | sass/ruby-sass | lib/sass/script/value/number.rb | Sass::Script::Value.Number.gt | def gt(other)
raise NoMethodError.new(nil, :gt) unless other.is_a?(Number)
operate(other, :>)
end | ruby | def gt(other)
raise NoMethodError.new(nil, :gt) unless other.is_a?(Number)
operate(other, :>)
end | [
"def",
"gt",
"(",
"other",
")",
"raise",
"NoMethodError",
".",
"new",
"(",
"nil",
",",
":gt",
")",
"unless",
"other",
".",
"is_a?",
"(",
"Number",
")",
"operate",
"(",
"other",
",",
":>",
")",
"end"
] | Hash-equality works differently than `==` equality for numbers.
Hash-equality must be transitive, so it just compares the exact value,
numerator units, and denominator units.
The SassScript `>` operation.
@param other [Number] The right-hand side of the operator
@return [Boolean] Whether this number is greater th... | [
"Hash",
"-",
"equality",
"works",
"differently",
"than",
"==",
"equality",
"for",
"numbers",
".",
"Hash",
"-",
"equality",
"must",
"be",
"transitive",
"so",
"it",
"just",
"compares",
"the",
"exact",
"value",
"numerator",
"units",
"and",
"denominator",
"units",... | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/script/value/number.rb#L235-L238 |
15,059 | sass/ruby-sass | lib/sass/script/value/number.rb | Sass::Script::Value.Number.gte | def gte(other)
raise NoMethodError.new(nil, :gte) unless other.is_a?(Number)
operate(other, :>=)
end | ruby | def gte(other)
raise NoMethodError.new(nil, :gte) unless other.is_a?(Number)
operate(other, :>=)
end | [
"def",
"gte",
"(",
"other",
")",
"raise",
"NoMethodError",
".",
"new",
"(",
"nil",
",",
":gte",
")",
"unless",
"other",
".",
"is_a?",
"(",
"Number",
")",
"operate",
"(",
"other",
",",
":>=",
")",
"end"
] | The SassScript `>=` operation.
@param other [Number] The right-hand side of the operator
@return [Boolean] Whether this number is greater than or equal to the other
@raise [NoMethodError] if `other` is an invalid type | [
"The",
"SassScript",
">",
"=",
"operation",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/script/value/number.rb#L245-L248 |
15,060 | sass/ruby-sass | lib/sass/script/value/number.rb | Sass::Script::Value.Number.lt | def lt(other)
raise NoMethodError.new(nil, :lt) unless other.is_a?(Number)
operate(other, :<)
end | ruby | def lt(other)
raise NoMethodError.new(nil, :lt) unless other.is_a?(Number)
operate(other, :<)
end | [
"def",
"lt",
"(",
"other",
")",
"raise",
"NoMethodError",
".",
"new",
"(",
"nil",
",",
":lt",
")",
"unless",
"other",
".",
"is_a?",
"(",
"Number",
")",
"operate",
"(",
"other",
",",
":<",
")",
"end"
] | The SassScript `<` operation.
@param other [Number] The right-hand side of the operator
@return [Boolean] Whether this number is less than the other
@raise [NoMethodError] if `other` is an invalid type | [
"The",
"SassScript",
"<",
"operation",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/script/value/number.rb#L255-L258 |
15,061 | sass/ruby-sass | lib/sass/script/value/number.rb | Sass::Script::Value.Number.lte | def lte(other)
raise NoMethodError.new(nil, :lte) unless other.is_a?(Number)
operate(other, :<=)
end | ruby | def lte(other)
raise NoMethodError.new(nil, :lte) unless other.is_a?(Number)
operate(other, :<=)
end | [
"def",
"lte",
"(",
"other",
")",
"raise",
"NoMethodError",
".",
"new",
"(",
"nil",
",",
":lte",
")",
"unless",
"other",
".",
"is_a?",
"(",
"Number",
")",
"operate",
"(",
"other",
",",
":<=",
")",
"end"
] | The SassScript `<=` operation.
@param other [Number] The right-hand side of the operator
@return [Boolean] Whether this number is less than or equal to the other
@raise [NoMethodError] if `other` is an invalid type | [
"The",
"SassScript",
"<",
"=",
"operation",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/script/value/number.rb#L265-L268 |
15,062 | sass/ruby-sass | lib/sass/script/value/number.rb | Sass::Script::Value.Number.inspect | def inspect(opts = {})
return original if original
value = self.class.round(self.value)
str = value.to_s
# Ruby will occasionally print in scientific notation if the number is
# small enough. That's technically valid CSS, but it's not well-supported
# and confusing.
str = ("%... | ruby | def inspect(opts = {})
return original if original
value = self.class.round(self.value)
str = value.to_s
# Ruby will occasionally print in scientific notation if the number is
# small enough. That's technically valid CSS, but it's not well-supported
# and confusing.
str = ("%... | [
"def",
"inspect",
"(",
"opts",
"=",
"{",
"}",
")",
"return",
"original",
"if",
"original",
"value",
"=",
"self",
".",
"class",
".",
"round",
"(",
"self",
".",
"value",
")",
"str",
"=",
"value",
".",
"to_s",
"# Ruby will occasionally print in scientific notat... | Returns a readable representation of this number.
This representation is valid CSS (and valid SassScript)
as long as there is only one unit.
@return [String] The representation | [
"Returns",
"a",
"readable",
"representation",
"of",
"this",
"number",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/script/value/number.rb#L285-L307 |
15,063 | sass/ruby-sass | lib/sass/script/value/number.rb | Sass::Script::Value.Number.is_unit? | def is_unit?(unit)
if unit
denominator_units.size == 0 && numerator_units.size == 1 && numerator_units.first == unit
else
unitless?
end
end | ruby | def is_unit?(unit)
if unit
denominator_units.size == 0 && numerator_units.size == 1 && numerator_units.first == unit
else
unitless?
end
end | [
"def",
"is_unit?",
"(",
"unit",
")",
"if",
"unit",
"denominator_units",
".",
"size",
"==",
"0",
"&&",
"numerator_units",
".",
"size",
"==",
"1",
"&&",
"numerator_units",
".",
"first",
"==",
"unit",
"else",
"unitless?",
"end",
"end"
] | Checks whether the number has the numerator unit specified.
@example
number = Sass::Script::Value::Number.new(10, "px")
number.is_unit?("px") => true
number.is_unit?(nil) => false
@param unit [::String, nil] The unit the number should have or nil if the number
should be unitless.
@see Number#unitless? ... | [
"Checks",
"whether",
"the",
"number",
"has",
"the",
"numerator",
"unit",
"specified",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/script/value/number.rb#L337-L343 |
15,064 | sass/ruby-sass | lib/sass/script/value/base.rb | Sass::Script::Value.Base.plus | def plus(other)
type = other.is_a?(Sass::Script::Value::String) ? other.type : :identifier
Sass::Script::Value::String.new(to_s(:quote => :none) + other.to_s(:quote => :none), type)
end | ruby | def plus(other)
type = other.is_a?(Sass::Script::Value::String) ? other.type : :identifier
Sass::Script::Value::String.new(to_s(:quote => :none) + other.to_s(:quote => :none), type)
end | [
"def",
"plus",
"(",
"other",
")",
"type",
"=",
"other",
".",
"is_a?",
"(",
"Sass",
"::",
"Script",
"::",
"Value",
"::",
"String",
")",
"?",
"other",
".",
"type",
":",
":identifier",
"Sass",
"::",
"Script",
"::",
"Value",
"::",
"String",
".",
"new",
... | The SassScript `+` operation.
@param other [Value] The right-hand side of the operator
@return [Script::Value::String] A string containing both values
without any separation | [
"The",
"SassScript",
"+",
"operation",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/script/value/base.rb#L99-L102 |
15,065 | sass/ruby-sass | lib/sass/script/value/base.rb | Sass::Script::Value.Base.with_contents | def with_contents(contents, separator: self.separator, bracketed: self.bracketed)
Sass::Script::Value::List.new(contents, separator: separator, bracketed: bracketed)
end | ruby | def with_contents(contents, separator: self.separator, bracketed: self.bracketed)
Sass::Script::Value::List.new(contents, separator: separator, bracketed: bracketed)
end | [
"def",
"with_contents",
"(",
"contents",
",",
"separator",
":",
"self",
".",
"separator",
",",
"bracketed",
":",
"self",
".",
"bracketed",
")",
"Sass",
"::",
"Script",
"::",
"Value",
"::",
"List",
".",
"new",
"(",
"contents",
",",
"separator",
":",
"sepa... | Creates a new list containing `contents` but with the same brackets and
separators as this object, when interpreted as a list.
@param contents [Array<Value>] The contents of the new list.
@param separator [Symbol] The separator of the new list. Defaults to \{#separator}.
@param bracketed [Boolean] Whether the new ... | [
"Creates",
"a",
"new",
"list",
"containing",
"contents",
"but",
"with",
"the",
"same",
"brackets",
"and",
"separators",
"as",
"this",
"object",
"when",
"interpreted",
"as",
"a",
"list",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/script/value/base.rb#L244-L246 |
15,066 | sass/ruby-sass | lib/sass/script/tree/variable.rb | Sass::Script::Tree.Variable._perform | def _perform(environment)
val = environment.var(name)
raise Sass::SyntaxError.new("Undefined variable: \"$#{name}\".") unless val
if val.is_a?(Sass::Script::Value::Number) && val.original
val = val.dup
val.original = nil
end
val
end | ruby | def _perform(environment)
val = environment.var(name)
raise Sass::SyntaxError.new("Undefined variable: \"$#{name}\".") unless val
if val.is_a?(Sass::Script::Value::Number) && val.original
val = val.dup
val.original = nil
end
val
end | [
"def",
"_perform",
"(",
"environment",
")",
"val",
"=",
"environment",
".",
"var",
"(",
"name",
")",
"raise",
"Sass",
"::",
"SyntaxError",
".",
"new",
"(",
"\"Undefined variable: \\\"$#{name}\\\".\"",
")",
"unless",
"val",
"if",
"val",
".",
"is_a?",
"(",
"Sa... | Evaluates the variable.
@param environment [Sass::Environment] The environment in which to evaluate the SassScript
@return [Sass::Script::Value] The SassScript object that is the value of the variable
@raise [Sass::SyntaxError] if the variable is undefined | [
"Evaluates",
"the",
"variable",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/script/tree/variable.rb#L47-L55 |
15,067 | sass/ruby-sass | lib/sass/exec/base.rb | Sass::Exec.Base.get_line | def get_line(exception)
# SyntaxErrors have weird line reporting
# when there's trailing whitespace
if exception.is_a?(::SyntaxError)
return (exception.message.scan(/:(\d+)/).first || ["??"]).first
end
(exception.backtrace[0].scan(/:(\d+)/).first || ["??"]).first
end | ruby | def get_line(exception)
# SyntaxErrors have weird line reporting
# when there's trailing whitespace
if exception.is_a?(::SyntaxError)
return (exception.message.scan(/:(\d+)/).first || ["??"]).first
end
(exception.backtrace[0].scan(/:(\d+)/).first || ["??"]).first
end | [
"def",
"get_line",
"(",
"exception",
")",
"# SyntaxErrors have weird line reporting",
"# when there's trailing whitespace",
"if",
"exception",
".",
"is_a?",
"(",
"::",
"SyntaxError",
")",
"return",
"(",
"exception",
".",
"message",
".",
"scan",
"(",
"/",
"\\d",
"/",... | Finds the line of the source template
on which an exception was raised.
@param exception [Exception] The exception
@return [String] The line number | [
"Finds",
"the",
"line",
"of",
"the",
"source",
"template",
"on",
"which",
"an",
"exception",
"was",
"raised",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/exec/base.rb#L67-L74 |
15,068 | sass/ruby-sass | lib/sass/exec/base.rb | Sass::Exec.Base.encoding_option | def encoding_option(opts)
encoding_desc = 'Specify the default encoding for input files.'
opts.on('-E', '--default-encoding ENCODING', encoding_desc) do |encoding|
Encoding.default_external = encoding
end
end | ruby | def encoding_option(opts)
encoding_desc = 'Specify the default encoding for input files.'
opts.on('-E', '--default-encoding ENCODING', encoding_desc) do |encoding|
Encoding.default_external = encoding
end
end | [
"def",
"encoding_option",
"(",
"opts",
")",
"encoding_desc",
"=",
"'Specify the default encoding for input files.'",
"opts",
".",
"on",
"(",
"'-E'",
",",
"'--default-encoding ENCODING'",
",",
"encoding_desc",
")",
"do",
"|",
"encoding",
"|",
"Encoding",
".",
"default_... | Set an option for specifying `Encoding.default_external`.
@param opts [OptionParser] | [
"Set",
"an",
"option",
"for",
"specifying",
"Encoding",
".",
"default_external",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/exec/base.rb#L90-L95 |
15,069 | sass/ruby-sass | lib/sass/exec/base.rb | Sass::Exec.Base.color | def color(color, str)
raise "[BUG] Unrecognized color #{color}" unless COLORS[color]
# Almost any real Unix terminal will support color,
# so we just filter for Windows terms (which don't set TERM)
# and not-real terminals, which aren't ttys.
return str if ENV["TERM"].nil? || ENV["TERM"].... | ruby | def color(color, str)
raise "[BUG] Unrecognized color #{color}" unless COLORS[color]
# Almost any real Unix terminal will support color,
# so we just filter for Windows terms (which don't set TERM)
# and not-real terminals, which aren't ttys.
return str if ENV["TERM"].nil? || ENV["TERM"].... | [
"def",
"color",
"(",
"color",
",",
"str",
")",
"raise",
"\"[BUG] Unrecognized color #{color}\"",
"unless",
"COLORS",
"[",
"color",
"]",
"# Almost any real Unix terminal will support color,",
"# so we just filter for Windows terms (which don't set TERM)",
"# and not-real terminals, wh... | Wraps the given string in terminal escapes
causing it to have the given color.
If terminal escapes aren't supported on this platform,
just returns the string instead.
@param color [Symbol] The name of the color to use.
Can be `:red`, `:green`, or `:yellow`.
@param str [String] The string to wrap in the given c... | [
"Wraps",
"the",
"given",
"string",
"in",
"terminal",
"escapes",
"causing",
"it",
"to",
"have",
"the",
"given",
"color",
".",
"If",
"terminal",
"escapes",
"aren",
"t",
"supported",
"on",
"this",
"platform",
"just",
"returns",
"the",
"string",
"instead",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/exec/base.rb#L148-L156 |
15,070 | sass/ruby-sass | lib/sass/script/value/helpers.rb | Sass::Script::Value.Helpers.hsl_color | def hsl_color(hue, saturation, lightness, alpha = nil)
attrs = {:hue => hue, :saturation => saturation, :lightness => lightness}
attrs[:alpha] = alpha if alpha
Color.new(attrs)
end | ruby | def hsl_color(hue, saturation, lightness, alpha = nil)
attrs = {:hue => hue, :saturation => saturation, :lightness => lightness}
attrs[:alpha] = alpha if alpha
Color.new(attrs)
end | [
"def",
"hsl_color",
"(",
"hue",
",",
"saturation",
",",
"lightness",
",",
"alpha",
"=",
"nil",
")",
"attrs",
"=",
"{",
":hue",
"=>",
"hue",
",",
":saturation",
"=>",
"saturation",
",",
":lightness",
"=>",
"lightness",
"}",
"attrs",
"[",
":alpha",
"]",
... | Construct a Sass Color from hsl values.
@param hue [::Number] The hue of the color in degrees.
A non-negative number, usually less than 360.
@param saturation [::Number] The saturation of the color.
Must be between 0 and 100 inclusive.
@param lightness [::Number] The lightness of the color.
Must be between... | [
"Construct",
"a",
"Sass",
"Color",
"from",
"hsl",
"values",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/script/value/helpers.rb#L34-L38 |
15,071 | sass/ruby-sass | lib/sass/script/value/helpers.rb | Sass::Script::Value.Helpers.rgb_color | def rgb_color(red, green, blue, alpha = nil)
attrs = {:red => red, :green => green, :blue => blue}
attrs[:alpha] = alpha if alpha
Color.new(attrs)
end | ruby | def rgb_color(red, green, blue, alpha = nil)
attrs = {:red => red, :green => green, :blue => blue}
attrs[:alpha] = alpha if alpha
Color.new(attrs)
end | [
"def",
"rgb_color",
"(",
"red",
",",
"green",
",",
"blue",
",",
"alpha",
"=",
"nil",
")",
"attrs",
"=",
"{",
":red",
"=>",
"red",
",",
":green",
"=>",
"green",
",",
":blue",
"=>",
"blue",
"}",
"attrs",
"[",
":alpha",
"]",
"=",
"alpha",
"if",
"alp... | Construct a Sass Color from rgb values.
@param red [::Number] The red component. Must be between 0 and 255 inclusive.
@param green [::Number] The green component. Must be between 0 and 255 inclusive.
@param blue [::Number] The blue component. Must be between 0 and 255 inclusive.
@param alpha [::Number] The alpha c... | [
"Construct",
"a",
"Sass",
"Color",
"from",
"rgb",
"values",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/script/value/helpers.rb#L48-L52 |
15,072 | sass/ruby-sass | lib/sass/script/value/helpers.rb | Sass::Script::Value.Helpers.parse_selector | def parse_selector(value, name = nil, allow_parent_ref = false)
str = normalize_selector(value, name)
begin
Sass::SCSS::StaticParser.new(str, nil, nil, 1, 1, allow_parent_ref).parse_selector
rescue Sass::SyntaxError => e
err = "#{value.inspect} is not a valid selector: #{e}"
er... | ruby | def parse_selector(value, name = nil, allow_parent_ref = false)
str = normalize_selector(value, name)
begin
Sass::SCSS::StaticParser.new(str, nil, nil, 1, 1, allow_parent_ref).parse_selector
rescue Sass::SyntaxError => e
err = "#{value.inspect} is not a valid selector: #{e}"
er... | [
"def",
"parse_selector",
"(",
"value",
",",
"name",
"=",
"nil",
",",
"allow_parent_ref",
"=",
"false",
")",
"str",
"=",
"normalize_selector",
"(",
"value",
",",
"name",
")",
"begin",
"Sass",
"::",
"SCSS",
"::",
"StaticParser",
".",
"new",
"(",
"str",
","... | Parses a user-provided selector.
@param value [Sass::Script::Value::String, Sass::Script::Value::List]
The selector to parse. This can be either a string, a list of
strings, or a list of lists of strings as returned by `&`.
@param name [Symbol, nil]
If provided, the name of the selector argument. This is us... | [
"Parses",
"a",
"user",
"-",
"provided",
"selector",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/script/value/helpers.rb#L145-L154 |
15,073 | sass/ruby-sass | lib/sass/script/value/helpers.rb | Sass::Script::Value.Helpers.parse_complex_selector | def parse_complex_selector(value, name = nil, allow_parent_ref = false)
selector = parse_selector(value, name, allow_parent_ref)
return seq if selector.members.length == 1
err = "#{value.inspect} is not a complex selector"
err = "$#{name.to_s.tr('_', '-')}: #{err}" if name
raise ArgumentE... | ruby | def parse_complex_selector(value, name = nil, allow_parent_ref = false)
selector = parse_selector(value, name, allow_parent_ref)
return seq if selector.members.length == 1
err = "#{value.inspect} is not a complex selector"
err = "$#{name.to_s.tr('_', '-')}: #{err}" if name
raise ArgumentE... | [
"def",
"parse_complex_selector",
"(",
"value",
",",
"name",
"=",
"nil",
",",
"allow_parent_ref",
"=",
"false",
")",
"selector",
"=",
"parse_selector",
"(",
"value",
",",
"name",
",",
"allow_parent_ref",
")",
"return",
"seq",
"if",
"selector",
".",
"members",
... | Parses a user-provided complex selector.
A complex selector can contain combinators but cannot contain commas.
@param value [Sass::Script::Value::String, Sass::Script::Value::List]
The selector to parse. This can be either a string or a list of
strings.
@param name [Symbol, nil]
If provided, the name of t... | [
"Parses",
"a",
"user",
"-",
"provided",
"complex",
"selector",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/script/value/helpers.rb#L170-L177 |
15,074 | sass/ruby-sass | lib/sass/script/value/helpers.rb | Sass::Script::Value.Helpers.parse_compound_selector | def parse_compound_selector(value, name = nil, allow_parent_ref = false)
assert_type value, :String, name
selector = parse_selector(value, name, allow_parent_ref)
seq = selector.members.first
sseq = seq.members.first
if selector.members.length == 1 && seq.members.length == 1 &&
s... | ruby | def parse_compound_selector(value, name = nil, allow_parent_ref = false)
assert_type value, :String, name
selector = parse_selector(value, name, allow_parent_ref)
seq = selector.members.first
sseq = seq.members.first
if selector.members.length == 1 && seq.members.length == 1 &&
s... | [
"def",
"parse_compound_selector",
"(",
"value",
",",
"name",
"=",
"nil",
",",
"allow_parent_ref",
"=",
"false",
")",
"assert_type",
"value",
",",
":String",
",",
"name",
"selector",
"=",
"parse_selector",
"(",
"value",
",",
"name",
",",
"allow_parent_ref",
")"... | Parses a user-provided compound selector.
A compound selector cannot contain combinators or commas.
@param value [Sass::Script::Value::String] The selector to parse.
@param name [Symbol, nil]
If provided, the name of the selector argument. This is used
for error reporting.
@param allow_parent_ref [Boolean]
... | [
"Parses",
"a",
"user",
"-",
"provided",
"compound",
"selector",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/script/value/helpers.rb#L191-L204 |
15,075 | sass/ruby-sass | lib/sass/script/value/helpers.rb | Sass::Script::Value.Helpers.normalize_selector | def normalize_selector(value, name)
if (str = selector_to_str(value))
return str
end
err = "#{value.inspect} is not a valid selector: it must be a string,\n" +
"a list of strings, or a list of lists of strings"
err = "$#{name.to_s.tr('_', '-')}: #{err}" if name
raise Argum... | ruby | def normalize_selector(value, name)
if (str = selector_to_str(value))
return str
end
err = "#{value.inspect} is not a valid selector: it must be a string,\n" +
"a list of strings, or a list of lists of strings"
err = "$#{name.to_s.tr('_', '-')}: #{err}" if name
raise Argum... | [
"def",
"normalize_selector",
"(",
"value",
",",
"name",
")",
"if",
"(",
"str",
"=",
"selector_to_str",
"(",
"value",
")",
")",
"return",
"str",
"end",
"err",
"=",
"\"#{value.inspect} is not a valid selector: it must be a string,\\n\"",
"+",
"\"a list of strings, or a li... | Converts a user-provided selector into string form or throws an
ArgumentError if it's in an invalid format. | [
"Converts",
"a",
"user",
"-",
"provided",
"selector",
"into",
"string",
"form",
"or",
"throws",
"an",
"ArgumentError",
"if",
"it",
"s",
"in",
"an",
"invalid",
"format",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/script/value/helpers.rb#L237-L246 |
15,076 | sass/ruby-sass | lib/sass/script/value/helpers.rb | Sass::Script::Value.Helpers.selector_to_str | def selector_to_str(value)
return value.value if value.is_a?(Sass::Script::String)
return unless value.is_a?(Sass::Script::List)
if value.separator == :comma
return value.to_a.map do |complex|
next complex.value if complex.is_a?(Sass::Script::String)
return unless complex.... | ruby | def selector_to_str(value)
return value.value if value.is_a?(Sass::Script::String)
return unless value.is_a?(Sass::Script::List)
if value.separator == :comma
return value.to_a.map do |complex|
next complex.value if complex.is_a?(Sass::Script::String)
return unless complex.... | [
"def",
"selector_to_str",
"(",
"value",
")",
"return",
"value",
".",
"value",
"if",
"value",
".",
"is_a?",
"(",
"Sass",
"::",
"Script",
"::",
"String",
")",
"return",
"unless",
"value",
".",
"is_a?",
"(",
"Sass",
"::",
"Script",
"::",
"List",
")",
"if"... | Converts a user-provided selector into string form or returns
`nil` if it's in an invalid format. | [
"Converts",
"a",
"user",
"-",
"provided",
"selector",
"into",
"string",
"form",
"or",
"returns",
"nil",
"if",
"it",
"s",
"in",
"an",
"invalid",
"format",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/script/value/helpers.rb#L250-L267 |
15,077 | sass/ruby-sass | lib/sass/error.rb | Sass.SyntaxError.backtrace | def backtrace
return nil if super.nil?
return super if sass_backtrace.all? {|h| h.empty?}
sass_backtrace.map do |h|
"#{h[:filename] || '(sass)'}:#{h[:line]}" +
(h[:mixin] ? ":in `#{h[:mixin]}'" : "")
end + super
end | ruby | def backtrace
return nil if super.nil?
return super if sass_backtrace.all? {|h| h.empty?}
sass_backtrace.map do |h|
"#{h[:filename] || '(sass)'}:#{h[:line]}" +
(h[:mixin] ? ":in `#{h[:mixin]}'" : "")
end + super
end | [
"def",
"backtrace",
"return",
"nil",
"if",
"super",
".",
"nil?",
"return",
"super",
"if",
"sass_backtrace",
".",
"all?",
"{",
"|",
"h",
"|",
"h",
".",
"empty?",
"}",
"sass_backtrace",
".",
"map",
"do",
"|",
"h",
"|",
"\"#{h[:filename] || '(sass)'}:#{h[:line]... | Returns the standard exception backtrace,
including the Sass backtrace.
@return [Array<String>] | [
"Returns",
"the",
"standard",
"exception",
"backtrace",
"including",
"the",
"Sass",
"backtrace",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/error.rb#L126-L133 |
15,078 | sass/ruby-sass | lib/sass/error.rb | Sass.SyntaxError.sass_backtrace_str | def sass_backtrace_str(default_filename = "an unknown file")
lines = message.split("\n")
msg = lines[0] + lines[1..-1].
map {|l| "\n" + (" " * "Error: ".size) + l}.join
"Error: #{msg}" +
sass_backtrace.each_with_index.map do |entry, i|
"\n #{i == 0 ? 'on' : 'from'} lin... | ruby | def sass_backtrace_str(default_filename = "an unknown file")
lines = message.split("\n")
msg = lines[0] + lines[1..-1].
map {|l| "\n" + (" " * "Error: ".size) + l}.join
"Error: #{msg}" +
sass_backtrace.each_with_index.map do |entry, i|
"\n #{i == 0 ? 'on' : 'from'} lin... | [
"def",
"sass_backtrace_str",
"(",
"default_filename",
"=",
"\"an unknown file\"",
")",
"lines",
"=",
"message",
".",
"split",
"(",
"\"\\n\"",
")",
"msg",
"=",
"lines",
"[",
"0",
"]",
"+",
"lines",
"[",
"1",
"..",
"-",
"1",
"]",
".",
"map",
"{",
"|",
... | Returns a string representation of the Sass backtrace.
@param default_filename [String] The filename to use for unknown files
@see #sass_backtrace
@return [String] | [
"Returns",
"a",
"string",
"representation",
"of",
"the",
"Sass",
"backtrace",
"."
] | 7a50eae567260a23d3bbf4d5aaf1a76db43dec32 | https://github.com/sass/ruby-sass/blob/7a50eae567260a23d3bbf4d5aaf1a76db43dec32/lib/sass/error.rb#L140-L150 |
15,079 | nesquena/rabl | lib/rabl/cache_engine.rb | Rabl.CacheEngine.fetch | def fetch(key, cache_options, &block)
if defined?(Rails)
Rails.cache.fetch(key, cache_options, &block)
else
@cache[key] ||= yield
end
end | ruby | def fetch(key, cache_options, &block)
if defined?(Rails)
Rails.cache.fetch(key, cache_options, &block)
else
@cache[key] ||= yield
end
end | [
"def",
"fetch",
"(",
"key",
",",
"cache_options",
",",
"&",
"block",
")",
"if",
"defined?",
"(",
"Rails",
")",
"Rails",
".",
"cache",
".",
"fetch",
"(",
"key",
",",
"cache_options",
",",
"block",
")",
"else",
"@cache",
"[",
"key",
"]",
"||=",
"yield"... | Fetch given a key and options and a fallback block attempts to find the key in the cache
and stores the block result in there if no key is found.
cache = Rabl::CacheEngine.new; cache.fetch("some_key") { "fallback data" } | [
"Fetch",
"given",
"a",
"key",
"and",
"options",
"and",
"a",
"fallback",
"block",
"attempts",
"to",
"find",
"the",
"key",
"in",
"the",
"cache",
"and",
"stores",
"the",
"block",
"result",
"in",
"there",
"if",
"no",
"key",
"is",
"found",
"."
] | a112a4dd783996dab88299bbfead3fcb3d28f0d3 | https://github.com/nesquena/rabl/blob/a112a4dd783996dab88299bbfead3fcb3d28f0d3/lib/rabl/cache_engine.rb#L43-L49 |
15,080 | nesquena/rabl | lib/rabl/multi_builder.rb | Rabl.MultiBuilder.map_cache_key_to_engine | def map_cache_key_to_engine(engine)
if cache_key = cache_key_for(engine)
result_cache_key = ActiveSupport::Cache.expand_cache_key(cache_key, :rabl)
@cache_key_to_engine[result_cache_key] = engine
disable_cache_read_on_render(engine)
end
end | ruby | def map_cache_key_to_engine(engine)
if cache_key = cache_key_for(engine)
result_cache_key = ActiveSupport::Cache.expand_cache_key(cache_key, :rabl)
@cache_key_to_engine[result_cache_key] = engine
disable_cache_read_on_render(engine)
end
end | [
"def",
"map_cache_key_to_engine",
"(",
"engine",
")",
"if",
"cache_key",
"=",
"cache_key_for",
"(",
"engine",
")",
"result_cache_key",
"=",
"ActiveSupport",
"::",
"Cache",
".",
"expand_cache_key",
"(",
"cache_key",
",",
":rabl",
")",
"@cache_key_to_engine",
"[",
"... | Maps a cache key to an engine | [
"Maps",
"a",
"cache",
"key",
"to",
"an",
"engine"
] | a112a4dd783996dab88299bbfead3fcb3d28f0d3 | https://github.com/nesquena/rabl/blob/a112a4dd783996dab88299bbfead3fcb3d28f0d3/lib/rabl/multi_builder.rb#L54-L60 |
15,081 | nesquena/rabl | lib/rabl/multi_builder.rb | Rabl.MultiBuilder.read_cache_results | def read_cache_results
@cache_results ||= begin
mutable_keys = @cache_key_to_engine.keys.map { |k| k.dup }
if mutable_keys.empty?
{}
else
Rabl.configuration.cache_engine.read_multi(*mutable_keys)
end
end
end | ruby | def read_cache_results
@cache_results ||= begin
mutable_keys = @cache_key_to_engine.keys.map { |k| k.dup }
if mutable_keys.empty?
{}
else
Rabl.configuration.cache_engine.read_multi(*mutable_keys)
end
end
end | [
"def",
"read_cache_results",
"@cache_results",
"||=",
"begin",
"mutable_keys",
"=",
"@cache_key_to_engine",
".",
"keys",
".",
"map",
"{",
"|",
"k",
"|",
"k",
".",
"dup",
"}",
"if",
"mutable_keys",
".",
"empty?",
"{",
"}",
"else",
"Rabl",
".",
"configuration"... | Returns the items that were found in the cache | [
"Returns",
"the",
"items",
"that",
"were",
"found",
"in",
"the",
"cache"
] | a112a4dd783996dab88299bbfead3fcb3d28f0d3 | https://github.com/nesquena/rabl/blob/a112a4dd783996dab88299bbfead3fcb3d28f0d3/lib/rabl/multi_builder.rb#L81-L90 |
15,082 | nesquena/rabl | lib/rabl/multi_builder.rb | Rabl.MultiBuilder.replace_engines_with_cache_results | def replace_engines_with_cache_results
@cache_results.each do |key, value|
engine = @cache_key_to_engine[key]
builder = @engine_to_builder[engine]
builder.replace_engine(engine, value) if value
end
end | ruby | def replace_engines_with_cache_results
@cache_results.each do |key, value|
engine = @cache_key_to_engine[key]
builder = @engine_to_builder[engine]
builder.replace_engine(engine, value) if value
end
end | [
"def",
"replace_engines_with_cache_results",
"@cache_results",
".",
"each",
"do",
"|",
"key",
",",
"value",
"|",
"engine",
"=",
"@cache_key_to_engine",
"[",
"key",
"]",
"builder",
"=",
"@engine_to_builder",
"[",
"engine",
"]",
"builder",
".",
"replace_engine",
"("... | Maps the results from the cache back to the builders | [
"Maps",
"the",
"results",
"from",
"the",
"cache",
"back",
"to",
"the",
"builders"
] | a112a4dd783996dab88299bbfead3fcb3d28f0d3 | https://github.com/nesquena/rabl/blob/a112a4dd783996dab88299bbfead3fcb3d28f0d3/lib/rabl/multi_builder.rb#L93-L99 |
15,083 | nesquena/rabl | lib/rabl/renderer.rb | Rabl.Renderer.process_source | def process_source(source)
return source if source.is_a?(String) && source =~ /\n/
source, _ = engine.fetch_source(source, { :view_path => options[:view_path] })
source
end | ruby | def process_source(source)
return source if source.is_a?(String) && source =~ /\n/
source, _ = engine.fetch_source(source, { :view_path => options[:view_path] })
source
end | [
"def",
"process_source",
"(",
"source",
")",
"return",
"source",
"if",
"source",
".",
"is_a?",
"(",
"String",
")",
"&&",
"source",
"=~",
"/",
"\\n",
"/",
"source",
",",
"_",
"=",
"engine",
".",
"fetch_source",
"(",
"source",
",",
"{",
":view_path",
"=>... | Returns the source given a relative template path | [
"Returns",
"the",
"source",
"given",
"a",
"relative",
"template",
"path"
] | a112a4dd783996dab88299bbfead3fcb3d28f0d3 | https://github.com/nesquena/rabl/blob/a112a4dd783996dab88299bbfead3fcb3d28f0d3/lib/rabl/renderer.rb#L63-L68 |
15,084 | nesquena/rabl | lib/rabl/helpers.rb | Rabl.Helpers.determine_object_root | def determine_object_root(data_token, data_name = nil, include_root = true)
return if object_root_name == false
root_name = data_name.to_s if include_root
if is_object?(data_token) || data_token.nil?
root_name
elsif is_collection?(data_token)
object_root_name || (root_name.singu... | ruby | def determine_object_root(data_token, data_name = nil, include_root = true)
return if object_root_name == false
root_name = data_name.to_s if include_root
if is_object?(data_token) || data_token.nil?
root_name
elsif is_collection?(data_token)
object_root_name || (root_name.singu... | [
"def",
"determine_object_root",
"(",
"data_token",
",",
"data_name",
"=",
"nil",
",",
"include_root",
"=",
"true",
")",
"return",
"if",
"object_root_name",
"==",
"false",
"root_name",
"=",
"data_name",
".",
"to_s",
"if",
"include_root",
"if",
"is_object?",
"(",
... | Returns the object rootname based on if the root should be included
Can be called with data as a collection or object
determine_object_root(@user, :user, true) => "user"
determine_object_root(@user, :person) => "person"
determine_object_root([@user, @user]) => "user" | [
"Returns",
"the",
"object",
"rootname",
"based",
"on",
"if",
"the",
"root",
"should",
"be",
"included",
"Can",
"be",
"called",
"with",
"data",
"as",
"a",
"collection",
"or",
"object",
"determine_object_root",
"("
] | a112a4dd783996dab88299bbfead3fcb3d28f0d3 | https://github.com/nesquena/rabl/blob/a112a4dd783996dab88299bbfead3fcb3d28f0d3/lib/rabl/helpers.rb#L62-L71 |
15,085 | nesquena/rabl | lib/rabl/helpers.rb | Rabl.Helpers.is_collection? | def is_collection?(obj, follow_symbols = true)
data_obj = follow_symbols ? data_object(obj) : obj
data_obj &&
data_obj.is_a?(Enumerable) &&
!(data_obj.is_a?(Struct) ||
defined?(Hashie::Mash) && data_obj.is_a?(Hashie::Mash))
end | ruby | def is_collection?(obj, follow_symbols = true)
data_obj = follow_symbols ? data_object(obj) : obj
data_obj &&
data_obj.is_a?(Enumerable) &&
!(data_obj.is_a?(Struct) ||
defined?(Hashie::Mash) && data_obj.is_a?(Hashie::Mash))
end | [
"def",
"is_collection?",
"(",
"obj",
",",
"follow_symbols",
"=",
"true",
")",
"data_obj",
"=",
"follow_symbols",
"?",
"data_object",
"(",
"obj",
")",
":",
"obj",
"data_obj",
"&&",
"data_obj",
".",
"is_a?",
"(",
"Enumerable",
")",
"&&",
"!",
"(",
"data_obj"... | Returns true if the obj is a collection of items
is_collection?(@user) => false
is_collection?([]) => true | [
"Returns",
"true",
"if",
"the",
"obj",
"is",
"a",
"collection",
"of",
"items",
"is_collection?",
"("
] | a112a4dd783996dab88299bbfead3fcb3d28f0d3 | https://github.com/nesquena/rabl/blob/a112a4dd783996dab88299bbfead3fcb3d28f0d3/lib/rabl/helpers.rb#L84-L90 |
15,086 | nesquena/rabl | lib/rabl/helpers.rb | Rabl.Helpers.object_to_engine | def object_to_engine(object, options = {}, &block)
return if object.nil?
options.reverse_merge!({
:format => "hash".freeze,
:view_path => view_path,
:root => (options[:root] || false)
})
Engine.new(options[:source], options).apply(context_scope, :object => ob... | ruby | def object_to_engine(object, options = {}, &block)
return if object.nil?
options.reverse_merge!({
:format => "hash".freeze,
:view_path => view_path,
:root => (options[:root] || false)
})
Engine.new(options[:source], options).apply(context_scope, :object => ob... | [
"def",
"object_to_engine",
"(",
"object",
",",
"options",
"=",
"{",
"}",
",",
"&",
"block",
")",
"return",
"if",
"object",
".",
"nil?",
"options",
".",
"reverse_merge!",
"(",
"{",
":format",
"=>",
"\"hash\"",
".",
"freeze",
",",
":view_path",
"=>",
"view... | Returns an Engine based representation of any data object given ejs template block
object_to_engine(@user) { attribute :full_name } => { ... }
object_to_engine(@user, :source => "...") { attribute :full_name } => { ... }
object_to_engine([@user], :source => "...") { attribute :full_name } => { ... }
options must ha... | [
"Returns",
"an",
"Engine",
"based",
"representation",
"of",
"any",
"data",
"object",
"given",
"ejs",
"template",
"block",
"object_to_engine",
"("
] | a112a4dd783996dab88299bbfead3fcb3d28f0d3 | https://github.com/nesquena/rabl/blob/a112a4dd783996dab88299bbfead3fcb3d28f0d3/lib/rabl/helpers.rb#L127-L137 |
15,087 | nesquena/rabl | lib/rabl/helpers.rb | Rabl.Helpers.template_cache_configured? | def template_cache_configured?
if defined?(Rails)
defined?(ActionController::Base) && ActionController::Base.perform_caching
else
Rabl.configuration.perform_caching
end
end | ruby | def template_cache_configured?
if defined?(Rails)
defined?(ActionController::Base) && ActionController::Base.perform_caching
else
Rabl.configuration.perform_caching
end
end | [
"def",
"template_cache_configured?",
"if",
"defined?",
"(",
"Rails",
")",
"defined?",
"(",
"ActionController",
"::",
"Base",
")",
"&&",
"ActionController",
"::",
"Base",
".",
"perform_caching",
"else",
"Rabl",
".",
"configuration",
".",
"perform_caching",
"end",
"... | Returns true if the cache has been enabled for the application | [
"Returns",
"true",
"if",
"the",
"cache",
"has",
"been",
"enabled",
"for",
"the",
"application"
] | a112a4dd783996dab88299bbfead3fcb3d28f0d3 | https://github.com/nesquena/rabl/blob/a112a4dd783996dab88299bbfead3fcb3d28f0d3/lib/rabl/helpers.rb#L154-L160 |
15,088 | nesquena/rabl | lib/rabl/engine.rb | Rabl.Engine.object | def object(template_data)
current_data = (@_locals[:object].nil? || template_data == false) ? template_data : @_locals[:object]
@_data_object = data_object(current_data)
@_root_name_data = template_data.is_a?(Hash) && !current_data.is_a?(Hash) ? template_data : current_data
@_root_name_data = @... | ruby | def object(template_data)
current_data = (@_locals[:object].nil? || template_data == false) ? template_data : @_locals[:object]
@_data_object = data_object(current_data)
@_root_name_data = template_data.is_a?(Hash) && !current_data.is_a?(Hash) ? template_data : current_data
@_root_name_data = @... | [
"def",
"object",
"(",
"template_data",
")",
"current_data",
"=",
"(",
"@_locals",
"[",
":object",
"]",
".",
"nil?",
"||",
"template_data",
"==",
"false",
")",
"?",
"template_data",
":",
"@_locals",
"[",
":object",
"]",
"@_data_object",
"=",
"data_object",
"(... | Sets the object to be used as the data source for this template
object(@user)
object @user => :person
object @users | [
"Sets",
"the",
"object",
"to",
"be",
"used",
"as",
"the",
"data",
"source",
"for",
"this",
"template",
"object",
"("
] | a112a4dd783996dab88299bbfead3fcb3d28f0d3 | https://github.com/nesquena/rabl/blob/a112a4dd783996dab88299bbfead3fcb3d28f0d3/lib/rabl/engine.rb#L163-L175 |
15,089 | nesquena/rabl | lib/rabl/engine.rb | Rabl.Engine.collection | def collection(data, options = {})
@_collection_name = options[:root] if options[:root]
@_collection_name ||= data.values.first if data.is_a?(Hash)
@_object_root_name = options[:object_root] if options.has_key?(:object_root)
object(data_object(data) || [])
end | ruby | def collection(data, options = {})
@_collection_name = options[:root] if options[:root]
@_collection_name ||= data.values.first if data.is_a?(Hash)
@_object_root_name = options[:object_root] if options.has_key?(:object_root)
object(data_object(data) || [])
end | [
"def",
"collection",
"(",
"data",
",",
"options",
"=",
"{",
"}",
")",
"@_collection_name",
"=",
"options",
"[",
":root",
"]",
"if",
"options",
"[",
":root",
"]",
"@_collection_name",
"||=",
"data",
".",
"values",
".",
"first",
"if",
"data",
".",
"is_a?",... | Sets the object as a collection casted to a simple array
collection @users
collection @users => :people
collection @users, :root => :person
collection @users, :object_root => :person | [
"Sets",
"the",
"object",
"as",
"a",
"collection",
"casted",
"to",
"a",
"simple",
"array",
"collection"
] | a112a4dd783996dab88299bbfead3fcb3d28f0d3 | https://github.com/nesquena/rabl/blob/a112a4dd783996dab88299bbfead3fcb3d28f0d3/lib/rabl/engine.rb#L201-L208 |
15,090 | nesquena/rabl | lib/rabl/engine.rb | Rabl.Engine.default_object | def default_object
return unless context_scope.respond_to?(:controller)
controller_name = context_scope.controller.controller_name
stripped_name = controller_name.split(%r{::|\/}).last
ivar_object = instance_variable_get("@#{stripped_name}")
ivar_object if is_object?(ivar_object... | ruby | def default_object
return unless context_scope.respond_to?(:controller)
controller_name = context_scope.controller.controller_name
stripped_name = controller_name.split(%r{::|\/}).last
ivar_object = instance_variable_get("@#{stripped_name}")
ivar_object if is_object?(ivar_object... | [
"def",
"default_object",
"return",
"unless",
"context_scope",
".",
"respond_to?",
"(",
":controller",
")",
"controller_name",
"=",
"context_scope",
".",
"controller",
".",
"controller_name",
"stripped_name",
"=",
"controller_name",
".",
"split",
"(",
"%r{",
"\\/",
"... | Returns a guess at the default object for this template
default_object => @user | [
"Returns",
"a",
"guess",
"at",
"the",
"default",
"object",
"for",
"this",
"template",
"default_object",
"=",
">"
] | a112a4dd783996dab88299bbfead3fcb3d28f0d3 | https://github.com/nesquena/rabl/blob/a112a4dd783996dab88299bbfead3fcb3d28f0d3/lib/rabl/engine.rb#L301-L308 |
15,091 | nesquena/rabl | lib/rabl/engine.rb | Rabl.Engine.request_format | def request_format
format = request_params[:format]
if format.nil? && context_scope.respond_to?(:request)
request = context_scope.request
format = request.format.to_sym.to_s if request.respond_to?(:format)
end
format = "json" unless format && respond_to?("to_#{forma... | ruby | def request_format
format = request_params[:format]
if format.nil? && context_scope.respond_to?(:request)
request = context_scope.request
format = request.format.to_sym.to_s if request.respond_to?(:format)
end
format = "json" unless format && respond_to?("to_#{forma... | [
"def",
"request_format",
"format",
"=",
"request_params",
"[",
":format",
"]",
"if",
"format",
".",
"nil?",
"&&",
"context_scope",
".",
"respond_to?",
"(",
":request",
")",
"request",
"=",
"context_scope",
".",
"request",
"format",
"=",
"request",
".",
"format... | Returns a guess at the format in this context_scope
request_format => "xml" | [
"Returns",
"a",
"guess",
"at",
"the",
"format",
"in",
"this",
"context_scope",
"request_format",
"=",
">",
"xml"
] | a112a4dd783996dab88299bbfead3fcb3d28f0d3 | https://github.com/nesquena/rabl/blob/a112a4dd783996dab88299bbfead3fcb3d28f0d3/lib/rabl/engine.rb#L312-L323 |
15,092 | nesquena/rabl | lib/rabl/engine.rb | Rabl.Engine.method_missing | def method_missing(name, *args, &block)
context_scope.respond_to?(name, true) ? context_scope.__send__(name, *args, &block) : super
end | ruby | def method_missing(name, *args, &block)
context_scope.respond_to?(name, true) ? context_scope.__send__(name, *args, &block) : super
end | [
"def",
"method_missing",
"(",
"name",
",",
"*",
"args",
",",
"&",
"block",
")",
"context_scope",
".",
"respond_to?",
"(",
"name",
",",
"true",
")",
"?",
"context_scope",
".",
"__send__",
"(",
"name",
",",
"args",
",",
"block",
")",
":",
"super",
"end"
... | Supports calling helpers defined for the template context_scope using method_missing hook | [
"Supports",
"calling",
"helpers",
"defined",
"for",
"the",
"template",
"context_scope",
"using",
"method_missing",
"hook"
] | a112a4dd783996dab88299bbfead3fcb3d28f0d3 | https://github.com/nesquena/rabl/blob/a112a4dd783996dab88299bbfead3fcb3d28f0d3/lib/rabl/engine.rb#L356-L358 |
15,093 | nesquena/rabl | lib/rabl/sources.rb | Rabl.Sources.fetch_padrino_source | def fetch_padrino_source(file, options = {})
view_path = Array(options[:view_path] || context_scope.settings.views)
# use Padrino's own template resolution mechanism
file_path, _ = context_scope.instance_eval { resolve_template(file) }
# Padrino chops the extension, stitch it back on
... | ruby | def fetch_padrino_source(file, options = {})
view_path = Array(options[:view_path] || context_scope.settings.views)
# use Padrino's own template resolution mechanism
file_path, _ = context_scope.instance_eval { resolve_template(file) }
# Padrino chops the extension, stitch it back on
... | [
"def",
"fetch_padrino_source",
"(",
"file",
",",
"options",
"=",
"{",
"}",
")",
"view_path",
"=",
"Array",
"(",
"options",
"[",
":view_path",
"]",
"||",
"context_scope",
".",
"settings",
".",
"views",
")",
"# use Padrino's own template resolution mechanism",
"file... | Returns the rabl template path for padrino views using configured views | [
"Returns",
"the",
"rabl",
"template",
"path",
"for",
"padrino",
"views",
"using",
"configured",
"views"
] | a112a4dd783996dab88299bbfead3fcb3d28f0d3 | https://github.com/nesquena/rabl/blob/a112a4dd783996dab88299bbfead3fcb3d28f0d3/lib/rabl/sources.rb#L33-L41 |
15,094 | nesquena/rabl | lib/rabl/sources.rb | Rabl.Sources.fetch_rails_source | def fetch_rails_source(file, options = {})
# use Rails template resolution mechanism if possible (find_template)
source_format = request_format if defined?(request_format)
if source_format && context_scope.respond_to?(:lookup_context) # Rails 3
lookup_proc = lambda do |partial|
... | ruby | def fetch_rails_source(file, options = {})
# use Rails template resolution mechanism if possible (find_template)
source_format = request_format if defined?(request_format)
if source_format && context_scope.respond_to?(:lookup_context) # Rails 3
lookup_proc = lambda do |partial|
... | [
"def",
"fetch_rails_source",
"(",
"file",
",",
"options",
"=",
"{",
"}",
")",
"# use Rails template resolution mechanism if possible (find_template)",
"source_format",
"=",
"request_format",
"if",
"defined?",
"(",
"request_format",
")",
"if",
"source_format",
"&&",
"conte... | Returns the rabl template path for Rails, including special lookups for Rails 2 and 3 | [
"Returns",
"the",
"rabl",
"template",
"path",
"for",
"Rails",
"including",
"special",
"lookups",
"for",
"Rails",
"2",
"and",
"3"
] | a112a4dd783996dab88299bbfead3fcb3d28f0d3 | https://github.com/nesquena/rabl/blob/a112a4dd783996dab88299bbfead3fcb3d28f0d3/lib/rabl/sources.rb#L44-L66 |
15,095 | nesquena/rabl | lib/rabl/sources.rb | Rabl.Sources.fetch_sinatra_source | def fetch_sinatra_source(file, options = {})
view_path = Array(options[:view_path] || context_scope.settings.views)
fetch_manual_template(view_path, file)
end | ruby | def fetch_sinatra_source(file, options = {})
view_path = Array(options[:view_path] || context_scope.settings.views)
fetch_manual_template(view_path, file)
end | [
"def",
"fetch_sinatra_source",
"(",
"file",
",",
"options",
"=",
"{",
"}",
")",
"view_path",
"=",
"Array",
"(",
"options",
"[",
":view_path",
"]",
"||",
"context_scope",
".",
"settings",
".",
"views",
")",
"fetch_manual_template",
"(",
"view_path",
",",
"fil... | Returns the rabl template path for sinatra views using configured views | [
"Returns",
"the",
"rabl",
"template",
"path",
"for",
"sinatra",
"views",
"using",
"configured",
"views"
] | a112a4dd783996dab88299bbfead3fcb3d28f0d3 | https://github.com/nesquena/rabl/blob/a112a4dd783996dab88299bbfead3fcb3d28f0d3/lib/rabl/sources.rb#L69-L72 |
15,096 | nesquena/rabl | lib/rabl/builder.rb | Rabl.Builder.child | def child(data, options = {}, &block)
return unless data.present? && resolve_condition(options)
name = is_name_value?(options[:root]) ? options[:root] : data_name(data)
object = data_object(data)
engine_options = @options.slice(:child_root)
engine_options[:root] = is_collecti... | ruby | def child(data, options = {}, &block)
return unless data.present? && resolve_condition(options)
name = is_name_value?(options[:root]) ? options[:root] : data_name(data)
object = data_object(data)
engine_options = @options.slice(:child_root)
engine_options[:root] = is_collecti... | [
"def",
"child",
"(",
"data",
",",
"options",
"=",
"{",
"}",
",",
"&",
"block",
")",
"return",
"unless",
"data",
".",
"present?",
"&&",
"resolve_condition",
"(",
"options",
")",
"name",
"=",
"is_name_value?",
"(",
"options",
"[",
":root",
"]",
")",
"?",... | Creates a child node that is included in json output
child(@user) { attribute :full_name }
child(@user => :person) { ... }
child(@users => :people) { ... } | [
"Creates",
"a",
"child",
"node",
"that",
"is",
"included",
"in",
"json",
"output",
"child",
"("
] | a112a4dd783996dab88299bbfead3fcb3d28f0d3 | https://github.com/nesquena/rabl/blob/a112a4dd783996dab88299bbfead3fcb3d28f0d3/lib/rabl/builder.rb#L170-L183 |
15,097 | nesquena/rabl | lib/rabl/builder.rb | Rabl.Builder.glue | def glue(data, options = {}, &block)
return unless data.present? && resolve_condition(options)
object = data_object(data)
engine = object_to_engine(object, :root => false, &block)
engines << engine if engine
end | ruby | def glue(data, options = {}, &block)
return unless data.present? && resolve_condition(options)
object = data_object(data)
engine = object_to_engine(object, :root => false, &block)
engines << engine if engine
end | [
"def",
"glue",
"(",
"data",
",",
"options",
"=",
"{",
"}",
",",
"&",
"block",
")",
"return",
"unless",
"data",
".",
"present?",
"&&",
"resolve_condition",
"(",
"options",
")",
"object",
"=",
"data_object",
"(",
"data",
")",
"engine",
"=",
"object_to_engi... | Glues data from a child node to the json_output
glue(@user) { attribute :full_name => :user_full_name } | [
"Glues",
"data",
"from",
"a",
"child",
"node",
"to",
"the",
"json_output",
"glue",
"("
] | a112a4dd783996dab88299bbfead3fcb3d28f0d3 | https://github.com/nesquena/rabl/blob/a112a4dd783996dab88299bbfead3fcb3d28f0d3/lib/rabl/builder.rb#L187-L193 |
15,098 | stffn/declarative_authorization | lib/declarative_authorization/authorization.rb | Authorization.Engine.permit? | def permit? (privilege, options = {}) # :yields:
if permit!(privilege, options.merge(:bang=> false))
yield if block_given?
true
else
false
end
end | ruby | def permit? (privilege, options = {}) # :yields:
if permit!(privilege, options.merge(:bang=> false))
yield if block_given?
true
else
false
end
end | [
"def",
"permit?",
"(",
"privilege",
",",
"options",
"=",
"{",
"}",
")",
"# :yields:",
"if",
"permit!",
"(",
"privilege",
",",
"options",
".",
"merge",
"(",
":bang",
"=>",
"false",
")",
")",
"yield",
"if",
"block_given?",
"true",
"else",
"false",
"end",
... | Calls permit! but doesn't raise authorization errors. If no exception is
raised, permit? returns true and yields to the optional block. | [
"Calls",
"permit!",
"but",
"doesn",
"t",
"raise",
"authorization",
"errors",
".",
"If",
"no",
"exception",
"is",
"raised",
"permit?",
"returns",
"true",
"and",
"yields",
"to",
"the",
"optional",
"block",
"."
] | 45e91af20eba71b2828c5c84066bcce3ef032e8a | https://github.com/stffn/declarative_authorization/blob/45e91af20eba71b2828c5c84066bcce3ef032e8a/lib/declarative_authorization/authorization.rb#L205-L212 |
15,099 | stffn/declarative_authorization | lib/declarative_authorization/authorization.rb | Authorization.Engine.roles_for | def roles_for (user)
user ||= Authorization.current_user
raise AuthorizationUsageError, "User object doesn't respond to roles (#{user.inspect})" \
if !user.respond_to?(:role_symbols) and !user.respond_to?(:roles)
Rails.logger.info("The use of user.roles is deprecated. Please add a method " +... | ruby | def roles_for (user)
user ||= Authorization.current_user
raise AuthorizationUsageError, "User object doesn't respond to roles (#{user.inspect})" \
if !user.respond_to?(:role_symbols) and !user.respond_to?(:roles)
Rails.logger.info("The use of user.roles is deprecated. Please add a method " +... | [
"def",
"roles_for",
"(",
"user",
")",
"user",
"||=",
"Authorization",
".",
"current_user",
"raise",
"AuthorizationUsageError",
",",
"\"User object doesn't respond to roles (#{user.inspect})\"",
"if",
"!",
"user",
".",
"respond_to?",
"(",
":role_symbols",
")",
"and",
"!"... | Returns the role symbols of the given user. | [
"Returns",
"the",
"role",
"symbols",
"of",
"the",
"given",
"user",
"."
] | 45e91af20eba71b2828c5c84066bcce3ef032e8a | https://github.com/stffn/declarative_authorization/blob/45e91af20eba71b2828c5c84066bcce3ef032e8a/lib/declarative_authorization/authorization.rb#L259-L274 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.