Module: ImporterHelper
- Included in:
- TerrImporter::Application::Importer
- Defined in:
- lib/terrimporter/importer_helper.rb
Constant Summary collapse
- CSS_PATTERN =
only check if a line starts with characters, not comments
/^[a-zA-Z]+/
Instance Method Summary collapse
Instance Method Details
#file_contains_valid_css?(file_path) ⇒ Boolean
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/terrimporter/importer_helper.rb', line 11 def file_contains_valid_css?(file_path) css_valid = false File.open(file_path) do |f| f.each_line do |line| if line =~ CSS_PATTERN css_valid = true break end end end css_valid end |
#replace_line!(line, what, with) ⇒ Object
5 6 7 8 9 |
# File 'lib/terrimporter/importer_helper.rb', line 5 def replace_line!(line, what, with) what = Regexp.new "#{$1}" if what.match(/^r\/(.*)\//) LOG.info "Replacing #{what.to_s} with #{with}" line.gsub! what, with end |