Class: Buildr::Settings

Inherits:
Object show all
Defined in:
lib/buildr/core/application.rb

Overview

Provide settings that come from three sources.

User settings are placed in the .buildr/settings.yaml file located in the user’s home directory. They should only be used for settings that are specific to the user and applied the same way across all builds. Example for user settings are preferred repositories, path to local repository, user/name password for uploading to remote repository.

Build settings are placed in the build.yaml file located in the build directory. They help keep the buildfile and build.yaml file simple and readable, working to the advantages of each one. Example for build settings are gems, repositories and artifacts used by that build.

Profile settings are placed in the profiles.yaml file located in the build directory. They provide settings that differ in each environment the build runs in. For example, URLs and database connections will be different when used in development, test and production environments. The settings for the current environment are obtained by calling #profile.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(application) ⇒ Settings

:nodoc:



69
70
71
72
73
74
# File 'lib/buildr/core/application.rb', line 69

def initialize(application) #:nodoc:
  @application = application
  @user = load_from('settings', @application.home_dir)
  @build = load_from('build')
  @profiles = load_from('profiles')
end

Instance Attribute Details

#buildObject (readonly)

Build settings loaded from build.yaml file in build directory.



80
81
82
# File 'lib/buildr/core/application.rb', line 80

def build
  @build
end

#profilesObject (readonly)

Profiles loaded from profiles.yaml file in build directory.



83
84
85
# File 'lib/buildr/core/application.rb', line 83

def profiles
  @profiles
end

#userObject (readonly)

User settings loaded from setting.yaml file in user’s home directory.



77
78
79
# File 'lib/buildr/core/application.rb', line 77

def user
  @user
end

Instance Method Details

#profileObject

:call-seq:

profile => hash

Returns the profile for the current environment.



89
90
91
# File 'lib/buildr/core/application.rb', line 89

def profile
  profiles[@application.environment] ||= {}
end