fig 2.0.0.pre.alpha.4 → 2.0.0.pre.alpha.10

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 (43) hide show
  1. checksums.yaml +4 -4
  2. data/lib/fig/operating_system.rb +3 -0
  3. data/lib/fig/protocol/artifactory.rb +389 -0
  4. data/lib/fig/spec_utils.rb +312 -0
  5. data/lib/fig/version.rb +1 -1
  6. data/spec/application_configuration_spec.rb +73 -0
  7. data/spec/command/clean_spec.rb +62 -0
  8. data/spec/command/command_line_vs_package_spec.rb +32 -0
  9. data/spec/command/dump_package_definition_spec.rb +104 -0
  10. data/spec/command/environment_variables_spec.rb +62 -0
  11. data/spec/command/grammar_asset_spec.rb +391 -0
  12. data/spec/command/grammar_command_spec.rb +88 -0
  13. data/spec/command/grammar_environment_variable_spec.rb +384 -0
  14. data/spec/command/grammar_retrieve_spec.rb +74 -0
  15. data/spec/command/grammar_spec.rb +87 -0
  16. data/spec/command/grammar_spec_helper.rb +23 -0
  17. data/spec/command/include_file_spec.rb +73 -0
  18. data/spec/command/listing_spec.rb +1574 -0
  19. data/spec/command/miscellaneous_spec.rb +145 -0
  20. data/spec/command/publish_local_and_updates_spec.rb +32 -0
  21. data/spec/command/publishing_retrieval_spec.rb +423 -0
  22. data/spec/command/publishing_spec.rb +596 -0
  23. data/spec/command/running_commands_spec.rb +354 -0
  24. data/spec/command/suppress_includes_spec.rb +65 -0
  25. data/spec/command/suppress_warning_include_statement_missing_version_spec.rb +134 -0
  26. data/spec/command/update_lock_response_spec.rb +47 -0
  27. data/spec/command/usage_errors_spec.rb +481 -0
  28. data/spec/command_options_spec.rb +184 -0
  29. data/spec/command_spec.rb +49 -0
  30. data/spec/deparser/v1_spec.rb +64 -0
  31. data/spec/environment_variables_spec.rb +91 -0
  32. data/spec/figrc_spec.rb +144 -0
  33. data/spec/parser_spec.rb +398 -0
  34. data/spec/protocol/artifactory_spec.rb +599 -0
  35. data/spec/repository_spec.rb +117 -0
  36. data/spec/runtime_environment_spec.rb +357 -0
  37. data/spec/spec_helper.rb +1 -0
  38. data/spec/split_repo_url_spec.rb +190 -0
  39. data/spec/statement/asset_spec.rb +203 -0
  40. data/spec/statement/configuration_spec.rb +41 -0
  41. data/spec/support/formatters/seed_spitter.rb +12 -0
  42. data/spec/working_directory_maintainer_spec.rb +102 -0
  43. metadata +72 -5
