fig 2.0.0.pre.alpha.3 → 2.0.0.pre.alpha.5

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.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/lib/fig/application_configuration.rb +2 -1
  3. data/lib/fig/command/options/parser.rb +4 -2
  4. data/lib/fig/command/options.rb +1 -1
  5. data/lib/fig/command.rb +17 -8
  6. data/lib/fig/figrc.rb +41 -14
  7. data/lib/fig/protocol/file.rb +3 -1
  8. data/lib/fig/protocol/ftp.rb +5 -5
  9. data/lib/fig/repository.rb +15 -11
  10. data/lib/fig/spec_utils.rb +312 -0
  11. data/lib/fig/url_access_disallowed_error.rb +5 -0
  12. data/lib/fig/version.rb +1 -1
  13. data/spec/application_configuration_spec.rb +73 -0
  14. data/spec/command/clean_spec.rb +62 -0
  15. data/spec/command/command_line_vs_package_spec.rb +32 -0
  16. data/spec/command/dump_package_definition_spec.rb +104 -0
  17. data/spec/command/environment_variables_spec.rb +62 -0
  18. data/spec/command/grammar_asset_spec.rb +391 -0
  19. data/spec/command/grammar_command_spec.rb +88 -0
  20. data/spec/command/grammar_environment_variable_spec.rb +384 -0
  21. data/spec/command/grammar_retrieve_spec.rb +74 -0
  22. data/spec/command/grammar_spec.rb +87 -0
  23. data/spec/command/grammar_spec_helper.rb +23 -0
  24. data/spec/command/include_file_spec.rb +73 -0
  25. data/spec/command/listing_spec.rb +1574 -0
  26. data/spec/command/miscellaneous_spec.rb +145 -0
  27. data/spec/command/publish_local_and_updates_spec.rb +32 -0
  28. data/spec/command/publishing_retrieval_spec.rb +423 -0
  29. data/spec/command/publishing_spec.rb +596 -0
  30. data/spec/command/running_commands_spec.rb +354 -0
  31. data/spec/command/suppress_includes_spec.rb +65 -0
  32. data/spec/command/suppress_warning_include_statement_missing_version_spec.rb +134 -0
  33. data/spec/command/update_lock_response_spec.rb +47 -0
  34. data/spec/command/usage_errors_spec.rb +481 -0
  35. data/spec/command_options_spec.rb +184 -0
  36. data/spec/command_spec.rb +49 -0
  37. data/spec/deparser/v1_spec.rb +64 -0
  38. data/spec/environment_variables_spec.rb +91 -0
  39. data/spec/figrc_spec.rb +144 -0
  40. data/spec/parser_spec.rb +398 -0
  41. data/spec/repository_spec.rb +117 -0
  42. data/spec/runtime_environment_spec.rb +357 -0
  43. data/spec/spec_helper.rb +1 -0
  44. data/spec/split_repo_url_spec.rb +190 -0
  45. data/spec/statement/asset_spec.rb +203 -0
  46. data/spec/statement/configuration_spec.rb +41 -0
  47. data/spec/support/formatters/seed_spitter.rb +12 -0
  48. data/spec/working_directory_maintainer_spec.rb +102 -0
  49. metadata +58 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bdd1e421366a665108de5fd81a68498c9809df0ce0ad07271101972a767d0d0f
4
- data.tar.gz: 68efbaf9fcdffc32985aa9f38816c6e5b924d511506f46710edb693c31b43f4c
3
+ metadata.gz: 62f48881b3ac7d401f94298e95315f0500b08a26635ecbc36a47de29e9ef172e
4
+ data.tar.gz: b1833add69c8cf53d54cd0ce76ee6cc1608c713eb487963f0af679671916e22e
5
5
  SHA512:
