Class: Buffet::Settings
- Inherits:
-
Object
- Object
- Buffet::Settings
- Defined in:
- lib/buffet/settings.rb
Overview
Stores configuration settings for Buffet.
Constant Summary collapse
- DEFAULT_LOG_FILE =
'buffet.log'- DEFAULT_SETTINGS_FILE =
'buffet.yml'- DEFAULT_PREPARE_COMMAND =
'bin/before-buffet-run'- DEFAULT_EXCLUDE_FILTER_FILE =
'.buffet-exclude-filter'
Class Method Summary collapse
- .[](name) ⇒ Object
- .allowed_slave_prepare_failures ⇒ Object
- .display_progress? ⇒ Boolean
- .exclude_filter_file ⇒ Object
- .excludes ⇒ Object
- .excludes=(exclusions) ⇒ Object
- .execution_environment ⇒ Object
- .failure_threshold ⇒ Object
- .file_excluded?(file) ⇒ Boolean
- .has_exclude_filter_file? ⇒ Boolean
- .log_file ⇒ Object
- .log_file=(log) ⇒ Object
- .prepare_command ⇒ Object
- .prepare_command? ⇒ Boolean
- .project ⇒ Object
- .project_name=(project_name) ⇒ Object
- .reset! ⇒ Object
- .settings_file ⇒ Object
- .settings_file=(settings_file) ⇒ Object
- .slaves ⇒ Object
- .worker_command ⇒ Object
Class Method Details
.[](name) ⇒ Object
21 22 23 24 |
# File 'lib/buffet/settings.rb', line 21 def [](name) @settings ||= load_file(settings_file) @settings[name] end |
.allowed_slave_prepare_failures ⇒ Object
32 33 34 |
# File 'lib/buffet/settings.rb', line 32 def allowed_slave_prepare_failures self['allowed_slave_prepare_failures'] || 0 end |
.display_progress? ⇒ Boolean
101 102 103 |
# File 'lib/buffet/settings.rb', line 101 def display_progress? @settings.fetch('display_progress', true) end |
.exclude_filter_file ⇒ Object
71 72 73 |
# File 'lib/buffet/settings.rb', line 71 def exclude_filter_file self['exclude_filter_file'] || DEFAULT_EXCLUDE_FILTER_FILE end |
.excludes ⇒ Object
87 88 89 |
# File 'lib/buffet/settings.rb', line 87 def excludes self['exclude'] || [] end |
.excludes=(exclusions) ⇒ Object
83 84 85 |
# File 'lib/buffet/settings.rb', line 83 def excludes=(exclusions) self['exclude'] = exclusions end |
.execution_environment ⇒ Object
40 41 42 43 44 45 |
# File 'lib/buffet/settings.rb', line 40 def execution_environment { 'BUFFET_MASTER' => Buffet.user, 'BUFFET_PROJECT' => project.name, }.merge(self['execution_environment'] || {}) end |
.failure_threshold ⇒ Object
79 80 81 |
# File 'lib/buffet/settings.rb', line 79 def failure_threshold self['failure_threshold'] || 3 end |
.file_excluded?(file) ⇒ Boolean
91 92 93 94 95 |
# File 'lib/buffet/settings.rb', line 91 def file_excluded?(file) excludes.any? do |exclude_prefix| file.start_with?(exclude_prefix) end end |
.has_exclude_filter_file? ⇒ Boolean
75 76 77 |
# File 'lib/buffet/settings.rb', line 75 def has_exclude_filter_file? self['exclude_filter_file'] || File.exist?(DEFAULT_EXCLUDE_FILTER_FILE) end |
.log_file ⇒ Object
51 52 53 |
# File 'lib/buffet/settings.rb', line 51 def log_file @log_file || self['log_file'] || DEFAULT_LOG_FILE end |
.log_file=(log) ⇒ Object
47 48 49 |
# File 'lib/buffet/settings.rb', line 47 def log_file=(log) @log_file = log end |
.prepare_command ⇒ Object
63 64 65 |
# File 'lib/buffet/settings.rb', line 63 def prepare_command self['prepare_command'] || DEFAULT_PREPARE_COMMAND end |
.prepare_command? ⇒ Boolean
67 68 69 |
# File 'lib/buffet/settings.rb', line 67 def prepare_command? self['prepare_command'] || File.exist?(DEFAULT_PREPARE_COMMAND) end |
.project ⇒ Object
59 60 61 |
# File 'lib/buffet/settings.rb', line 59 def project @project ||= Project.new Dir.pwd end |
.project_name=(project_name) ⇒ Object
55 56 57 |
# File 'lib/buffet/settings.rb', line 55 def project_name=(project_name) project.name = project_name end |
.reset! ⇒ Object
97 98 99 |
# File 'lib/buffet/settings.rb', line 97 def reset! @settings = nil end |
.settings_file ⇒ Object
17 18 19 |
# File 'lib/buffet/settings.rb', line 17 def settings_file @settings_file || DEFAULT_SETTINGS_FILE end |
.settings_file=(settings_file) ⇒ Object
12 13 14 15 |
# File 'lib/buffet/settings.rb', line 12 def settings_file=(settings_file) @settings_file = settings_file reset! end |
.slaves ⇒ Object
26 27 28 29 30 |
# File 'lib/buffet/settings.rb', line 26 def slaves @slaves ||= self['slaves'].map do |slave_hash| Slave.new slave_hash['user'], slave_hash['host'], project end end |
.worker_command ⇒ Object
36 37 38 |
# File 'lib/buffet/settings.rb', line 36 def worker_command self['worker_command'] || '.buffet/buffet-worker' end |