fig 0.1.65 → 0.1.67
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.
- data/Changes +29 -0
- data/bin/fig +1 -1
- data/bin/fig-debug +1 -1
- data/lib/fig.rb +3 -0
- data/lib/fig/{applicationconfiguration.rb → application_configuration.rb} +0 -0
- data/lib/fig/{atexit.rb → at_exit.rb} +0 -0
- data/lib/fig/command.rb +190 -200
- data/lib/fig/command/action.rb +83 -0
- data/lib/fig/command/action/clean.rb +33 -0
- data/lib/fig/command/action/get.rb +48 -0
- data/lib/fig/command/action/help.rb +29 -0
- data/lib/fig/command/action/list_configs.rb +39 -0
- data/lib/fig/command/action/list_dependencies.rb +19 -0
- data/lib/fig/command/action/list_dependencies/all_configs.rb +44 -0
- data/lib/fig/command/action/list_dependencies/default.rb +40 -0
- data/lib/fig/command/action/list_dependencies/tree.rb +40 -0
- data/lib/fig/command/action/list_dependencies/tree_all_configs.rb +40 -0
- data/lib/fig/command/action/list_local.rb +29 -0
- data/lib/fig/command/action/list_remote.rb +33 -0
- data/lib/fig/command/action/list_variables.rb +23 -0
- data/lib/fig/command/action/list_variables/all_configs.rb +61 -0
- data/lib/fig/command/action/list_variables/default.rb +48 -0
- data/lib/fig/command/action/list_variables/tree.rb +20 -0
- data/lib/fig/command/action/list_variables/tree_all_configs.rb +20 -0
- data/lib/fig/command/action/publish.rb +52 -0
- data/lib/fig/command/action/publish_local.rb +29 -0
- data/lib/fig/command/action/role/has_no_sub_action.rb +10 -0
- data/lib/fig/command/action/role/has_sub_action.rb +58 -0
- data/lib/fig/command/action/role/list_all_configs.rb +14 -0
- data/lib/fig/command/action/role/list_base_config.rb +14 -0
- data/lib/fig/command/action/role/list_dependencies_flat.rb +22 -0
- data/lib/fig/command/action/role/list_dependencies_in_a_tree.rb +21 -0
- data/lib/fig/command/action/role/list_variables_in_a_tree.rb +150 -0
- data/lib/fig/command/action/role/list_walking_dependency_tree.rb +90 -0
- data/lib/fig/command/action/role/publish.rb +90 -0
- data/lib/fig/command/action/role/update.rb +46 -0
- data/lib/fig/command/action/run_command_line.rb +45 -0
- data/lib/fig/command/action/run_command_statement.rb +52 -0
- data/lib/fig/command/action/update.rb +17 -0
- data/lib/fig/command/action/update_if_missing.rb +17 -0
- data/lib/fig/command/action/version.rb +27 -0
- data/lib/fig/command/{coveragesupport.rb → coverage_support.rb} +0 -0
- data/lib/fig/command/{optionerror.rb → option_error.rb} +1 -1
- data/lib/fig/command/options.rb +185 -127
- data/lib/fig/command/package_applier.rb +140 -0
- data/lib/fig/command/package_loader.rb +124 -0
- data/lib/fig/{configfileerror.rb → config_file_error.rb} +1 -1
- data/lib/fig/{environmentvariables.rb → environment_variables.rb} +0 -0
- data/lib/fig/{environmentvariables/caseinsensitive.rb → environment_variables/case_insensitive.rb} +1 -1
- data/lib/fig/{environmentvariables/casesensitive.rb → environment_variables/case_sensitive.rb} +1 -1
- data/lib/fig/figrc.rb +3 -3
- data/lib/fig/grammar.treetop +1 -1
- data/lib/fig/{backtrace.rb → include_backtrace.rb} +7 -2
- data/lib/fig/log4r/outputter.rb +1 -1
- data/lib/fig/{log4rconfigerror.rb → log4r_config_error.rb} +1 -1
- data/lib/fig/logging.rb +2 -2
- data/lib/fig/{networkerror.rb → network_error.rb} +1 -1
- data/lib/fig/{nosuchpackageconfigerror.rb → no_such_package_config_error.rb} +2 -2
- data/lib/fig/{notfounderror.rb → not_found_error.rb} +0 -0
- data/lib/fig/{operatingsystem.rb → operating_system.rb} +5 -5
- data/lib/fig/package.rb +3 -3
- data/lib/fig/{packagecache.rb → package_cache.rb} +0 -0
- data/lib/fig/{packagedescriptor.rb → package_descriptor.rb} +1 -1
- data/lib/fig/{packagedescriptorparseerror.rb → package_descriptor_parse_error.rb} +1 -1
- data/lib/fig/{packageparseerror.rb → package_parse_error.rb} +1 -1
- data/lib/fig/parser.rb +4 -4
- data/lib/fig/{parserpackagebuildstate.rb → parser_package_build_state.rb} +1 -1
- data/lib/fig/repository.rb +17 -17
- data/lib/fig/{repositoryerror.rb → repository_error.rb} +1 -1
- data/lib/fig/{environment.rb → runtime_environment.rb} +15 -8
- data/lib/fig/statement/include.rb +1 -1
- data/lib/fig/statement/override.rb +1 -1
- data/lib/fig/{urlaccesserror.rb → url_access_error.rb} +1 -1
- data/lib/fig/{userinputerror.rb → user_input_error.rb} +0 -0
- data/lib/fig/{workingdirectorymaintainer.rb → working_directory_maintainer.rb} +4 -4
- data/lib/fig/{workingdirectorymetadata.rb → working_directory_metadata.rb} +0 -0
- metadata +88 -54
- data/VERSION +0 -1
- data/lib/fig/command/listing.rb +0 -363
- data/lib/fig/command/packageload.rb +0 -236
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.1.65
|
data/lib/fig/command/listing.rb
DELETED
@@ -1,363 +0,0 @@
|
|
1
|
-
require 'set'
|
2
|
-
|
3
|
-
require 'fig/backtrace'
|
4
|
-
require 'fig/package'
|
5
|
-
require 'fig/packagedescriptor'
|
6
|
-
require 'fig/userinputerror'
|
7
|
-
|
8
|
-
module Fig; end
|
9
|
-
class Fig::Command; end
|
10
|
-
|
11
|
-
# Parts of the Command class related to handling of --list-* options, simply to
|
12
|
-
# keep the size of command.rb down.
|
13
|
-
module Fig::Command::Listing
|
14
|
-
private
|
15
|
-
|
16
|
-
def display_local_package_list()
|
17
|
-
check_disallowed_package_descriptor('--list-local')
|
18
|
-
@repository.list_packages.sort.each do |item|
|
19
|
-
puts item
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def display_remote_package_list()
|
24
|
-
check_disallowed_package_descriptor('--list-remote')
|
25
|
-
@repository.list_remote_packages.sort.each do |item|
|
26
|
-
puts item
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def display_configs_in_local_packages_list()
|
31
|
-
@base_package.configs.each do |config|
|
32
|
-
puts config.name
|
33
|
-
end
|
34
|
-
|
35
|
-
return
|
36
|
-
end
|
37
|
-
|
38
|
-
def handle_pre_parse_list_options()
|
39
|
-
case @options.listing()
|
40
|
-
when :local_packages
|
41
|
-
display_local_package_list()
|
42
|
-
when :remote_packages
|
43
|
-
display_remote_package_list()
|
44
|
-
else
|
45
|
-
return false
|
46
|
-
end
|
47
|
-
|
48
|
-
return true
|
49
|
-
end
|
50
|
-
|
51
|
-
def display_dependencies()
|
52
|
-
if @options.list_tree?
|
53
|
-
display_dependencies_in_tree()
|
54
|
-
else
|
55
|
-
display_dependencies_flat()
|
56
|
-
end
|
57
|
-
|
58
|
-
return
|
59
|
-
end
|
60
|
-
|
61
|
-
def display_variables()
|
62
|
-
if @options.list_tree?
|
63
|
-
display_variables_in_tree()
|
64
|
-
elsif @options.list_all_configs?
|
65
|
-
display_variables_flat_from_repository()
|
66
|
-
else
|
67
|
-
display_variables_flat_from_environment()
|
68
|
-
end
|
69
|
-
|
70
|
-
return
|
71
|
-
end
|
72
|
-
|
73
|
-
def display_dependencies_in_tree()
|
74
|
-
walk_dependency_tree(@base_package, derive_base_display_config_names(), nil, 0) do
|
75
|
-
|package, config_name, depth|
|
76
|
-
|
77
|
-
print ' ' * (depth * 4)
|
78
|
-
puts package.to_s_with_config(config_name)
|
79
|
-
end
|
80
|
-
|
81
|
-
return
|
82
|
-
end
|
83
|
-
|
84
|
-
def walk_dependency_tree(base_package, config_names, backtrace, depth, &block)
|
85
|
-
config_names.each do
|
86
|
-
|config_name|
|
87
|
-
|
88
|
-
if depth < 1
|
89
|
-
@repository.reset_cached_data
|
90
|
-
end
|
91
|
-
|
92
|
-
yield base_package, config_name, depth
|
93
|
-
|
94
|
-
new_backtrace = Fig::Backtrace.new(
|
95
|
-
backtrace,
|
96
|
-
Fig::PackageDescriptor.new(
|
97
|
-
base_package.name(),
|
98
|
-
base_package.version(),
|
99
|
-
config_name
|
100
|
-
)
|
101
|
-
)
|
102
|
-
|
103
|
-
base_package.package_dependencies(config_name, new_backtrace).each do
|
104
|
-
|descriptor|
|
105
|
-
|
106
|
-
package = nil
|
107
|
-
if descriptor.name
|
108
|
-
package =
|
109
|
-
@repository.get_package(descriptor, :allow_any_version)
|
110
|
-
else
|
111
|
-
package = base_package
|
112
|
-
end
|
113
|
-
|
114
|
-
walk_dependency_tree(
|
115
|
-
package, [descriptor.config], new_backtrace, depth + 1, &block
|
116
|
-
)
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
return
|
121
|
-
end
|
122
|
-
|
123
|
-
def display_dependencies_flat()
|
124
|
-
packages = gather_package_dependency_configurations()
|
125
|
-
|
126
|
-
if packages.empty? and $stdout.tty?
|
127
|
-
puts '<no dependencies>'
|
128
|
-
else
|
129
|
-
strings = []
|
130
|
-
|
131
|
-
packages.keys.each do
|
132
|
-
|package|
|
133
|
-
|
134
|
-
if @options.list_all_configs?
|
135
|
-
packages[package].each do
|
136
|
-
|config_name|
|
137
|
-
|
138
|
-
strings << package.to_s_with_config(config_name)
|
139
|
-
end
|
140
|
-
else
|
141
|
-
strings << package
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
puts strings.uniq.sort.join("\n")
|
146
|
-
end
|
147
|
-
|
148
|
-
return
|
149
|
-
end
|
150
|
-
|
151
|
-
def derive_base_display_config_names()
|
152
|
-
if @options.list_all_configs?
|
153
|
-
return @base_package.config_names
|
154
|
-
end
|
155
|
-
|
156
|
-
return [ base_config() ]
|
157
|
-
end
|
158
|
-
|
159
|
-
def gather_package_dependency_configurations()
|
160
|
-
packages = {}
|
161
|
-
starting_config_names = derive_base_display_config_names()
|
162
|
-
|
163
|
-
if ! @base_package.name.nil?
|
164
|
-
packages[@base_package] = starting_config_names.to_set
|
165
|
-
end
|
166
|
-
|
167
|
-
walk_dependency_tree(@base_package, starting_config_names, nil, 0) do
|
168
|
-
|package, config_name, depth|
|
169
|
-
|
170
|
-
if (
|
171
|
-
! package.name.nil? \
|
172
|
-
&& ! (
|
173
|
-
! @options.list_all_configs? \
|
174
|
-
&& @descriptor \
|
175
|
-
&& package.name == @descriptor.name
|
176
|
-
)
|
177
|
-
)
|
178
|
-
packages[package] ||= Set.new
|
179
|
-
packages[package] << config_name
|
180
|
-
end
|
181
|
-
end
|
182
|
-
|
183
|
-
if ! @options.list_all_configs? && @descriptor
|
184
|
-
packages.reject! do |package, config_names|
|
185
|
-
package.name == @descriptor.name
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
|
-
return packages
|
190
|
-
end
|
191
|
-
|
192
|
-
def handle_post_parse_list_options()
|
193
|
-
case @options.listing()
|
194
|
-
when :configs
|
195
|
-
display_configs_in_local_packages_list()
|
196
|
-
when :dependencies
|
197
|
-
display_dependencies()
|
198
|
-
when :variables
|
199
|
-
display_variables()
|
200
|
-
else
|
201
|
-
raise %Q<Bug in code! Found unknown :listing option value "#{options.listing()}">
|
202
|
-
end
|
203
|
-
|
204
|
-
return
|
205
|
-
end
|
206
|
-
|
207
|
-
VariableTreePackageConfig =
|
208
|
-
Struct.new(
|
209
|
-
:package, :config_name, :variable_statements, :child_configs, :parent
|
210
|
-
)
|
211
|
-
|
212
|
-
def display_variables_in_tree()
|
213
|
-
# We can't just display as we walk the dependency tree because we need to
|
214
|
-
# know in advance how many configurations we're going display under
|
215
|
-
# another.
|
216
|
-
tree = build_variable_tree()
|
217
|
-
|
218
|
-
tree.child_configs().each do
|
219
|
-
|child|
|
220
|
-
|
221
|
-
display_variable_tree_level(child, '', '')
|
222
|
-
end
|
223
|
-
|
224
|
-
return
|
225
|
-
end
|
226
|
-
|
227
|
-
def build_variable_tree()
|
228
|
-
tree = VariableTreePackageConfig.new(nil, nil, nil, [], nil)
|
229
|
-
prior_depth = 0
|
230
|
-
prior_node = nil
|
231
|
-
current_parent = tree
|
232
|
-
|
233
|
-
walk_dependency_tree(@base_package, derive_base_display_config_names(), nil, 0) do
|
234
|
-
|package, config_name, depth|
|
235
|
-
|
236
|
-
if depth < prior_depth
|
237
|
-
(depth .. (prior_depth - 1)).each do
|
238
|
-
current_parent = current_parent.parent
|
239
|
-
end
|
240
|
-
elsif depth == prior_depth + 1
|
241
|
-
current_parent = prior_node
|
242
|
-
elsif depth > prior_depth
|
243
|
-
raise "Bug in code! Descended more than one level! (#{prior_depth} to #{depth}"
|
244
|
-
end
|
245
|
-
|
246
|
-
variable_statements = gather_variable_statements(package[config_name])
|
247
|
-
node = VariableTreePackageConfig.new(
|
248
|
-
package, config_name, variable_statements, [], current_parent
|
249
|
-
)
|
250
|
-
current_parent.child_configs() << node
|
251
|
-
|
252
|
-
prior_depth = depth
|
253
|
-
prior_node = node
|
254
|
-
end
|
255
|
-
|
256
|
-
return tree
|
257
|
-
end
|
258
|
-
|
259
|
-
def gather_variable_statements(config_statement)
|
260
|
-
variable_statements = []
|
261
|
-
config_statement.walk_statements() do |statement|
|
262
|
-
case statement
|
263
|
-
when Fig::Statement::Path
|
264
|
-
variable_statements << statement
|
265
|
-
when Fig::Statement::Set
|
266
|
-
variable_statements << statement
|
267
|
-
end
|
268
|
-
end
|
269
|
-
|
270
|
-
return variable_statements
|
271
|
-
end
|
272
|
-
|
273
|
-
def display_variable_tree_level(node, base_indent, package_indent)
|
274
|
-
print package_indent
|
275
|
-
puts node.package().to_s_with_config(node.config_name())
|
276
|
-
|
277
|
-
display_variable_tree_level_variables(node, base_indent)
|
278
|
-
|
279
|
-
child_configs = node.child_configs()
|
280
|
-
child_count = child_configs.size()
|
281
|
-
|
282
|
-
new_indent = base_indent + (child_count > 0 ? '|' : ' ') + ' ' * 3
|
283
|
-
new_package_indent = base_indent + %q<'--->
|
284
|
-
|
285
|
-
(0 .. (child_count - 2)).each do
|
286
|
-
|child_index|
|
287
|
-
|
288
|
-
display_variable_tree_level(
|
289
|
-
child_configs[child_index], new_indent, new_package_indent
|
290
|
-
)
|
291
|
-
end
|
292
|
-
|
293
|
-
if child_count > 0
|
294
|
-
display_variable_tree_level(
|
295
|
-
child_configs[-1], (base_indent + ' ' * 4), new_package_indent
|
296
|
-
)
|
297
|
-
end
|
298
|
-
end
|
299
|
-
|
300
|
-
def display_variable_tree_level_variables(node, base_indent)
|
301
|
-
if node.child_configs().size() > 0
|
302
|
-
variable_indent = base_indent + '|' + ' ' * 3
|
303
|
-
else
|
304
|
-
variable_indent = base_indent + ' ' * 4
|
305
|
-
end
|
306
|
-
|
307
|
-
variable_statements = node.variable_statements()
|
308
|
-
|
309
|
-
name_width =
|
310
|
-
(variable_statements.map { |statement| statement.name().length() }).max()
|
311
|
-
|
312
|
-
variable_statements.each do
|
313
|
-
|statement|
|
314
|
-
|
315
|
-
print "#{variable_indent}"
|
316
|
-
print "#{statement.name().ljust(name_width)}"
|
317
|
-
print " = #{statement.value}"
|
318
|
-
if statement.is_a?(Fig::Statement::Path)
|
319
|
-
print ":$#{statement.name}"
|
320
|
-
end
|
321
|
-
print "\n"
|
322
|
-
end
|
323
|
-
|
324
|
-
return
|
325
|
-
end
|
326
|
-
|
327
|
-
def display_variables_flat_from_repository()
|
328
|
-
variable_names = Set.new()
|
329
|
-
|
330
|
-
walk_dependency_tree(@base_package, derive_base_display_config_names(), nil, 0) do
|
331
|
-
|package, config_name, depth|
|
332
|
-
|
333
|
-
package[config_name].walk_statements() do |statement|
|
334
|
-
case statement
|
335
|
-
when Fig::Statement::Path
|
336
|
-
variable_names << statement.name()
|
337
|
-
when Fig::Statement::Set
|
338
|
-
variable_names << statement.name()
|
339
|
-
end
|
340
|
-
end
|
341
|
-
end
|
342
|
-
|
343
|
-
variable_names.sort.each { |name| puts name }
|
344
|
-
|
345
|
-
return
|
346
|
-
end
|
347
|
-
|
348
|
-
def display_variables_flat_from_environment()
|
349
|
-
register_package_with_environment()
|
350
|
-
|
351
|
-
variables = @environment.variables()
|
352
|
-
|
353
|
-
if variables.empty? and $stdout.tty?
|
354
|
-
puts '<no variables>'
|
355
|
-
else
|
356
|
-
variables.keys.sort.each do |variable|
|
357
|
-
puts variable + "=" + variables[variable]
|
358
|
-
end
|
359
|
-
end
|
360
|
-
|
361
|
-
return
|
362
|
-
end
|
363
|
-
end
|
@@ -1,236 +0,0 @@
|
|
1
|
-
require 'fig/package'
|
2
|
-
require 'fig/packagedescriptor'
|
3
|
-
require 'fig/parser'
|
4
|
-
|
5
|
-
module Fig; end
|
6
|
-
class Fig::Command; end
|
7
|
-
|
8
|
-
# Parts of the Command class related to loading of the base Package object,
|
9
|
-
# simply to keep the size of command.rb down.
|
10
|
-
module Fig::Command::PackageLoad
|
11
|
-
DEFAULT_FIG_FILE = 'package.fig'
|
12
|
-
|
13
|
-
private
|
14
|
-
|
15
|
-
def read_in_package_definition_file(config_file)
|
16
|
-
if File.exist?(config_file)
|
17
|
-
@package_loaded_from_path = config_file
|
18
|
-
|
19
|
-
return File.read(config_file)
|
20
|
-
else
|
21
|
-
raise Fig::UserInputError.new(%Q<File "#{config_file}" does not exist.>)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def load_package_definition_file_contents()
|
26
|
-
package_definition_file = @options.package_definition_file()
|
27
|
-
|
28
|
-
if package_definition_file == :none
|
29
|
-
return nil
|
30
|
-
elsif package_definition_file == '-'
|
31
|
-
@package_loaded_from_path = '<standard input>'
|
32
|
-
|
33
|
-
return $stdin.read
|
34
|
-
elsif package_definition_file.nil?
|
35
|
-
if File.exist?(DEFAULT_FIG_FILE)
|
36
|
-
@package_loaded_from_path = DEFAULT_FIG_FILE
|
37
|
-
|
38
|
-
return File.read(DEFAULT_FIG_FILE)
|
39
|
-
end
|
40
|
-
else
|
41
|
-
return read_in_package_definition_file(package_definition_file)
|
42
|
-
end
|
43
|
-
|
44
|
-
return
|
45
|
-
end
|
46
|
-
|
47
|
-
def register_package_with_environment_if_not_listing_or_publishing()
|
48
|
-
return if @options.listing || @options.publishing?
|
49
|
-
|
50
|
-
register_package_with_environment()
|
51
|
-
|
52
|
-
return
|
53
|
-
end
|
54
|
-
|
55
|
-
def register_package_with_environment()
|
56
|
-
if @options.updating?
|
57
|
-
@base_package.retrieves.each do |statement|
|
58
|
-
@environment.add_retrieve(statement)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
@environment.register_package(@base_package)
|
63
|
-
apply_base_config_to_environment()
|
64
|
-
|
65
|
-
return
|
66
|
-
end
|
67
|
-
|
68
|
-
def parse_package_definition_file(definition_text)
|
69
|
-
if definition_text.nil?
|
70
|
-
# This package gets a free ride in terms of requiring a base config; we
|
71
|
-
# synthesize it.
|
72
|
-
set_base_package_to_empty_synthetic_one()
|
73
|
-
return
|
74
|
-
end
|
75
|
-
|
76
|
-
source_description = derive_package_source_description()
|
77
|
-
@base_package =
|
78
|
-
Fig::Parser.new(@configuration, :check_include_versions).parse_package(
|
79
|
-
Fig::PackageDescriptor.new(
|
80
|
-
nil, nil, nil, :source_description => source_description
|
81
|
-
),
|
82
|
-
'.',
|
83
|
-
source_description,
|
84
|
-
definition_text
|
85
|
-
)
|
86
|
-
|
87
|
-
return
|
88
|
-
end
|
89
|
-
|
90
|
-
def load_package_object_from_file()
|
91
|
-
definition_text = load_package_definition_file_contents()
|
92
|
-
|
93
|
-
parse_package_definition_file(definition_text)
|
94
|
-
end
|
95
|
-
|
96
|
-
def load_package_object()
|
97
|
-
if @descriptor.nil?
|
98
|
-
load_package_object_from_file()
|
99
|
-
else
|
100
|
-
@base_package = @repository.get_package(@descriptor)
|
101
|
-
end
|
102
|
-
|
103
|
-
register_package_with_environment_if_not_listing_or_publishing()
|
104
|
-
|
105
|
-
return
|
106
|
-
end
|
107
|
-
|
108
|
-
def apply_base_config_to_environment(ignore_base_package = false)
|
109
|
-
begin
|
110
|
-
@environment.apply_config(
|
111
|
-
synthesize_package_for_command_line_options(ignore_base_package),
|
112
|
-
Fig::Package::DEFAULT_CONFIG,
|
113
|
-
nil
|
114
|
-
)
|
115
|
-
rescue Fig::NoSuchPackageConfigError => exception
|
116
|
-
make_no_such_package_exception_descriptive(exception)
|
117
|
-
end
|
118
|
-
|
119
|
-
return
|
120
|
-
end
|
121
|
-
|
122
|
-
def set_base_package_to_empty_synthetic_one()
|
123
|
-
@base_package = Fig::Package.new(
|
124
|
-
nil,
|
125
|
-
nil,
|
126
|
-
'.',
|
127
|
-
[
|
128
|
-
Fig::Statement::Configuration.new(
|
129
|
-
nil,
|
130
|
-
%Q<[synthetic statement created in #{__FILE__} line #{__LINE__}]>,
|
131
|
-
base_config(),
|
132
|
-
[]
|
133
|
-
)
|
134
|
-
]
|
135
|
-
)
|
136
|
-
|
137
|
-
return
|
138
|
-
end
|
139
|
-
|
140
|
-
def synthesize_package_for_command_line_options(ignore_base_package)
|
141
|
-
configuration_statements = []
|
142
|
-
|
143
|
-
if not ignore_base_package
|
144
|
-
configuration_statements << Fig::Statement::Include.new(
|
145
|
-
nil,
|
146
|
-
%Q<[synthetic statement created in #{__FILE__} line #{__LINE__}]>,
|
147
|
-
Fig::PackageDescriptor.new(
|
148
|
-
@base_package.name(), @base_package.version(), base_config()
|
149
|
-
),
|
150
|
-
nil
|
151
|
-
)
|
152
|
-
end
|
153
|
-
|
154
|
-
configuration_statements << @options.environment_statements()
|
155
|
-
|
156
|
-
configuration_statement =
|
157
|
-
Fig::Statement::Configuration.new(
|
158
|
-
nil,
|
159
|
-
%Q<[synthetic statement created in #{__FILE__} line #{__LINE__}]>,
|
160
|
-
Fig::Package::DEFAULT_CONFIG,
|
161
|
-
configuration_statements.flatten()
|
162
|
-
)
|
163
|
-
|
164
|
-
return Fig::Package.new(nil, nil, '.', [configuration_statement])
|
165
|
-
end
|
166
|
-
|
167
|
-
def make_no_such_package_exception_descriptive(exception)
|
168
|
-
if not @descriptor
|
169
|
-
make_no_such_package_exception_descriptive_without_descriptor(exception)
|
170
|
-
end
|
171
|
-
|
172
|
-
check_no_such_package_exception_is_for_command_line_package(exception)
|
173
|
-
source = derive_exception_source()
|
174
|
-
|
175
|
-
message = %Q<There's no "#{base_config()}" config#{source}.>
|
176
|
-
message += %q< Specify one that does like this: ">
|
177
|
-
message +=
|
178
|
-
Fig::PackageDescriptor.format(@descriptor.name, @descriptor.version, 'some_existing_config')
|
179
|
-
message += %q<".>
|
180
|
-
|
181
|
-
if @options.publishing?
|
182
|
-
message += ' (Yes, this does work with --publish.)'
|
183
|
-
end
|
184
|
-
|
185
|
-
raise Fig::UserInputError.new(message)
|
186
|
-
end
|
187
|
-
|
188
|
-
def make_no_such_package_exception_descriptive_without_descriptor(exception)
|
189
|
-
raise exception if config_was_specified_by_user()
|
190
|
-
raise exception if not exception.descriptor.nil?
|
191
|
-
|
192
|
-
source = derive_exception_source()
|
193
|
-
message =
|
194
|
-
%Q<No config was specified and there's no "#{Fig::Package::DEFAULT_CONFIG}" config#{source}.>
|
195
|
-
config_names = @base_package.config_names()
|
196
|
-
if config_names.size > 1
|
197
|
-
message +=
|
198
|
-
%Q< The valid configs are "#{config_names.join('", "')}".>
|
199
|
-
elsif config_names.size == 1
|
200
|
-
message += %Q< The only config is "#{config_names[0]}".>
|
201
|
-
else
|
202
|
-
message += ' Actually, there are no configs.'
|
203
|
-
end
|
204
|
-
|
205
|
-
raise Fig::UserInputError.new(message)
|
206
|
-
end
|
207
|
-
|
208
|
-
def check_no_such_package_exception_is_for_command_line_package(exception)
|
209
|
-
descriptor = exception.descriptor
|
210
|
-
|
211
|
-
raise exception if
|
212
|
-
descriptor.name && descriptor.name != @descriptor.name
|
213
|
-
raise exception if
|
214
|
-
descriptor.version && descriptor.version != @descriptor.version
|
215
|
-
raise exception if descriptor.config != base_config()
|
216
|
-
|
217
|
-
return
|
218
|
-
end
|
219
|
-
|
220
|
-
def derive_exception_source()
|
221
|
-
source = derive_package_source_description()
|
222
|
-
|
223
|
-
return source ? %Q< in #{source}> : ''
|
224
|
-
end
|
225
|
-
|
226
|
-
def derive_package_source_description()
|
227
|
-
if @package_loaded_from_path
|
228
|
-
return @package_loaded_from_path
|
229
|
-
elsif @descriptor
|
230
|
-
return
|
231
|
-
Fig::PackageDescriptor.format(@descriptor.name, @descriptor.version, nil)
|
232
|
-
end
|
233
|
-
|
234
|
-
return nil
|
235
|
-
end
|
236
|
-
end
|