Sha256: e6cd6784c2071736f5125727942ac9bd9f56b67f1d15d6453b452da92c5b47a1

Contents?: true

Size: 1.02 KB

Versions: 13

Compression:

Stored size: 1.02 KB

Contents

class String
  # see if string has any content
  def blank?; self.length.zero?; end
  
  # strip space after :, remove newlines, replace multiple spaces with only one space, remove comments
  def strip_space!
    replace self.gsub(/:\s*/, ':').gsub(/\n/, '').gsub(/\s+/, ' ').gsub(/(\/\*).*?(\*\/)/, '')
  end
  
  # remove newlines, insert space after comma, replace two spaces with one space after comma
  def strip_selector_space!
    replace self.gsub(/(\n)/, '').gsub(',', ', ').gsub(',  ', ', ')
  end
  
  # remove leading whitespace, remove end whitespace
  def strip_side_space!
    replace self.gsub(/^\s+/, '').gsub(/\s+$/, $/)
  end
end

class NilClass
  def blank?
    true
  end
end

class File
  # string output from file
  def self.path_to_string(path)
    File.new(path).read
  end
  
  # saves a string to a specified file path
  def self.string_to_file(string, path)
    directory = File.dirname(path)
    FileUtils.mkdir_p directory unless File.directory?(directory)
    File.open(path, 'w') { |f| f << string }
  end
end

Version data entries

13 entries across 13 versions & 3 rubygems

Version Path
arnebrasseur-compass-0.3.5.1 lib/compass/core_ext.rb
arnebrasseur-compass-0.3.5 lib/compass/core_ext.rb
chriseppstein-compass-0.1.1 lib/compass/core_ext.rb
chriseppstein-compass-0.3.0 lib/compass/core_ext.rb
chriseppstein-compass-0.3.1 lib/compass/core_ext.rb
chriseppstein-compass-0.3.2 lib/compass/core_ext.rb
chriseppstein-compass-0.3.3 lib/compass/core_ext.rb
chriseppstein-compass-0.3.4 lib/compass/core_ext.rb
chriseppstein-compass-0.3.6 lib/compass/core_ext.rb
chriseppstein-compass-0.3.7 lib/compass/core_ext.rb
chriseppstein-compass-0.3.8 lib/compass/core_ext.rb
chriseppstein-compass-0.3.9 lib/compass/core_ext.rb
blueprintr-0.1.0 lib/blueprint-css/lib/blueprint/core_ext.rb