fig 1.1.0 → 1.2.0

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 (46) hide show
  1. data/Changes +94 -0
  2. data/lib/fig.rb +1 -1
  3. data/lib/fig/command.rb +18 -7
  4. data/lib/fig/command/action/dump_package_definition_for_command_line.rb +2 -2
  5. data/lib/fig/command/action/dump_package_definition_parsed.rb +2 -2
  6. data/lib/fig/command/action/dump_package_definition_text.rb +2 -2
  7. data/lib/fig/command/action/source_package.rb +65 -0
  8. data/lib/fig/command/options.rb +64 -15
  9. data/lib/fig/command/options/parser.rb +24 -14
  10. data/lib/fig/command/package_applier.rb +32 -7
  11. data/lib/fig/command/package_loader.rb +16 -7
  12. data/lib/fig/external_program.rb +72 -0
  13. data/lib/fig/figrc.rb +1 -1
  14. data/lib/fig/grammar/v0.rb +2 -2
  15. data/lib/fig/grammar/v0.treetop +2 -2
  16. data/lib/fig/grammar/v1.rb +17 -1737
  17. data/lib/fig/grammar/v1.treetop +6 -217
  18. data/lib/fig/grammar/v1_base.rb +1750 -0
  19. data/lib/fig/grammar/v1_base.treetop +229 -0
  20. data/lib/fig/grammar/v2.rb +508 -0
  21. data/lib/fig/grammar/v2.treetop +65 -0
  22. data/lib/fig/grammar_monkey_patches.rb +7 -0
  23. data/lib/fig/no_such_package_config_error.rb +3 -1
  24. data/lib/fig/not_yet_parsed_package.rb +27 -0
  25. data/lib/fig/operating_system.rb +5 -5
  26. data/lib/fig/package.rb +20 -2
  27. data/lib/fig/package_definition_text_assembler.rb +2 -1
  28. data/lib/fig/package_descriptor.rb +11 -4
  29. data/lib/fig/parser.rb +44 -58
  30. data/lib/fig/parser_package_build_state.rb +39 -4
  31. data/lib/fig/protocol/file.rb +2 -2
  32. data/lib/fig/protocol/ftp.rb +15 -10
  33. data/lib/fig/protocol/http.rb +1 -1
  34. data/lib/fig/protocol/netrc_enabled.rb +29 -16
  35. data/lib/fig/protocol/sftp.rb +19 -12
  36. data/lib/fig/repository.rb +33 -21
  37. data/lib/fig/repository_package_publisher.rb +129 -8
  38. data/lib/fig/runtime_environment.rb +114 -28
  39. data/lib/fig/statement/include.rb +21 -4
  40. data/lib/fig/statement/include_file.rb +94 -0
  41. data/lib/fig/unparser.rb +15 -7
  42. data/lib/fig/unparser/v1.rb +2 -80
  43. data/lib/fig/unparser/v1_base.rb +85 -0
  44. data/lib/fig/unparser/v2.rb +55 -0
  45. data/lib/fig/working_directory_maintainer.rb +12 -0
  46. metadata +61 -51