@@ -0,0 +1,203 @@
1
+ # coding: utf-8
2
+
3
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
4
+
5
+ require 'fig/statement/archive'
6
+ require 'fig/statement/resource'
7
+
8
+ [Fig::Statement::Archive, Fig::Statement::Resource].each do
9
+ |statement_type|
10
+
11
+ describe statement_type do
12
+ describe '.validate_and_process_escapes_in_location()' do
13
+ def test_should_equal_and_should_glob(
14
+ statement_type, original_location, location
15
+ )
16
+ block_message = nil
17
+ location = location.clone
18
+
19
+ tokenized_location =
20
+ statement_type.validate_and_process_escapes_in_location(location) do
21
+ |message| block_message = message
22
+ end
23
+
24
+ block_message.should be_nil
25
+
26
+ location = tokenized_location.to_expanded_string
27
+ need_to_glob = ! tokenized_location.single_quoted?
28
+
29
+ location.should == original_location
30
+ need_to_glob.should be true
31
+
32
+ return
33
+ end
34
+
35
+ def test_should_equal_and_should_not_glob(
36
+ statement_type, original_location, location
37
+ )
38
+ block_message = nil
39
+ location = location.clone
40
+
41
+ tokenized_location =
42
+ statement_type.validate_and_process_escapes_in_location(location) do
43
+ |message| block_message = message
44
+ end
45
+
46
+ location = tokenized_location.to_expanded_string
47
+ need_to_glob = ! tokenized_location.single_quoted?
48
+
49
+ block_message.should be_nil
50
+ location.should == original_location
51
+ need_to_glob.should be false
52
+
53
+ return
54
+ end
55
+
56
+ # "foo * bar": whitespace and glob character
57
+ [%q<foo * bar>].each do
58
+ |original_location|
59
+
60
+ it %Q<does not modify «#{original_location}» and says that it should be globbed> do
61
+ test_should_equal_and_should_glob(
62
+ statement_type, original_location, original_location
63
+ )
64
+ end
65
+ it %Q<strips quotes from «"#{original_location}"» and says that it should be globbed> do
66
+ test_should_equal_and_should_glob(
67
+ statement_type, original_location, %Q<"#{original_location}">
68
+ )
69
+ end
70
+
71
+ it %Q<strips quotes from «'#{original_location}'» and says that it should not be globbed> do
72
+ test_should_equal_and_should_not_glob(
73
+ statement_type, original_location, %Q<'#{original_location}'>
74
+ )
75
+ end
76
+ end
77
+
78
+ %w< \\ ' >.each do
79
+ |character|
80
+
81
+ escaped_location = %Q<foo \\#{character} bar>
82
+ unescaped_location = %Q<foo #{character} bar>
83
+ it %Q<processes escapes from «'#{escaped_location}'» and says that it should not be globbed> do
84
+ test_should_equal_and_should_not_glob(
85
+ statement_type, unescaped_location, %Q<'#{escaped_location}'>
86
+ )
87
+ end
88
+ end
89
+
90
+ %w< \\ " >.each do
91
+ |character|
92
+
93
+ escaped_location = %Q<foo \\#{character} bar>
94
+ unescaped_location = %Q<foo #{character} bar>
95
+ it %Q<processes escapes from «#{escaped_location}» and says that it should be globbed> do
96
+ test_should_equal_and_should_glob(
97
+ statement_type, unescaped_location, escaped_location
98
+ )
99
+ end
100
+ it %Q<processes escapes from «"#{escaped_location}"» and says that it should be globbed> do
101
+ test_should_equal_and_should_glob(
102
+ statement_type, unescaped_location, %Q<"#{escaped_location}">
103
+ )
104
+ end
105
+ end
106
+
107
+ def test_got_error_message(statement_type, location, error_regex)
108
+ block_message = nil
109
+
110
+ statement_type.validate_and_process_escapes_in_location(location.dup) do
111
+ |message| block_message = message
112
+ end
113
+
114
+ block_message.should =~ error_regex
115
+
116
+ return
117
+ end
118
+
119
+ def test_contains_bad_escape(statement_type, location)
120
+ test_got_error_message(
121
+ statement_type, location, /contains a bad escape sequence/i
122
+ )
123
+
124
+ return
125
+ end
126
+
127
+ %w< @ " >.each do
128
+ |character|
129
+
130
+ it %Q<says «'foo \\#{character} bar'» isn't allowed> do
131
+ test_contains_bad_escape(statement_type, %Q<'foo \\#{character} bar'>)
132
+ end
133
+ end
134
+
135
+ %w< ' 'xxx xxx' '\' '\\ >.each do
136
+ |location|
137
+
138
+ it %Q<says «#{location}» has unbalanced quotes> do
139
+ test_got_error_message(
140
+ statement_type, location, /has unbalanced single quotes/i
141
+ )
142
+ end
143
+ end
144
+
145
+ %w< " "xxx xxx" "\" "\\ >.each do
146
+ |location|
147
+
148
+ it %Q<says «#{location}» has unbalanced quotes> do
149
+ test_got_error_message(
150
+ statement_type, location, /has unbalanced double quotes/i
151
+ )
152
+ end
153
+ end
154
+
155
+ %w< xxx'xxx xxx"xxx >.each do
156
+ |location|
157
+
158
+ it %Q<says «#{location}» has unescaped quote> do
159
+ test_got_error_message(
160
+ statement_type, location, /unescaped .* quote/i
161
+ )
162
+ end
163
+ end
164
+
165
+ %w< \\ xxx\\ >.each do
166
+ |location|
167
+
168
+ it %Q<says «#{location}» has incomplete escape> do
169
+ test_got_error_message(statement_type, location, /incomplete escape/i)
170
+ end
171
+ end
172
+
173
+ %w< \\n '\\n' "\\n" >.each do
174
+ |location|
175
+
176
+ it %Q<says «#{location}» has bad escape> do
177
+ test_got_error_message(statement_type, location, /bad escape/i)
178
+ end
179
+ end
180
+
181
+ %w<
182
+ foo\\\\\\\\bar\\\\baz 'foo\\\\\\\\bar\\\\baz' "foo\\\\\\\\bar\\\\baz"
183
+ >.each do
184
+ |original_location|
185
+
186
+ it %Q<collapses the backslashes in «#{original_location}»> do
187
+ location = original_location.clone
188
+ block_message = nil
189
+
190
+ tokenized_location =
191
+ statement_type.validate_and_process_escapes_in_location(location) do
192
+ |message| block_message = message
193
+ end
194
+
195
+ tokenized_location.to_expanded_string == 'foo\\\\bar\\baz'
196
+ block_message.should be_nil
197
+ end
198
+ end
199
+ end
200
+ end
201
+ end
202
+
203
+ # vim: set fileencoding=utf8 :
@@ -0,0 +1,41 @@
1
+ # coding: utf-8
2
+
3
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
4
+
5
+ require 'fig/statement/command'
6
+ require 'fig/statement/configuration'
7
+ require 'fig/statement/include'
8
+ require 'fig/statement/override'
9
+ require 'fig/statement/path'
10
+ require 'fig/statement/set'
11
+ require 'fig/statement/synthetic_raw_text'
12
+
13
+ describe 'Statement::Configuration' do
14
+ it 'moves override statements to the front of the set of statements' do
15
+ override_c = Fig::Statement::Override.new(nil, nil, 'C', 'version')
16
+ override_b = Fig::Statement::Override.new(nil, nil, 'B', 'version')
17
+ override_a = Fig::Statement::Override.new(nil, nil, 'A', 'version')
18
+
19
+ command = Fig::Statement::Command.new(nil, nil, %w< something to run >)
20
+ incorporate = Fig::Statement::Include.new(nil, nil, nil, nil, nil)
21
+
22
+ parsed_name, parsed_value =
23
+ Fig::Statement::Path.parse_name_value 'name=value'
24
+ path = Fig::Statement::Path.new(nil, nil, parsed_name, parsed_value)
25
+ set = Fig::Statement::Set.new(nil, nil, parsed_name, parsed_value)
26
+
27
+ config = Fig::Statement::Configuration.new(
28
+ nil,
29
+ nil,
30
+ 'name',
31
+ [command, override_c, incorporate, override_b, path, override_a, set]
32
+ )
33
+
34
+ statements_to_be_checked =
35
+ config.statements.reject {
36
+ |statement| statement.is_a? Fig::Statement::SyntheticRawText
37
+ }
38
+ statements_to_be_checked.should ==
39
+ [override_c, override_b, override_a, command, incorporate, path, set]
40
+ end
41
+ end
@@ -0,0 +1,12 @@
1
+ # coding: utf-8
2
+
3
+ require 'rspec/core/formatters/documentation_formatter'
4
+
5
+ class SeedSpitter < RSpec::Core::Formatters::DocumentationFormatter
6
+
7
+ def start(*)
8
+ super
9
+ output.puts "\nSeed: #{RSpec.configuration.seed}"
10
+ end
11
+
12
+ end
@@ -0,0 +1,102 @@
1
+ # coding: utf-8
2
+
3
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
4
+
5
+ require 'fig/operating_system'
6
+ require 'fig/working_directory_maintainer'
7
+
8
+ describe 'WorkingDirectoryMaintainer' do
9
+ let(:base_directory) { "#{CURRENT_DIRECTORY}/retrieve-test" }
10
+ let(:working_directory) { "#{base_directory}/working" }
11
+ let(:source_directory) { "#{base_directory}/source" }
12
+
13
+ def new_maintainer
14
+ return Fig::WorkingDirectoryMaintainer.new(
15
+ working_directory, Fig::OperatingSystem.macos?,
16
+ )
17
+ end
18
+
19
+ before(:each) do
20
+ clean_up_test_environment
21
+ set_up_test_environment
22
+
23
+ [working_directory, source_directory].each do
24
+ |directory|
25
+
26
+ FileUtils.rm_rf(directory)
27
+ FileUtils.mkdir_p(directory)
28
+ end
29
+ end
30
+
31
+ it 'maintains files for a single package' do
32
+ # Set up some test files
33
+ source_foo = "#{source_directory}/foo.txt"
34
+ source_bar = "#{source_directory}/bar.txt"
35
+ source_baz = "#{source_directory}/baz.txt"
36
+ File.open(source_foo, 'w') {|f| f << 'FOO'}
37
+ File.open(source_bar, 'w') {|f| f << 'BAR'}
38
+ File.open(source_baz, 'w') {|f| f << 'BAZ'}
39
+
40
+ working_foo = File.join(working_directory, 'foo.txt')
41
+ working_bar = File.join(working_directory, 'bar.txt')
42
+ working_baz = File.join(working_directory, 'baz.txt')
43
+
44
+ # Retrieve files A and B
45
+ maintainer = new_maintainer
46
+ maintainer.switch_to_package_version('foo', '1.2.3')
47
+ maintainer.retrieve(source_foo, 'foo.txt')
48
+ maintainer.retrieve(source_bar, 'bar.txt')
49
+ File.read(working_foo).should == 'FOO'
50
+ File.read(working_bar).should == 'BAR'
51
+
52
+ # Retrieve files B and C for a different version
53
+ maintainer.switch_to_package_version('foo', '4.5.6')
54
+ maintainer.retrieve(source_bar, 'bar.txt')
55
+ maintainer.retrieve(source_baz, 'baz.txt')
56
+ File.read(working_bar).should == 'BAR'
57
+ File.read(working_baz).should == 'BAZ'
58
+ File.exist?(working_foo).should == false
59
+
60
+ # Save and reload
61
+ maintainer.prepare_for_shutdown(:purged_unused_packages)
62
+ maintainer = new_maintainer
63
+
64
+ # Switch back to original version
65
+ maintainer.switch_to_package_version('foo', '1.2.3')
66
+ maintainer.retrieve(source_foo, 'foo.txt')
67
+ maintainer.retrieve(source_bar, 'bar.txt')
68
+
69
+ File.read(working_foo).should == 'FOO'
70
+ File.read(working_bar).should == 'BAR'
71
+ File.exist?(working_baz).should == false
72
+ end
73
+
74
+ it 'preserves executable bit' do
75
+ File.open("#{source_directory}/plain", 'w') {|f| f << 'plain'}
76
+ File.open("#{source_directory}/executable", 'w') {|f| f << 'executable.exe'}
77
+ FileUtils.chmod(0755, "#{source_directory}/executable")
78
+
79
+ maintainer = new_maintainer
80
+ maintainer.switch_to_package_version('foo', '1.2.3')
81
+ maintainer.retrieve("#{source_directory}/plain", 'plain')
82
+ maintainer.retrieve("#{source_directory}/executable", 'executable.exe')
83
+
84
+ File.stat(File.join(working_directory, 'plain')).executable?.should == false
85
+ File.stat(File.join(working_directory, 'executable.exe')).executable?.should == true
86
+ end
87
+
88
+ it 'fails on corrupted metadata' do
89
+ FileUtils.mkdir_p("#{working_directory}/.fig")
90
+
91
+ metadata_file = "#{working_directory}/.fig/retrieve"
92
+ IO.write(metadata_file, 'random garbage')
93
+
94
+ expect { new_maintainer }.to raise_error(/parse error/)
95
+
96
+ # This is so much fun. It appears that once we've had a file open within
97
+ # this process, we cannot delete that file, i.e. "File.rm(metadata_file)"
98
+ # results in an EACCESS on Windows. So, in lieu of removing the file, we
99
+ # just make it empty.
100
+ IO.write(metadata_file, '')
101
+ end
102
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fig
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.pre.alpha.4
4
+ version: 2.0.0.pre.alpha.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fig Folks
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-06-02 00:00:00.000000000 Z
10
+ date: 2025-09-24 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: bcrypt_pbkdf
@@ -233,6 +233,34 @@ dependencies:
233
233
  - - "~>"