6
- metadata.gz: 70d69aa2ba2cfd2ecba24909220b1b4f88f642e026fb3b553ac4025d4dc3d5676f0e8489b787f683ccc9f87fc1b1e3dbade15c7384dcad9340c0b3249c3d998f
7
- data.tar.gz: 04b889ccfc8c71e306184cecfe406d482f2200354b72f71a48771057b6ad3d210b9745eddb934555ff227acc88a17f9d8079fb309656ae12de277ae19176d424
6
+ metadata.gz: 062e6bb0dc0a5ccaa087022de0398cb641393f2dd4938afeecf1199ab0a8d81ef3b7c6c784d116b9f9b43aac5c769df1e177b12ac85a06fa4c54dd08b7249a7a
7
+ data.tar.gz: 77ec6f3a04820f24d373304f5289c5164ffd66984f3d6922a6de2d02fd3be288432e0b07a319e52dd36f633f877b109b859b79feef609a7aeef9e32ffe8bd98a
@@ -5,7 +5,8 @@ module Fig; end
5
5
  # Configuration for the Fig program, as opposed to a config in a package.
6
6
  class Fig::ApplicationConfiguration
7
7
  attr_accessor :base_whitelisted_url
8
- attr_accessor :remote_repository_url
8
+ attr_accessor :remote_download_url
9
+ attr_accessor :remote_upload_url
9
10
 
10
11
  def initialize()
11
12
  @data = []
@@ -115,8 +115,10 @@ required or allowed is dependent upon what your are doing.
115
115
 
116
116
  Environment variables:
117
117
 
118
- FIG_REMOTE_URL location of remote repository, required for remote
119
- operations
118
+ FIG_DOWNLOAD_URL location of remote repository for download, required for remote
119
+ download operations
120
+ FIG_UPLOAD_URL location of remote repository for upload, required for remote
121
+ publish/upload operations
120
122
  FIG_HOME path to local repository, defaults to $HOME/.fighome
121
123
  FIG_SVN_EXECUTABLE path to svn executable, set to empty string to suppress
122
124
  use of Subversion
@@ -712,7 +712,7 @@ Running commands:
712
712
  end
713
713
 
714
714
  @parser.on('--no-figrc', 'ignore ~/.figrc') { @no_figrc = true }
715
- @parser.on('--no-remote-figrc', 'ignore $FIG_REMOTE_URL/_meta/figrc') {
715
+ @parser.on('--no-remote-figrc', 'ignore $FIG_DOWNLOAD_URL/_meta/figrc') {
716
716
  @no_remote_figrc = true
717
717
  }
718
718
 
data/lib/fig/command.rb CHANGED
@@ -236,20 +236,28 @@ class Fig::Command
236
236
  def set_up_application_configuration()
237
237
  @application_configuration = Fig::FigRC.find(
238
238
  @options.figrc,
239
- ENV['FIG_REMOTE_URL'],
239
+ ENV['FIG_DOWNLOAD_URL'],
240
+ ENV['FIG_UPLOAD_URL'],
240
241
  @operating_system,
241
242
  @options.home,
242
243
  @options.no_figrc?,
243
244
  @options.no_remote_figrc?
244
245
  )
245
246
 
246
- if \
247
- remote_operation_necessary? \
248
- && @application_configuration.remote_repository_url.nil?
247
+ if remote_operation_necessary?
248
+ # Check if any action is a publishing operation. Note that "publish" doesn't
249
+ # necessarily mean "upload" b/c it could be publishing to a local repo.
250
+ publishing_operation = @options.actions.any? {|action| action.publish?}
249
251
 
250
- raise Fig::UserInputError.new(
251
- 'Please define the FIG_REMOTE_URL environment variable.'
252
- )
252
+ if publishing_operation && @application_configuration.remote_upload_url.nil?
253
+ raise Fig::UserInputError.new(
254
+ 'Must set FIG_UPLOAD_URL for publish/upload operations.'
255
+ )
256
+ elsif !publishing_operation && @application_configuration.remote_download_url.nil?
257
+ raise Fig::UserInputError.new(
258
+ 'Must set FIG_DOWNLOAD_URL for download repository operations.'
259
+ )
260
+ end
253
261
  end
254
262
 
255
263
  return
@@ -261,7 +269,8 @@ class Fig::Command
261
269
  @options,
262
270
  @operating_system,
263
271
  @options.home(),
264
- @application_configuration.remote_repository_url,
272
+ @application_configuration.remote_download_url,
273
+ @application_configuration.remote_upload_url,
265
274
  @parser,
266
275
  @publish_listeners,
267
276
  )
