Sha256: 2619c4633f7a9ec28a4161796c3bae8c195befe8647a89add9dee2ca56ef6660

Contents?: true

Size: 1.49 KB

Versions: 1

Compression:

Stored size: 1.49 KB

Contents

require_relative 'ro/_lib'

Ro.load_dependencies!

module Ro
  class << Ro
    # top-level 
    # |
    # v
    def root
      Ro.config.root
    end

    def root=(root)
      Ro.config.root = root
    end

    def collections
      root.collections
    end

    def nodes
      root.nodes
    end

    # config
    # |
    # v
    def env
      Map.for({
        :root      => ENV['RO_ROOT'],
        :build     => ENV['RO_BUILD'],
        :url       => ENV['RO_URL'],
        :page_size => ENV['RO_PAGE_SIZE'],
        :log       => ENV['RO_LOG'],
        :debug     => ENV['RO_DEBUG'],
        :port      => ENV['RO_PORT'],
        :md_theme  => ENV['RO_MD_THEME'],
      })
    end

    def defaults
      Map.for({
        :root      => './public/ro',
        :build     => './public/api/ro',
        :url       => "/ro",
        :page_size => 42,
        :log       => nil,
        :debug     => nil,
        :port      => 4242,
        :md_theme  => 'github',
      })
    end

    def config
      @config ||= Config.new
    end

    # ro init
    # |
    # v
    def initialize!
      Ro.load %w[
        error.rb
        klass.rb
        slug.rb
        path.rb
        template.rb
        methods.rb
        config.rb
        root.rb
        collection.rb
        collection/list.rb
        node.rb
        asset.rb
      ]

      if defined?(ActiveModel)
        Ro.load %w[
          model.rb
        ]
      end

      Ro.log! if Ro.config.log
      Ro.debug! if Ro.config.debug
    end
  end
end

Ro.initialize!

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ro-4.2.0 lib/ro.rb