234
234
  - !ruby/object:Gem::Version
235
235
  version: 2.6.0
236
+ - !ruby/object:Gem::Dependency
237
+ name: artifactory
238
+ requirement: !ruby/object:Gem::Requirement
239
+ requirements:
240
+ - - "~>"
241
+ - !ruby/object:Gem::Version
242
+ version: 3.0.17
243
+ type: :runtime
244
+ prerelease: false
245
+ version_requirements: !ruby/object:Gem::Requirement
246
+ requirements:
247
+ - - "~>"
248
+ - !ruby/object:Gem::Version
249
+ version: 3.0.17
250
+ - !ruby/object:Gem::Dependency
251
+ name: rexml
252
+ requirement: !ruby/object:Gem::Requirement
253
+ requirements:
254
+ - - "~>"
255
+ - !ruby/object:Gem::Version
256
+ version: '3.0'
257
+ type: :runtime
258
+ prerelease: false
259
+ version_requirements: !ruby/object:Gem::Requirement
260
+ requirements:
261
+ - - "~>"
262
+ - !ruby/object:Gem::Version
263
+ version: '3.0'
236
264
  - !ruby/object:Gem::Dependency
237
265
  name: rdoc
238
266
  requirement: !ruby/object:Gem::Requirement
@@ -306,7 +334,7 @@ dependencies:
306
334
  description: |-
