Class: OvercommitConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/overcommit_config.rb

Class Method Summary collapse

Class Method Details

.generate_configObject

Generate popular config for Overcommit. Run overcommit_config to generate .overcommit.yml file.



6
7
8
9
10
11
12
13
# File 'lib/overcommit_config.rb', line 6

def self.generate_config
  puts "Generating overcommit config ..."
  file_name = ".overcommit.yml"
  config_file = File.expand_path File.dirname(__FILE__) + '/.overcommit_popular_config.yml'
  config = YAML.safe_load(ERB.new(File.read(config_file)).result)
  File.open(file_name, "w") { |f| f << config.to_yaml }
  self.generate_rubo_script
end

.generate_rubo_scriptObject



15
16
17
18
19
20
21
22
# File 'lib/overcommit_config.rb', line 15

def self.generate_rubo_script
  puts "Generating overcommit rubocop executable script ..."
  file_name = "./bin/custom-script"
  script_file = File.expand_path File.dirname(__FILE__) + '/custom-script'
  config = ERB.new(File.read(script_file)).result
  File.open(file_name, "w") { |f| f << config }
  FileUtils.chmod("a+x", file_name)
end