Class: NeetoCompliance::NeetoCommonsSyncVerifier

Inherits:
Base
  • Object
show all
Defined in:
lib/neeto_compliance/verifiers/neeto_commons_sync_verifier.rb

Instance Method Summary collapse

Methods inherited from Base

#app_is_exception?, #app_name, #apps_exception_list, #audit, #error_message, #print_description, #process, #verifier_name

Instance Method Details

#auto_correct!Object



14
15
16
17
18
19
# File 'lib/neeto_compliance/verifiers/neeto_commons_sync_verifier.rb', line 14

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

#autofix_suggestionObject



21
22
23
# File 'lib/neeto_compliance/verifiers/neeto_commons_sync_verifier.rb', line 21

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

#same_file?(local_file, common_file) ⇒ Boolean

Returns:

  • (Boolean)


37
38
39
40
# File 'lib/neeto_compliance/verifiers/neeto_commons_sync_verifier.rb', line 37

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

#valid?Boolean

Returns:

  • (Boolean)


25
26
27
28
29
30
31
32
33
34
35
# File 'lib/neeto_compliance/verifiers/neeto_commons_sync_verifier.rb', line 25

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

#webpack_config_filesObject



5
6
7
8
9
10
11
12
# File 'lib/neeto_compliance/verifiers/neeto_commons_sync_verifier.rb', line 5

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