307
335
  Fig is a utility for configuring environments and managing dependencies across a team of developers. Given a list of packages and a command to run, Fig builds environment variables named in those packages (e.g., CLASSPATH), then executes the command in that environment. The caller's environment is not affected.
308
336
 
309
- Built from git SHA1: c0b5d8c
337
+ Built from git SHA1: 46bcf5e-dirty
310
338
  email: maintainer@figpackagemanager.org
311
339
  executables:
312
340
  - fig
@@ -438,6 +466,7 @@ files:
438
466
  - lib/fig/parser.rb
439
467
  - lib/fig/parser_package_build_state.rb
440
468
  - lib/fig/protocol.rb
469
+ - lib/fig/protocol/artifactory.rb
441
470
  - lib/fig/protocol/file.rb
442
471
  - lib/fig/protocol/ftp.rb
443
472
  - lib/fig/protocol/http.rb
@@ -448,6 +477,7 @@ files:
448
477
  - lib/fig/repository_error.rb
449
478
  - lib/fig/repository_package_publisher.rb
450
479
  - lib/fig/runtime_environment.rb
480
+ - lib/fig/spec_utils.rb
451
481
  - lib/fig/statement.rb
452
482
  - lib/fig/statement/archive.rb
453
483
  - lib/fig/statement/asset.rb
