Module: Aladdin

Extended by:
Aladdin
Included in:
Aladdin
Defined in:
lib/aladdin.rb,
lib/aladdin/app.rb,
lib/aladdin/config.rb,
lib/aladdin/support.rb,
lib/aladdin/version.rb,
lib/aladdin/commands.rb,
lib/aladdin/constants.rb,
lib/aladdin/submission.rb,
lib/aladdin/commands/new.rb,
lib/aladdin/commands/server.rb,
lib/aladdin/support/multiroute.rb,
lib/aladdin/support/weak_comparator.rb

Defined Under Namespace

Modules: Commands, Support Classes: App, Config, ConfigError, Submission

Constant Summary collapse

VERSION =
'0.2'
PATHS =

Paths to other parts of the library.

{
  root:     root,
  public:   File.expand_path('public', root),
  skeleton: File.expand_path('skeleton', root)
}.to_struct.freeze
VIEWS =

Paths to different types of views.

{
  haml:     File.expand_path('views/haml', root),
  default:  File.expand_path('views', root)
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#configHash

Returns configuration hash.

Returns:

  • (Hash)

    configuration hash



11
12
13
# File 'lib/aladdin.rb', line 11

def config
  @config
end

Instance Method Details

#launch(opts = {}) ⇒ void

This method returns an undefined value.

Launches the previewer app.



26
27
28
29
30
31
# File 'lib/aladdin.rb', line 26

def launch(opts = {})
  prepare opts
  Aladdin::App.run!
rescue => e
  puts e.message
end

#prepare(opts = {}) ⇒ void

This method returns an undefined value.

Prepares to launch the previewer app by configuring sinatra.

Parameters:

  • opts (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opts):

  • from (String) — default: Dir.pwd

    path to author’s markdown documents



16
17
18
19
20
21
22
# File 'lib/aladdin.rb', line 16

def prepare(opts = {})
  root = opts[:from] || Dir.pwd
  @config = Config.new root
  require 'aladdin/app'
  Aladdin::App.set :root, root
  Aladdin::App.set :views, Aladdin::VIEWS.merge(markdown: root)
end