Class: AppCommand::Validate

Inherits:
Convoy::ActionCommand::Base
  • Object
show all
Defined in:
lib/routes/validate.rb

Instance Method Summary collapse

Instance Method Details

#executeObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 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_routingObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# 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_validateObject



23
24
25
# File 'lib/routes/validate.rb', line 23

def opts_validate

end