source: ether_2012/web/resources/css/blueprint-css/lib/blueprint/core_ext.rb @ 319

Last change on this file since 319 was 319, checked in by vmipsl, 12 years ago

Import du projet Ether pour le nouveau look 2012

File size: 1.0 KB
Line 
1class String
2  # see if string has any content
3  def blank?; self.length.zero?; end
4
5  # strip space after :, remove newlines, replace multiple spaces with only one space, remove comments
6  def strip_space!
7    replace self.gsub(/:\s*/, ":").gsub(/\n/, "").gsub(/\s+/, " ").gsub(/(\/\*).*?(\*\/)/, "")
8  end
9
10  # remove newlines, insert space after comma, replace two spaces with one space after comma
11  def strip_selector_space!
12    replace self.gsub(/\n/, "").gsub(",", ", ").gsub(",  ", ", ")
13  end
14
15  # remove leading whitespace, remove end whitespace
16  def strip_side_space!
17    replace self.gsub(/^\s+/, "").gsub(/\s+$/, $/)
18  end
19end
20
21class NilClass
22  def blank?
23    true
24  end
25end
26
27class File
28  # string output from file
29  def self.path_to_string(path)
30    File.new(path).read
31  end
32
33  # saves a string to a specified file path
34  def self.string_to_file(string, path)
35    directory = File.dirname(path)
36    FileUtils.mkdir_p directory unless File.directory?(directory)
37    File.open(path, "w") { |f| f << string }
38  end
39end
Note: See TracBrowser for help on using the repository browser.