Class: CheckDuplication

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

Class Method Summary collapse

Class Method Details

.check_si_arg_est_valide(arg) ⇒ Object



15
16
17
# File 'lib/check_duplication.rb', line 15

def check_si_arg_est_valide(arg)
  print message_erreur(arg) unless mot_cles_gere_par_la_gem?(arg)
end

.formate_les_resultats_par_fichier(duplication_final, arg) ⇒ Object



46
47
48
49
50
51
# File 'lib/check_duplication.rb', line 46

def formate_les_resultats_par_fichier(duplication_final, arg)
  array_reconstitue = @array_filename.zip(duplication_final)
  return if arg.nil?
  affiche_les_resultats_par_fichier(array_reconstitue, arg)
  affiche_les_resultats_pour_ensemble_des_specs(array_reconstitue, arg)
end

.identifie_duplication_au_sein_d_un_mm_file(datas, arg) ⇒ Object



36
37
38
39
40
41
42
43
44
# File 'lib/check_duplication.rb', line 36

def identifie_duplication_au_sein_d_un_mm_file(datas, arg)
  duplication_final = []
  datas.each do |data|
    duplication = []
    data.each{ |expect| duplication << expect }
    duplication_final << duplication.flatten
  end
  formate_les_resultats_par_fichier(duplication_final, arg)
end

.message_erreur(arg) ⇒ Object



19
20
21
# File 'lib/check_duplication.rb', line 19

def message_erreur(arg)
  "Sorry we does not handle '#{arg}', feel free to make a PR about ! ;)"
end

.mot_cles_gere_par_la_gem?(mot_cle) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
26
# File 'lib/check_duplication.rb', line 23

def mot_cles_gere_par_la_gem?(mot_cle)
  array = ['expect', 'result']
  array.include?(mot_cle)
end

.recupere_data_from_spec(arg) ⇒ Object



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

def recupere_data_from_spec(arg)
  check_si_arg_est_valide(arg)
  return unless mot_cles_gere_par_la_gem?(arg)
  datas = GetDataFromSpec.resultat_trie(arg)
  trie_les_expects_et_les_noms_de_fichiers(datas)
  identifie_duplication_au_sein_d_un_mm_file(datas, arg)
end

.trie_les_expects_et_les_noms_de_fichiers(datas) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/check_duplication.rb', line 28

def trie_les_expects_et_les_noms_de_fichiers(datas)
  @array_filename = []
  datas.each do |a|
    @array_filename << a.first
    a.shift
  end
end