Module: App

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

Defined Under Namespace

Classes: AWSProfile, 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



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
# File 'lib/eworld.rb', line 23

def self.execute

    begin

        unless ARGV[0] == 'config' || ARGV[0] == 'x'
            Blufin::Config::init(SCHEMA_FILE, TEMPLATE_FILE, CONFIG_FILE, GEM_NAME)
            App::AWSProfile::init(Blufin::Config::get)
            Blufin::Projects.new(Blufin::Config::get['Projects'], App::AWSProfile::get)
        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
            if is_albert_mac
                app.command :generate, :aliases => [:g] do |generate|
                    generate.summary 'Generate boiler-plate code'
                    generate.options do |opts|
                        opts.opt :silent, 'Run in silent mode', :short => '-s', :long => '--silent', :type => :boolean
                    end
                    generate.action do |opts, args|
                        AppCommand::Generate.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

            # v - VALIDATE
            if is_albert_mac
                app.command :validate, :aliases => [:v] do |validate|
                    validate.summary 'Valdiate the codebase'
                    validate.options do |opts|
                        opts.opt :project, 'Specify Project ID', :short => '-p', :long => '--project', :type => :string
                    end
                    validate.action do |opts, args|
                        AppCommand::Validate.new(opts, args).execute
                    end
                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



106
107
108
109
110
111
# File 'lib/eworld.rb', line 106

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