data/Changes CHANGED
@@ -1,3 +1,97 @@
1
+ v1.2.0
2
+
3
+ Bug fixes:
4
+
5
+ - Unparsing of unglobbed asset paths containing single quotes was broken.
6
+
7
+ - Deal with differences between return types of stat() from Net::SFTP and
8
+ File.
9
+
10
+ New features:
11
+
12
+ - Now looks in figrc for an array under the key "environment variables to
13
+ include in comments in published packages". If present, the values of
14
+ those environment variables will, surprise, show up in the text of
15
+ published packages.
16
+
17
+ - When publishing, attempts to identify VCS (currently Subversion and Git)
18
+ URLs for the package and includes that information in comments in the
19
+ package. This can be turned off via the
20
+ --suppress-vcs-comments-in-published-packages option. The path to the VCS
21
+ programs can be controlled via the FIG_SVN_EXECUTABLE and
22
+ FIG_GIT_EXECUTABLE environment variables; individual VCS can be turned off
23
+ by setting the variable to the empty string.
24
+
25
+ - New --source-package option that will tell you what package a file was
26
+ retrieved from:
27
+
28
+ # Assuming a retrieve caused lib/libboost_timer.so to exist:
29
+ > fig --source-package lib/libboost_timer.so
30
+ boost/1.51.0.redhat6.gcc472
31
+
32
+ > fig --source-package lib
33
+ "lib" is a directory. Fig does not keep track of directories.
34
+
35
+ > fig --source-package some-local-file.txt
36
+ Don't know anything about "some-local-file.txt".
37
+
38
+ - New --suppress-retrieves option that stops "retrieve" statements from
39
+ firing, even if the --update* options are specified. Useful if you want to
40
+ do things like "fig --update package/version
41
+ --dump-package-definition-text" without clobbering anything in your current
42
+ directory.
43
+
44
+ - It is now possible to use an unpublished package from within another via a
45
+ "include-file" statement/--include-file command-line option.
46
+
47
+ This is considered an experimental feature and its behavior has not been
48
+ set in stone yet; changes may happen without notice. Comments on its
49
+ behavior, especially in terms of assets and of retrieves are welcome.
50
+
51
+ Using this statement requires grammar version 2. The
52
+ statement/command-line option takes a single argument of a path to a
53
+ package definition file, optionally followed by a colon and a config name.
54
+ If the path requires quoting, the quotes go around the path and not the
55
+ config name; this allows for use of the default config in a file path
56
+ containing a colon, e.g. MS Windows absolute paths. Given an unpublished
57
+ package in ./foo/bar/baz.fig, your can use it in ./foo/bar.fig like so:
58
+
59
+ grammar v2
60
+ config default
61
+ include-file 'bar/baz.fig':some-config
62
+ end
63
+
64
+ Note that the path is relative to including package, not relative to the
65
+ current directory.
66
+
67
+ The included package will act like a regularly published package with the
68
+ exception that retrieves will be ignored because "[package]" substitution
69
+ won't work because the package does not have a name.
70
+
71
+ Packages that use include-file cannot be published.
72
+
73
+ Miscellaneous:
74
+
75
+ - Fig now depends upon the open4 gem.
76
+
77
+ - Login behavior change for FTP with --login and for SFTP: Fig will not
78
+ attempt to use login credentials from FIG_USERNAME/FIG_PASSWORD or use
79
+ prompting for asset URLs. Credentials in ~/.netrc will continue to be
80
+ used.
81
+
82
+ - Add -T as the short option for --dump-package-definition-text.
83
+
84
+ - Add -R as the short option for --suppress-retrieves.
85
+
86
+ v1.1.1.beta.6
87
+ v1.1.1.beta.5
88
+ v1.1.1.beta.4
89
+ v1.1.1.beta.3
90
+ v1.1.1.beta.2
91
+ v1.1.1.beta.1
92
+
93
+ - Test releases.
94
+
1
95
  v1.1.0
2
96
 
3
97
  Backwards incompatibilities:
data/lib/fig.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Fig
2
- VERSION = '1.1.0'
2
+ VERSION = '1.2.0'
3
3
  end
data/lib/fig/command.rb CHANGED
@@ -70,6 +70,7 @@ class Fig::Command
70
70
  base_config(),
71
71
  @environment,
72
72
  @repository,
73
+ @working_directory_maintainer,
73
74
  @operating_system,
74
75
  @package_source_description,
75
76
  @package_loaded_from_path
@@ -130,6 +131,7 @@ class Fig::Command
130
131
  :base_config,
131
132
  :environment,
132
133
  :repository,
134
+ :working_directory_maintainer,
133
135
  :operating_system,
134
136
  :package_source_description,
135
137
  :package_loaded_from_path
@@ -177,8 +179,12 @@ class Fig::Command
177
179
  @options.log_level()
