Sha256: 89393653e96682ad66ebedc1226296a8e8eb2fc0893f3e0d29ac2b79e5183979

Contents?: true

Size: 1.22 KB

Versions: 4

Compression:

Stored size: 1.22 KB

Contents

# frozen_string_literal: true

module NeetoCompliance
  class NeetoCommonsSyncVerifier < Base
    def webpack_config_files
      @_webpack_config_files ||= {
        "config/webpack/development.js" => NeetoCompliance::NeetoCommons.path.join("webpack/development.js"),
        "config/webpack/production.js" => NeetoCompliance::NeetoCommons.path.join("webpack/production.js"),
        "config/webpack/staging.js" => NeetoCompliance::NeetoCommons.path.join("webpack/staging.js"),
        "config/webpack/test.js" => NeetoCompliance::NeetoCommons.path.join("webpack/test.js")
      }
    end

    def auto_correct!
      @autofix_commands.each do |command|
        puts command
        system(command)
      end
    end

    def autofix_suggestion
      @autofix_commands.join("\n").yellow
    end

    def valid?
      @autofix_commands = []

      webpack_config_files.each_pair do |local_file, common_file|
        unless same_file?(local_file, common_file)
          @autofix_commands << "cp #{common_file.to_s} #{local_file}"
        end
      end

      @autofix_commands.length == 0
    end

    def same_file?(local_file, common_file)
      File.exist?(local_file) &&
      `diff #{local_file} #{common_file.to_s}`.empty?
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
neeto-compliance-1.0.58 lib/neeto_compliance/verifiers/neeto_commons_sync_verifier.rb
neetob-0.1.2 neeto_compliance/lib/neeto_compliance/verifiers/neeto_commons_sync_verifier.rb
neetob-0.1.1 /Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/neeto_commons_sync_verifier.rb
neetob-0.1.0 /Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/neeto_commons_sync_verifier.rb