lazy-check 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
 - data/.gitignore +8 -0
 - data/.travis.yml +6 -0
 - data/CHANGELOG.md +3 -0
 - data/Gemfile +7 -0
 - data/Gemfile.lock +48 -0
 - data/Notes-developper.md +39 -0
 - data/README.md +148 -0
 - data/Rakefile +10 -0
 - data/bin/console +14 -0
 - data/bin/setup +8 -0
 - data/lazy-check.gemspec +34 -0
 - data/lib/lazy/check/Nokogiri_extension.rb +147 -0
 - data/lib/lazy/check/checked_tag.rb +337 -0
 - data/lib/lazy/check/checked_url.rb +81 -0
 - data/lib/lazy/check/checker.rb +82 -0
 - data/lib/lazy/check/checker_case.rb +111 -0
 - data/lib/lazy/check/checker_code.rb +108 -0
 - data/lib/lazy/check/checker_test.rb +137 -0
 - data/lib/lazy/check/checker_url.rb +117 -0
 - data/lib/lazy/check/constants.rb +17 -0
 - data/lib/lazy/check/locales/en/errors.yaml +13 -0
 - data/lib/lazy/check/locales/fr/errors.yaml +142 -0
 - data/lib/lazy/check/locales/fr/messages.yaml +18 -0
 - data/lib/lazy/check/reporter.rb +84 -0
 - data/lib/lazy/check/version.rb +5 -0
 - data/lib/lazy/check.rb +18 -0
 - data/recipe.yaml +1 -0
 - metadata +130 -0
 
| 
         @@ -0,0 +1,137 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Lazy
         
     | 
| 
      
 2 
     | 
    
         
            +
            class Checker
         
     | 
| 
      
 3 
     | 
    
         
            +
            class Test
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
              # Instance Lazy::Checker principale qui lance les tests
         
     | 
| 
      
 6 
     | 
    
         
            +
              # 
         
     | 
| 
      
 7 
     | 
    
         
            +
              attr_reader :checker
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
              # Données du test
         
     | 
| 
      
 10 
     | 
    
         
            +
              # 
         
     | 
| 
      
 11 
     | 
    
         
            +
              # Doit contenir :
         
     | 
| 
      
 12 
     | 
    
         
            +
              #   - :url    [String] Adresse à visiter
         
     | 
| 
      
 13 
     | 
    
         
            +
              #   - :checks [Array] Liste des checks à faire
         
     | 
| 
      
 14 
     | 
    
         
            +
              # 
         
     | 
| 
      
 15 
     | 
    
         
            +
              attr_reader :data
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
              # Instanciation d'un test
         
     | 
| 
      
 18 
     | 
    
         
            +
              # 
         
     | 
| 
      
 19 
     | 
    
         
            +
              # @param data [Hash] Table de données du test
         
     | 
| 
      
 20 
     | 
    
         
            +
              # 
         
     | 
| 
      
 21 
     | 
    
         
            +
              def initialize(checker, data)
         
     | 
| 
      
 22 
     | 
    
         
            +
                @checker = checker
         
     | 
| 
      
 23 
     | 
    
         
            +
                @data = data
         
     | 
| 
      
 24 
     | 
    
         
            +
                check_data
         
     | 
| 
      
 25 
     | 
    
         
            +
              end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
              # On procède à ce test qui doit réussir
         
     | 
| 
      
 28 
     | 
    
         
            +
              # Ça consiste à :
         
     | 
| 
      
 29 
     | 
    
         
            +
              #   - si :checks est défini : boucler sur tous les :checks pour
         
     | 
| 
      
 30 
     | 
    
         
            +
              #     ce test dans la recette.
         
     | 
| 
      
 31 
     | 
    
         
            +
              #   - si :redirect_to est défini : vérifier qu'on obtient bien une
         
     | 
| 
      
 32 
     | 
    
         
            +
              #     redirection.
         
     | 
| 
      
 33 
     | 
    
         
            +
              #   - si :response est défini : vérifier que c'est bien la réponse
         
     | 
| 
      
 34 
     | 
    
         
            +
              # 
         
     | 
| 
      
 35 
     | 
    
         
            +
              # Cf. checker_url.rb pour le détail
         
     | 
| 
      
 36 
     | 
    
         
            +
              # 
         
     | 
| 
      
 37 
     | 
    
         
            +
              def check(**options)
         
     | 
| 
      
 38 
     | 
    
         
            +
                if data.key?(:checks)
         
     | 
| 
      
 39 
     | 
    
         
            +
                  check_with_checks(**options)
         
     | 
| 
      
 40 
     | 
    
         
            +
                else
         
     | 
| 
      
 41 
     | 
    
         
            +
                  check_autre(**options)
         
     | 
| 
      
 42 
     | 
    
         
            +
                end
         
     | 
| 
      
 43 
     | 
    
         
            +
              end
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
              def check_with_checks(**options)
         
     | 
| 
      
 46 
     | 
    
         
            +
                data[:checks].each do |dcheck|
         
     | 
| 
      
 47 
     | 
    
         
            +
                  check_case = CheckCase.new(urler, dcheck, checker.reporter)
         
     | 
| 
      
 48 
     | 
    
         
            +
                  result = check_case.check
         
     | 
| 
      
 49 
     | 
    
         
            +
                  if result === true
         
     | 
| 
      
 50 
     | 
    
         
            +
                    # Success
         
     | 
| 
      
 51 
     | 
    
         
            +
                  elsif result === false
         
     | 
| 
      
 52 
     | 
    
         
            +
                    # Failure
         
     | 
| 
      
 53 
     | 
    
         
            +
                  else
         
     | 
| 
      
 54 
     | 
    
         
            +
                    # Unknown result — Résultat inconnu
         
     | 
| 
      
 55 
     | 
    
         
            +
                  end
         
     | 
| 
      
 56 
     | 
    
         
            +
                end
         
     | 
| 
      
 57 
     | 
    
         
            +
              end
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
              # Pour checker la redirection ou l'http response
         
     | 
| 
      
 60 
     | 
    
         
            +
              def check_autre(**options)
         
     | 
| 
      
 61 
     | 
    
         
            +
                churl = CheckedUrl.new(data.merge(urler: urler, reporter: reporter))
         
     | 
| 
      
 62 
     | 
    
         
            +
                churl.check(**options)
         
     | 
| 
      
 63 
     | 
    
         
            +
              end
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
              def urler
         
     | 
| 
      
 66 
     | 
    
         
            +
                @urler ||= begin
         
     | 
| 
      
 67 
     | 
    
         
            +
                  full_url = checker.base ? File.join(checker.base, url) : url
         
     | 
| 
      
 68 
     | 
    
         
            +
                  Url.new(full_url)
         
     | 
| 
      
 69 
     | 
    
         
            +
                end
         
     | 
| 
      
 70 
     | 
    
         
            +
              end
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
              def url
         
     | 
| 
      
 73 
     | 
    
         
            +
                @url ||= data[:url]
         
     | 
