Sha256: e0510b3f9ef3e696cab9ca7946fe7c883ef71273cbbc8e55e23882ceb980792c
Contents?: true
Size: 1.08 KB
Versions: 1
Compression:
Stored size: 1.08 KB
Contents
require 'rainbow' module Codeguard class Install extend Forwardable attr_accessor :lint def self.perform(lint) new(lint).tap(&:perform) end def initialize(lint) @lint = lint end def perform output = config_gem_path.read prepare_dir output = if write_to_file(config_project_path, output) "File: #{config_project_path} was updated!" else "File: #{config_project_path} was created!" end puts Rainbow(output).green lint.after_install if lint.respond_to?(:after_install) end private def prepare_dir dir = config_project_path.to_s[%r{(.*)\/[\w\.-]*}, 1] FileUtils.mkdir_p(dir) unless dir.nil? end def write_to_file(path, content) if (updating = File.exist?(path)) FileUtils.chmod 'a+w', path end File.open(path, 'w+') { |f| f.write(content) } FileUtils.chmod 'a-w', path updating end def_delegators :lint, :config_project_path, :config_gem_path end # class Install end # module Codeguard
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
codeguard-0.1.0 | lib/codeguard/install.rb |