Class: Praxis::BootloaderStages::Environment

Inherits:
Stage
  • Object
show all
Defined in:
lib/praxis/bootloader_stages/environment.rb

Instance Attribute Summary

Attributes inherited from Stage

#after_callbacks, #before_callbacks, #context, #name, #stages

Instance Method Summary collapse

Methods inherited from Stage

#after, #application, #before, #callback_args, #execute_callbacks, #initialize, #run, #setup!, #setup_deferred_callbacks!

Constructor Details

This class inherits a constructor from Praxis::Stage

Instance Method Details

#executeObject

require environment files. we will require 2 files: 1) the environment.rb file - generic stuff for all environments 2) “Deployer.environment”.rb - environment specific stuff



9
10
11
12
13
14
15
16
# File 'lib/praxis/bootloader_stages/environment.rb', line 9

def execute
  setup_initial_config!

  env_file = application.root / 'config/environment.rb'
  require env_file if File.exist? env_file

  setup_default_layout! unless application.file_layout
end

#setup_default_layout!Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/praxis/bootloader_stages/environment.rb', line 18

def setup_default_layout!
  application.layout do
    map :initializers, 'config/initializers/**/*'
    map :lib, 'lib/**/*'
    map :design, 'design/' do
      map :api, 'api.rb'
      map :helpers, '**/helpers/**/*'
      map :types, '**/types/**/*'
      map :media_types, '**/media_types/**/*'
      map :endpoints, '**/endpoints/**/*'
    end
    map :app, 'app/' do
      map :models, 'models/**/*'
      map :responses, '**/responses/**/*'
      map :exceptions, '**/exceptions/**/*'
      map :concerns, '**/concerns/**/*'
      map :resources, '**/resources/**/*'
      map :controllers, '**/controllers/**/*'
    end
  end
end

#setup_initial_config!Object

TODO: not really sure I like this here… but where else is better?



41
42
43
44
45
46
47
48
49
50
51
# File 'lib/praxis/bootloader_stages/environment.rb', line 41

def setup_initial_config!
  application.config do
    attribute :praxis do
      attribute :validate_responses, Attributor::Boolean, default: false
      attribute :validate_response_bodies, Attributor::Boolean, default: false

      attribute :show_exceptions, Attributor::Boolean, default: false
      attribute :x_cascade, Attributor::Boolean, default: true
    end
  end
end