| 
      
 74 
     | 
    
         
            +
              end
         
     | 
| 
      
 75 
     | 
    
         
            +
             
     | 
| 
      
 76 
     | 
    
         
            +
              # raccourci
         
     | 
| 
      
 77 
     | 
    
         
            +
              def reporter
         
     | 
| 
      
 78 
     | 
    
         
            +
                checker.reporter
         
     | 
| 
      
 79 
     | 
    
         
            +
              end
         
     | 
| 
      
 80 
     | 
    
         
            +
             
     | 
| 
      
 81 
     | 
    
         
            +
              private
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
      
 83 
     | 
    
         
            +
             
     | 
| 
      
 84 
     | 
    
         
            +
                def check_data
         
     | 
| 
      
 85 
     | 
    
         
            +
                  # -- Pour simplifier l'écriture des erreurs --
         
     | 
| 
      
 86 
     | 
    
         
            +
                  data_keys   = data.keys.pretty_join
         
     | 
| 
      
 87 
     | 
    
         
            +
                  data_class  = data.class.name
         
     | 
| 
      
 88 
     | 
    
         
            +
                  # -- Tests de validité --
         
     | 
| 
      
 89 
     | 
    
         
            +
                  data.is_a?(Hash)                    || raise(ERRORS[300] % {c: data_class})
         
     | 
| 
      
 90 
     | 
    
         
            +
                  data.key?(:url)                     || raise(ERRORS[300] % {ks: data_keys})
         
     | 
| 
      
 91 
     | 
    
         
            +
                  err = check_url(data[:url])
         
     | 
| 
      
 92 
     | 
    
         
            +
                  err.nil?                            || raise(ERRORS[302] % {e: err, u: data[:url]})
         
     | 
| 
      
 93 
     | 
    
         
            +
                  data.key?(:name)                    || raise(ERRORS[307] % {ks: data_keys})
         
     | 
| 
      
 94 
     | 
    
         
            +
                  if data.key?(:checks)
         
     | 
| 
      
 95 
     | 
    
         
            +
                    data[:checks].is_a?(Array)        || raise(ERRORS[309] % {c: data_class})
         
     | 
| 
      
 96 
     | 
    
         
            +
                  elsif data.key?(:redirect_to)
         
     | 
| 
      
 97 
     | 
    
         
            +
                    data[:redirect_to].is_a?(String)  || raise(ERRORS[310] % {a: data[:redirect_to].inspect, c: data[:redirect_to].class.name})
         
     | 
| 
      
 98 
     | 
    
         
            +
                    data[:redirect_to].start_with?('http')  || raise(ERRORS[311] % {a: data[:redirect_to].inspect})
         
     | 
| 
      
 99 
     | 
    
         
            +
                  elsif data.key?(:response)
         
     | 
| 
      
 100 
     | 
    
         
            +
                    data[:response].is_a?(Integer)    || raise(ERRORS[312] % {a:data[:response].inspect, c: data[:response].class.name})
         
     | 
| 
      
 101 
     | 
    
         
            +
                  else
         
     | 
| 
      
 102 
     | 
    
         
            +
                    raise(ERRORS[308] % {ks: data_keys})
         
     | 
| 
      
 103 
     | 
    
         
            +
                  end
         
     | 
| 
      
 104 
     | 
    
         
            +
                end
         
     | 
| 
      
 105 
     | 
    
         
            +
             
     | 
| 
      
 106 
     | 
    
         
            +
                # S'assure que +url+ est une url valide. @return nil si c'est le
         
     | 
| 
      
 107 
     | 
    
         
            +
                # cas où l'erreur dans le cas contraire.
         
     | 
| 
      
 108 
     | 
    
         
            +
                # 
         
     | 
| 
      
 109 
     | 
    
         
            +
                # @note 
         
     | 
| 
      
 110 
     | 
    
         
            +
                # 
         
     | 
| 
      
 111 
     | 
    
         
            +
                #   Ce qu'on appelle une +url+ ici peut être un URI (https://...)
         
     | 
| 
      
 112 
     | 
    
         
            +
                #   ou le code résultant du chargement de cette URI, qui sera 
         
     | 
| 
      
 113 
     | 
    
         
            +
                #   reconnaissable parce qu'il commence par "<" et finit par ">"
         
     | 
| 
      
 114 
     | 
    
         
            +
                #   (oui, c'est de la reconnaissance paresseuse…)
         
     | 
| 
      
 115 
     | 
    
         
            +
                # 
         
     | 
| 
      
 116 
     | 
    
         
            +
                def check_url(url)
         
     | 
| 
      
 117 
     | 
    
         
            +
                  url                     || raise(ERRORS[303])
         
     | 
| 
      
 118 
     | 
    
         
            +
                  url.is_a?(String)       || raise(ERRORS[304] % {c: url.class.name})
         
     | 
| 
      
 119 
     | 
    
         
            +
                  if url.match?(/^<.+>$/.freeze)
         
     | 
| 
      
 120 
     | 
    
         
            +
                    # Du code HTML/XML
         
     | 
| 
      
 121 
     | 
    
         
            +
                  else
         
     | 
| 
      
 122 
     | 
    
         
            +
                    if checker.base?
         
     | 
| 
      
 123 
     | 
    
         
            +
                      # Pas à tester le début
         
     | 
| 
      
 124 
     | 
    
         
            +
                    else
         
     | 
| 
      
 125 
     | 
    
         
            +
                      url.start_with?('http') || raise(ERRORS[305])
         
     | 
| 
      
 126 
     | 
    
         
            +
                    end
         
     | 
| 
      
 127 
     | 
    
         
            +
                    not(url.match?(/ /))    || raise(ERRORS[306])
         
     | 
| 
      
 128 
     | 
    
         
            +
                  end
         
     | 
| 
      
 129 
     | 
    
         
            +
                rescue Exception => e
         
     | 
| 
      
 130 
     | 
    
         
            +
                  return e.message
         
     | 
| 
      
 131 
     | 
    
         
            +
                else
         
     | 
| 
      
 132 
     | 
    
         
            +
                  return nil
         
     | 
| 
      
 133 
     | 
    
         
            +
                end
         
     | 
| 
      
 134 
     | 
    
         
            +
             
     | 
| 
      
 135 
     | 
    
         
            +
            end #/class Test
         
     | 
| 
      
 136 
     | 
    
         
            +
            end #/class Checker
         
     | 
| 
      
 137 
     | 
    
         
            +
            end #/module Lazy
         
     | 
| 
         @@ -0,0 +1,117 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'net/http'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'nokogiri'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            module Lazy
         
     | 
| 
      
 5 
     | 
    
         
            +
            class Checker
         
     | 
| 
      
 6 
     | 
    
         
            +
            class Url
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
              attr_reader :uri_string
         
     | 
| 
      
 9 
     | 
    
         
            +
              
         
     | 
| 
      
 10 
     | 
    
         
            +
              # Instanciation d'un test
         
     | 
| 
      
 11 
     | 
    
         
            +
              # 
         
     | 
