Class: Jenkins::Build::Configuration
- Inherits:
-
Object
- Object
- Jenkins::Build::Configuration
- Extended by:
- Forwardable
- Defined in:
- lib/jenkins/build/configuration.rb
Constant Summary collapse
- CONFIG =
Pathname('.jenkins-build').freeze
- CONFIG_KEYS =
[:server, :project, :api_key, :user]
Class Method Summary collapse
Instance Method Summary collapse
- #exists? ⇒ Boolean
-
#initialize(folder) ⇒ Configuration
constructor
A new instance of Configuration.
- #merge!(opts) ⇒ Object
- #options ⇒ Object
- #read ⇒ Object
- #write(options = @options) ⇒ Object
Constructor Details
#initialize(folder) ⇒ Configuration
Returns a new instance of Configuration.
23 24 25 26 |
# File 'lib/jenkins/build/configuration.rb', line 23 def initialize(folder) @config = Pathname(CONFIG).(folder).freeze @store = YAML::Store.new(@config) end |
Class Method Details
.current ⇒ Object
16 17 18 |
# File 'lib/jenkins/build/configuration.rb', line 16 def current new(Dir.pwd) end |
Instance Method Details
#exists? ⇒ Boolean
34 35 36 |
# File 'lib/jenkins/build/configuration.rb', line 34 def exists? @config.exist? end |
#merge!(opts) ⇒ Object
38 39 40 41 42 |
# File 'lib/jenkins/build/configuration.rb', line 38 def merge!(opts) CONFIG_KEYS.each do |key| [key] = opts[key] end end |
#options ⇒ Object
44 45 46 |
# File 'lib/jenkins/build/configuration.rb', line 44 def @options ||= read end |
#read ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/jenkins/build/configuration.rb', line 48 def read @store.transaction(true) do @options = CONFIG_KEYS.map do |key| [ key, @store[key] ] end.to_h end end |
#write(options = @options) ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/jenkins/build/configuration.rb', line 56 def write( = @options) @store.transaction do CONFIG_KEYS.each do |key| @store[key] = .fetch(key) end end end |