crowbar-client 2.4.1 → 2.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/README.md +18 -6
- data/lib/crowbar/client.rb +54 -0
- data/lib/crowbar/client/app.rb +3 -0
- data/lib/crowbar/client/app/backup.rb +62 -1
- data/lib/crowbar/client/app/barclamp.rb +10 -0
- data/lib/crowbar/client/app/base.rb +50 -0
- data/lib/crowbar/client/app/batch.rb +25 -0
- data/lib/crowbar/client/app/entry.rb +26 -1
- data/lib/crowbar/client/app/host_ip.rb +24 -0
- data/lib/crowbar/client/app/installer.rb +16 -1
- data/lib/crowbar/client/app/interface.rb +21 -0
- data/lib/crowbar/client/app/network.rb +3 -0
- data/lib/crowbar/client/app/node.rb +3 -0
- data/lib/crowbar/client/app/proposal.rb +3 -0
- data/lib/crowbar/client/app/repository.rb +3 -0
- data/lib/crowbar/client/app/role.rb +3 -0
- data/lib/crowbar/client/app/server.rb +56 -0
- data/lib/crowbar/client/app/virtual_ip.rb +24 -0
- data/lib/crowbar/client/command.rb +3 -0
- data/lib/crowbar/client/command/backup.rb +3 -0
- data/lib/crowbar/client/command/backup/create.rb +3 -0
- data/lib/crowbar/client/command/backup/delete.rb +3 -0
- data/lib/crowbar/client/command/backup/download.rb +3 -0
- data/lib/crowbar/client/command/backup/list.rb +3 -0
- data/lib/crowbar/client/command/backup/restore.rb +3 -0
- data/lib/crowbar/client/command/backup/upload.rb +3 -0
- data/lib/crowbar/client/command/barclamp.rb +3 -0
- data/lib/crowbar/client/command/barclamp/list.rb +3 -0
- data/lib/crowbar/client/command/base.rb +3 -0
- data/lib/crowbar/client/command/batch.rb +3 -0
- data/lib/crowbar/client/command/batch/build.rb +3 -0
- data/lib/crowbar/client/command/batch/export.rb +3 -0
- data/lib/crowbar/client/command/host_ip.rb +3 -0
- data/lib/crowbar/client/command/host_ip/allocate.rb +3 -0
- data/lib/crowbar/client/command/host_ip/deallocate.rb +3 -0
- data/lib/crowbar/client/command/installer.rb +3 -0
- data/lib/crowbar/client/command/installer/start.rb +3 -0
- data/lib/crowbar/client/command/installer/status.rb +3 -0
- data/lib/crowbar/client/command/interface.rb +3 -0
- data/lib/crowbar/client/command/interface/disable.rb +3 -0
- data/lib/crowbar/client/command/interface/enable.rb +3 -0
- data/lib/crowbar/client/command/node.rb +3 -0
- data/lib/crowbar/client/command/node/allocate.rb +4 -1
- data/lib/crowbar/client/command/node/delete.rb +3 -0
- data/lib/crowbar/client/command/node/group.rb +3 -0
- data/lib/crowbar/client/command/node/hardware.rb +4 -1
- data/lib/crowbar/client/command/node/identify.rb +4 -1
- data/lib/crowbar/client/command/node/list.rb +3 -0
- data/lib/crowbar/client/command/node/powercycle.rb +4 -1
- data/lib/crowbar/client/command/node/poweroff.rb +4 -1
- data/lib/crowbar/client/command/node/poweron.rb +4 -1
- data/lib/crowbar/client/command/node/reboot.rb +4 -1
- data/lib/crowbar/client/command/node/reinstall.rb +4 -1
- data/lib/crowbar/client/command/node/rename.rb +3 -0
- data/lib/crowbar/client/command/node/reset.rb +4 -1
- data/lib/crowbar/client/command/node/role.rb +3 -0
- data/lib/crowbar/client/command/node/show.rb +3 -0
- data/lib/crowbar/client/command/node/shutdown.rb +4 -1
- data/lib/crowbar/client/command/node/status.rb +3 -0
- data/lib/crowbar/client/command/node/transition.rb +3 -0
- data/lib/crowbar/client/command/proposal.rb +3 -0
- data/lib/crowbar/client/command/proposal/commit.rb +3 -0
- data/lib/crowbar/client/command/proposal/create.rb +3 -0
- data/lib/crowbar/client/command/proposal/delete.rb +3 -0
- data/lib/crowbar/client/command/proposal/dequeue.rb +3 -0
- data/lib/crowbar/client/command/proposal/edit.rb +3 -0
- data/lib/crowbar/client/command/proposal/list.rb +3 -0
- data/lib/crowbar/client/command/proposal/reset.rb +3 -0
- data/lib/crowbar/client/command/proposal/show.rb +3 -0
- data/lib/crowbar/client/command/repository.rb +3 -0
- data/lib/crowbar/client/command/repository/activate.rb +3 -0
- data/lib/crowbar/client/command/repository/activate_all.rb +3 -0
- data/lib/crowbar/client/command/repository/deactivate.rb +3 -0
- data/lib/crowbar/client/command/repository/deactivate_all.rb +3 -0
- data/lib/crowbar/client/command/repository/list.rb +3 -0
- data/lib/crowbar/client/command/role.rb +3 -0
- data/lib/crowbar/client/command/role/list.rb +3 -0
- data/lib/crowbar/client/command/role/show.rb +3 -0
- data/lib/crowbar/client/command/server.rb +5 -0
- data/lib/crowbar/client/command/server/api.rb +3 -0
- data/lib/crowbar/client/command/server/check.rb +75 -0
- data/lib/crowbar/client/command/virtual_ip.rb +3 -0
- data/lib/crowbar/client/command/virtual_ip/allocate.rb +3 -0
- data/lib/crowbar/client/command/virtual_ip/deallocate.rb +3 -0
- data/lib/crowbar/client/config.rb +128 -1
- data/lib/crowbar/client/filter.rb +3 -0
- data/lib/crowbar/client/filter/array.rb +3 -0
- data/lib/crowbar/client/filter/base.rb +3 -0
- data/lib/crowbar/client/filter/hash.rb +3 -0
- data/lib/crowbar/client/filter/subset.rb +3 -0
- data/lib/crowbar/client/formatter.rb +3 -0
- data/lib/crowbar/client/formatter/array.rb +3 -0
- data/lib/crowbar/client/formatter/base.rb +3 -0
- data/lib/crowbar/client/formatter/hash.rb +3 -0
- data/lib/crowbar/client/formatter/nested.rb +3 -0
- data/lib/crowbar/client/mixin.rb +3 -0
- data/lib/crowbar/client/mixin/barclamp.rb +3 -0
- data/lib/crowbar/client/mixin/filter.rb +3 -0
- data/lib/crowbar/client/mixin/format.rb +3 -0
- data/lib/crowbar/client/request.rb +3 -0
- data/lib/crowbar/client/request/backup.rb +3 -0
- data/lib/crowbar/client/request/backup/create.rb +18 -0
- data/lib/crowbar/client/request/backup/delete.rb +13 -0
- data/lib/crowbar/client/request/backup/download.rb +13 -0
- data/lib/crowbar/client/request/backup/list.rb +13 -0
- data/lib/crowbar/client/request/backup/restore.rb +13 -0
- data/lib/crowbar/client/request/backup/upload.rb +13 -0
- data/lib/crowbar/client/request/barclamp.rb +3 -0
- data/lib/crowbar/client/request/barclamp/list.rb +13 -0
- data/lib/crowbar/client/request/base.rb +42 -11
- data/lib/crowbar/client/request/batch.rb +3 -0
- data/lib/crowbar/client/request/batch/build.rb +13 -0
- data/lib/crowbar/client/request/batch/export.rb +18 -0
- data/lib/crowbar/client/request/host_ip.rb +3 -0
- data/lib/crowbar/client/request/host_ip/allocate.rb +18 -0
- data/lib/crowbar/client/request/host_ip/deallocate.rb +18 -0
- data/lib/crowbar/client/request/installer.rb +3 -0
- data/lib/crowbar/client/request/installer/start.rb +18 -0
- data/lib/crowbar/client/request/installer/status.rb +13 -0
- data/lib/crowbar/client/request/interface.rb +3 -0
- data/lib/crowbar/client/request/interface/disable.rb +18 -0
- data/lib/crowbar/client/request/interface/enable.rb +18 -0
- data/lib/crowbar/client/request/node.rb +33 -0
- data/lib/crowbar/client/request/node/action.rb +13 -0
- data/lib/crowbar/client/request/node/allocate.rb +29 -0
- data/lib/crowbar/client/request/node/delete.rb +13 -0
- data/lib/crowbar/client/request/node/group.rb +13 -0
- data/lib/crowbar/client/request/node/hardware.rb +29 -0
- data/lib/crowbar/client/request/node/identify.rb +29 -0
- data/lib/crowbar/client/request/node/list.rb +13 -0
- data/lib/crowbar/client/request/node/powercycle.rb +29 -0
- data/lib/crowbar/client/request/node/poweroff.rb +29 -0
- data/lib/crowbar/client/request/node/poweron.rb +29 -0
- data/lib/crowbar/client/request/node/reboot.rb +29 -0
- data/lib/crowbar/client/request/node/reinstall.rb +29 -0
- data/lib/crowbar/client/request/node/rename.rb +18 -0
- data/lib/crowbar/client/request/node/reset.rb +29 -0
- data/lib/crowbar/client/request/node/role.rb +18 -0
- data/lib/crowbar/client/request/node/show.rb +13 -0
- data/lib/crowbar/client/request/node/shutdown.rb +29 -0
- data/lib/crowbar/client/request/node/status.rb +13 -0
- data/lib/crowbar/client/request/node/transition.rb +18 -0
- data/lib/crowbar/client/request/party.rb +3 -0
- data/lib/crowbar/client/request/proposal.rb +3 -0
- data/lib/crowbar/client/request/proposal/commit.rb +13 -0
- data/lib/crowbar/client/request/proposal/create.rb +18 -0
- data/lib/crowbar/client/request/proposal/delete.rb +13 -0
- data/lib/crowbar/client/request/proposal/dequeue.rb +13 -0
- data/lib/crowbar/client/request/proposal/edit.rb +18 -0
- data/lib/crowbar/client/request/proposal/list.rb +13 -0
- data/lib/crowbar/client/request/proposal/reset.rb +13 -0
- data/lib/crowbar/client/request/proposal/show.rb +13 -0
- data/lib/crowbar/client/request/proposal/template.rb +13 -0
- data/lib/crowbar/client/request/repository.rb +3 -0
- data/lib/crowbar/client/request/repository/activate.rb +18 -0
- data/lib/crowbar/client/request/repository/activate_all.rb +13 -0
- data/lib/crowbar/client/request/repository/deactivate.rb +18 -0
- data/lib/crowbar/client/request/repository/deactivate_all.rb +13 -0
- data/lib/crowbar/client/request/repository/list.rb +13 -0
- data/lib/crowbar/client/request/role.rb +3 -0
- data/lib/crowbar/client/request/role/list.rb +13 -0
- data/lib/crowbar/client/request/role/show.rb +13 -0
- data/lib/crowbar/client/request/server.rb +5 -0
- data/lib/crowbar/client/request/server/api.rb +13 -0
- data/lib/crowbar/client/request/server/check.rb +49 -0
- data/lib/crowbar/client/request/virtual_ip.rb +3 -0
- data/lib/crowbar/client/request/virtual_ip/allocate.rb +18 -0
- data/lib/crowbar/client/request/virtual_ip/deallocate.rb +18 -0
- data/lib/crowbar/client/util.rb +3 -0
- data/lib/crowbar/client/util/editor.rb +3 -0
- data/lib/crowbar/client/util/runner.rb +3 -0
- data/lib/crowbar/client/version.rb +23 -1
- data/spec/crowbar/client/command/backup/create_spec.rb +8 -16
- data/spec/crowbar/client/command/backup/delete_spec.rb +8 -16
- data/spec/crowbar/client/command/backup/download_spec.rb +8 -16
- data/spec/crowbar/client/command/backup/list_spec.rb +7 -15
- data/spec/crowbar/client/command/backup/restore_spec.rb +8 -16
- data/spec/crowbar/client/command/backup/upload_spec.rb +11 -19
- data/spec/crowbar/client/command/barclamp/list_spec.rb +7 -15
- data/spec/crowbar/client/command/batch/build_spec.rb +11 -19
- data/spec/crowbar/client/command/batch/export_spec.rb +7 -15
- data/spec/crowbar/client/command/host_ip/allocate_spec.rb +7 -15
- data/spec/crowbar/client/command/host_ip/deallocate_spec.rb +7 -15
- data/spec/crowbar/client/command/installer/start_spec.rb +8 -16
- data/spec/crowbar/client/command/installer/status_spec.rb +7 -15
- data/spec/crowbar/client/command/interface/disable_spec.rb +7 -15
- data/spec/crowbar/client/command/interface/enable_spec.rb +7 -15
- data/spec/crowbar/client/command/node/allocate_spec.rb +7 -15
- data/spec/crowbar/client/command/node/delete_spec.rb +7 -15
- data/spec/crowbar/client/command/node/group_spec.rb +7 -15
- data/spec/crowbar/client/command/node/hardware_spec.rb +7 -15
- data/spec/crowbar/client/command/node/identify_spec.rb +7 -15
- data/spec/crowbar/client/command/node/list_spec.rb +9 -17
- data/spec/crowbar/client/command/node/powercycle_spec.rb +7 -15
- data/spec/crowbar/client/command/node/poweroff_spec.rb +7 -15
- data/spec/crowbar/client/command/node/poweron_spec.rb +7 -15
- data/spec/crowbar/client/command/node/reboot_spec.rb +7 -15
- data/spec/crowbar/client/command/node/reinstall_spec.rb +7 -15
- data/spec/crowbar/client/command/node/rename_spec.rb +7 -15
- data/spec/crowbar/client/command/node/reset_spec.rb +7 -15
- data/spec/crowbar/client/command/node/role_spec.rb +7 -15
- data/spec/crowbar/client/command/node/show_spec.rb +7 -15
- data/spec/crowbar/client/command/node/shutdown_spec.rb +7 -15
- data/spec/crowbar/client/command/node/status_spec.rb +7 -15
- data/spec/crowbar/client/command/node/transition_spec.rb +7 -15
- data/spec/crowbar/client/command/proposal/commit_spec.rb +7 -15
- data/spec/crowbar/client/command/proposal/delete_spec.rb +7 -15
- data/spec/crowbar/client/command/proposal/dequeue_spec.rb +7 -15
- data/spec/crowbar/client/command/proposal/list_spec.rb +7 -15
- data/spec/crowbar/client/command/proposal/reset_spec.rb +7 -15
- data/spec/crowbar/client/command/proposal/show_spec.rb +7 -15
- data/spec/crowbar/client/command/repository/activate_all_spec.rb +7 -15
- data/spec/crowbar/client/command/repository/activate_spec.rb +7 -15
- data/spec/crowbar/client/command/repository/deactivate_all_spec.rb +7 -15
- data/spec/crowbar/client/command/repository/deactivate_spec.rb +7 -15
- data/spec/crowbar/client/command/repository/list_spec.rb +7 -15
- data/spec/crowbar/client/command/role/list_spec.rb +7 -15
- data/spec/crowbar/client/command/role/show_spec.rb +7 -15
- data/spec/crowbar/client/command/server/api_spec.rb +7 -15
- data/spec/crowbar/client/command/server/check_spec.rb +31 -0
- data/spec/crowbar/client/command/virtual_ip/allocate_spec.rb +7 -15
- data/spec/crowbar/client/command/virtual_ip/deallocate_spec.rb +7 -15
- data/spec/crowbar/client/request/server/check_spec.rb +50 -0
- data/spec/support/command_examples.rb +59 -0
- metadata +117 -95
@@ -17,9 +17,14 @@
|
|
17
17
|
module Crowbar
|
18
18
|
module Client
|
19
19
|
module Command
|
20
|
+
#
|
21
|
+
# Module for the server command implementations
|
22
|
+
#
|
20
23
|
module Server
|
21
24
|
autoload :Api,
|
22
25
|
File.expand_path("../server/api", __FILE__)
|
26
|
+
autoload :Check,
|
27
|
+
File.expand_path("../server/check", __FILE__)
|
23
28
|
end
|
24
29
|
end
|
25
30
|
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
#
|
2
|
+
# Copyright 2016, SUSE Linux GmbH
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
|
17
|
+
module Crowbar
|
18
|
+
module Client
|
19
|
+
module Command
|
20
|
+
module Server
|
21
|
+
#
|
22
|
+
# Implementation for the server check command
|
23
|
+
#
|
24
|
+
class Check < Base
|
25
|
+
include Mixin::Format
|
26
|
+
include Mixin::Filter
|
27
|
+
|
28
|
+
def request
|
29
|
+
@request ||= Request::Server::Check.new(
|
30
|
+
args
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
def execute
|
35
|
+
request.process do |request|
|
36
|
+
formatter = Formatter::Array.new(
|
37
|
+
format: provide_format,
|
38
|
+
headings: ["Errors"],
|
39
|
+
values: Filter::Array.new(
|
40
|
+
filter: provide_filter,
|
41
|
+
values: content_from(request)
|
42
|
+
).result
|
43
|
+
)
|
44
|
+
|
45
|
+
case request.code
|
46
|
+
when 200
|
47
|
+
if formatter.empty?
|
48
|
+
say "Crowbar is in a sane state"
|
49
|
+
else
|
50
|
+
say formatter.result
|
51
|
+
end
|
52
|
+
when 409
|
53
|
+
err "Could not perform sanity checks: #{request.parsed_response["error"]}"
|
54
|
+
else
|
55
|
+
err request.parsed_response["error"]
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
protected
|
61
|
+
|
62
|
+
def content_from(request)
|
63
|
+
[].tap do |row|
|
64
|
+
request.parsed_response.each do |child|
|
65
|
+
row.push(
|
66
|
+
child
|
67
|
+
)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -20,6 +20,9 @@ require "singleton"
|
|
20
20
|
|
21
21
|
module Crowbar
|
22
22
|
module Client
|
23
|
+
#
|
24
|
+
# General configuration for the Crowbar CLI
|
25
|
+
#
|
23
26
|
class Config
|
24
27
|
include Singleton
|
25
28
|
|
@@ -27,6 +30,11 @@ module Crowbar
|
|
27
30
|
attr_writer :config
|
28
31
|
attr_writer :values
|
29
32
|
|
33
|
+
#
|
34
|
+
# Define base configuration
|
35
|
+
#
|
36
|
+
# @param options [Hash] the base configuration
|
37
|
+
#
|
30
38
|
def configure(options)
|
31
39
|
self.options = Hashie::Mash.new(
|
32
40
|
options
|
@@ -36,6 +44,11 @@ module Crowbar
|
|
36
44
|
self.values = merge
|
37
45
|
end
|
38
46
|
|
47
|
+
#
|
48
|
+
# Define default config
|
49
|
+
#
|
50
|
+
# @return [Hashie::Mash] the default config
|
51
|
+
#
|
39
52
|
def defaults
|
40
53
|
@defaults ||= Hashie::Mash.new(
|
41
54
|
alias: default_alias,
|
@@ -48,44 +61,89 @@ module Crowbar
|
|
48
61
|
)
|
49
62
|
end
|
50
63
|
|
64
|
+
#
|
65
|
+
# Define parameter config
|
66
|
+
#
|
67
|
+
# @return [Hashie::Mash] the parameter config
|
68
|
+
#
|
51
69
|
def options
|
52
70
|
@options ||= defaults
|
53
71
|
end
|
54
72
|
|
73
|
+
#
|
74
|
+
# Define file config
|
75
|
+
#
|
76
|
+
# @return [Hashie::Mash] the file config
|
77
|
+
#
|
55
78
|
def config
|
56
79
|
@config ||= Hashie::Mash.new
|
57
80
|
end
|
58
81
|
|
82
|
+
#
|
83
|
+
# Define merged config
|
84
|
+
#
|
85
|
+
# @return [Hashie::Mash] the merged config
|
86
|
+
#
|
59
87
|
def values
|
60
88
|
@values ||= Hashie::Mash.new
|
61
89
|
end
|
62
90
|
|
63
91
|
protected
|
64
92
|
|
93
|
+
#
|
94
|
+
# Define a default alias value
|
95
|
+
#
|
96
|
+
# @return [String] the default alias value
|
97
|
+
#
|
65
98
|
def default_alias
|
66
99
|
ENV["CROWBAR_ALIAS"] || "default"
|
67
100
|
end
|
68
101
|
|
102
|
+
#
|
103
|
+
# Define a default username value
|
104
|
+
#
|
105
|
+
# @return [String] the default username value
|
106
|
+
#
|
69
107
|
def default_username
|
70
108
|
ENV["CROWBAR_USERNAME"] || "crowbar"
|
71
109
|
end
|
72
110
|
|
111
|
+
#
|
112
|
+
# Define a default password value
|
113
|
+
#
|
114
|
+
# @return [String] the default password value
|
115
|
+
#
|
73
116
|
def default_password
|
74
117
|
ENV["CROWBAR_PASSWORD"] || "crowbar"
|
75
118
|
end
|
76
119
|
|
120
|
+
#
|
121
|
+
# Define a default server value
|
122
|
+
#
|
123
|
+
# @return [String] the default server value
|
124
|
+
#
|
77
125
|
def default_server
|
78
126
|
ENV["CROWBAR_SERVER"] || "http://127.0.0.1:80"
|
79
127
|
end
|
80
128
|
|
129
|
+
#
|
130
|
+
# Define a default timeout value
|
131
|
+
#
|
132
|
+
# @return [Integer] the default timeout value
|
133
|
+
#
|
81
134
|
def default_timeout
|
82
135
|
if ENV["CROWBAR_TIMEOUT"].present?
|
83
136
|
ENV["CROWBAR_TIMEOUT"].to_i
|
84
137
|
else
|
85
|
-
|
138
|
+
180
|
86
139
|
end
|
87
140
|
end
|
88
141
|
|
142
|
+
#
|
143
|
+
# Define a default anonymous flag
|
144
|
+
#
|
145
|
+
# @return [Bool] the default anonymous flag
|
146
|
+
#
|
89
147
|
def default_anonymous
|
90
148
|
if ENV["CROWBAR_ANONYMOUS"].present?
|
91
149
|
[
|
@@ -96,6 +154,11 @@ module Crowbar
|
|
96
154
|
end
|
97
155
|
end
|
98
156
|
|
157
|
+
#
|
158
|
+
# Define a default debug flag
|
159
|
+
#
|
160
|
+
# @return [String] the default alias flag
|
161
|
+
#
|
99
162
|
def default_debug
|
100
163
|
if ENV["CROWBAR_DEBUG"].present?
|
101
164
|
[
|
@@ -106,6 +169,11 @@ module Crowbar
|
|
106
169
|
end
|
107
170
|
end
|
108
171
|
|
172
|
+
#
|
173
|
+
# Merge the different configs together
|
174
|
+
#
|
175
|
+
# @return [Hashie::Mash] the merged config
|
176
|
+
#
|
109
177
|
def merge
|
110
178
|
result = {}.tap do |overwrite|
|
111
179
|
defaults.keys.each do |key|
|
@@ -127,6 +195,11 @@ module Crowbar
|
|
127
195
|
)
|
128
196
|
end
|
129
197
|
|
198
|
+
#
|
199
|
+
# Load and parse the config file
|
200
|
+
#
|
201
|
+
# @return [Hashie::Mash] the config content
|
202
|
+
#
|
130
203
|
def parser
|
131
204
|
ini = Hashie::Mash.new(
|
132
205
|
IniFile.load(
|
@@ -143,12 +216,22 @@ module Crowbar
|
|
143
216
|
Hashie::Mash.new
|
144
217
|
end
|
145
218
|
|
219
|
+
#
|
220
|
+
# Find the first config file
|
221
|
+
#
|
222
|
+
# @return [String] the first config
|
223
|
+
#
|
146
224
|
def finder
|
147
225
|
paths.detect do |temp|
|
148
226
|
File.exist? temp
|
149
227
|
end
|
150
228
|
end
|
151
229
|
|
230
|
+
#
|
231
|
+
# Define the available config file paths
|
232
|
+
#
|
233
|
+
# @return [Array] the available paths
|
234
|
+
#
|
152
235
|
def paths
|
153
236
|
[
|
154
237
|
File.join(
|
@@ -163,26 +246,63 @@ module Crowbar
|
|
163
246
|
end
|
164
247
|
|
165
248
|
class << self
|
249
|
+
#
|
250
|
+
# Define base configuration
|
251
|
+
#
|
252
|
+
# @see #configure
|
253
|
+
# @param options [Hash] the base configuration
|
254
|
+
#
|
166
255
|
def configure(options)
|
167
256
|
instance.configure(options)
|
168
257
|
end
|
169
258
|
|
259
|
+
#
|
260
|
+
# Define default config
|
261
|
+
#
|
262
|
+
# @see #defaults
|
263
|
+
# @return [Hashie::Mash] the default config
|
264
|
+
#
|
170
265
|
def defaults
|
171
266
|
instance.defaults
|
172
267
|
end
|
173
268
|
|
269
|
+
#
|
270
|
+
# Define parameter config
|
271
|
+
#
|
272
|
+
# @see #options
|
273
|
+
# @return [Hashie::Mash] the parameter config
|
274
|
+
#
|
174
275
|
def options
|
175
276
|
instance.options
|
176
277
|
end
|
177
278
|
|
279
|
+
#
|
280
|
+
# Define file config
|
281
|
+
#
|
282
|
+
# @see #config
|
283
|
+
# @return [Hashie::Mash] the file config
|
284
|
+
#
|
178
285
|
def config
|
179
286
|
instance.config
|
180
287
|
end
|
181
288
|
|
289
|
+
#
|
290
|
+
# Define merged config
|
291
|
+
#
|
292
|
+
# @see #values
|
293
|
+
# @return [Hashie::Mash] the merged config
|
294
|
+
#
|
182
295
|
def values
|
183
296
|
instance.values
|
184
297
|
end
|
185
298
|
|
299
|
+
#
|
300
|
+
# Magic to catch missing method calls
|
301
|
+
#
|
302
|
+
# @param method [Symbol] the method that is missing
|
303
|
+
# @param arguments [Array] the list of attributes
|
304
|
+
# @yield
|
305
|
+
#
|
186
306
|
def method_missing(method, *arguments, &block)
|
187
307
|
case
|
188
308
|
when method.to_s.ends_with?("=")
|
@@ -200,6 +320,13 @@ module Crowbar
|
|
200
320
|
end
|
201
321
|
end
|
202
322
|
|
323
|
+
#
|
324
|
+
# Magic to catch missing respond_to calls
|
325
|
+
#
|
326
|
+
# @param method [Symbol] the method that is missing
|
327
|
+
# @param include_private [Bool] should include private methods
|
328
|
+
# @return [Bool] the class responds to it or not
|
329
|
+
#
|
203
330
|
def respond_to?(method, include_private = false)
|
204
331
|
case
|
205
332
|
when method.to_s.ends_with?("=")
|