@@ -475,10 +505,47 @@ files:
475
505
  - lib/fig/working_directory_maintainer.rb
476
506
  - lib/fig/working_directory_metadata.rb
477
507
  - lib/git_helper.rb
508
+ - spec/application_configuration_spec.rb
509
+ - spec/command/clean_spec.rb
510
+ - spec/command/command_line_vs_package_spec.rb
511
+ - spec/command/dump_package_definition_spec.rb
512
+ - spec/command/environment_variables_spec.rb
513
+ - spec/command/grammar_asset_spec.rb
514
+ - spec/command/grammar_command_spec.rb
515
+ - spec/command/grammar_environment_variable_spec.rb
516
+ - spec/command/grammar_retrieve_spec.rb
517
+ - spec/command/grammar_spec.rb
518
+ - spec/command/grammar_spec_helper.rb
519
+ - spec/command/include_file_spec.rb
520
+ - spec/command/listing_spec.rb
521
+ - spec/command/miscellaneous_spec.rb
522
+ - spec/command/publish_local_and_updates_spec.rb
523
+ - spec/command/publishing_retrieval_spec.rb
524
+ - spec/command/publishing_spec.rb
525
+ - spec/command/running_commands_spec.rb
526
+ - spec/command/suppress_includes_spec.rb
527
+ - spec/command/suppress_warning_include_statement_missing_version_spec.rb
528
+ - spec/command/update_lock_response_spec.rb
529
+ - spec/command/usage_errors_spec.rb
530
+ - spec/command_options_spec.rb
531
+ - spec/command_spec.rb
532
+ - spec/deparser/v1_spec.rb
533
+ - spec/environment_variables_spec.rb
534
+ - spec/figrc_spec.rb
535
+ - spec/parser_spec.rb
536
+ - spec/protocol/artifactory_spec.rb
537
+ - spec/repository_spec.rb
538
+ - spec/runtime_environment_spec.rb
539
+ - spec/spec_helper.rb
540
+ - spec/split_repo_url_spec.rb
541
+ - spec/statement/asset_spec.rb
542
+ - spec/statement/configuration_spec.rb
543
+ - spec/support/formatters/seed_spitter.rb
544
+ - spec/working_directory_maintainer_spec.rb
478
545
  licenses:
479
546
  - BSD-3-Clause
480
547
  metadata:
481
- git_sha: c0b5d8c
548
+ git_sha: 46bcf5e-dirty
482
549
  rdoc_options: []
483
550
  require_paths:
484
551
  - lib
@@ -496,5 +563,5 @@ requirements: []
496
563
  rubygems_version: 3.6.1
497
564
  specification_version: 4
498
565
  summary: 'Utility for configuring environments and managing dependencies across a
499
- team of developers. Built from git SHA1: c0b5d8c'
566
+ team of developers. Built from git SHA1: 46bcf5e-dirty'
500
567
  test_files: []