code
stringlengths
26
124k
docstring
stringlengths
23
125k
func_name
stringlengths
1
98
language
stringclasses
1 value
repo
stringlengths
5
53
path
stringlengths
7
151
url
stringlengths
50
211
license
stringclasses
7 values
def within_loop sync do |sync_code| @cur_index = :variadic_mode "#{sync_code} && #{yield}" end || yield end
NOTE: assumes `@cur_index != :seq_head`. Node types using `within_loop` must have `def in_sequence_head; :raise; end`
within_loop
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/rubocop-ast-1.28.1/lib/rubocop/ast/node_pattern/compiler/sequence_subcompiler.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/rubocop-ast-1.28.1/lib/rubocop/ast/node_pattern/compiler/sequence_subcompiler.rb
Apache-2.0
def use_index_from_end return if @cur_index == :seq_head || @remaining_arity.begin != @remaining_arity.max @cur_index = -@remaining_arity.begin - DELTA end
returns truthy iff `@cur_index` switched to relative from end mode (i.e. < 0)
use_index_from_end
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/rubocop-ast-1.28.1/lib/rubocop/ast/node_pattern/compiler/sequence_subcompiler.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/rubocop-ast-1.28.1/lib/rubocop/ast/node_pattern/compiler/sequence_subcompiler.rb
Apache-2.0
def preserve_union_start(forks) return if @cur_index != :variadic_mode || forks.size <= 1 compiler.with_temp_variables do |union_reset| cur = "(#{union_reset} = [#{@cur_child_var}, #{@cur_index_var}]) && " reset = "(#{@cur_child_var}, #{@cur_index_var} = #{union_reset}) && " forks.transform_values! do |code| code = "#{cur}#{code}" cur = reset code end end end
Modifies in place `forks` to insure that `cur_{child|index}_var` are ok
preserve_union_start
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/rubocop-ast-1.28.1/lib/rubocop/ast/node_pattern/compiler/sequence_subcompiler.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/rubocop-ast-1.28.1/lib/rubocop/ast/node_pattern/compiler/sequence_subcompiler.rb
Apache-2.0
def merge_forks!(forks) sub_compilers = forks.keys if !node.variadic? # e.g {a b | c d} @cur_index = sub_compilers.first.cur_index # all cur_index should be equivalent elsif use_index_from_end # nothing to do else # can't use index from end, so we must sync all forks @cur_index = :variadic_mode forks.each do |sub, code| sub.sync { |sync_code| forks[sub] = "#{code} && #{sync_code}" } end end @in_sync = sub_compilers.all?(&:in_sync) end
Modifies in place `forks` Syncs our state
merge_forks!
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/rubocop-ast-1.28.1/lib/rubocop/ast/node_pattern/compiler/sequence_subcompiler.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/rubocop-ast-1.28.1/lib/rubocop/ast/node_pattern/compiler/sequence_subcompiler.rb
Apache-2.0
def to_h { 'output_stream' => output.__send__(:stream), 'length' => output.length, 'title' => title_component.title, 'progress_mark' => bar_component.progress_mark, 'remainder_mark' => bar_component.remainder_mark, 'progress' => progressable.progress, 'total' => progressable.total, 'percentage' => progressable.percentage_completed_with_precision.to_f, 'elapsed_time_in_seconds' => time_component.__send__(:timer).elapsed_seconds, 'estimated_time_remaining_in_seconds' => time_component.__send__(:estimated_seconds_remaining), 'base_rate_of_change' => rate_component.__send__(:base_rate), 'scaled_rate_of_change' => rate_component.__send__(:scaled_rate), 'unknown_progress_animation_steps' => bar_component.upa_steps, 'throttle_rate' => output.__send__(:throttle).rate, 'started?' => started?, 'stopped?' => stopped?, 'finished?' => finished? } end
rubocop:disable Metrics/AbcSize, Layout/LineLength
to_h
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/base.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/base.rb
Apache-2.0
def inspect "#<ProgressBar:#{progress}/#{total || 'unknown'}>" end
rubocop:enable Metrics/AbcSize, Layout/LineLength
inspect
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/base.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/ruby-progressbar-1.13.0/lib/ruby-progressbar/base.rb
Apache-2.0
def to_binary_dos_time (sec / 2) + (min << 5) + (hour << 11) end
MS-DOS File Date and Time format as used in Interrupt 21H Function 57H: Register CX, the Time: Bits 0-4 2 second increments (0-29) Bits 5-10 minutes (0-59) bits 11-15 hours (0-24) Register DX, the Date: Bits 0-4 day (1-31) bits 5-8 month (1-12) bits 9-15 year (four digit year minus 1980)
to_binary_dos_time
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/dos_time.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/dos_time.rb
Apache-2.0
def dos_equals(other) to_i / 2 == other.to_i / 2 end
Dos time is only stored with two seconds accuracy
dos_equals
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/dos_time.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/dos_time.rb
Apache-2.0
def name_safe? cleanpath = Pathname.new(@name).cleanpath return false unless cleanpath.relative? root = ::File::SEPARATOR naive_expanded_path = ::File.join(root, cleanpath.to_s) ::File.absolute_path(cleanpath.to_s, root) == naive_expanded_path end
Is the name a relative path, free of `..` patterns that could lead to path traversal attacks? This does NOT handle symlinks; if the path contains symlinks, this check is NOT enough to guarantee safety.
name_safe?
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/entry.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/entry.rb
Apache-2.0
def verify_local_header_size! return if @local_header_size.nil? new_size = calculate_local_header_size raise Error, "local header size changed (#{@local_header_size} -> #{new_size})" if @local_header_size != new_size end
check before rewriting an entry (after file sizes are known) that we didn't change the header size (and thus clobber file data or something)
verify_local_header_size!
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/entry.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/entry.rb
Apache-2.0
def extract(dest_path = nil, &block) if dest_path.nil? && !name_safe? warn "WARNING: skipped '#{@name}' as unsafe." return self end dest_path ||= @name block ||= proc { ::Zip.on_exists_proc } raise "unknown file type #{inspect}" unless directory? || file? || symlink? __send__("create_#{@ftype}", dest_path, &block) self end
Extracts entry to file dest_path (defaults to @name). NB: The caller is responsible for making sure dest_path is safe, if it is passed.
extract
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/entry.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/entry.rb
Apache-2.0
def get_input_stream(&block) if @ftype == :directory yield ::Zip::NullInputStream if block_given? ::Zip::NullInputStream elsif @filepath case @ftype when :file ::File.open(@filepath, 'rb', &block) when :symlink linkpath = ::File.readlink(@filepath) stringio = ::StringIO.new(linkpath) yield(stringio) if block_given? stringio else raise "unknown @file_type #{@ftype}" end else zis = ::Zip::InputStream.new(@zipfile, local_header_offset) zis.instance_variable_set(:@complete_entry, self) zis.get_next_entry if block_given? begin yield(zis) ensure zis.close end else zis end end end
Returns an IO like object for the given ZipEntry. Warning: may behave weird with symlinks.
get_input_stream
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/entry.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/entry.rb
Apache-2.0
def parse_zip64_extra(for_local_header) #:nodoc:all return if @extra['Zip64'].nil? if for_local_header @size, @compressed_size = @extra['Zip64'].parse(@size, @compressed_size) else @size, @compressed_size, @local_header_offset = @extra['Zip64'].parse(@size, @compressed_size, @local_header_offset) end end
apply missing data from the zip64 extra information field, if present (required when file sizes exceed 2**32, but can be used for all files)
parse_zip64_extra
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/entry.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/entry.rb
Apache-2.0
def prep_zip64_extra(for_local_header) #:nodoc:all return unless ::Zip.write_zip64_support need_zip64 = @size >= 0xFFFFFFFF || @compressed_size >= 0xFFFFFFFF need_zip64 ||= @local_header_offset >= 0xFFFFFFFF unless for_local_header if need_zip64 @version_needed_to_extract = VERSION_NEEDED_TO_EXTRACT_ZIP64 @extra.delete('Zip64Placeholder') zip64 = @extra.create('Zip64') if for_local_header # local header always includes size and compressed size zip64.original_size = @size zip64.compressed_size = @compressed_size else # central directory entry entries include whichever fields are necessary zip64.original_size = @size if @size >= 0xFFFFFFFF zip64.compressed_size = @compressed_size if @compressed_size >= 0xFFFFFFFF zip64.relative_header_offset = @local_header_offset if @local_header_offset >= 0xFFFFFFFF end else @extra.delete('Zip64') # if this is a local header entry, create a placeholder # so we have room to write a zip64 extra field afterward # (we won't know if it's needed until the file data is written) if for_local_header @extra.create('Zip64Placeholder') else @extra.delete('Zip64Placeholder') end end end
create a zip64 extra information field if we need one
prep_zip64_extra
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/entry.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/entry.rb
Apache-2.0
def ordered_values result = [] each { |k, v| k == 'Unknown' ? result.push(v) : result.unshift(v) } result end
place Unknown last, so "extra" data that is missing the proper signature/size does not prevent known fields from being read back in
ordered_values
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/extra_field.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/extra_field.rb
Apache-2.0
def initialize(path_or_io, create = false, buffer = false, options = {}) super() options = DEFAULT_OPTIONS.merge(options) @name = path_or_io.respond_to?(:path) ? path_or_io.path : path_or_io @comment = '' @create = create ? true : false # allow any truthy value to mean true if ::File.size?(@name.to_s) # There is a file, which exists, that is associated with this zip. @create = false @file_permissions = ::File.stat(@name).mode if buffer read_from_stream(path_or_io) else ::File.open(@name, 'rb') do |f| read_from_stream(f) end end elsif buffer && path_or_io.size > 0 # This zip is probably a non-empty StringIO. read_from_stream(path_or_io) elsif @create # This zip is completely new/empty and is to be created. @entry_set = EntrySet.new elsif ::File.zero?(@name) # A file exists, but it is empty. raise Error, "File #{@name} has zero size. Did you mean to pass the create flag?" else # Everything is wrong. raise Error, "File #{@name} not found" end @stored_entries = @entry_set.dup @stored_comment = @comment @restore_ownership = options[:restore_ownership] @restore_permissions = options[:restore_permissions] @restore_times = options[:restore_times] end
Opens a zip archive. Pass true as the second parameter to create a new archive if it doesn't exist already.
initialize
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/file.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/file.rb
Apache-2.0
def open(file_name, create = false, options = {}) zf = ::Zip::File.new(file_name, create, false, options) return zf unless block_given? begin yield zf ensure zf.close end end
Similar to ::new. If a block is passed the Zip::File object is passed to the block and is automatically closed afterwards, just as with ruby's builtin File::open method.
open
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/file.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/file.rb
Apache-2.0
def add_buffer io = ::StringIO.new('') zf = ::Zip::File.new(io, true, true) yield zf zf.write_buffer(io) end
Same as #open. But outputs data to a buffer instead of a file
add_buffer
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/file.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/file.rb
Apache-2.0
def open_buffer(io, options = {}) unless IO_METHODS.map { |method| io.respond_to?(method) }.all? || io.kind_of?(String) raise "Zip::File.open_buffer expects a String or IO-like argument (responds to #{IO_METHODS.join(', ')}). Found: #{io.class}" end io = ::StringIO.new(io) if io.kind_of?(::String) # https://github.com/rubyzip/rubyzip/issues/119 io.binmode if io.respond_to?(:binmode) zf = ::Zip::File.new(io, true, true, options) return zf unless block_given? yield zf begin zf.write_buffer(io) rescue IOError => e raise unless e.message == 'not opened for writing' end end
Like #open, but reads zip archive contents from a String or open IO stream, and outputs data to a buffer. (This can be used to extract data from a downloaded zip archive without first saving it to disk.)
open_buffer
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/file.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/file.rb
Apache-2.0
def foreach(zip_file_name, &block) ::Zip::File.open(zip_file_name) do |zip_file| zip_file.each(&block) end end
Iterates over the contents of the ZipFile. This is more efficient than using a ZipInputStream since this methods simply iterates through the entries in the central directory structure in the archive whereas ZipInputStream jumps through the entire archive accessing the local entry headers (which contain the same information as the central directory).
foreach
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/file.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/file.rb
Apache-2.0
def save_splited_part(zip_file, partial_zip_file_name, zip_file_size, szip_file_index, segment_size, segment_count) ssegment_size = zip_file_size - zip_file.pos ssegment_size = segment_size if ssegment_size > segment_size szip_file_name = "#{partial_zip_file_name}.#{format('%03d', szip_file_index)}" ::File.open(szip_file_name, 'wb') do |szip_file| if szip_file_index == 1 ssegment_size = put_split_signature(szip_file, segment_size) end chunk_bytes = 0 until ssegment_size == chunk_bytes || zip_file.eof? segment_bytes_left = ssegment_size - chunk_bytes buffer_size = segment_bytes_left < DATA_BUFFER_SIZE ? segment_bytes_left : DATA_BUFFER_SIZE chunk = zip_file.read(buffer_size) chunk_bytes += buffer_size szip_file << chunk # Info for track splitting yield segment_count, szip_file_index, chunk_bytes, ssegment_size if block_given? end end end
TODO: Make the code more understandable
save_splited_part
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/file.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/file.rb
Apache-2.0
def split(zip_file_name, segment_size = MAX_SEGMENT_SIZE, delete_zip_file = true, partial_zip_file_name = nil) raise Error, "File #{zip_file_name} not found" unless ::File.exist?(zip_file_name) raise Errno::ENOENT, zip_file_name unless ::File.readable?(zip_file_name) zip_file_size = ::File.size(zip_file_name) segment_size = get_segment_size_for_split(segment_size) return if zip_file_size <= segment_size segment_count = get_segment_count_for_split(zip_file_size, segment_size) # Checking for correct zip structure ::Zip::File.open(zip_file_name) {} partial_zip_file_name = get_partial_zip_file_name(zip_file_name, partial_zip_file_name) szip_file_index = 0 ::File.open(zip_file_name, 'rb') do |zip_file| until zip_file.eof? szip_file_index += 1 save_splited_part(zip_file, partial_zip_file_name, zip_file_size, szip_file_index, segment_size, segment_count) end end ::File.delete(zip_file_name) if delete_zip_file szip_file_index end
Splits an archive into parts with segment size
split
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/file.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/file.rb
Apache-2.0
def get_output_stream(entry, permission_int = nil, comment = nil, extra = nil, compressed_size = nil, crc = nil, compression_method = nil, size = nil, time = nil, &a_proc) new_entry = if entry.kind_of?(Entry) entry else Entry.new(@name, entry.to_s, comment, extra, compressed_size, crc, compression_method, size, time) end if new_entry.directory? raise ArgumentError, "cannot open stream to directory entry - '#{new_entry}'" end new_entry.unix_perms = permission_int zip_streamable_entry = StreamableStream.new(new_entry) @entry_set << zip_streamable_entry zip_streamable_entry.get_output_stream(&a_proc) end
Returns an output stream to the specified entry. If entry is not an instance of Zip::Entry, a new Zip::Entry will be initialized using the arguments specified. If a block is passed the stream object is passed to the block and the stream is automatically closed afterwards just as with ruby's builtin File.open method.
get_output_stream
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/file.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/file.rb
Apache-2.0
def read(entry) get_input_stream(entry, &:read) end
Returns a string containing the contents of the specified entry
read
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/file.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/file.rb
Apache-2.0
def add(entry, src_path, &continue_on_exists_proc) continue_on_exists_proc ||= proc { ::Zip.continue_on_exists_proc } check_entry_exists(entry, continue_on_exists_proc, 'add') new_entry = entry.kind_of?(::Zip::Entry) ? entry : ::Zip::Entry.new(@name, entry.to_s) new_entry.gather_fileinfo_from_srcpath(src_path) new_entry.dirty = true @entry_set << new_entry end
Convenience method for adding the contents of a file to the archive
add
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/file.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/file.rb
Apache-2.0
def add_stored(entry, src_path, &continue_on_exists_proc) entry = ::Zip::Entry.new(@name, entry.to_s, nil, nil, nil, nil, ::Zip::Entry::STORED) add(entry, src_path, &continue_on_exists_proc) end
Convenience method for adding the contents of a file to the archive in Stored format (uncompressed)
add_stored
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/file.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/file.rb
Apache-2.0
def replace(entry, src_path) check_file(src_path) remove(entry) add(entry, src_path) end
Replaces the specified entry with the contents of src_path (from the file system).
replace
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/file.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/file.rb
Apache-2.0
def write_buffer(io = ::StringIO.new('')) ::Zip::OutputStream.write_buffer(io) do |zos| @entry_set.each { |e| e.write_to_zip_output_stream(zos) } zos.comment = comment end end
Write buffer write changes to buffer and return
write_buffer
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/file.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/file.rb
Apache-2.0
def find_entry(entry_name) selected_entry = @entry_set.find_entry(entry_name) return if selected_entry.nil? selected_entry.restore_ownership = @restore_ownership selected_entry.restore_permissions = @restore_permissions selected_entry.restore_times = @restore_times selected_entry end
Searches for entry with the specified name. Returns nil if no entry is found. See also get_entry
find_entry
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/file.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/file.rb
Apache-2.0
def get_entry(entry) selected_entry = find_entry(entry) raise Errno::ENOENT, entry if selected_entry.nil? selected_entry end
Searches for an entry just as find_entry, but throws Errno::ENOENT if no entry is found.
get_entry
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/file.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/file.rb
Apache-2.0
def size?(filename) entry = @mapped_zip.find_entry(filename) entry.nil? || entry.directory? ? nil : entry.size end
Returns nil for not found and nil for directories
size?
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/filesystem.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/filesystem.rb
Apache-2.0
def each @zip_file.each do |e| yield('/' + e.to_s.chomp('/')) end end
Turns entries into strings and adds leading / and removes trailing slash on directories
each
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/filesystem.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/filesystem.rb
Apache-2.0
def initialize(context, offset = 0, decrypter = nil) super() @archive_io = get_io(context, offset) @decompressor = ::Zip::NullDecompressor @decrypter = decrypter || ::Zip::NullDecrypter.new @current_entry = nil end
Opens the indicated zip file. An exception is thrown if the specified offset in the specified filename is not a local zip entry header. @param context [String||IO||StringIO] file path or IO/StringIO object @param offset [Integer] offset in the IO/StringIO
initialize
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/input_stream.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/input_stream.rb
Apache-2.0
def get_next_entry @archive_io.seek(@current_entry.next_header_offset, IO::SEEK_SET) if @current_entry open_entry end
Returns a Entry object. It is necessary to call this method on a newly created InputStream before reading from the first entry in the archive. Returns nil when there are no more entries.
get_next_entry
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/input_stream.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/input_stream.rb
Apache-2.0
def rewind return if @current_entry.nil? @lineno = 0 @pos = 0 @archive_io.seek(@current_entry.local_header_offset, IO::SEEK_SET) open_entry end
Rewinds the stream to the beginning of the current entry
rewind
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/input_stream.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/input_stream.rb
Apache-2.0
def open(filename_or_io, offset = 0, decrypter = nil) zio = new(filename_or_io, offset, decrypter) return zio unless block_given? begin yield zio ensure zio.close if zio end end
Same as #initialize but if a block is passed the opened stream is passed to the block and closed when the block returns.
open
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/input_stream.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/input_stream.rb
Apache-2.0
def initialize(file_name, stream = false, encrypter = nil) super() @file_name = file_name @output_stream = if stream iostream = @file_name.dup iostream.reopen(@file_name) iostream.rewind iostream else ::File.new(@file_name, 'wb') end @entry_set = ::Zip::EntrySet.new @compressor = ::Zip::NullCompressor.instance @encrypter = encrypter || ::Zip::NullEncrypter.new @closed = false @current_entry = nil @comment = nil end
Opens the indicated zip file. If a file with that name already exists it will be overwritten.
initialize
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/output_stream.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/output_stream.rb
Apache-2.0
def write_buffer(io = ::StringIO.new(''), encrypter = nil) io.binmode if io.respond_to?(:binmode) zos = new(io, true, encrypter) yield zos zos.close_buffer end
Same as #open but writes to a filestream instead
write_buffer
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/output_stream.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/output_stream.rb
Apache-2.0
def close return if @closed finalize_current_entry update_local_headers write_central_directory @output_stream.close @closed = true end
Closes the stream and writes the central directory to the zip file
close
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/output_stream.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/output_stream.rb
Apache-2.0
def close_buffer return @output_stream if @closed finalize_current_entry update_local_headers write_central_directory @closed = true @output_stream end
Closes the stream and writes the central directory to the zip file
close_buffer
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/output_stream.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/output_stream.rb
Apache-2.0
def put_next_entry(entry_name, comment = nil, extra = nil, compression_method = Entry::DEFLATED, level = Zip.default_compression) raise Error, 'zip stream is closed' if @closed new_entry = if entry_name.kind_of?(Entry) entry_name else Entry.new(@file_name, entry_name.to_s) end new_entry.comment = comment unless comment.nil? unless extra.nil? new_entry.extra = extra.kind_of?(ExtraField) ? extra : ExtraField.new(extra.to_s) end new_entry.compression_method = compression_method unless compression_method.nil? init_next_entry(new_entry, level) @current_entry = new_entry end
Closes the current entry and opens a new for writing. +entry+ can be a ZipEntry object or a string.
put_next_entry
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/output_stream.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/output_stream.rb
Apache-2.0
def initial_parse(binstr) return false unless binstr if binstr[0, 2] != self.class.const_get(:HEADER_ID) warn 'WARNING: weird extra field header ID. Skip parsing it.' return false end [binstr[2, 2].unpack1('v'), binstr[4..-1]] end
return field [size, content] or false
initial_parse
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/extra_field/generic.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/extra_field/generic.rb
Apache-2.0
def pack_for_c_dir # reserved 0 and tag 1 s = [0, 1].pack('Vv') tag1 = ''.force_encoding(Encoding::BINARY) if @mtime tag1 << [to_ntfs_time(@mtime)].pack('Q<') if @atime tag1 << [to_ntfs_time(@atime)].pack('Q<') tag1 << [to_ntfs_time(@ctime)].pack('Q<') if @ctime end end s << [tag1.bytesize].pack('v') << tag1 s end
But 7-zip for Windows only stores at central dir
pack_for_c_dir
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/extra_field/ntfs.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/extra_field/ntfs.rb
Apache-2.0
def parse(original_size, compressed_size, relative_header_offset = nil, disk_start_number = nil) @original_size = extract(8, 'Q<') if original_size == 0xFFFFFFFF @compressed_size = extract(8, 'Q<') if compressed_size == 0xFFFFFFFF @relative_header_offset = extract(8, 'Q<') if relative_header_offset && relative_header_offset == 0xFFFFFFFF @disk_start_number = extract(4, 'V') if disk_start_number && disk_start_number == 0xFFFF @content = nil [@original_size || original_size, @compressed_size || compressed_size, @relative_header_offset || relative_header_offset, @disk_start_number || disk_start_number] end
pass the values from the base entry (if applicable) wider values are only present in the extra field for base values set to all FFs returns the final values for the four attributes (from the base or zip64 extra record)
parse
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/extra_field/zip64.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/lib/zip/extra_field/zip64.rb
Apache-2.0
def initialize(input_dir, output_file) @input_dir = input_dir @output_file = output_file end
Initialize with the directory to zip and the location of the output archive.
initialize
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/samples/example_recursive.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/samples/example_recursive.rb
Apache-2.0
def write_entries(entries, path, zipfile) entries.each do |e| zipfile_path = path == '' ? e : File.join(path, e) disk_file_path = File.join(@input_dir, zipfile_path) if File.directory? disk_file_path recursively_deflate_directory(disk_file_path, zipfile, zipfile_path) else put_into_archive(disk_file_path, zipfile, zipfile_path) end end end
A helper method to make the recursion work.
write_entries
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/samples/example_recursive.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/rubyzip-2.3.2/samples/example_recursive.rb
Apache-2.0
def initialize(file_name, yaml_opts = {}, safe_yaml_opts = {}) @safe_yaml_opts = safe_yaml_opts super(file_name, yaml_opts) end
Override YAML::Store#initialize to accept additional option +safe_yaml_opts+.
initialize
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/safe_yaml-1.0.5/lib/safe_yaml/store.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/safe_yaml-1.0.5/lib/safe_yaml/store.rb
Apache-2.0
def load(content) table = safe_yaml_load(content) table == false ? {} : table end
Override YAML::Store#load to use SafeYAML.load instead of YAML.load (via #safe_yaml_load). -- PStore#load is private, while YAML::Store#load is public. ++
load
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/safe_yaml-1.0.5/lib/safe_yaml/store.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/safe_yaml-1.0.5/lib/safe_yaml/store.rb
Apache-2.0
def parse_and_test(yaml) safe_result = parse(yaml) exception_thrown = nil unsafe_result = begin YAML.unsafe_load(yaml) rescue Exception => e exception_thrown = e end if exception_thrown # If the underlying YAML parser (e.g. Psych) threw an exception, I'm # honestly not sure what the right thing to do is. For now I'll just # print a warning. Should SafeYAML fail when Psych fails? Kernel.warn "\n" Kernel.warn "Discrepancy between SafeYAML and #{SafeYAML::YAML_ENGINE} on input:\n" Kernel.warn "#{yaml.unindent}\n" Kernel.warn "SafeYAML result:" Kernel.warn "#{safe_result.inspect}\n" Kernel.warn "#{SafeYAML::YAML_ENGINE} result:" Kernel.warn "#{exception_thrown.inspect}\n" else expect(safe_result).to eq(unsafe_result) end end
Isn't this how I should've been doing it all along?
parse_and_test
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/safe_yaml-1.0.5/spec/resolver_specs.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/safe_yaml-1.0.5/spec/resolver_specs.rb
Apache-2.0
def silence_warnings $VERBOSE = nil; yield ensure $VERBOSE = true end
Stolen from Rails: https://github.com/rails/rails/blob/3-2-stable/activesupport/lib/active_support/core_ext/kernel/reporting.rb#L10-25
silence_warnings
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/safe_yaml-1.0.5/spec/spec_helper.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/safe_yaml-1.0.5/spec/spec_helper.rb
Apache-2.0
def clear_callbacks! @_sass_callbacks = {} end
Removes all callbacks registered against this object.
clear_callbacks!
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/callbacks.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/callbacks.rb
Apache-2.0
def define_callback(name) class_eval <<RUBY, __FILE__, __LINE__ + 1 def on_#{name}(&block) @_sass_callbacks = {} unless defined? @_sass_callbacks (@_sass_callbacks[#{name.inspect}] ||= []) << block end def run_#{name}(*args) return unless defined? @_sass_callbacks return unless @_sass_callbacks[#{name.inspect}] @_sass_callbacks[#{name.inspect}].each {|c| c[*args]} end private :run_#{name} RUBY end
Define a callback with the given name. This will define an `on_#{name}` method that registers a block, and a `run_#{name}` method that runs that block (optionall with some arguments). @param name [Symbol] The name of the callback @return [void]
define_callback
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/callbacks.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/callbacks.rb
Apache-2.0
def initialize(template, options = {}) if template.is_a? IO template = template.read end @options = options.merge(:_convert => true) # Backwards compatibility @options[:old] = true if @options[:alternate] == false @template = template @checked_encoding = false end
@param template [String] The CSS stylesheet. This stylesheet can be encoded using any encoding that can be converted to Unicode. If the stylesheet contains an `@charset` declaration, that overrides the Ruby encoding (see {file:SASS_REFERENCE.md#Encodings the encoding documentation}) @option options :old [Boolean] (false) Whether or not to output old property syntax (`:color blue` as opposed to `color: blue`). This is only meaningful when generating Sass code, rather than SCSS. @option options :indent [String] (" ") The string to use for indenting each line. Defaults to two spaces.
initialize
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/css.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/css.rb
Apache-2.0
def render(fmt = :sass) check_encoding! build_tree.send("to_#{fmt}", @options).strip + "\n" rescue Sass::SyntaxError => err err.modify_backtrace(:filename => @options[:filename] || '(css)') raise err end
Converts the CSS template into Sass or SCSS code. @param fmt [Symbol] `:sass` or `:scss`, designating the format to return. @return [String] The resulting Sass or SCSS code @raise [Sass::SyntaxError] if there's an error parsing the CSS template
render
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/css.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/css.rb
Apache-2.0
def source_encoding check_encoding! @original_encoding end
Returns the original encoding of the document. @return [Encoding, nil] @raise [Encoding::UndefinedConversionError] if the source encoding cannot be converted to UTF-8 @raise [ArgumentError] if the document uses an unknown encoding with `@charset`
source_encoding
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/css.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/css.rb
Apache-2.0
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 end
Parses the CSS template and applies various transformations @return [Tree::Node] The root node of the parsed tree
build_tree
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/css.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/css.rb
Apache-2.0
def parse_selectors(root) root.children.each do |child| next parse_selectors(child) if child.is_a?(Tree::DirectiveNode) next unless child.is_a?(Tree::RuleNode) parser = Sass::SCSS::CssParser.new(child.rule.first, child.filename, nil, child.line) child.parsed_rules = parser.parse_selector end end
Parse all the selectors in the document and assign them to {Sass::Tree::RuleNode#parsed_rules}. @param root [Tree::Node] The parent node
parse_selectors
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/css.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/css.rb
Apache-2.0
def expand_commas(root) root.children.map! do |child| # child.parsed_rules.members.size > 1 iff the rule contains a comma unless child.is_a?(Tree::RuleNode) && child.parsed_rules.members.size > 1 expand_commas(child) if child.is_a?(Tree::DirectiveNode) next child end child.parsed_rules.members.map do |seq| node = Tree::RuleNode.new([]) node.parsed_rules = make_cseq(seq) node.children = child.children node end end root.children.flatten! end
Transform foo, bar, baz color: blue into foo color: blue bar color: blue baz color: blue @param root [Tree::Node] The parent node
expand_commas
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/css.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/css.rb
Apache-2.0
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, rest = seq.members.first, seq.members[1..-1] if current_rule.nil? || first_sseq(current_rule) != first current_rule = Tree::RuleNode.new([]) current_rule.parsed_rules = make_seq(first) end if rest.empty? current_rule.children += child.children else child.parsed_rules = make_seq(*rest) current_rule << child end current_rule end root.children.compact! root.children.uniq! root.children.each {|v| nest_seqs(v)} end
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
nest_seqs
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/css.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/css.rb
Apache-2.0
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::SimpleSequence) firsts, rest = [sseq.members.first], sseq.members[1..-1] firsts.push rest.shift if firsts.first.is_a?(Sass::Selector::Parent) last_simple_subject = rest.empty? && sseq.subject? if current_rule.nil? || first_sseq(current_rule).members != firsts || !!first_sseq(current_rule).subject? != !!last_simple_subject current_rule = Tree::RuleNode.new([]) current_rule.parsed_rules = make_sseq(last_simple_subject, *firsts) end if rest.empty? current_rule.children += child.children else rest.unshift Sass::Selector::Parent.new child.parsed_rules = make_sseq(sseq.subject?, *rest) current_rule << child end current_rule end root.children.compact! root.children.uniq! root.children.each {|v| parent_ref_rules(v)} end
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
parent_ref_rules
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/css.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/css.rb
Apache-2.0
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
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
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/css.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/css.rb
Apache-2.0
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 rule.parsed_rules = make_seq(*(first_seq(rule).members + first_seq(child).members)) end rule.children = child.children end flatten_rules(rule) end
Flattens a single rule. @param rule [Tree::RuleNode] The candidate for flattening @see #flatten_rules
flatten_rule
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/css.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/css.rb
Apache-2.0
def fold_commas(root) prev_rule = nil root.children.map! do |child| unless child.is_a?(Tree::RuleNode) fold_commas(child) if child.is_a?(Tree::DirectiveNode) next child end if prev_rule && prev_rule.children.map {|c| c.to_sass} == child.children.map {|c| c.to_sass} prev_rule.parsed_rules.members << first_seq(child) next nil end fold_commas(child) prev_rule = child child end root.children.compact! end
Transform foo bar color: blue baz color: blue into foo bar, baz color: blue @param root [Tree::Node] The parent node
fold_commas
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/css.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/css.rb
Apache-2.0
def dump_selectors(root) root.children.each do |child| next dump_selectors(child) if child.is_a?(Tree::DirectiveNode) next unless child.is_a?(Tree::RuleNode) child.rule = [child.parsed_rules.to_s] dump_selectors(child) end end
Dump all the parsed {Sass::Tree::RuleNode} selectors to strings. @param root [Tree::Node] The parent node
dump_selectors
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/css.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/css.rb
Apache-2.0
def make_sseq(subject, *sseqs) make_seq(Sass::Selector::SimpleSequence.new(sseqs, subject)) end
Create a {Sass::Selector::CommaSequence} containing only a single {Sass::Selector::Sequence} which in turn contains only a single {Sass::Selector::SimpleSequence}. @param subject [Boolean] Whether this is a subject selector @param sseqs [Array<Sass::Selector::Sequence, String>] @return [Sass::Selector::CommaSequence]
make_sseq
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/css.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/css.rb
Apache-2.0
def first_simple_sel(rule) sseq = first_sseq(rule) return unless sseq.is_a?(Sass::Selector::SimpleSequence) sseq.members.first end
Return the first {Sass::Selector::Simple} in a {Sass::Tree::RuleNode}, unless the rule begins with a combinator. @param rule [Sass::Tree::RuleNode] @return [Sass::Selector::Simple?]
first_simple_sel
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/css.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/css.rb
Apache-2.0
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 column location << " of #{filename}" if filename Sass::Util.sass_warn("DEPRECATION WARNING on #{location}:\n#{message}") end
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] @overload warn(filename, line, column, message) @param filename [String, nil] @param line [Number] @param column [Number] @param message [String]
warn
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/deprecation.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/deprecation.rb
Apache-2.0
def initialize(template, options = {}) @options = self.class.normalize_options(options) @template = template @checked_encoding = false @filename = nil @line = nil end
Creates a new Engine. Note that Engine should only be used directly when compiling in-memory Sass code. If you're compiling a single Sass file from the filesystem, use \{Sass::Engine.for\_file}. If you're compiling multiple files from the filesystem, use {Sass::Plugin}. @param template [String] The Sass template. This template can be encoded using any encoding that can be converted to Unicode. If the template contains an `@charset` declaration, that overrides the Ruby encoding (see {file:SASS_REFERENCE.md#Encodings the encoding documentation}) @param options [{Symbol => Object}] An options hash. See {file:SASS_REFERENCE.md#Options the Sass options documentation}. @see {Sass::Engine.for_file} @see {Sass::Plugin}
initialize
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/engine.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/engine.rb
Apache-2.0
def render return _to_tree.render unless @options[:quiet] Sass::Util.silence_sass_warnings {_to_tree.render} end
Render the template to CSS. @return [String] The CSS @raise [Sass::SyntaxError] if there's an error in the document @raise [Encoding::UndefinedConversionError] if the source encoding cannot be converted to UTF-8 @raise [ArgumentError] if the document uses an unknown encoding with `@charset`
render
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/engine.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/engine.rb
Apache-2.0
def render_with_sourcemap(sourcemap_uri) return _render_with_sourcemap(sourcemap_uri) unless @options[:quiet] Sass::Util.silence_sass_warnings {_render_with_sourcemap(sourcemap_uri)} end
Render the template to CSS and return the source map. @param sourcemap_uri [String] The sourcemap URI to use in the `@sourceMappingURL` comment. If this is relative, it should be relative to the location of the CSS file. @return [(String, Sass::Source::Map)] The rendered CSS and the associated source map @raise [Sass::SyntaxError] if there's an error in the document, or if the public URL for this document couldn't be determined. @raise [Encoding::UndefinedConversionError] if the source encoding cannot be converted to UTF-8 @raise [ArgumentError] if the document uses an unknown encoding with `@charset`
render_with_sourcemap
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/engine.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/engine.rb
Apache-2.0
def to_tree @tree ||= if @options[:quiet] Sass::Util.silence_sass_warnings {_to_tree} else _to_tree end end
Parses the document into its parse tree. Memoized. @return [Sass::Tree::Node] The root of the parse tree. @raise [Sass::SyntaxError] if there's an error in the document
to_tree
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/engine.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/engine.rb
Apache-2.0
def source_encoding check_encoding! @source_encoding end
Returns the original encoding of the document. @return [Encoding, nil] @raise [Encoding::UndefinedConversionError] if the source encoding cannot be converted to UTF-8 @raise [ArgumentError] if the document uses an unknown encoding with `@charset`
source_encoding
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/engine.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/engine.rb
Apache-2.0
def dependencies _dependencies(Set.new, engines = Set.new) Sass::Util.array_minus(engines, [self]) end
Gets a set of all the documents that are (transitive) dependencies of this document, not including the document itself. @return [[Sass::Engine]] The dependency documents.
dependencies
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/engine.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/engine.rb
Apache-2.0
def to_parser_offset(offset) offset + 1 end
Parser tracks 1-based line and offset, so our offset should be converted.
to_parser_offset
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/engine.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/engine.rb
Apache-2.0
def inherited_hash_accessor(name) inherited_hash_reader(name) inherited_hash_writer(name) end
Note: when updating this, update sass/yard/inherited_hash.rb as well.
inherited_hash_accessor
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/environment.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/environment.rb
Apache-2.0
def initialize(parent = nil, options = nil) @parent = parent @options = options || (parent && parent.options) || {} @stack = @parent.nil? ? Sass::Stack.new : nil @caller = nil @content = nil @filename = nil @functions = nil @mixins = nil @selector = nil @vars = nil end
@param options [{Symbol => Object}] The options hash. See {file:SASS_REFERENCE.md#Options the Sass options documentation}. @param parent [Environment] See \{#parent}
initialize
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/environment.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/environment.rb
Apache-2.0
def caller @caller || (@parent && @parent.caller) end
The environment of the caller of this environment's mixin or function. @return {Environment?}
caller
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/environment.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/environment.rb
Apache-2.0
def content @content || (@parent && @parent.content) end
The content passed to this environment. This is naturally only set for mixin body environments with content passed in. @return {[Array<Sass::Tree::Node>, Environment]?} The content nodes and the lexical environment of the content block.
content
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/environment.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/environment.rb
Apache-2.0
def selector @selector || (@caller && @caller.selector) || (@parent && @parent.selector) end
The selector for the current CSS rule, or nil if there is no current CSS rule. @return [Selector::CommaSequence?] The current selector, with any nesting fully resolved.
selector
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/environment.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/environment.rb
Apache-2.0
def global_env @global_env ||= global? ? self : @parent.global_env end
The top-level Environment object. @return [Environment]
global_env
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/environment.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/environment.rb
Apache-2.0
def stack @stack || global_env.stack end
The import/mixin stack. @return [Sass::Stack]
stack
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/environment.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/environment.rb
Apache-2.0
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}
caller
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/environment.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/environment.rb
Apache-2.0
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 content's environment read-only if env && !env.is_a?(ReadOnlyEnvironment) env = ReadOnlyEnvironment.new(env, env.options) end @content_cached = true @content = [tree, env] else @content_cached = true @content = nil end end
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 in this environment.
content
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/environment.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/environment.rb
Apache-2.0
def initialize(msg, attrs = {}) @message = msg @sass_backtrace = [] add_backtrace(attrs) end
@param msg [String] The error message @param attrs [{Symbol => Object}] The information in the backtrace entry. See \{#sass\_backtrace}
initialize
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/error.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/error.rb
Apache-2.0
def add_backtrace(attrs) sass_backtrace << attrs.reject {|_k, v| v.nil?} end
Adds an entry to the exception's Sass backtrace. @param attrs [{Symbol => Object}] The information in the backtrace entry. See \{#sass\_backtrace}
add_backtrace
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/error.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/error.rb
Apache-2.0
def modify_backtrace(attrs) attrs = attrs.reject {|_k, v| v.nil?} # Move backwards through the backtrace (0...sass_backtrace.size).to_a.reverse_each do |i| entry = sass_backtrace[i] sass_backtrace[i] = attrs.merge(entry) attrs.reject! {|k, _v| entry.include?(k)} break if attrs.empty? end end
Modify the top Sass backtrace entries (that is, the most deeply nested ones) to have the given attributes. Specifically, this goes through the backtrace entries from most deeply nested to least, setting the given attributes for each entry. If an entry already has one of the given attributes set, the pre-existing attribute takes precedence and is not used for less deeply-nested entries (even if they don't have that attribute set). @param attrs [{Symbol => Object}] The information to add to the backtrace entry. See \{#sass\_backtrace}
modify_backtrace
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/error.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/error.rb
Apache-2.0
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
Returns the standard exception backtrace, including the Sass backtrace. @return [Array<String>]
backtrace
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/error.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/error.rb
Apache-2.0
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'} line #{entry[:line]}" + " of #{entry[:filename] || default_filename}" + (entry[:mixin] ? ", in `#{entry[:mixin]}'" : "") end.join end
Returns a string representation of the Sass backtrace. @param default_filename [String] The filename to use for unknown files @see #sass_backtrace @return [String]
sass_backtrace_str
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/error.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/error.rb
Apache-2.0
def exception_to_css(e, line_offset = 1) header = header_string(e, line_offset) <<END /* #{header.gsub('*/', '*\\/')} Backtrace:\n#{e.backtrace.join("\n").gsub('*/', '*\\/')} */ body:before { white-space: pre; font-family: monospace; content: "#{header.gsub('"', '\"').gsub("\n", '\\A ')}"; } END end
Returns an error report for an exception in CSS format. @param e [Exception] @param line_offset [Integer] The number of the first line of the Sass template. @return [String] The error report @raise [Exception] `e`, if the {file:SASS_REFERENCE.md#full_exception-option `:full_exception`} option is set to false.
exception_to_css
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/error.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/error.rb
Apache-2.0
def add_feature(feature_name) unless feature_name[0] == ?- raise ArgumentError.new("Plugin feature names must begin with a dash") end KNOWN_FEATURES << feature_name end
Add a feature to Sass. Plugins can use this to easily expose their availability to end users. Plugins must prefix their feature names with a dash to distinguish them from official features. @example Sass.add_feature("-import-globbing") Sass.add_feature("-math-cos") @param feature_name [String] The case sensitive name of the feature to to add to Sass. Must begin with a dash.
add_feature
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/features.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/features.rb
Apache-2.0
def initialize(queries) @queries = queries end
@param queries [Array<Query>] See \{#queries}
initialize
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/media.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/media.rb
Apache-2.0
def merge(other) new_queries = queries.map {|q1| other.queries.map {|q2| q1.merge(q2)}}.flatten.compact return if new_queries.empty? QueryList.new(new_queries) end
Merges this query list with another. The returned query list queries for the intersection between the two inputs. Both query lists should be resolved. @param other [QueryList] @return [QueryList?] The merged list, or nil if there is no intersection.
merge
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/media.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/media.rb
Apache-2.0
def to_css queries.map {|q| q.to_css}.join(', ') end
Returns the CSS for the media query list. @return [String]
to_css
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/media.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/media.rb
Apache-2.0
def to_src(options) queries.map {|q| q.to_src(options)}.join(', ') end
Returns the Sass/SCSS code for the media query list. @param options [{Symbol => Object}] An options hash (see {Sass::CSS#initialize}). @return [String]
to_src
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/media.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/media.rb
Apache-2.0
def to_a Sass::Util.intersperse(queries.map {|q| q.to_a}, ', ').flatten end
Returns a representation of the query as an array of strings and potentially {Sass::Script::Tree::Node}s (if there's interpolation in it). When the interpolation is resolved and the strings are joined together, this will be the string representation of this query. @return [Array<String, Sass::Script::Tree::Node>]
to_a
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/media.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/media.rb
Apache-2.0
def deep_copy QueryList.new(queries.map {|q| q.deep_copy}) end
Returns a deep copy of this query list and all its children. @return [QueryList]
deep_copy
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/media.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/media.rb
Apache-2.0
def initialize(modifier, type, expressions) @modifier = modifier @type = type @expressions = expressions end
@param modifier [Array<String, Sass::Script::Tree::Node>] See \{#modifier} @param type [Array<String, Sass::Script::Tree::Node>] See \{#type} @param expressions [Array<Array<String, Sass::Script::Tree::Node>>] See \{#expressions}
initialize
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/media.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/media.rb
Apache-2.0
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 mod = m1 == 'not' ? m2 : m1 elsif m1 == 'not' && m2 == 'not' # CSS has no way of representing "neither screen nor print" return unless t1 == t2 type = t1 mod = 'not' elsif t1 != t2 return else # t1 == t2, neither m1 nor m2 are "not" type = t1 mod = m1.empty? ? m2 : m1 end Query.new([mod], [type], other.expressions + expressions) end
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.
merge
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/media.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/media.rb
Apache-2.0
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 # we're converting to CSS in the case where we parsed the document as # CSS originally (as in css_test.rb). e.map {|c| c.is_a?(Sass::Script::Tree::Node) ? c.to_sass : c.to_s}.join end.join(' and ') css end
Returns the CSS for the media query. @return [String]
to_css
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/media.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/media.rb
Apache-2.0
def to_src(options) src = '' src << Sass::Media._interp_to_src(modifier, options) src << ' ' unless modifier.empty? src << Sass::Media._interp_to_src(type, options) src << ' and ' unless type.empty? || expressions.empty? src << expressions.map do |e| Sass::Media._interp_to_src(e, options) end.join(' and ') src end
Returns the Sass/SCSS code for the media query. @param options [{Symbol => Object}] An options hash (see {Sass::CSS#initialize}). @return [String]
to_src
ruby
collabnix/kubelabs
.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/media.rb
https://github.com/collabnix/kubelabs/blob/master/.bundles_cache/ruby/2.6.0/gems/sass-3.7.4/lib/sass/media.rb
Apache-2.0