Module: RuleImporter

Defined in:
lib/sasslint/helpers/rule_importer.rb

Class Method Summary collapse

Class Method Details

.importObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/sasslint/helpers/rule_importer.rb', line 4

def self.import
  target_dir = File.join(SassLint.gem_root, 'lib', 'sasslint', 'rules', 'css')
  input_files = File.join(SassLint.gem_root, 'lib', 'sasslint', 'rules', 'js', '*.js')

  Dir.glob(input_files) do |js_file|
    rb_file_name = "#{File.basename(js_file, '.*')}.rb"
    rb_file = File.new(File.join(target_dir, rb_file_name), 'w+')
    rb_file.puts "\# This rule is taken from https://github.com/stubbornella/csslint/tree/master/src/rules"
    rb_file.puts "\#"
    rb_file.puts "\#"
    rb_file.puts "\# Copyright (c) 2011 Nicole Sullivan and Nicholas C. Zakas. All rights reserved."
    rb_file.puts "\# TODO: Paste the CSSLint LICENSE here."
    rb_file.puts "\#"
    rb_file.puts "\#"
    File.open(js_file).each do |line|
      rb_file.puts "\# #{line}"
    end

    rb_file.close
  end
end