| 
      
 12 
     | 
    
         
            +
              # @param uri [String] URL ou code
         
     | 
| 
      
 13 
     | 
    
         
            +
              # 
         
     | 
| 
      
 14 
     | 
    
         
            +
              def initialize(uri)
         
     | 
| 
      
 15 
     | 
    
         
            +
                @uri_string = uri.strip
         
     | 
| 
      
 16 
     | 
    
         
            +
              end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
              # @return Nokogiri Document
         
     | 
| 
      
 19 
     | 
    
         
            +
              def nokogiri
         
     | 
| 
      
 20 
     | 
    
         
            +
                @nokogiri ||= Nokogiri::XML(code_html)#.tap { |n| dbg("Classe : #{n.class}".bleu)}
         
     | 
| 
      
 21 
     | 
    
         
            +
              end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
              # -- Predicate Methods --
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
              # @return true si la page a pu être chargée correctement
         
     | 
| 
      
 26 
     | 
    
         
            +
              def ok?
         
     | 
| 
      
 27 
     | 
    
         
            +
                not(code_html.nil?)
         
     | 
| 
      
 28 
     | 
    
         
            +
              end
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
              # @return true si la page est une redirection
         
     | 
| 
      
 31 
     | 
    
         
            +
              # @note la redirection se trouve dans @redirect_to
         
     | 
| 
      
 32 
     | 
    
         
            +
              def redirection?
         
     | 
| 
      
 33 
     | 
    
         
            +
                code_html.nil? && not(@redirect_to.nil?)
         
     | 
| 
      
 34 
     | 
    
         
            +
              end
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
              # @return la redirection
         
     | 
| 
      
 37 
     | 
    
         
            +
              # 
         
     | 
| 
      
 38 
     | 
    
         
            +
              # @note Il faut avoir appelé #code_html ou #read avant de
         
     | 
| 
      
 39 
     | 
    
         
            +
              # pouvoir l'utiliser.
         
     | 
| 
      
 40 
     | 
    
         
            +
              def redirect_to
         
     | 
| 
      
 41 
     | 
    
         
            +
                @redirect_to
         
     | 
| 
      
 42 
     | 
    
         
            +
              end
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
              # @return la response.value
         
     | 
| 
      
 45 
     | 
    
         
            +
              # @note Il faut que #code_html ou #read ait été appelé avant
         
     | 
| 
      
 46 
     | 
    
         
            +
              def rvalue
         
     | 
| 
      
 47 
     | 
    
         
            +
                @rvalue
         
     | 
| 
      
 48 
     | 
    
         
            +
              end
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
              def code_html
         
     | 
| 
      
 51 
     | 
    
         
            +
                @code_html ||= readit
         
     | 
| 
      
 52 
     | 
    
         
            +
              end
         
     | 
| 
      
 53 
     | 
    
         
            +
              
         
     | 
| 
      
 54 
     | 
    
         
            +
              def readit
         
     | 
| 
      
 55 
     | 
    
         
            +
                if uri_string.start_with?('http')
         
     | 
| 
      
 56 
     | 
    
         
            +
                  uri = URI(uri_string)
         
     | 
| 
      
 57 
     | 
    
         
            +
                  begin
         
     | 
| 
      
 58 
     | 
    
         
            +
                    response = Net::HTTP.get_response(uri)
         
     | 
| 
      
 59 
     | 
    
         
            +
                  rescue SocketError => e
         
     | 
| 
      
 60 
     | 
    
         
            +
                    @rvalue = e.message.match(/([4][0-9][0-9])/).to_a[1].to_i
         
     | 
| 
      
 61 
     | 
    
         
            +
                    return
         
     | 
| 
      
 62 
     | 
    
         
            +
                  rescue Net::HTTPServerException => e
         
     | 
| 
      
 63 
     | 
    
         
            +
                    @rvalue = e.message.match(/([4][0-9][0-9])/).to_a[1].to_i
         
     | 
| 
      
 64 
     | 
    
         
            +
                    return
         
     | 
| 
      
 65 
     | 
    
         
            +
                  rescue Net::HTTPClientException => e
         
     | 
| 
      
 66 
     | 
    
         
            +
                    @rvalue = e.message.match(/([4][0-9][0-9])/).to_a[1].to_i
         
     | 
| 
      
 67 
     | 
    
         
            +
                    return
         
     | 
| 
      
 68 
     | 
    
         
            +
                  end
         
     | 
| 
      
 69 
     | 
    
         
            +
                  begin
         
     | 
| 
      
 70 
     | 
    
         
            +
                    @rvalue = response.value
         
     | 
| 
      
 71 
     | 
    
         
            +
                  # rescue Net::HTTPServerException => e
         
     | 
| 
      
 72 
     | 
    
         
            +
                  #   @rvalue = e.message.match(/([4][0-9][0-9])/).to_a[1].to_i
         
     | 
| 
      
 73 
     | 
    
         
            +
                  #   puts "rvalue: #{@rvalue.inspect}".jaune
         
     | 
| 
      
 74 
     | 
    
         
            +
                  #   exit
         
     | 
| 
      
 75 
     | 
    
         
            +
                  #   return
         
     | 
| 
      
 76 
     | 
    
         
            +
                  rescue Net::HTTPClientException => e
         
     | 
| 
      
 77 
     | 
    
         
            +
                    @rvalue = e.message.match(/([4][0-9][0-9])/).to_a[1].to_i
         
     | 
| 
      
 78 
     | 
    
         
            +
                    return
         
     | 
| 
      
 79 
     | 
    
         
            +
                  end
         
     | 
| 
      
 80 
     | 
    
         
            +
                  case response
         
     | 
| 
      
 81 
     | 
    
         
            +
                  when Net::HTTPSuccess
         
     | 
| 
      
 82 
     | 
    
         
            +
                    body = response.body # toute la page html
         
     | 
| 
      
 83 
     | 
    
         
            +
                    @rvalue = response.code.to_i
         
     | 
| 
      
 84 
     | 
    
         
            +
                    # dbg("response.value = #{response.methods.inspect}".bleu)
         
     | 
| 
      
 85 
     | 
    
         
            +
                    # dbg("response.code = #{response.code.inspect}".bleu)
         
     | 
| 
      
 86 
     | 
    
         
            +
                    if body.match?(REG_REDIRECTION)
         
     | 
| 
      
 87 
     | 
    
         
            +
                      #
         
     | 
| 
      
 88 
     | 
    
         
            +
                      # -- la page html définit une redirection par
         
     | 
| 
      
 89 
     | 
    
         
            +
                      #    balise meta --
         
     | 
| 
      
 90 
     | 
    
         
            +
                      # 
         
     | 
| 
      
 91 
     | 
    
         
            +
                      @redirect_to = body.match(REG_REDIRECTION).to_a[1].strip
         
     | 
| 
      
 92 
     | 
    
         
            +
                      return nil
         
     | 
| 
      
 93 
     | 
    
         
            +
                    else
         
     | 
