Sha256: 65e5339b940c50d02868170b591fa1c08fc51c97ab1bf6f9360bb4d912d5c470

Contents?: true

Size: 927 Bytes

Versions: 5

Compression:

Stored size: 927 Bytes

Contents

desc 'Exception utilities'
namespace :exception do

  desc 'List all error codes'
  task :codes => :environment do
    wiki = defined? ENV['WIKI']
    exceptions = [
      ::Foreman::Exception,
      ::Foreman::WrappedException,
    ]
    result = {}
    regexp = /raise.*:?:?(#{exceptions.join('|')})(\.new)?\(?N_\(?(["'])([^\3]+?)\3\)?\)?/
    Dir['app/**/*rb', 'lib/**/*rb'].each do |path|
      File.open(path) do |f|
        f.grep( /#{regexp}/ ) do |line|
          code = ::Foreman::Exception.calculate_error_code $1, $4
          result[$4] = code
        end
      end
    end

    puts "\n\nh1. Foreman error codes:\n\n<pre>\n"
    result.keys.sort.each do |msg|
      code = result[msg]
      puts "#{code} #{msg}"
    end
    puts "</pre>\n\nGenerated with `rake exception:codes`, for more info and options see"
    puts "https://github.com/theforeman/foreman/blob/develop/lib/tasks/exception.rake\n\n"
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
foreman_discovery-1.0.0 test/foreman_app/lib/tasks/exception.rake
foreman_discovery-1.0.0.rc4 test/foreman_app/lib/tasks/exception.rake
foreman_discovery-1.0.0.rc3 test/foreman_app/lib/tasks/exception.rake
foreman_discovery-1.0.0.rc2 test/foreman_app/lib/tasks/exception.rake
foreman_discovery-1.0.0.rc1 test/foreman_app/lib/tasks/exception.rake