Module: Engine2

Defined in:
lib/engine2/model.rb,
lib/engine2/action.rb,
lib/engine2/scheme.rb,
lib/engine2/handler.rb,
lib/engine2/version.rb,
lib/engine2/templates.rb,
lib/engine2/type_info.rb,
lib/engine2/action/form.rb,
lib/engine2/action/link.rb,
lib/engine2/action/list.rb,
lib/engine2/action/save.rb,
lib/engine2/action/view.rb,
lib/engine2/action_node.rb,
lib/engine2/action/array.rb,
lib/engine2/action/infra.rb,
lib/engine2/models/Files.rb,
lib/engine2/action/decode.rb,
lib/engine2/action/delete.rb,
lib/engine2/models/UserInfo.rb,
lib/engine2/core.rb

Defined Under Namespace

Modules: ActionAPISupport, ActionAngularSupport, ActionApproveSupport, ActionBulkDeleteSupport, ActionCreateSupport, ActionDeleteSupport, ActionFormSupport, ActionInsertSupport, ActionListSupport, ActionMenuSupport, ActionModelSupport, ActionModifySupport, ActionOnChangeSupport, ActionPanelSupport, ActionQuerySupport, ActionSaveSupport, ActionTabSupport, ActionUpdateSupport, ActionViewSupport, ActionWebSocketSupport, BlobSupportAction, MemoryModel, Model Classes: Action, ActionMenuBuilder, ActionNode, ActionNodeBundle, ArrayListAction, BlobStoreAction, BulkDeleteAction, ConfirmAction, CreateAction, DecodeAction, DecodeEntryAction, DecodeListAction, DeleteAction, DeleteActionBase, DownloadBlobStoreAction, DownloadFileStoreAction, DownloadForeignBlobStoreAction, E2Error, E2Files, FileStoreAction, ForeignBlobStoreAction, FormAction, Handler, InfraAction, InlineAction, InsertAction, InspectModalAction, ListAction, LoginAction, LoginFormAction, LogoutAction, LogoutFormAction, ManyToOneListAction, MenuAction, MenuBuilder, ModifyAction, RootAction, SaveAction, Schemes, SearchTemplates, StarToManyBulkUnlinkAction, StarToManyFieldAction, StarToManyFieldInsertAction, StarToManyFieldLinkListAction, StarToManyFieldUpdateAction, StarToManyLinkAction, StarToManyLinkListAction, StarToManyListAction, StarToManyUnlinkAction, StarToManyUnlinkActionBase, Templates, TypeAheadAction, TypeInfo, UpdateAction, UploadBlobStoreAction, UploadFileStoreAction, UserInfo, ViewAction, WebSocketAction

Constant Summary collapse

VERSION =
[MAJOR, MINOR, TINY].join('.').freeze

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.core_loadedObject (readonly)

Returns the value of attribute core_loaded.



479
480
481
# File 'lib/engine2/core.rb', line 479

def core_loaded
  @core_loaded
end

Class Method Details

.boot(&blk) ⇒ Object



490
491
492
# File 'lib/engine2/core.rb', line 490

def boot &blk
    @boot_blk = blk
end

.bootstrap(path, settings = {}) ⇒ Object



534
535
536
537
538
539
540
541
542
543
544
545
546
# File 'lib/engine2/core.rb', line 534

def bootstrap path, settings = {}
    SETTINGS.merge! settings
    SETTINGS[:path] = path
    SETTINGS[:name] ||= File::basename(path)
    SETTINGS.freeze
    Handler.set :public_folder, "public"
    Handler.set :views, [SETTINGS.path_for(:view_path), "#{Engine2::PATH}/views"]
    bootstrap_e2db

    require 'engine2/pre_bootstrap'
    reload
    require 'engine2/post_bootstrap'
end

.bootstrap_e2dbObject



498
499
500
501
502
503
504
# File 'lib/engine2/core.rb', line 498

def bootstrap_e2db
    e2_db_path = "#{Engine2::SETTINGS.path_for(:db_path)}/engine2.db"
    e2_db_url = (defined? JRUBY_VERSION) ? "jdbc:sqlite:#{e2_db_path}" : "sqlite://#{e2_db_path}"
    const_set :E2DB, connect(e2_db_url, loggers: [Logger.new($stdout)], convert_types: false, name: :engine2)
    const_set :DUMMYDB, Sequel::Database.new(uri: 'dummy')
    def DUMMYDB.synchronize *args;end
end

.connect(*args) ⇒ Object



485
486
487
488
# File 'lib/engine2/core.rb', line 485

def connect *args
    db = Sequel.connect *args
    db
end

.database(name) ⇒ Object



481
482
483
# File 'lib/engine2/core.rb', line 481

def database name
    Object.const_set(name, yield) unless Object.const_defined?(name)
end

.model_boot(&blk) ⇒ Object



494
495
496
# File 'lib/engine2/core.rb', line 494

def model_boot &blk
    @model_boot_blk = blk
end

.reloadObject



506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
# File 'lib/engine2/core.rb', line 506

def reload
    @core_loaded = true
    t = Time.now
    ActionNode.count = 0
    SCHEMES.user.clear

    Sequel::DATABASES.each do |db|
        db.models.each{|n, m| Object.send(:remove_const, n) if Object.const_defined?(n)} unless db == E2DB || db == DUMMYDB
    end

    load "#{Engine2::SETTINGS[:app_path]}/boot.rb"

    Sequel::DATABASES.each &:load_schema_cache_from_file
    @model_boot_blk.() if @model_boot_blk
    load 'engine2/models/Files.rb'
    load 'engine2/models/UserInfo.rb'
    Dir["#{Engine2::SETTINGS.path_for(:model_path)}/*"].each{|m| load m}
    puts "MODELS: #{Sequel::DATABASES.reduce(0){|s, d|s + d.models.size}}, Time: #{Time.now - t}"
    Sequel::DATABASES.each &:dump_schema_cache_to_file

    send(:remove_const, :ROOT) if defined? ROOT
    const_set(:ROOT, ActionNode.new(nil, :api, RootAction, {}))

    @boot_blk.(ROOT)
    ROOT.setup_node_tree
    puts "BOOTSTRAP #{Engine2::SETTINGS[:name]}, Time: #{Time.new - t}"
end

.versionObject



7
8
9
# File 'lib/engine2/version.rb', line 7

def self.version
    VERSION
end