class AppCommand::Validate

Public Instance Methods

execute() click to toggle source
# File lib/routes/validate.rb, line 5
def execute

    begin

        @opts = command_options
        @args = arguments

        opts_validate
        opts_routing

    rescue => e

        Blufin::Terminal::print_exception(e)

    end

end
opts_routing() click to toggle source
# File lib/routes/validate.rb, line 27
def opts_routing

    # TODO - This cannot be hard-coded forever!
    group = 'fmm'

    @errors = []
    @js     = nil
    @java   = nil

    Blufin::Projects::get_projects_as_array.each do |project|
        if project[Blufin::Projects::PROJECT] == group
            project_id         = project[Blufin::Projects::PROJECT_ID]
            project_type       = project[Blufin::Projects::TYPE]
            project_path       = Blufin::Projects::get_project_path(project_id)
            project_path_inner = Blufin::Projects::get_project_path(project_id, true)
            case project_type
                when Blufin::Projects::TYPE_API_SIMPLE
                    raise RuntimeError, "Project with type: #{Blufin::Projects::TYPE_API_SIMPLE} already scanned." unless @java.nil?
                    @java, errors_java = Blufin::ScannerJava::scan("#{project_path_inner}")
                    @errors.concat(errors_java)
                when Blufin::Projects::TYPE_QUASAR
                    raise RuntimeError, "Project with type: #{Blufin::Projects::TYPE_QUASAR} already scanned." unless @s.nil?
                    # Scan the routes.
                    @routes, errors_routes = EWorld::RouteScanner::scan(project)
                    @errors.concat(errors_routes)
                    # Extract JS data.
                    td   = project[Blufin::Projects::TRANSIENT_DATA]
                    root = Blufin::Strings::remove_surrounding_slashes(td[Blufin::Projects::CG_QUASAR_ROOT])
                    js   = Blufin::Strings::remove_surrounding_slashes(td[Blufin::Projects::CG_QUASAR_JS])
                    jst  = Blufin::Strings::remove_surrounding_slashes(td[Blufin::Projects::CG_QUASAR_TESTS])
                    if project.has_key?(Blufin::Projects::TRANSIENT_DATA) && td.has_key?(Blufin::Projects::CG_QUASAR_JS)
                        @js, errors_js             = Blufin::ScannerJs::scan("#{project_path}/#{root}/#{js}")
                        @js_tests, errors_js_tests = Blufin::ScannerJsTests::scan("#{project_path}/#{root}/#{jst}")
                        @vue, errors_vue           = Blufin::ScannerVue::scan("#{project_path}/#{root}")
                        @errors.concat(errors_js)
                        @errors.concat(errors_js_tests)
                        @errors.concat(errors_vue)
                    end
                else
                    raise RuntimeError, "Unsupported project type: #{project_type}"
            end
        end
    end

    # Output Errors (if any).
    Blufin::ScannerError::output_cli(@errors)

end
opts_validate() click to toggle source
# File lib/routes/validate.rb, line 23
def opts_validate

end