Module: App

Defined in:
lib/eworld.rb,
lib/core/opt.rb

Defined Under Namespace

Classes: Opt

Constant Summary collapse

GEM_NAME =
'eworld'
SCHEMA_FILE =
"#{App::Opt::get_base_path}#{App::Opt::OPT_PATH}/config/schema.yml"
TEMPLATE_FILE =
"#{App::Opt::get_base_path}#{App::Opt::OPT_PATH}/config/template.yml"
CONFIG_FILE =
'~/.eworld.yml'
SECRET =
'dLZDk82LU8kEZ6pbcuyJHmbrWs3ujzvM2cHNtD6BgKyvDZAcJRjU7yHde7nWejnR'

Class Method Summary collapse

Class Method Details

.executeObject



18
19
20
21
22
23
24
25
26
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/eworld.rb', line 18

def self.execute

    begin

        unless ARGV[0] == 'config' || ARGV[0] == 'x'
            Blufin::Config::init(SCHEMA_FILE, TEMPLATE_FILE, CONFIG_FILE, GEM_NAME)
            Blufin::Projects.new(Blufin::Config::get['Projects'])
        end

        Convoy::App.create do |app|

            app.version EWORLD_VERSION
            app.summary <<TEMPLATE
 \x1B[48;5;89m\x1B[38;5;255m eWorld-CLI \x1B[0m\x1B[0m \x1B[38;5;89m\xe2\x80\x94 eWorld Commmand-Line Interface\x1B[38;5;248m

    __        __         _     _            _ _
  __\\ \\      / /__  _ __| | __| |       ___| (_)
 / _ \\ \\ /\\ / / _ \\| '__| |/ _` |_____ / __| | |
|  __/\\ V  V / (_) | |  | | (_| |_____| (__| | |
 \\___| \\_/\\_/ \\___/|_|  |_|\\__,_|      \\___|_|_|\x1B[0m
TEMPLATE
            app.description "\x1B[38;5;240mAn internal tool intended for improving/automating development tasks.\x1B[0m"

            # g - GENERATE
            app.command :generate, :aliases => [:g] do |generate|
                generate.summary 'Generate boiler-plate code'
                # a - GENERATE API
                generate.command :api, :aliases => [:a] do |generate_api|
                    generate_api.summary 'Generate API code'
                    # e - GENERATE API ENTITIES
                    generate_api.command :api_entities, :aliases => [:e] do |generate_api_entities|
                        generate_api_entities.summary 'Generate boiler-plate entity code'
                        generate_api_entities.action do |opts, args|
                            AppCommand::GenerateApiEntities.new(opts, args).execute
                        end
                    end
                    # GENERATE API (Default)
                    generate_api.action do
                        system("#{App::GEM_NAME} g a -h")
                    end
                end
                # generate - GENERATE UI
                generate.command :ui, :aliases => [:u] do |generate_ui|
                    generate_ui.summary 'Generate UI code'
                    # r - GENERATE UI ROUTES
                    generate_ui.command :ui_routes, :aliases => [:r] do |generate_ui_routes|
                        generate_ui_routes.summary 'Generate routes.js (and blank routes if not exists)'
                        generate_ui_routes.action do |opts, args|
                            AppCommand::GenerateUiRoutes.new(opts, args).execute
                        end
                    end
                    # GENERATE UI (Default)
                    generate_ui.action do
                        system("#{App::GEM_NAME} g u -h")
                    end
                end
                # GENERATE (Default)
                generate.action do
                    system("#{App::GEM_NAME} g -h")
                end
            end

            # s - SCAN
            if is_albert_mac
                app.command :scan, :aliases => [:s] do |scan|
                    scan.summary 'Scan the codebase for inconsistencies'
                    scan.action do |opts, args|
                        AppCommand::Scan.new(opts, args).execute
                    end
                end
            end

            # U - UPDATE
            app.command :update, :aliases => [:U] do |update|
                update.summary 'Check for updates'
                update.action do
                    Blufin::Update::run(App::GEM_NAME)
                end
            end

            # x - CONFIG
            app.command :config, :aliases => [:x] do |config|
                config.summary 'Setup your configuration file'
                config.action do
                    Blufin::Config::edit_config(App::CONFIG_FILE)
                end
            end

            # eworld - DEFAULT
            app.action do
                system("#{App::GEM_NAME} -h")
            end

        end

    rescue RuntimeError => e

        Blufin::Terminal::print_exception(e);

    end

end

.is_albert_macObject

Very hacky code that looks in the configuration file for a key/pair value and if exists, returns true.

Returns:

  • bool



123
124
125
126
127
128
# File 'lib/eworld.rb', line 123

def self.is_albert_mac
    if Blufin::Config::get.has_key?('CustomOptions') && Blufin::Config::get['CustomOptions'].has_key?('Secret')
        return Blufin::Config::get['CustomOptions']['Secret'] == SECRET
    end
    false
end