178
180
  )
179
181
 
182
+ @parser = Fig::Parser.new(
183
+ @application_configuration, check_include_statements_versions?
184
+ )
185
+
180
186
  prepare_repository()
181
- prepare_environment()
187
+ prepare_runtime_environment()
182
188
  end
183
189
 
184
190
  def set_up_update_lock()
@@ -227,11 +233,13 @@ class Fig::Command
227
233
 
228
234
  def prepare_repository()
229
235
  @repository = Fig::Repository.new(
236
+ @application_configuration,
237
+ @options,
230
238
  @operating_system,
231
239
  @options.home(),
232
- @application_configuration,
240
+ @application_configuration.remote_repository_url,
241
+ @parser,
233
242
  @publish_listeners,
234
- check_include_statements_versions?
235
243
  )
236
244
 
237
245
  @options.actions.each {|action| action.prepare_repository(@repository)}
@@ -239,11 +247,11 @@ class Fig::Command
239
247
  return
240
248
  end
241
249
 
242
- def prepare_environment()
243
- working_directory_maintainer = Fig::WorkingDirectoryMaintainer.new('.')
250
+ def prepare_runtime_environment()
251
+ @working_directory_maintainer = Fig::WorkingDirectoryMaintainer.new('.')
244
252
 
245
253
  Fig::AtExit.add do