| 
      
 94 
     | 
    
         
            +
                      # 
         
     | 
| 
      
 95 
     | 
    
         
            +
                      # Un corps de page normal (note : <html>...</html>)
         
     | 
| 
      
 96 
     | 
    
         
            +
                      # 
         
     | 
| 
      
 97 
     | 
    
         
            +
                      return body
         
     | 
| 
      
 98 
     | 
    
         
            +
                    end
         
     | 
| 
      
 99 
     | 
    
         
            +
                  when Net::HTTPRedirect
         
     | 
| 
      
 100 
     | 
    
         
            +
                    @redirect_to = response['location']
         
     | 
| 
      
 101 
     | 
    
         
            +
                    return nil
         
     | 
| 
      
 102 
     | 
    
         
            +
                  else
         
     | 
| 
      
 103 
     | 
    
         
            +
                    return nil
         
     | 
| 
      
 104 
     | 
    
         
            +
                  end
         
     | 
| 
      
 105 
     | 
    
         
            +
                elsif uri_string.start_with?('<') and uri_string.end_with?('>')
         
     | 
| 
      
 106 
     | 
    
         
            +
                  uri_string
         
     | 
| 
      
 107 
     | 
    
         
            +
                else
         
     | 
| 
      
 108 
     | 
    
         
            +
                  raise ArgumentError.new(ERRORS[201] % {a:uri_string.inspect})
         
     | 
| 
      
 109 
     | 
    
         
            +
                end
         
     | 
| 
      
 110 
     | 
    
         
            +
              end
         
     | 
| 
      
 111 
     | 
    
         
            +
             
     | 
| 
      
 112 
     | 
    
         
            +
              REG_REDIRECTION = /<meta.+http-equiv="refresh".+content="[0-9]+;(.+)">/.freeze
         
     | 
| 
      
 113 
     | 
    
         
            +
             
     | 
| 
      
 114 
     | 
    
         
            +
             
     | 
| 
      
 115 
     | 
    
         
            +
            end #/class Url
         
     | 
| 
      
 116 
     | 
    
         
            +
            end #/class Checker
         
     | 
| 
      
 117 
     | 
    
         
            +
            end #/module Lazy
         
     | 
| 
         @@ -0,0 +1,17 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module Lazy
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            KNOWN_LANGS = ['fr','en']
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            lang = ENV['LANG'][0..1] || 'en'
         
     | 
| 
      
 6 
     | 
    
         
            +
            # lang = 'en' # pour tester
         
     | 
| 
      
 7 
     | 
    
         
            +
            lang = 'en' unless KNOWN_LANGS.include?(lang)
         
     | 
| 
      
 8 
     | 
    
         
            +
            LANG = lang
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            APP_FOLDER = File.dirname(File.dirname(File.dirname(__dir__)))
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            YAML_OPTIONS = {symbolize_names:true, aliases:true, permitted_classes:[Date,Integer,Float]}
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            ERRORS    = YAML.safe_load(File.read(File.join(__dir__,'locales',LANG,'errors.yaml')), **YAML_OPTIONS)
         
     | 
| 
      
 15 
     | 
    
         
            +
            MESSAGES  = YAML.safe_load(File.read(File.join(__dir__,'locales',LANG,'messages.yaml')), **YAML_OPTIONS)
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            end #/module Lazy
         
     | 
| 
         @@ -0,0 +1,13 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ---
         
     | 
| 
      
 2 
     | 
    
         
            +
            1000: |
         
     | 
| 
      
 3 
     | 
    
         
            +
              Lazy::Checker::CheckCase instanciation requires a Lazy::Checker::Url (first argument).
         
     | 
| 
      
 4 
     | 
    
         
            +
              Actual value is %{a}::%{c}.
         
     | 
| 
      
 5 
     | 
    
         
            +
            1001: |
         
     | 
| 
      
 6 
     | 
    
         
            +
              Lazy::Checker::CheckCase instanciation requires a Hash (second argument).
         
     | 
| 
      
 7 
     | 
    
         
            +
              Actual value is %{a}::%{c}.
         
     | 
| 
      
 8 
     | 
    
         
            +
            1002: |
         
     | 
| 
      
 9 
     | 
    
         
            +
              CheckCase data should define :tag value (tag name with at least id or css class).
         
     | 
| 
      
 10 
     | 
    
         
            +
              They only define : %{ks}.
         
     | 
| 
      
 11 
     | 
    
         
            +
            1003: |
         
     | 