data/lib/fig/figrc.rb CHANGED
@@ -15,10 +15,10 @@ module Fig; end
15
15
  class Fig::FigRC
16
16
  REPOSITORY_CONFIGURATION =
17
17
  "#{Fig::Repository::METADATA_SUBDIRECTORY}/figrc"
18
-
19
18
  def self.find(
20
19
  override_path,
21
- specified_repository_url,
20
+ download_repository_url,
21
+ upload_repository_url,
22
22
  operating_system,
23
23
  fig_home,
24
24
  disable_figrc = false,
@@ -28,17 +28,44 @@ class Fig::FigRC
28
28
 
29
29
  handle_override_configuration(configuration, override_path)
30
30
  handle_figrc(configuration) if not disable_figrc
31
+
32
+ # Check for legacy environment variable usage
33
+ download_url = derive_repository_url(download_repository_url, 'DOWNLOAD', configuration)
34
+ upload_url = derive_repository_url(upload_repository_url, 'UPLOAD', configuration)
35
+ remote_url = ENV['FIG_REMOTE_URL']
36
+
37
+ has_download = !download_url.nil? && !download_url.strip.empty?
38
+ has_upload = !upload_url.nil? && !upload_url.strip.empty?
39
+ has_remote = !remote_url.nil? && !remote_url.strip.empty?
40
+
41
+ # Error case: FIG_REMOTE_URL exists but one or both new URLs missing
42
+ if has_remote && (!has_download || !has_upload)
43
+ raise Fig::UserInputError.new(
44
+ 'FIG_REMOTE_URL is set but FIG_DOWNLOAD_URL and/or FIG_UPLOAD_URL are missing. ' +
45
+ 'Please set both FIG_DOWNLOAD_URL and FIG_UPLOAD_URL instead of FIG_REMOTE_URL.'
46
+ )
47
+ end
31
48
 
32
- repository_url =
33
- derive_repository_url(specified_repository_url, configuration)
34
-
35
- configuration.base_whitelisted_url = repository_url
36
- configuration.remote_repository_url = repository_url
37
-
38
- handle_repository_configuration(
39
- configuration, repository_url, operating_system, fig_home
40
- ) if not disable_remote_figrc
41
-
49
+ # Warning case: All three variables exist
50
+ if has_remote && has_download && has_upload
51
+ $stderr.puts "WARNING: FIG_REMOTE_URL is set but will be ignored. Using FIG_DOWNLOAD_URL and FIG_UPLOAD_URL instead."
52
+ end
53
+
54
+ # Set the new URL attributes
55
+ configuration.remote_download_url = download_url
56
+ configuration.remote_upload_url = upload_url
57
+
58
+ # For backward compatibility with code expecting whitelisted URLs
59
+ url_for_whitelist = has_download ? download_url : nil
60
+ configuration.base_whitelisted_url = url_for_whitelist
61
+
62
+ # Handle repository configuration if enabled
63
+ if !disable_remote_figrc && has_download
64
+ handle_repository_configuration(
65
+ configuration, download_url, operating_system, fig_home
66
+ )
67
+ end
68
+
42
69
  return configuration
43
70
  end
44
71
 
@@ -73,9 +100,9 @@ class Fig::FigRC
73
100
  return
74
101
  end
75
102
 
76
- def self.derive_repository_url(specified_repository_url, configuration)
103
+ def self.derive_repository_url(specified_repository_url, which, configuration)
77
104
  if specified_repository_url.nil?
78
- return configuration['default FIG_REMOTE_URL']
105
+ return configuration["default FIG_#{which}_URL"]
79
106
  end
80
107
 
81
108
  if specified_repository_url.empty? || specified_repository_url =~ /\A\s*\z/
@@ -21,10 +21,12 @@ class Fig::Protocol::File
21
21
  return packages if ! ::File.exist?(unescaped_path)
22
22
 
23
23
  ls = ''
24
+
25
+ unescaped_path = FileTest.symlink?(unescaped_path) ? ::File.realpath(unescaped_path) : unescaped_path
24
26
  Find.find(unescaped_path) {
25
27
  |file|
26
28
 
27
- if FileTest.directory? file
29
+ if FileTest.directory?(file)
28
30
  ls << file.to_s
29
31
  ls << "\n"
30
32
  end
@@ -90,17 +90,17 @@ class Fig::Protocol::FTP
90
90
  end
91
91
 
92
92
  def upload(local_file, uri)
93
- ftp_uri = Fig::URL.parse(ENV['FIG_REMOTE_URL'])
93
+ ftp_uri = Fig::URL.parse(ENV['FIG_UPLOAD_URL'])
94
94
  ftp_root_path = ftp_uri.path
95
95
  ftp_root_dirs = ftp_uri.path.split('/')
96
- remote_publish_path = uri.path[0, uri.path.rindex('/')]
97
- remote_publish_dirs = remote_publish_path.split('/')
96
+ remote_upload_path = uri.path[0, uri.path.rindex('/')]
97
+ remote_upload_dirs = remote_upload_path.split('/')
98
98
  # Use array subtraction to deduce which project/version folder to upload
99
99
  # to, i.e. [1,2,3] - [2,3,4] = [1]
100
- remote_project_dirs = remote_publish_dirs - ftp_root_dirs
100
+ remote_project_dirs = remote_upload_dirs - ftp_root_dirs
101
101
  Net::FTP.open(uri.host) do |ftp|
102
102
  ftp_login(ftp, uri.host, :prompt_for_login)
103
- # Assume that the FIG_REMOTE_URL path exists.
103
+ # Assume that the FIG_UPLOAD_URL path exists.
104
104
  ftp.chdir(ftp_root_path)
105
105
  remote_project_dirs.each do |dir|
106
106
  # Can't automatically create parent directories, so do it manually.
@@ -33,7 +33,8 @@ class Fig::Repository
33
33
  options,
34
34
  operating_system,
35
35
  local_repository_directory,
36
- remote_repository_url,
36
+ remote_download_url,
37
+ remote_upload_url,
37
38
  parser,
38
39
  publish_listeners
39
40
  )
@@ -41,7 +42,8 @@ class Fig::Repository
41
42
  @options = options
42
43
  @operating_system = operating_system
43
44
  @local_repository_directory = local_repository_directory
44
- @remote_repository_url = remote_repository_url
45
+ @remote_download_url = remote_download_url
46
+ @remote_upload_url = remote_upload_url
45
47
  @parser = parser
46
48
  @publish_listeners = publish_listeners
47
49
 
@@ -77,7 +79,7 @@ class Fig::Repository
77
79
  def list_remote_packages
78
80
  check_remote_repository_format()
79
81
 
80
- paths = @operating_system.download_list(remote_repository_url())
82
+ paths = @operating_system.download_list(remote_download_url())
81
83
 
82
84
  return paths.reject { |path| path =~ %r< ^ #{METADATA_SUBDIRECTORY} / >xs }
83
85
  end
@@ -156,9 +158,9 @@ class Fig::Repository
156
158
 
157
159
  if not local_only
158
160
  publisher.remote_directory_for_package =
159
- remote_directory_for_package(descriptor)
161
+ remote_directory_for_package(descriptor, for_publishing: true)
160
162
  publisher.remote_fig_file_for_package =
161
- remote_fig_file_for_package(descriptor)
163
+ remote_fig_file_for_package(descriptor, for_publishing: true)
162
164
  end
163
165
 
164
166
  return publisher.publish_package()
@@ -174,7 +176,8 @@ class Fig::Repository
174
176
 
175
177
  private
176
178
 
177
- attr_reader :remote_repository_url
179
+ attr_reader :remote_download_url
180
+ attr_reader :remote_upload_url
178
181
 
179
182
  def initialize_local_repository()
180
183
  FileUtils.mkdir_p(@local_repository_directory)
@@ -244,7 +247,7 @@ class Fig::Repository
244
247
  temp_dir = base_temp_dir()
245
248
  @operating_system.delete_and_recreate_directory(temp_dir)
246
249
  remote_version_file = Fig::URL.append_path_components(
247
- remote_repository_url(), [VERSION_FILE_NAME]
250
+ remote_download_url(), [VERSION_FILE_NAME]
248
251
  )
249
252
  local_version_file = File.join(temp_dir, "remote-#{VERSION_FILE_NAME}")
250
253
  begin
@@ -452,9 +455,9 @@ class Fig::Repository
452
455
  return
453
456
  end
454
457
 
455
- def remote_fig_file_for_package(descriptor)
458
+ def remote_fig_file_for_package(descriptor, for_publishing: false)
456
459
  return Fig::URL.append_path_components(
457
- remote_directory_for_package(descriptor), [PACKAGE_FILE_IN_REPO]
460
+ remote_directory_for_package(descriptor, for_publishing: for_publishing), [PACKAGE_FILE_IN_REPO]
458
461
  )
459
462
  end
460
463
 
@@ -466,9 +469,10 @@ class Fig::Repository
466
469
  File.join(package_download_dir, PACKAGE_FILE_IN_REPO)
467
470
  end
468
471
 
469
- def remote_directory_for_package(descriptor)
472
+ def remote_directory_for_package(descriptor, for_publishing: false)
473
+ url = for_publishing ? remote_upload_url() : remote_download_url()
470
474
  return Fig::URL.append_path_components(
471
- remote_repository_url(), [descriptor.name, descriptor.version]
475
+ url, [descriptor.name, descriptor.version]
472
476
  )
473
477
  end
474
478
 
@@ -0,0 +1,312 @@
1
+ # coding: utf-8
2
+
3
+ if ENV['FIG_COVERAGE']
4
+ require 'simplecov' # note that .simplecov will be loaded here.
5
+
6
+ SimpleCov.start
7
+ end
8
+
9
+ require 'rubygems'
10
+ require 'rbconfig'
11
+ require 'rspec'
12
+
13
+ require 'fileutils'
14
+ require 'tmpdir'
15
+
16
+ require 'fig/command'
17
+ require 'fig/external_program'
18
+ require 'fig/figrc'
19
+ require 'fig/logging'
20
+ require 'fig/repository'
21
+
22
+ FIG_SPEC_BASE_DIRECTORY = Dir.mktmpdir 'fig-rspec-'
23
+ at_exit { FileUtils.rm_rf FIG_SPEC_BASE_DIRECTORY }
24
+
25
+ # "Current" as in current directory when running fig.
26
+ CURRENT_DIRECTORY = FIG_SPEC_BASE_DIRECTORY + '/current-directory'
27
+
28
+ USER_HOME = FIG_SPEC_BASE_DIRECTORY + '/user-home'
29
+ FIG_HOME = FIG_SPEC_BASE_DIRECTORY + '/fig-home'
30
+
31
+ # For split URL behavior - using distinct directories to catch incorrect URL usage
32
+ FIG_DOWNLOAD_DIR = File.join(FIG_SPEC_BASE_DIRECTORY, 'remote')
33
+ FIG_UPLOAD_DIR = File.join(FIG_SPEC_BASE_DIRECTORY, 'upload')
34
+ FIG_DOWNLOAD_URL = %Q<file://#{FIG_DOWNLOAD_DIR}>
35
+ FIG_UPLOAD_URL = %Q<file://#{FIG_UPLOAD_DIR}>
36
+
37
+ #FIG_DIRECTORY ||= File.expand_path(File.dirname(__FILE__)) + '/../bin'
38
+ FIG_DIRECTORY ||= File.expand_path(File.dirname(__FILE__)) + '/../../bin'
39
+ FIG_COMMAND_CLASS ||= Fig::Command
40
+ FIG_PROGRAM ||= ENV['FIG_SPEC_DEBUG'] \
41
+ ? 'exit Fig::Command.new.run_fig ARGV' \
42
+ : 'exit Fig::Command.new.run_fig_with_exception_handling ARGV'
43
+
44
+ # Needed for testing of resources.
45
+ FIG_FILE_GUARANTEED_TO_EXIST =
46
+ File.expand_path(CURRENT_DIRECTORY + '/file-guaranteed-to-exist')
47
+
48
+ RUBY_EXE ||= RbConfig.ruby
49
+ BASE_FIG_COMMAND_LINE ||= [
50
+ RUBY_EXE,
51
+ '--external-encoding', 'UTF-8',
52
+ '--internal-encoding', 'UTF-8',
53
+ '-r', "#{FIG_DIRECTORY}/../lib/fig/command/initialization.rb",
54
+ '-e', FIG_PROGRAM,
55
+ '--',
56
+ ]
57
+
58
+ ENV['HOME'] = USER_HOME
59
+ ENV['FIG_HOME'] = FIG_HOME
60
+ # Set up new environment variables for tests
61
+ ENV['FIG_DOWNLOAD_URL'] = FIG_DOWNLOAD_URL
62
+ ENV['FIG_UPLOAD_URL'] = FIG_UPLOAD_URL
63
+
64
+ ENV['FIG_COVERAGE_ROOT_DIRECTORY'] =
65
+ File.expand_path(File.dirname(__FILE__) + '/..')
66
+
67
+ Fig::Logging.initialize_post_configuration(nil, false, 'off', true)
68
+
69
+ $fig_run_count = 0 # Nasty, nasty global.
70
+
71
+ # Options:
72
+ #
73
+ # :current_directory What the current directory should be when starting fig.
74
+ #
75
+ # :figrc Value of the --figrc option. If not specified,
76
+ # --no-figrc will be passed to fig.
77
+ #
78
+ # :no_raise_on_error Normally an exception is thrown if fig returns an error
79
+ # code. If this option is true, then no exception will
80
+ # be raised, allowing testing of failure states/output.
81
+ #
82
+ # :fork If specified as false, don't run fig as an external
83
+ # process, but in-process instead. This will run faster,
84
+ # but will screw up the test suite if fig invokes
85
+ # Kernel#exec (due to a command statement) or otherwise
86
+ # depends upon at-exit behavior.
87
+ def fig(command_line, first_extra = nil, rest_extra = nil)
88
+ input, options = _fig_input_options(first_extra, rest_extra)
89
+
90
+ $fig_run_count += 1
91
+ ENV['FIG_COVERAGE_RUN_COUNT'] = $fig_run_count.to_s
92
+
93
+ out = err = exit_code = nil
94
+
95
+ current_directory = options[:current_directory] || CURRENT_DIRECTORY
96
+ Dir.chdir current_directory do
97
+ standard_options = []
98
+ standard_options.concat %w< --log-level warn >
99
+ standard_options.concat %w< --file - > if input
100
+
101
+ figrc = options[:figrc]
102
+ if figrc
103
+ standard_options << '--figrc' << figrc
104
+ else
105
+ standard_options << '--no-figrc'
106
+ end
107
+
108
+ if command_line.include?('--update-lock-response')
109
+ if ! options.fetch(:fork, true)
110
+ raise 'Cannot specify both ":fork => false" and --update-lock-response.'
111
+ end
112
+ elsif ! options.fetch(:fork, true) || Fig::OperatingSystem.windows?
113
+ standard_options.concat %w< --update-lock-response ignore >
114
+ end
115
+
116
+ command_line = [standard_options, command_line].flatten
117
+ out, err, exit_code = _run_command command_line, input, options
118
+ end
119
+
120
+ return out, err, exit_code
121
+ end
122
+
123
+ # A bit of ruby magic to make invoking fig() nicer; this takes advantage of the
124
+ # hash assignment syntax so you can call it like any of
125
+ #
126
+ # fig([arguments])
127
+ # fig([arguments], input)
128
+ # fig([arguments], input, :no_raise_on_error => true)
129
+ # fig([arguments], :no_raise_on_error => true)
130
+ def _fig_input_options(first_extra, rest_extra)
131
+ return nil, rest_extra || {} if first_extra.nil?
132
+
133
+ if first_extra.is_a? Hash
134
+ return nil, first_extra
135
+ end
136
+
137
+ return first_extra, rest_extra || {}
138
+ end
139
+
140
+ def _run_command(command_line, input, options)
141
+ out = err = exit_code = exit_string = nil
142
+
143
+ if options.fetch(:fork, true)
144
+ out, err, exit_code, exit_string =
145
+ _run_command_externally command_line, input, options
146
+ else
147
+ out, err, exit_code, exit_string =
148
+ _run_command_internally command_line, input, options
149
+ end
150
+
151
+ if exit_string
152
+ # Common scenario during development is that the fig process will fail for
153
+ # whatever reason, but the RSpec expectation is checking whether a file was
154
+ # created, etc. meaning that we don't see stdout, stderr, etc. but RSpec's
155
+ # failure message for the expectation, which isn't informative. Throwing
156
+ # an exception that RSpec will catch will correctly integrate the fig
157
+ # output with the rest of the RSpec output.
158
+ fig_failure = "Fig process failed:\n"
159
+ fig_failure << "command: #{command_line.join(' ')}\n"
160
+ fig_failure << "result: #{exit_string}\n"
161
+ fig_failure << "stdout: #{out.nil? ? '<nil>' : out}\n"
162
+ fig_failure << "stderr: #{err.nil? ? '<nil>' : err}\n"
163
+ if input
164
+ fig_failure << "input: #{input}\n"
165
+ end
166
+
167
+ raise fig_failure
168
+ end
169
+
170
+ if ! options[:dont_strip_output]
171
+ err.strip!
172
+ out.strip!
173
+ end
174
+
175
+ return out, err, exit_code
176
+ end
177
+
178
+ def _run_command_externally(command_line, input, options)
179
+ full_command_line = BASE_FIG_COMMAND_LINE + command_line
180
+ out, err, result = Fig::ExternalProgram.capture(full_command_line, input)
181
+
182
+ exit_code = result.nil? ? 0 : result.exitstatus
183
+ exit_string = nil
184
+ if result && ! result.success? && ! options[:no_raise_on_error]
185
+ exit_string = result.to_s
186
+ end
187
+
188
+ # Hooray for Windows line endings! Not.
189
+ if out
190
+ out.gsub!(/\r+\n/, "\n")
191
+ end
192
+ if err
193
+ err.gsub!(/\r+\n/, "\n")
194
+ end
195
+
196
+ return out, err, exit_code, exit_string
197
+ end
198
+
199
+ def _run_command_internally(command_line, input, options)
200
+ original_stdin = $stdin
201
+ original_stdout = $stdout
202
+ original_stderr = $stderr
203
+
204
+ begin
205
+ stdin = input ? StringIO.new(input) : StringIO.new
206
+ stdout = StringIO.new
207
+ stderr = StringIO.new
208
+ exit_code = nil
209
+
210
+ $stdin = stdin
211
+ $stdout = stdout
212
+ $stderr = stderr
213
+
214
+ if ENV['FIG_SPEC_DEBUG']
215
+ exit_code = FIG_COMMAND_CLASS.new.run_fig command_line
216
+ else
217
+ exit_code =
218
+ FIG_COMMAND_CLASS.new.run_fig_with_exception_handling command_line
219
+ end
220
+
221
+ exit_string = nil
222
+ if exit_code != 0 && ! options[:no_raise_on_error]
223
+ exit_string = exit_code.to_s
224
+ end
225
+
226
+ return stdout.string, stderr.string, exit_code, exit_string
227
+ ensure
228
+ $stdin = original_stdin
229
+ $stdout = original_stdout
230
+ $stderr = original_stderr
231
+ end
232
+ end
233
+
234
+ def set_up_test_environment()
235
+ FileUtils.mkdir_p FIG_SPEC_BASE_DIRECTORY
236
+ FileUtils.mkdir_p CURRENT_DIRECTORY
237
+ FileUtils.mkdir_p USER_HOME
238
+ FileUtils.mkdir_p FIG_HOME
239
+ FileUtils.mkdir_p FIG_UPLOAD_DIR
240
+ FileUtils.ln_s FIG_UPLOAD_DIR, FIG_DOWNLOAD_DIR
241
+
242
+ FileUtils.touch FIG_FILE_GUARANTEED_TO_EXIST
243
+
244
+ metadata_directory =
245
+ File.join FIG_UPLOAD_DIR, Fig::Repository::METADATA_SUBDIRECTORY
246
+ FileUtils.mkdir_p metadata_directory
247
+
248
+ File.open(
249
+ File.join(FIG_UPLOAD_DIR, Fig::FigRC::REPOSITORY_CONFIGURATION), 'w'
250
+ ) do
251
+ |handle|
252
+ handle.puts '{}' # Empty Javascript/JSON object
253
+ end
254
+
255
+ return
256
+ end
257
+
258
+ def clean_up_test_environment()
259
+ FileUtils.rm_rf(FIG_SPEC_BASE_DIRECTORY)
260
+
261
+ return
262
+ end
263
+
264
+ def cleanup_home_and_remote(unified: true)
265
+ FileUtils.rm_rf(FIG_HOME)
266
+
267
+ # Clean up split URL directories
268
+ FileUtils.rm_rf(FIG_DOWNLOAD_DIR)
269
+ FileUtils.rm_rf(FIG_UPLOAD_DIR)
270
+
271
+ # Create base directories for split URLs
272
+ FileUtils.mkdir_p(FIG_UPLOAD_DIR)
273
+ FileUtils.mkdir_p(File.join(FIG_UPLOAD_DIR, Fig::Repository::METADATA_SUBDIRECTORY))
274
+
275
+ if unified
276
+ # use symlink to simulate an aggregated artifactory repo
277
+ FileUtils.ln_s(FIG_UPLOAD_DIR, FIG_DOWNLOAD_DIR)
278
+ else
279
+ FileUtils.mkdir_p(FIG_DOWNLOAD_DIR)
280
+ FileUtils.mkdir_p(File.join(FIG_DOWNLOAD_DIR, Fig::Repository::METADATA_SUBDIRECTORY))
281
+ end
282
+
283
+ return
284
+ end
285
+
286
+ def set_local_repository_format_to_future_version()
287
+ version_file = File.join(FIG_HOME, Fig::Repository::VERSION_FILE_NAME)
288
+ FileUtils.mkdir_p(FIG_HOME)
289
+ File.open(version_file, 'w') {
290
+ |handle| handle.write(Fig::Repository::LOCAL_VERSION_SUPPORTED + 1)
291
+ }
292
+
293
+ return
294
+ end
295
+
296
+ def set_remote_repository_format_to_future_version()
297
+ # Set future version in download dir
298
+ version_file = File.join(FIG_DOWNLOAD_DIR, Fig::Repository::VERSION_FILE_NAME)
299
+ FileUtils.mkdir_p(FIG_DOWNLOAD_DIR)
300
+ File.open(version_file, 'w') {
301
+ |handle| handle.write(Fig::Repository::REMOTE_VERSION_SUPPORTED + 1)
302
+ }
303
+
304
+ # Set future version in upload dir
305
+ version_file = File.join(FIG_UPLOAD_DIR, Fig::Repository::VERSION_FILE_NAME)
306
+ FileUtils.mkdir_p(FIG_UPLOAD_DIR)
307
+ File.open(version_file, 'w') {
308
+ |handle| handle.write(Fig::Repository::REMOTE_VERSION_SUPPORTED + 1)
309
+ }
310
+
311
+ return
312
+ end
@@ -11,5 +11,10 @@ module Fig
11
11
  @urls = urls
12
12
  @descriptor = descriptor
13
13
  end
14
+
15
+ def message
16
+ "URLAccessDisallowedError:\n descriptor = #{descriptor.inspect}\n urls = " +
17
+ @urls.map { |k,v| " - #{k}: #{v.inspect}" }.join("\n ")
18
+ end
14
19
  end
15
20
  end
data/lib/fig/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # coding: utf-8
2
2
 
3
3
  module Fig
4
- VERSION = '2.0.0-alpha.3'.freeze
4
+ VERSION = '2.0.0-alpha.5'.freeze
5
5
  end