246
- working_directory_maintainer.prepare_for_shutdown(
254
+ @working_directory_maintainer.prepare_for_shutdown(
247
255
  @base_package &&
248
256
  retrieves_should_happen? &&
249
257
  ! @options.suppress_cleanup_of_retrieves
@@ -257,9 +265,10 @@ class Fig::Command
257
265
 
258
266
  @environment = Fig::RuntimeEnvironment.new(
259
267
  @repository,
268
+ @parser,
260
269
  @options.suppress_includes,
261
270
  environment_variables,
262
- working_directory_maintainer,
271
+ @working_directory_maintainer,
263
272
  )
264
273
 
265
274
  Fig::AtExit.add { @environment.check_unused_retrieves() }
@@ -419,6 +428,8 @@ class Fig::Command
419
428
  end
420
429
 
421
430
  def retrieves_should_happen?()
431
+ return false if @options.suppress_retrieves
432
+
422
433
  return @options.actions.any? {|action| action.retrieves_should_happen?}
423
434
  end
424
435
 
@@ -31,11 +31,11 @@ class Fig::Command::Action::DumpPackageDefinitionForCommandLine
31
31
  end
32
32
 
33
33
  def register_base_package?()
34
- return false
34
+ return nil # don't care
35
35
  end
36
36
 
37
37
  def apply_config?()
38
- return false
38
+ return nil # don't care
39
39
  end
40
40
 
41
41
  def configure(options)
@@ -27,11 +27,11 @@ class Fig::Command::Action::DumpPackageDefinitionParsed
27
27
  end
28
28
 
29
29
  def register_base_package?()
30
- return false
30
+ return nil # don't care
31
31
  end
32
32
 
33
33
  def apply_config?()
34
- return false
34
+ return nil # don't care
35
35
  end
36
36
 
37
37
  def execute()
@@ -26,11 +26,11 @@ class Fig::Command::Action::DumpPackageDefinitionText
26
26
  end
27
27
 
28
28
  def register_base_package?()
29
- return false
29
+ return nil # don't care
30
30
  end
31
31
 
32
32
  def apply_config?()
33
- return false
33
+ return nil # don't care
34
34
  end
35
35
 
36
36
  def execute()
@@ -0,0 +1,65 @@
1
+ require 'fig/command/action'
2
+ require 'fig/command/action/role/has_no_sub_action'
3
+
4
+ module Fig; end
5
+ class Fig::Command; end
6
+ module Fig::Command::Action; end
7
+
8
+ class Fig::Command::Action::SourcePackage
9
+ include Fig::Command::Action
10
+ include Fig::Command::Action::Role::HasNoSubAction
11
+
12
+ def options()
13
+ return %w<--get>
14
+ end
15
+
16
+ def descriptor_requirement()
17
+ return nil
18
+ end
19
+
20
+ def modifies_repository?()
21
+ return false
22
+ end
23
+
24
+ def load_base_package?()
25
+ return true
26
+ end
27
+
28
+ def register_base_package?()
29
+ return true
30
+ end
31
+
32
+ def apply_config?()
33
+ return true
34
+ end
35
+
36
+ def apply_base_config?()
37
+ return true
38
+ end
39
+
40
+ def configure(options)
41
+ @file = options.file_to_find_package_for
42
+ end
43
+
44
+ def execute()
45
+ if ! File.exist? @file
46
+ $stderr.puts %Q<"#{@file}" does not exist.>
47
+ return EXIT_FAILURE
48
+ end
49
+ if File.directory? @file
50
+ $stderr.puts %Q<"#{@file}" is a directory. Fig does not keep track of directories.>
51
+ return EXIT_FAILURE
52
+ end
53
+
54
+ maintainer = @execution_context.working_directory_maintainer
55
+ package_version = maintainer.find_package_version_for_file @file
56
+ if ! package_version
57
+ $stderr.puts %Q<Don't know anything about "#{@file}".>
58
+ return EXIT_FAILURE
59
+ end
60
+
61
+ puts package_version
62
+
63
+ return EXIT_SUCCESS
64
+ end
65
+ end
@@ -27,6 +27,7 @@ require 'fig/command/action/publish'
27
27
  require 'fig/command/action/publish_local'
28
28
  require 'fig/command/action/run_command_line'
29
29
  require 'fig/command/action/run_command_statement'
30
+ require 'fig/command/action/source_package'
30
31
  require 'fig/command/action/update'
31
32
  require 'fig/command/action/update_if_missing'
32
33
  require 'fig/command/action/version'
@@ -53,6 +54,7 @@ class Fig::Command::Options
53
54
  attr_reader :environment_statements
54
55
  attr_reader :exit_code
55
56
  attr_reader :figrc
57
+ attr_reader :file_to_find_package_for
56
58
  attr_reader :home
57
59
  attr_reader :log_config
58
60
  attr_reader :log_level
@@ -61,6 +63,7 @@ class Fig::Command::Options
61
63
  attr_reader :shell_command
62
64
  attr_reader :suppress_cleanup_of_retrieves
63
65
  attr_reader :suppress_includes
66
+ attr_reader :suppress_retrieves
64
67
  attr_reader :update_lock_response
65
68
  attr_reader :variable_to_get
66
69
  attr_accessor :version_message
@@ -121,6 +124,10 @@ class Fig::Command::Options
121
124
  return @force
122
125
  end
123
126
 
127
+ def suppress_vcs_comments_in_published_packages?()
128
+ return @suppress_vcs_comments_in_published_packages
129
+ end
130
+
124
131
  def short_help_message()
125
132
  return @parser.short_help
126
133
  end
@@ -249,7 +256,16 @@ class Fig::Command::Options
249
256
  set_up_listings()
250
257
 
251
258
  @parser.on(
252
- '--dump-package-definition-text',
259
+ '--source-package FILE',
260
+ STARTS_WITH_NON_HYPHEN,
261
+ 'print package FILE was retrieved from'
262
+ ) do |file_to_find_package_for|
263
+ set_base_action(Fig::Command::Action::SourcePackage)
264
+ @file_to_find_package_for = file_to_find_package_for
265
+ end
266
+
267
+ @parser.on(
268
+ '-T', '--dump-package-definition-text',
253
269
  'emit the unparsed definition of the base package, if there is one'
254
270
  ) do
255
271
  set_base_action(Fig::Command::Action::DumpPackageDefinitionText)
@@ -354,6 +370,13 @@ class Fig::Command::Options
354
370
  @force = force
355
371
  end
356
372
 
373
+ @parser.on(
374
+ '--suppress-vcs-comments-in-published-packages',
375
+ %q<don't attempt to identify version control information when publishing>
376
+ ) do |suppress|
377
+ @suppress_vcs_comments_in_published_packages = suppress
378
+ end
379
+
357
380
  @parser.on('--clean', 'remove package from $FIG_HOME') do
358
381
  set_base_action(Fig::Command::Action::Clean)
359
382
  end
@@ -452,16 +475,16 @@ class Fig::Command::Options
452
475
  STARTS_WITH_NON_HYPHEN,
453
476
  'include package/version:config specified in DESCRIPTOR in environment'
454
477
  ) do |descriptor_string|
455
- statement =
456
- Fig::Statement::Include.new(
457
- nil,
458
- '--include option',
459
- Fig::Statement::Include.parse_descriptor(
460
- descriptor_string,
461
- :validation_context => ' given in a --include option'
462
- ),
463
- nil
464
- )
478
+ statement = Fig::Statement::Include.new(
479
+ nil,
480
+ '--include option',
481
+ Fig::Statement::Include.parse_descriptor(
482
+ descriptor_string,
483
+ :validation_context => ' given in a --include option'
484
+ ),
485
+ nil,
486
+ nil
487
+ )
465
488
 
466
489
  # We've never allowed versionless includes from the command-line. Hooray!
467
490
  statement.complain_if_version_missing()
@@ -469,6 +492,26 @@ class Fig::Command::Options
469
492
  @environment_statements << statement
470
493
  end
471
494
 
495
+ @parser.on(
496
+ '--include-file PATH:CONFIG',
497
+ STARTS_WITH_NON_HYPHEN,
498
+ 'include package-definition-in-file:config in environment (incompatible with --publish)'
499
+ ) do |path_with_config|
500
+ path, config_name =
501
+ Fig::Statement::IncludeFile.parse_path_with_config(path_with_config) {
502
+ |message|
503
+
504
+ @parser.raise_invalid_argument(
505
+ '--include-file', path_with_config, message
506
+ )
507
+ }
508
+ statement = Fig::Statement::IncludeFile.new(
509
+ nil, '--include-file option', path, config_name, nil,
510
+ )
511
+
512
+ @environment_statements << statement
513
+ end
514
+
472
515
  @parser.on(
473
516
  '--override DESCRIPTOR',
474
517
  STARTS_WITH_NON_HYPHEN,
@@ -479,10 +522,9 @@ class Fig::Command::Options
479
522
  descriptor_string,
480
523
  :validation_context => ' given in a --override option'
481
524
  )
482
- statement =
483
- Fig::Statement::Override.new(
484
- nil, '--override option', descriptor.name, descriptor.version
485
- )
525
+ statement = Fig::Statement::Override.new(
526
+ nil, '--override option', descriptor.name, descriptor.version
527
+ )
486
528
 
487
529
  @environment_statements << statement
488
530
  end
@@ -530,6 +572,13 @@ class Fig::Command::Options
530
572
  set_update_action(Fig::Command::Action::UpdateIfMissing)
531
573
  end
532
574
 
575
+ @parser.on(
576
+ '-R', '--suppress-retrieves',
577
+ %q<don't process retrieves, even if they would otherwise be active>,
578
+ ) do
579
+ @suppress_retrieves = true
580
+ end
581
+
533
582
  @parser.on(
534
583
  '--suppress-cleanup-of-retrieves',
535
584
  %q<don't delete files from unreferenced retrieves>,
@@ -19,10 +19,7 @@ Running under Fig:
19
19
  fig [...] [DESCRIPTOR] --run-command-statement
20
20
 
21
21
  Publishing packages:
22
- fig {--publish | --publish-local} DESCRIPTOR
23
- [--resource PATH] [--archive PATH]
24
- [--include DESCRIPTOR] [--override DESCRIPTOR]
25
- [...]
22
+ fig {--publish | --publish-local} [--force] DESCRIPTOR [...]
26
23
 
27
24
  Querying:
28
25
  fig {-g | --get} VARIABLE [DESCRIPTOR] [...]
@@ -33,6 +30,9 @@ Standard options (represented as "[...]" above):
33
30
  [--update | --update-if-missing]
34
31
  [--set VARIABLE=VALUE]
35
32
  [--append VARIABLE=VALUE]
33
+ [--resource PATH] [--archive PATH]
34
+ [--include DESCRIPTOR] [--include-file PATH:CONFIG]
35
+ [--override DESCRIPTOR]
36
36
  [--file PATH] [--no-file]
37
37
 
38
38
  (--options for full option list; --help-long for everything)
@@ -47,13 +47,7 @@ Running under Fig:
47
47
 
48
48
  Publishing packages:
49
49
 
50
- fig {--publish | --publish-local} DESCRIPTOR
51
- [--resource PATH]
52
- [--archive PATH]
53
- [{-i | --include} DESCRIPTOR]
54
- [--override DESCRIPTOR]
55
- [--force]
56
- [...]
50
+ fig {--publish | --publish-local} [--force] DESCRIPTOR [...]
57
51
 
58
52
  Local repository maintenance:
59
53
 
@@ -66,7 +60,8 @@ Querying:
66
60
  fig --list-dependencies [...list options...] [DESCRIPTOR] [...]
67
61
  fig --list-variables [...list options...] [DESCRIPTOR] [...]
68
62
  fig --list-configs [DESCRIPTOR] [...]
69
- fig --dump-package-definition-text [DESCRIPTOR] [...]
63
+ fig --source-package FILE [DESCRIPTOR] [...]
64
+ fig {-T | --dump-package-definition-text} [DESCRIPTOR] [...]
70
65
  fig --dump-package-definition-parsed [DESCRIPTOR] [...]
71
66
  fig --dump-package-definition-for-command-line [DESCRIPTOR] [...]
72
67
 
@@ -83,6 +78,15 @@ Standard options (represented as "[...]" above):
83
78
  [{-s | --set} VARIABLE=VALUE]
84
79
  [{-p | --append} VARIABLE=VALUE]
85
80
 
81
+ [--resource PATH]
82
+ [--archive PATH]
83
+ [{-i | --include} DESCRIPTOR]
84
+ [--include-file PATH:CONFIG]
85
+ [--override DESCRIPTOR]
86
+
87
+ [-R | --suppress-retrieves] [--suppress-cleanup-of-retrieves]
88
+ [--suppress-all-includes] [--suppress-cross-package-includes]
89
+
86
90
  [--file PATH] [--no-file]
87
91
  [{-c | --config} CONFIG]
88
92
 
@@ -91,6 +95,7 @@ Standard options (represented as "[...]" above):
91
95
  [--log-level LEVEL] [--log-config PATH]
92
96
  [--figrc PATH] [--no-figrc]
93
97
 
98
+ [--suppress-vcs-comments-in-published-packages]
94
99
  [--suppress-warning-include-statement-missing-version]
95
100
 
96
101
  Information:
@@ -107,8 +112,13 @@ required or allowed is dependent upon what your are doing.
107
112
 
108
113
  Environment variables:
109
114
 
110
- FIG_REMOTE_URL location of remote repository, required for remote operations
111
- FIG_HOME path to local repository, defaults to $HOME/.fighome
115
+ FIG_REMOTE_URL location of remote repository, required for remote
116
+ operations
117
+ FIG_HOME path to local repository, defaults to $HOME/.fighome
118
+ FIG_SVN_EXECUTABLE path to svn executable, set to empty string to suppress
119
+ use of Subversion
120
+ FIG_GIT_EXECUTABLE path to git executable, set to empty string to suppress
121
+ use of Git
112
122
  END_FULL_USAGE
113
123
 
114
124
  def initialize()