| 
      
 12 
     | 
    
         
            +
              :tag value of the CheckCase data should define at least a id (tagName#id) or a css 
         
     | 
| 
      
 13 
     | 
    
         
            +
              class (tagName.css_class). '%{a}' defines neither.
         
     | 
| 
         @@ -0,0 +1,142 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ---
         
     | 
| 
      
 2 
     | 
    
         
            +
            # -- Erreurs de recette --
         
     | 
| 
      
 3 
     | 
    
         
            +
            200: |
         
     | 
| 
      
 4 
     | 
    
         
            +
              Le fichier recette '%{path}' est introuvable.
         
     | 
| 
      
 5 
     | 
    
         
            +
            201: |
         
     | 
| 
      
 6 
     | 
    
         
            +
              La donnée %{a} n'est pas valide, pour instancier un Checker::Url. Il faudrait soit
         
     | 
| 
      
 7 
     | 
    
         
            +
              une URL (conforme) soit un code HTML (valide).
         
     | 
| 
      
 8 
     | 
    
         
            +
            202: |
         
     | 
| 
      
 9 
     | 
    
         
            +
              Le fichier recette ne contient aucune donnée.
         
     | 
| 
      
 10 
     | 
    
         
            +
            203: |
         
     | 
| 
      
 11 
     | 
    
         
            +
              Les données de la recette devraient être une table (Hash) pas un %{c}.
         
     | 
| 
      
 12 
     | 
    
         
            +
            204: |
         
     | 
| 
      
 13 
     | 
    
         
            +
              La recette devrait définir la clé :tests. Elle ne définit que les clés %{ks}.
         
     | 
| 
      
 14 
     | 
    
         
            +
            205: |
         
     | 
| 
      
 15 
     | 
    
         
            +
              Les données :tests devraient être un Array, pas un %{c}.
         
     | 
| 
      
 16 
     | 
    
         
            +
            206: |
         
     | 
| 
      
 17 
     | 
    
         
            +
              La recette doit définir son nom avec la clé :name.
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            # -- Erreurs de la définition d'un test --
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
            300: |
         
     | 
| 
      
 22 
     | 
    
         
            +
              Les données du test devraient être une table Hash, pas un %{c}.
         
     | 
| 
      
 23 
     | 
    
         
            +
            301: |
         
     | 
| 
      
 24 
     | 
    
         
            +
              La table du test devrait définir la propriété :url, qui est la page à atteindre. 
         
     | 
| 
      
 25 
     | 
    
         
            +
              Je ne trouve que les propriétés %{ks}.
         
     | 
| 
      
 26 
     | 
    
         
            +
            302: |
         
     | 
| 
      
 27 
     | 
    
         
            +
              L'URL fournie (%{u}) n'est pas valide : %{e}.
         
     | 
| 
      
 28 
     | 
    
         
            +
            303: |
         
     | 
| 
      
 29 
     | 
    
         
            +
              elle doit être définie, pas nil.
         
     | 
| 
      
 30 
     | 
    
         
            +
            304: |
         
     | 
| 
      
 31 
     | 
    
         
            +
              elle doit être un string, pas un %{c}.
         
     | 
| 
      
 32 
     | 
    
         
            +
            305: |
         
     | 
| 
      
 33 
     | 
    
         
            +
              elle doit obligatoirement commencer par 'http' ou 'https'.
         
     | 
| 
      
 34 
     | 
    
         
            +
            306: |
         
     | 
| 
      
 35 
     | 
    
         
            +
              elle ne devrait contenir aucune espace…
         
     | 
| 
      
 36 
     | 
    
         
            +
            307: |
         
     | 
| 
      
 37 
     | 
    
         
            +
              Un test doit définir son nom (dans :name), il ne définit que les clés
         
     | 
| 
      
 38 
     | 
    
         
            +
              %{ks}.
         
     | 
| 
      
 39 
     | 
    
         
            +
            308: |
         
     | 
| 
      
 40 
     | 
    
         
            +
              Un test doit définir les checks à faire dans une propriété qui s'appelle
         
     | 
| 
      
 41 
     | 
    
         
            +
              justement :checks. Le test ne définit que les propriétés %{ks}…
         
     | 
| 
      
 42 
     | 
    
         
            +
            309: |
         
     | 
| 
      
 43 
     | 
    
         
            +
              Les checks à faire pour le test (:checks) devraient être une liste
         
     | 
| 
      
 44 
     | 
    
         
            +
              Array, par un %{c}.
         
     | 
| 
      
 45 
     | 
    
         
            +
            310: |
         
     | 
| 
      
 46 
     | 
    
         
            +
              La redirection %{a} devrait être une chaine de caractères, pas un %{c}.
         
     | 
| 
      
 47 
     | 
    
         
            +
            311: |
         
     | 
| 
      
 48 
     | 
    
         
            +
              La redirection %{a} devrait commencer par 'http[s]'…
         
     | 
| 
      
 49 
     | 
    
         
            +
            312: |
         
     | 
| 
      
 50 
     | 
    
         
            +
              Pour tester la réponse HTTP, il faut donner le nombre attendu, donc il
         
     | 
| 
      
 51 
     | 
    
         
            +
              faut donner un Integer, or %{a} est un %{c}. 
         
     | 
| 
      
 52 
     | 
    
         
            +
              Par exemple : 404.
         
     | 
| 
      
 53 
     | 
    
         
            +
            800: |
         
     | 
| 
      
 54 
     | 
    
         
            +
              -- INUTILISÉ --
         
     | 
| 
      
 55 
     | 
    
         
            +
            1000: |
         
     | 
| 
      
 56 
     | 
    
         
            +
              L'instanciation de Lazy::Checker::CheckCase nécessite un Lazy::Checker::Url
         
     | 
| 
      
 57 
     | 
    
         
            +
              en premier argument. La valeur est %{a}::%{c}.
         
     | 
| 
      
 58 
     | 
    
         
            +
            1001: |
         
     | 
| 
      
 59 
     | 
    
         
            +
              L'instanciation de Lazy::Checker::CheckCase nécessite un Hash en second
         
     | 
| 
      
 60 
     | 
    
         
            +
              argument, une table définissant ce cas de test. La valeur est %{a}::%{c}…
         
     | 
| 
      
 61 
     | 
    
         
            +
            1002: |
         
     | 
| 
      
 62 
     | 
    
         
            +
              Les données du CheckCase devraient définir :tag, la balise avec son
         
     | 
| 
      
 63 
     | 
    
         
            +
              identifiant et ses classes CSS. Elles ne définissent que :
         
     | 
| 
      
 64 
     | 
    
         
            +
              %{ks}.
         
     | 
| 
      
 65 
     | 
    
         
            +
            1003: |
         
     | 
| 
      
 66 
     | 
    
         
            +
              La donnée :tag du check case devrait au moins définir un identifiant (tag#id)
         
     | 
| 
      
 67 
     | 
    
         
            +
              ou une classe CSS (tag.css). '%{a}' ne définit ni l'un ni l'autre.
         
     | 
| 
      
 68 
     | 
    
         
            +
            1004: |
         
     | 
| 
      
 69 
     | 
    
         
            +
              Dans la donnée :tag, :count (%{a}) devrait être un nombre, pas un %{c}…
         
     | 
| 
      
 70 
     | 
    
         
            +
            2000: |
         
     | 
| 
      
 71 
     | 
    
         
            +
              Définition de :contains erroné. Doit être une table (définissant au moins
         
     | 
| 
      
 72 
     | 
    
         
            +
              :tag), un string (un texte à contenir ou une balise avec identifiant et/ou
         
     | 
| 
      
 73 
     | 
    
         
            +
              class CSS) ou une liste de ces éléments. La classe de l'élément, quoi qu'il
         
     | 
| 
      
 74 
     | 
    
         
            +
              en soit, ne peut être %{c}.
         
     | 
| 
      
 75 
     | 
    
         
            +
             
     | 
| 
      
 76 
     | 
    
         
            +
            # --- Les erreurs de check de la page ---
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
      
 78 
     | 
    
         
            +
            4999: |
         
     | 
| 
      
 79 
     | 
    
         
            +
              Aucun élément %{tag} n'a été trouvé alors qu'on en 
         
     | 
| 
      
 80 
     | 
    
         
            +
              attendait %{e}.
         
     | 
| 
      
 81 
     | 
    
         
            +
            5000: |
         
     | 
| 
      
 82 
     | 
    
         
            +
              Mauvais compte. On attend %{e} éléments %{tag}. On en a trouvé
         
     | 
| 
      
 83 
     | 
    
         
            +
              %{a} dans la page.
         
     | 
| 
      
 84 
     | 
    
         
            +
            5001: |
         
     | 
| 
      
 85 
     | 
    
         
            +
              Le contenu de %{tag} devrait être vide. Mais il contient le texte "%{a}".
         
     | 
| 
      
 86 
     | 
    
         
            +
            5002: |
         
     | 
| 
      
 87 
     | 
    
         
            +
              Le contenu de %{tag} ne devrait pas être vide. Or il l'est.
         
     | 
| 
      
 88 
     | 
    
         
            +
            5003: |
         
     | 
| 
      
 89 
     | 
    
         
            +
              Le contenu de %{tag} ne devrait comporter aucun texte, or 
         
     | 
| 
      
 90 
     | 
    
         
            +
              il contient %{a}.
         
     | 
| 
      
 91 
     | 
    
         
            +
            5004: |
         
     | 
| 
      
 92 
     | 
    
         
            +
              Le contenu de %{tag} devrait comporter du texte, or il n'en affiche
         
     | 
| 
      
 93 
     | 
    
         
            +
              aucun.
         
     | 
| 
      
 94 
     | 
    
         
            +
            5010: |
         
     | 
| 
      
 95 
     | 
    
         
            +
              On devrait trouver %{tag} contenant %{e}. Les problèmes suivants ont été
         
     | 
| 
      
 96 
     | 
    
         
            +
              rencontrés : %{a}.
         
     | 
| 
      
 97 
     | 
    
         
            +
            5011: |
         
     | 
| 
      
 98 
     | 
    
         
            +
              On devrait trouver %{tag} contenant le texte %{e}.
         
     | 
| 
      
 99 
     | 
    
         
            +
            5020: |
         
     | 
| 
      
 100 
     | 
    
         
            +
              devrait contenir la chaine %{e}
         
     | 
| 
      
 101 
     | 
    
         
            +
            5021: |
         
     | 
| 
      
 102 
     | 
    
         
            +
              devrait contenir la tag définie par %{e}
         
     | 
| 
      
 103 
     | 
    
         
            +
            5030: |
         
     | 
| 
      
 104 
     | 
    
         
            +
              devrait définir les attributs
         
     | 
| 
      
 105 
     | 
    
         
            +
            5031: |
         
     | 
| 
      
 106 
     | 
    
         
            +
              attributs manquants ou inégaux : %{e}.
         
     | 
| 
      
 107 
     | 
    
         
            +
            5032: |
         
     | 
| 
      
 108 
     | 
    
         
            +
              le contenu n'est pas assez long. Il devrait faire au moins %{e} caractères,
         
     | 
| 
      
 109 
     | 
    
         
            +
              il en fait %{a}.
         
     | 
| 
      
 110 
     | 
    
         
            +
            5033: |
         
     | 
| 
      
 111 
     | 
    
         
            +
              le contenu est trop long. Il devrait faire moins de %{e} caractères, or il
         
     | 
| 
      
 112 
     | 
    
         
            +
              en fait %{a}.
         
     | 
| 
      
 113 
     | 
    
         
            +
             
     | 
| 
      
 114 
     | 
    
         
            +
            5500: |
         
     | 
| 
      
 115 
     | 
    
         
            +
              L'URL n'est pas redirigée. Elle aurait dû être redirigée vers
         
     | 
| 
      
 116 
     | 
    
         
            +
              %{e}
         
     | 
| 
      
 117 
     | 
    
         
            +
            5501: |
         
     | 
| 
      
 118 
     | 
    
         
            +
              L'URL est redirigée vers la mauvaise adresse. Elle aurait dû être redirigée
         
     | 
| 
      
 119 
     | 
    
         
            +
              vers : %{e}
         
     | 
| 
      
 120 
     | 
    
         
            +
              Elle est redirigée vers : %{a}.
         
     | 
| 
      
 121 
     | 
    
         
            +
            5502: |
         
     | 
| 
      
 122 
     | 
    
         
            +
              L'HTTP Response attendue n'est pas la bonne…
         
     | 
| 
      
 123 
     | 
    
         
            +
              On attendait la réponse : %{e}
         
     | 
| 
      
 124 
     | 
    
         
            +
              On a reçu la réponse    : %{a} 
         
     | 
| 
      
 125 
     | 
    
         
            +
            5503: |
         
     | 
| 
      
 126 
     | 
    
         
            +
              Erreur 404. La page %{e} est introuvable.
         
     | 
| 
      
 127 
     | 
    
         
            +
            6000: |
         
     | 
| 
      
 128 
     | 
    
         
            +
              Le premier argument de Lazy::Checker.check doit être du code XML valide.
         
     | 
| 
      
 129 
     | 
    
         
            +
              Or, %{se}.
         
     | 
| 
      
 130 
     | 
    
         
            +
            6001: |
         
     | 
| 
      
 131 
     | 
    
         
            +
              %{a} n'est pas un String, c'est un %{c}.
         
     | 
| 
      
 132 
     | 
    
         
            +
            6002: |
         
     | 
| 
      
 133 
     | 
    
         
            +
              un code XML valide se trouve enroulé dans un nœud racine. Ce n'est pas le
         
     | 
| 
      
 134 
     | 
    
         
            +
              cas pour %{a}…
         
     | 
| 
      
 135 
     | 
    
         
            +
            6003: |
         
     | 
| 
      
 136 
     | 
    
         
            +
              la donnée est nulle (nil).
         
     | 
| 
      
 137 
     | 
    
         
            +
            6010: |
         
     | 
| 
      
 138 
     | 
    
         
            +
              Le second argument de Lazy::Checker.check doit être une table Hash valide
         
     | 
| 
      
 139 
     | 
    
         
            +
              donc un Hash contenant les bonnes clés : %{se}
         
     | 
| 
      
 140 
     | 
    
         
            +
            6011: |
         
     | 
| 
      
 141 
     | 
    
         
            +
              %{a} n'est pas un Hash, c'est un %{c}…
         
     | 
| 
      
 142 
     | 
    
         
            +
             
     | 
| 
         @@ -0,0 +1,18 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ---
         
     | 
| 
      
 2 
     | 
    
         
            +
            # -- Termes de messages --
         
     | 
| 
      
 3 
     | 
    
         
            +
            10: 'nombre '
         
     | 
| 
      
 4 
     | 
    
         
            +
            11: 'longueur '
         
     | 
| 
      
 5 
     | 
    
         
            +
            12: 'longueur min '
         
     | 
| 
      
 6 
     | 
    
         
            +
            13: 'longueur max '
         
     | 
| 
      
 7 
     | 
    
         
            +
            14: 'vide'
         
     | 
| 
      
 8 
     | 
    
         
            +
            15: 'non vide'
         
     | 
| 
      
 9 
     | 
    
         
            +
            16: 'contenant'
         
     | 
| 
      
 10 
     | 
    
         
            +
            17: 'contenant le texte'
         
     | 
| 
      
 11 
     | 
    
         
            +
            20: 'seulement parmi les enfants directs'
         
     | 
| 
      
 12 
     | 
    
         
            +
            21: 'avec les attributs'
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            # -- Les messages de retour des checks --
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            4999: |
         
     | 
| 
      
 17 
     | 
    
         
            +
              La balise %{tag} a été trouvée avec les données attendues :
         
     | 
| 
      
 18 
     | 
    
         
            +
              %{f_data}
         
     | 
| 
         @@ -0,0 +1,84 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            #
         
     | 
| 
      
 2 
     | 
    
         
            +
            # Class Lazy::Checker::Reporter
         
     | 
| 
      
 3 
     | 
    
         
            +
            # 
         
     | 
| 
      
 4 
     | 
    
         
            +
            # Pour établie le rapport de fin.
         
     | 
| 
      
 5 
     | 
    
         
            +
            # 
         
     | 
| 
      
 6 
     | 
    
         
            +
            module Lazy
         
     | 
| 
      
 7 
     | 
    
         
            +
            class Checker
         
     | 
| 
      
 8 
     | 
    
         
            +
              class Reporter
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                attr_reader :checker
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                def initialize(checker)
         
     | 
| 
      
 13 
     | 
    
         
            +
                  @checker = checker
         
     | 
| 
      
 14 
     | 
    
         
            +
                end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                #
         
     | 
| 
      
 17 
     | 
    
         
            +
                # Affichage du rapport
         
     | 
| 
      
 18 
     | 
    
         
            +
                # 
         
     | 
| 
      
 19 
     | 
    
         
            +
                def display
         
     | 
| 
      
 20 
     | 
    
         
            +
                  puts "\n\n"
         
     | 
| 
      
 21 
     | 
    
         
            +
                  puts "#{checker.name}".jaune
         
     | 
| 
      
 22 
     | 
    
         
            +
                  puts "-"* checker.name.length
         
     | 
| 
      
 23 
     | 
    
         
            +
                  nombre_erreurs = @failures.count
         
     | 
| 
      
 24 
     | 
    
         
            +
                  if true #verbose? # TODO À RÉGLER
         
     | 
| 
      
 25 
     | 
    
         
            +
                    display_list_resultats(success = true)
         
     | 
| 
      
 26 
     | 
    
         
            +
                  end
         
     | 
| 
      
 27 
     | 
    
         
            +
                  if nombre_erreurs > 0
         
     | 
| 
      
 28 
     | 
    
         
            +
                    display_list_resultats(success = false)
         
     | 
| 
      
 29 
     | 
    
         
            +
                  end
         
     | 
| 
      
 30 
     | 
    
         
            +
                  color = nombre_erreurs > 0 ? :red : :vert
         
     | 
| 
      
 31 
     | 
    
         
            +
                  msg = "Success #{@successs.count} Failures #{@failures.count} Temps #{formated_duree}"
         
     | 
| 
      
 32 
     | 
    
         
            +
                  puts "-" * msg.length
         
     | 
| 
      
 33 
     | 
    
         
            +
                  puts msg.send(color)
         
     | 
| 
      
 34 
     | 
    
         
            +
                end
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                def add_success(check_case)
         
     | 
| 
      
 37 
     | 
    
         
            +
                  @successs << check_case
         
     | 
| 
      
 38 
     | 
    
         
            +
                end
         
     | 
| 
      
 39 
     | 
    
         
            +
                def add_failure(check_case)
         
     | 
| 
      
 40 
     | 
    
         
            +
                  @failures << check_case
         
     | 
| 
      
 41 
     | 
    
         
            +
                end
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
                # Pour afficher la liste de succès ou de failures
         
     | 
| 
      
 44 
     | 
    
         
            +
                def display_list_resultats(success)
         
     | 
| 
      
 45 
     | 
    
         
            +
                  methode = success ? :message   : :errors
         
     | 
| 
      
 46 
     | 
    
         
            +
                  color   = success ? :vert      : :red
         
     | 
| 
      
 47 
     | 
    
         
            +
                  liste   = success ? @successs  : @failures
         
     | 
| 
      
 48 
     | 
    
         
            +
                  prefix  = success ? 'SUCCESS'  : 'FAILURE'
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
                  max_index = liste.count + 1
         
     | 
| 
      
 51 
     | 
    
         
            +
                  max_len_index = "[#{prefix} #{max_index}] ".length
         
     | 
| 
      
 52 
     | 
    
         
            +
                  indent = ' ' * max_len_index
         
     | 
| 
      
 53 
     | 
    
         
            +
                  liste.each_with_index do |checkedthing, idx|
         
     | 
| 
      
 54 
     | 
    
         
            +
                    index_str = "[#{prefix} #{idx + 1}]".ljust(max_len_index)
         
     | 
| 
      
 55 
     | 
    
         
            +
                    puts "#{index_str}#{checkedthing.send(methode).split("\n").join("\n#{indent}")}".send(color)
         
     | 
| 
      
 56 
     | 
    
         
            +
                  end
         
     | 
| 
      
 57 
     | 
    
         
            +
                end
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
                def start
         
     | 
| 
      
 60 
     | 
    
         
            +
                  @start_time = Time.now
         
     | 
| 
      
 61 
     | 
    
         
            +
                  @successs = []
         
     | 
| 
      
 62 
     | 
    
         
            +
                  @failures = []
         
     | 
| 
      
 63 
     | 
    
         
            +
                end
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
                def end
         
     | 
| 
      
 66 
     | 
    
         
            +
                  @end_time = Time.now
         
     | 
| 
      
 67 
     | 
    
         
            +
                end
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
                def formated_duree
         
     | 
| 
      
 70 
     | 
    
         
            +
                  @formated_duree ||= begin
         
     | 
| 
      
 71 
     | 
    
         
            +
                    if duree < 0.10
         
     | 
| 
      
 72 
     | 
    
         
            +
                      "#{(duree.to_f * 1000).round(4)} ms"
         
     | 
| 
      
 73 
     | 
    
         
            +
                    else
         
     | 
| 
      
 74 
     | 
    
         
            +
                      "#{duree.round(4)} s"
         
     | 
| 
      
 75 
     | 
    
         
            +
                    end
         
     | 
| 
      
 76 
     | 
    
         
            +
                  end
         
     | 
| 
      
 77 
     | 
    
         
            +
                end
         
     | 
| 
      
 78 
     | 
    
         
            +
                def duree
         
     | 
| 
      
 79 
     | 
    
         
            +
                  @duree ||= @end_time - @start_time
         
     | 
| 
      
 80 
     | 
    
         
            +
                end
         
     | 
| 
      
 81 
     | 
    
         
            +
             
     | 
| 
      
 82 
     | 
    
         
            +
              end #/class Reporter
         
     | 
| 
      
 83 
     | 
    
         
            +
            end #/class Checker
         
     | 
| 
      
 84 
     | 
    
         
            +
            end #/module Lazy
         
     | 
    
        data/lib/lazy/check.rb
    ADDED
    
    | 
         @@ -0,0 +1,18 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'clir'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'yaml'
         
     | 
| 
      
 3 
     | 
    
         
            +
            require 'nokogiri'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require "lazy/check/version"
         
     | 
| 
      
 5 
     | 
    
         
            +
            require 'lazy/check/constants'
         
     | 
| 
      
 6 
     | 
    
         
            +
            require "lazy/check/checker"
         
     | 
| 
      
 7 
     | 
    
         
            +
            require "lazy/check/checker_test"
         
     | 
| 
      
 8 
     | 
    
         
            +
            require "lazy/check/checker_url"
         
     | 
| 
      
 9 
     | 
    
         
            +
            require "lazy/check/checked_tag"
         
     | 
| 
      
 10 
     | 
    
         
            +
            require "lazy/check/checked_url"
         
     | 
| 
      
 11 
     | 
    
         
            +
            require 'lazy/check/Nokogiri_extension'
         
     | 
| 
      
 12 
     | 
    
         
            +
            require "lazy/check/checker_case"
         
     | 
| 
      
 13 
     | 
    
         
            +
            require "lazy/check/checker_code"
         
     | 
| 
      
 14 
     | 
    
         
            +
            require "lazy/check/reporter"
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            def dbg(msg)
         
     | 
| 
      
 17 
     | 
    
         
            +
              STDOUT.write "\n#{msg}"
         
     | 
| 
      
 18 
     | 
    
         
            +
            end
         
     | 
    
        data/recipe.yaml
    ADDED
    
    | 
         @@ -0,0 +1 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ---
         
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,130 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: lazy-check
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.0.0
         
     | 
| 
      
 5 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 6 
     | 
    
         
            +
            authors:
         
     | 
| 
      
 7 
     | 
    
         
            +
            - PhilippePerret
         
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire:
         
     | 
| 
      
 9 
     | 
    
         
            +
            bindir: exe
         
     | 
| 
      
 10 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2023-09-29 00:00:00.000000000 Z
         
     | 
| 
      
 12 
     | 
    
         
            +
            dependencies:
         
     | 
| 
      
 13 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 14 
     | 
    
         
            +
              name: minitest
         
     | 
| 
      
 15 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 16 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 17 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 18 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 19 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 20 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 21 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 22 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 23 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 24 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 25 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 26 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 27 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 28 
     | 
    
         
            +
              name: minitest-color
         
     | 
| 
      
 29 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 30 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 31 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 32 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 33 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 34 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 35 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 36 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 37 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 38 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 39 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 40 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 41 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 42 
     | 
    
         
            +
              name: clir
         
     | 
| 
      
 43 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 44 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 45 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 46 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 47 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 48 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 49 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 50 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 51 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 52 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 53 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 54 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 55 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 56 
     | 
    
         
            +
              name: nokogiri
         
     | 
| 
      
 57 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 58 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 59 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 60 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 61 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 62 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 63 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 64 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 65 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 66 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 67 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 68 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 69 
     | 
    
         
            +
            description: Ce gem permet de façon paresseuse mais néanmoins sérieuse de tester qu'un
         
     | 
| 
      
 70 
     | 
    
         
            +
              site web est valide au niveau de ses pages et de son contenu.
         
     | 
| 
      
 71 
     | 
    
         
            +
            email:
         
     | 
| 
      
 72 
     | 
    
         
            +
            - philippe.perret@yahoo.fr
         
     | 
| 
      
 73 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 74 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 75 
     | 
    
         
            +
            extra_rdoc_files: []
         
     | 
| 
      
 76 
     | 
    
         
            +
            files:
         
     | 
| 
      
 77 
     | 
    
         
            +
            - ".gitignore"
         
     | 
| 
      
 78 
     | 
    
         
            +
            - ".travis.yml"
         
     | 
| 
      
 79 
     | 
    
         
            +
            - CHANGELOG.md
         
     | 
| 
      
 80 
     | 
    
         
            +
            - Gemfile
         
     | 
| 
      
 81 
     | 
    
         
            +
            - Gemfile.lock
         
     | 
| 
      
 82 
     | 
    
         
            +
            - Notes-developper.md
         
     | 
| 
      
 83 
     | 
    
         
            +
            - README.md
         
     | 
| 
      
 84 
     | 
    
         
            +
            - Rakefile
         
     | 
| 
      
 85 
     | 
    
         
            +
            - bin/console
         
     | 
| 
      
 86 
     | 
    
         
            +
            - bin/setup
         
     | 
| 
      
 87 
     | 
    
         
            +
            - lazy-check.gemspec
         
     | 
| 
      
 88 
     | 
    
         
            +
            - lib/lazy/check.rb
         
     | 
| 
      
 89 
     | 
    
         
            +
            - lib/lazy/check/Nokogiri_extension.rb
         
     | 
| 
      
 90 
     | 
    
         
            +
            - lib/lazy/check/checked_tag.rb
         
     | 
| 
      
 91 
     | 
    
         
            +
            - lib/lazy/check/checked_url.rb
         
     | 
| 
      
 92 
     | 
    
         
            +
            - lib/lazy/check/checker.rb
         
     | 
| 
      
 93 
     | 
    
         
            +
            - lib/lazy/check/checker_case.rb
         
     | 
| 
      
 94 
     | 
    
         
            +
            - lib/lazy/check/checker_code.rb
         
     | 
| 
      
 95 
     | 
    
         
            +
            - lib/lazy/check/checker_test.rb
         
     | 
| 
      
 96 
     | 
    
         
            +
            - lib/lazy/check/checker_url.rb
         
     | 
| 
      
 97 
     | 
    
         
            +
            - lib/lazy/check/constants.rb
         
     | 
| 
      
 98 
     | 
    
         
            +
            - lib/lazy/check/locales/en/errors.yaml
         
     | 
| 
      
 99 
     | 
    
         
            +
            - lib/lazy/check/locales/fr/errors.yaml
         
     | 
| 
      
 100 
     | 
    
         
            +
            - lib/lazy/check/locales/fr/messages.yaml
         
     | 
| 
      
 101 
     | 
    
         
            +
            - lib/lazy/check/reporter.rb
         
     | 
| 
      
 102 
     | 
    
         
            +
            - lib/lazy/check/version.rb
         
     | 
| 
      
 103 
     | 
    
         
            +
            - recipe.yaml
         
     | 
| 
      
 104 
     | 
    
         
            +
            homepage: https://rubygems.org/gems/lazy-check
         
     | 
| 
      
 105 
     | 
    
         
            +
            licenses: []
         
     | 
| 
      
 106 
     | 
    
         
            +
            metadata:
         
     | 
| 
      
 107 
     | 
    
         
            +
              allowed_push_host: https://rubygems.org
         
     | 
| 
      
 108 
     | 
    
         
            +
              homepage_uri: https://rubygems.org/gems/lazy-check
         
     | 
| 
      
 109 
     | 
    
         
            +
              source_code_uri: https://github.com/PhilippePerret/gem-lazy-check
         
     | 
| 
      
 110 
     | 
    
         
            +
              changelog_uri: https://github.com/PhilippePerret/gem-lazy-check/CHANGELOG.md
         
     | 
| 
      
 111 
     | 
    
         
            +
            post_install_message:
         
     | 
| 
      
 112 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 113 
     | 
    
         
            +
            require_paths:
         
     | 
| 
      
 114 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 115 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 116 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 117 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 118 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 119 
     | 
    
         
            +
                  version: 2.3.0
         
     | 
| 
      
 120 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 121 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 122 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 123 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 124 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 125 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 126 
     | 
    
         
            +
            rubygems_version: 3.1.6
         
     | 
| 
      
 127 
     | 
    
         
            +
            signing_key:
         
     | 
| 
      
 128 
     | 
    
         
            +
            specification_version: 4
         
     | 
| 
      
 129 
     | 
    
         
            +
            summary: Vérification paresseuse d'un site web
         
     | 
| 
      
 130 
     | 
    
         
            +
            test_files: []
         
     |