fig 0.2.1 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/Changes CHANGED
@@ -1,3 +1,53 @@
1
+ v0.2.3
2
+
3
+ Backwards incompatibilities:
4
+
5
+ - Now requires Ruby v1.9.2.
6
+
7
+ Miscellaneous:
8
+
9
+ - Warns about environment variables that refer to non-existent paths after
10
+ publishing.
11
+
12
+ fig --publish package/version --set foo=@/bar
13
+
14
+ Checking status of package/version...
15
+ Publishing package/version.
16
+ Publishing using the v0 grammar.
17
+ The foo variable points to a path that does not exist
18
+ (/tmp/fig-testing/home/repos/package/version/bar); retrieve statements
19
+ that are active when this package is included may fail.
20
+
21
+ Note that this check is done after the package has been successfully
22
+ published; it does not prevent problems, but only detects potential ones.
23
+ Due to the indirect and inexact relationship between paths from asset
24
+ statements and environment variable statements, the check cannot be done
25
+ before publishing.
26
+
27
+ - Warning about unused retrieve no longer appears when there is a problem
28
+ with the variable itself.
29
+
30
+ - Stack traces of includes contain file names and "command-line" if the
31
+ includes came from package definition files or from "--include" options.
32
+ E.g.
33
+
34
+ fig --update --list-variables --include thingy/1.0.0.30 --file some-dependencies.fig --config blahblahblah
35
+
36
+ Version mismatch for package thingy (1.0.0.30 vs 1.0.0.81).
37
+ <command-line>:default
38
+ thingy/1.0.0.30:default
39
+ <command-line>:default
40
+ <some-dependencies.fig>:blahblahblah
41
+ thingy/1.0.0.81:default
42
+
43
+ - Other error message clarifications.
44
+
45
+ v0.2.2.beta.3
46
+ v0.2.2.beta.2
47
+ v0.2.2.beta.1
48
+
49
+ - Test releases
50
+
1
51
  v0.2.1
2
52
 
3
53
  Backwards incompatibilities:
data/bin/fig CHANGED
@@ -1,5 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ ( [1, 9, 2] <=> ( RUBY_VERSION.split(".").collect {|x| x.to_i} ) ) <= 0 or
4
+ abort "Ruby v1.9.2 is required; this is v#{RUBY_VERSION}."
5
+
3
6
  if ENV['FIG_COVERAGE']
4
7
  require File.expand_path(
5
8
  File.join(
data/bin/fig-debug CHANGED
@@ -1,5 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ ( [1, 9, 2] <=> ( RUBY_VERSION.split(".").collect {|x| x.to_i} ) ) <= 0 or
4
+ abort "Ruby v1.9.2 is required; this is v#{RUBY_VERSION}."
5
+
3
6
  if ENV['FIG_COVERAGE']
4
7
  require File.expand_path(
5
8
  File.join(
data/bin/fig-download CHANGED
@@ -1,5 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ ( [1, 9, 2] <=> ( RUBY_VERSION.split(".").collect {|x| x.to_i} ) ) <= 0 or
4
+ abort "Ruby v1.9.2 is required; this is v#{RUBY_VERSION}."
5
+
3
6
  # todo copied from os.rb
4
7
  NOT_MODIFIED = 3
5
8
  NOT_FOUND = 4
@@ -17,4 +20,4 @@ File.open(path) do |file|
17
20
  end
18
21
  end
19
22
 
20
- exit SUCCESS
23
+ exit SUCCESS
data/lib/fig.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Fig
2
- VERSION = '0.2.1'
2
+ VERSION = '0.2.3'
3
3
  end
data/lib/fig/command.rb CHANGED
@@ -58,7 +58,7 @@ class Fig::Command
58
58
  if actions.any? {|action| not action.allow_both_descriptor_and_file? }
59
59
  ensure_descriptor_and_file_were_not_both_specified()
60
60
  end
61
- check_package_content_options()
61
+ check_asset_options()
62
62
 
63
63
  configure()
64
64
  set_up_base_package()
@@ -71,7 +71,8 @@ class Fig::Command
71
71
  @environment,
72
72
  @repository,
73
73
  @operating_system,
74
- @package_source_description
74
+ @package_source_description,
75
+ @package_loaded_from_path
75
76
  )
76
77
 
77
78
  actions.each do
@@ -130,7 +131,8 @@ class Fig::Command
130
131
  :environment,
131
132
  :repository,
132
133
  :operating_system,
133
- :package_source_description
134
+ :package_source_description,
135
+ :package_loaded_from_path
134
136
  )
135
137
 
136
138
  def handle_nothing_to_do()
@@ -149,6 +151,7 @@ class Fig::Command
149
151
  end
150
152
 
151
153
  $stderr.puts %q<Run "fig --help" for a full list of commands.>
154
+ check_asset_options
152
155
 
153
156
  return Fig::Command::Action::EXIT_FAILURE
154
157
  end
@@ -296,6 +299,7 @@ class Fig::Command
296
299
  @base_package = package_loader.load_package_object_from_file()
297
300
  end
298
301
  @package_source_description = package_loader.package_source_description()
302
+ @package_loaded_from_path = package_loader.package_loaded_from_path()
299
303
 
300
304
  return
301
305
  end
@@ -380,12 +384,12 @@ class Fig::Command
380
384
  return
381
385
  end
382
386
 
383
- def check_package_content_options()
384
- statements = @options.package_contents_statements
387
+ def check_asset_options()
388
+ statements = @options.asset_statements
385
389
  return if statements.empty?
386
390
 
387
391
  return if @options.actions.any? \
388
- {|action| action.cares_about_package_content_options?}
392
+ {|action| action.cares_about_asset_options?}
389
393
 
390
394
  statements.each do
391
395
  |statement|
@@ -39,7 +39,7 @@ module Fig::Command::Action
39
39
 
40
40
  # Does the action care about command-line options that affect package
41
41
  # contents, i.e. --resource/--archive?
42
- def cares_about_package_content_options?()
42
+ def cares_about_asset_options?()
43
43
  return false
44
44
  end
45
45
 
@@ -18,6 +18,10 @@ class Fig::Command::Action::DumpPackageDefinitionForCommandLine
18
18
  return nil
19
19
  end
20
20
 
21
+ def cares_about_asset_options?()
22
+ return true
23
+ end
24
+
21
25
  def modifies_repository?()
22
26
  return false
23
27
  end
@@ -35,15 +39,15 @@ class Fig::Command::Action::DumpPackageDefinitionForCommandLine
35
39
  end
36
40
 
37
41
  def configure(options)
38
- @environment_statements = options.environment_statements
39
- @package_contents_statements = options.package_contents_statements
42
+ @environment_statements = options.environment_statements
43
+ @asset_statements = options.asset_statements
40
44
 
41
45
  return
42
46
  end
43
47
 
44
48
  def execute()
45
49
  text_assembler = Fig::PackageDefinitionTextAssembler.new :emit_as_input
46
- text_assembler.add_output @package_contents_statements
50
+ text_assembler.add_output @asset_statements
47
51
  text_assembler.add_output [
48
52
  Fig::Statement::Configuration.new(
49
53
  nil,
@@ -28,7 +28,8 @@ module Fig::Command::Action::Role::ListWalkingDependencyTree
28
28
  Fig::PackageDescriptor.new(
29
29
  base_package.name(),
30
30
  base_package.version(),
31
- config_name
31
+ config_name,
32
+ :description => base_package.description
32
33
  )
33
34
  )
34
35
 
@@ -19,7 +19,7 @@ module Fig::Command::Action::Role::Publish
19
19
  return true
20
20
  end
21
21
 
22
- def cares_about_package_content_options?()
22
+ def cares_about_asset_options?()
23
23
  return true
24
24
  end
25
25
 
@@ -48,10 +48,10 @@ module Fig::Command::Action::Role::Publish
48
48
  end
49
49
 
50
50
  def configure(options)
51
- @descriptor = options.descriptor
52
- @environment_statements = options.environment_statements
53
- @package_contents_statements = options.package_contents_statements
54
- @force = options.force?
51
+ @descriptor = options.descriptor
52
+ @environment_statements = options.environment_statements
53
+ @asset_statements = options.asset_statements
54
+ @force = options.force?
55
55
 
56
56
  return
57
57
  end
@@ -70,7 +70,7 @@ module Fig::Command::Action::Role::Publish
70
70
 
71
71
  if not @environment_statements.empty?
72
72
  derive_publish_statements_from_environment_statements
73
- elsif not @package_contents_statements.empty?
73
+ elsif not @asset_statements.empty?
74
74
  raise Fig::UserInputError.new(
75
75
  '--resource/--archive options were specified, but no --set/--append option was given. Will not publish.'
76
76
  )
@@ -86,9 +86,9 @@ module Fig::Command::Action::Role::Publish
86
86
  end
87
87
 
88
88
  def derive_publish_statements_from_environment_statements
89
- if @execution_context.package_source_description
89
+ if @execution_context.package_loaded_from_path
90
90
  message = 'Cannot publish based upon both a package definition file ('
91
- message << @execution_context.package_source_description
91
+ message << @execution_context.package_loaded_from_path
92
92
  message << ') and --set/--append options.'
93
93
 
94
94
  if @execution_context.package_source_description ==
@@ -104,7 +104,7 @@ module Fig::Command::Action::Role::Publish
104
104
  end
105
105
 
106
106
  @publish_statements =
107
- @package_contents_statements +
107
+ @asset_statements +
108
108
  [
109
109
  Fig::Statement::Configuration.new(
110
110
  nil,
@@ -51,7 +51,7 @@ class Fig::Command::Options
51
51
  attr_reader :home
52
52
  attr_reader :log_config
53
53
  attr_reader :log_level
54
- attr_reader :package_contents_statements
54
+ attr_reader :asset_statements
55
55
  attr_reader :package_definition_file
56
56
  attr_reader :parser
57
57
  attr_reader :shell_command
@@ -191,7 +191,7 @@ class Fig::Command::Options
191
191
  set_up_remote_repository_access()
192
192
  set_up_commands()
193
193
  set_up_environment_statements()
194
- set_up_package_contents_statements()
194
+ set_up_asset_statements()
195
195
  set_up_queries()
196
196
  set_up_program_configuration()
197
197
 
@@ -459,15 +459,15 @@ class Fig::Command::Options
459
459
  return
460
460
  end
461
461
 
462
- def set_up_package_contents_statements()
463
- @package_contents_statements = []
462
+ def set_up_asset_statements()
463
+ @asset_statements = []
464
464
  @parser.on(
465
465
  '--archive PATH',
466
466
  STARTS_WITH_NON_HYPHEN,
467
467
  'include PATH archive in package (when using --publish)'
468
468
  ) do |path|
469
- @package_contents_statements <<
470
- new_content_statement('--archive', path, Fig::Statement::Archive)
469
+ @asset_statements <<
470
+ new_asset_statement('--archive', path, Fig::Statement::Archive)
471
471
  end
472
472
 
473
473
  @parser.on(
@@ -475,8 +475,8 @@ class Fig::Command::Options
475
475
  STARTS_WITH_NON_HYPHEN,
476
476
  'include PATH resource in package (when using --publish)'
477
477
  ) do |path|
478
- @package_contents_statements <<
479
- new_content_statement('--resource', path, Fig::Statement::Resource)
478
+ @asset_statements <<
479
+ new_asset_statement('--resource', path, Fig::Statement::Resource)
480
480
  end
481
481
 
482
482
  return
@@ -608,7 +608,7 @@ class Fig::Command::Options
608
608
  return statement_class.new(nil, "#{option} option", variable, value)
609
609
  end
610
610
 
611
- def new_content_statement(option, raw_path, statement_class)
611
+ def new_asset_statement(option, raw_path, statement_class)
612
612
  tokenized_path =
613
613
  statement_class.validate_and_process_escapes_in_location(raw_path) do
614
614
  |error_description|
@@ -66,7 +66,10 @@ class Fig::Command::PackageApplier
66
66
  nil,
67
67
  %Q<[synthetic statement created in #{__FILE__} line #{__LINE__}]>,
68
68
  Fig::PackageDescriptor.new(
69
- @base_package.name(), @base_package.version(), @base_config
69
+ @base_package.name(),
70
+ @base_package.version(),
71
+ @base_config,
72
+ :description => @base_package.description
70
73
  ),
71
74
  nil
72
75
  )
@@ -82,7 +85,9 @@ class Fig::Command::PackageApplier
82
85
  configuration_statements.flatten()
83
86
  )
84
87
 
85
- return Fig::Package.new(nil, nil, '.', [configuration_statement])
88
+ return Fig::Package.new(
89
+ nil, nil, 'command-line', '.', [configuration_statement]
90
+ )
86
91
  end
87
92
 
88
93
  def make_no_such_package_exception_descriptive(exception)
@@ -5,6 +5,8 @@ module Fig; end
5
5
  class Fig::Command; end
6
6
 
7
7
  class Fig::Command::PackageLoader
8
+ attr_reader :package_loaded_from_path
9
+
8
10
  DEFAULT_FIG_FILE = 'package.fig'
9
11
 
10
12
  def initialize(
@@ -43,8 +45,9 @@ class Fig::Command::PackageLoader
43
45
  if @package_loaded_from_path
44
46
  return @package_loaded_from_path
45
47
  elsif @descriptor
46
- return
47
- Fig::PackageDescriptor.format(@descriptor.name, @descriptor.version, nil)
48
+ return Fig::PackageDescriptor.format(
49
+ @descriptor.name, @descriptor.version, nil
50
+ )
48
51
  end
49
52
 
50
53
  return nil
@@ -92,14 +95,17 @@ class Fig::Command::PackageLoader
92
95
 
93
96
  source_description = package_source_description()
94
97
 
98
+ descriptor = Fig::PackageDescriptor.new(
99
+ nil,
100
+ nil,
101
+ nil,
102
+ :description => source_description,
103
+ :source_description => source_description
104
+ )
105
+
95
106
  @base_package =
96
107
  Fig::Parser.new(@application_configuration, :check_include_versions).parse_package(
97
- Fig::PackageDescriptor.new(
98
- nil, nil, nil, :source_description => source_description
99
- ),
100
- '.',
101
- source_description,
102
- definition_text
108
+ descriptor, '.', source_description, definition_text
103
109
  )
104
110
 
105
111
  return
@@ -109,6 +115,7 @@ class Fig::Command::PackageLoader
109
115
  @base_package = Fig::Package.new(
110
116
  nil,
111
117
  nil,
118
+ 'synthetic',
112
119
  '.',
113
120
  [
114
121
  Fig::Statement::Configuration.new(
@@ -51,7 +51,7 @@ class Fig::IncludeBacktrace
51
51
  for descriptor in stack
52
52
  indent=''
53
53
  i.times { indent += ' ' }
54
- out.puts indent + descriptor.to_string(:use_default_config)
54
+ out.puts indent + descriptor.to_string(:use_default_config, :use_description)
55
55
  i += 1
56
56
  end
57
57
  end
@@ -3,7 +3,7 @@ require 'fileutils'
3
3
  require 'find'
4
4
  # Must specify absolute path of ::Archive when using
5
5
  # this module to avoid conflicts with Fig::Statement::Archive
6
- require 'libarchive_ruby' unless RUBY_PLATFORM == 'java'
6
+ require 'libarchive_ruby'
7
7
  require 'net/http'
8
8
  require 'net/ssh'
9
9
  require 'net/sftp'
@@ -19,6 +19,7 @@ require 'fig/environment_variables/case_sensitive'
19
19
  require 'fig/file_not_found_error'
20
20
  require 'fig/logging'
21
21
  require 'fig/network_error'
22
+ require 'fig/repository_error'
22
23
  require 'fig/url'
23
24
  require 'fig/user_input_error'
24
25
 
@@ -34,10 +35,6 @@ class Fig::OperatingSystem
34
35
  RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
35
36
  end
36
37
 
37
- def self.java?
38
- RUBY_PLATFORM == 'java'
39
- end
40
-
41
38
  def self.unix?
42
39
  !windows?
43
40
  end
@@ -418,26 +415,22 @@ class Fig::OperatingSystem
418
415
 
419
416
  # Expects files_to_archive as an Array of filenames.
420
417
  def create_archive(archive_name, files_to_archive)
421
- if Fig::OperatingSystem.java?
422
- `tar czvf #{archive_name} #{files_to_archive.join(' ')}`
423
- else
424
- # TODO: Need to verify files_to_archive exists.
425
- ::Archive.write_open_filename(
426
- archive_name, ::Archive::COMPRESSION_GZIP, ::Archive::FORMAT_TAR
427
- ) do |writer|
428
- files_to_archive.each do |file_name|
429
- writer.new_entry do |entry|
430
- entry.copy_lstat(file_name)
431
- entry.pathname = file_name
432
- if entry.symbolic_link?
433
- linked = File.readlink(file_name)
434
- entry.symlink = linked
435
- end
436
- writer.write_header(entry)
418
+ # TODO: Need to verify files_to_archive exists.
419
+ ::Archive.write_open_filename(
420
+ archive_name, ::Archive::COMPRESSION_GZIP, ::Archive::FORMAT_TAR
421
+ ) do |writer|
422
+ files_to_archive.each do |file_name|
423
+ writer.new_entry do |entry|
424
+ entry.copy_lstat(file_name)
425
+ entry.pathname = file_name
426
+ if entry.symbolic_link?
427
+ linked = File.readlink(file_name)
428
+ entry.symlink = linked
429
+ end
430
+ writer.write_header(entry)
437
431
 
438
- if entry.regular?
439
- writer.write_data(open(file_name) {|f| f.binmode; f.read })
440
- end
432
+ if entry.regular?
433
+ writer.write_data(open(file_name) {|f| f.binmode; f.read })
441
434
  end
442
435
  end
443
436
  end
@@ -451,12 +444,21 @@ class Fig::OperatingSystem
451
444
  # .zip
452
445
  def unpack_archive(dir, file)
453
446
  Dir.chdir(dir) do
454
- if Fig::OperatingSystem.java?
455
- `tar xzvf #{file}`
456
- else
457
- ::Archive.read_open_filename(file) do |reader|
458
- while entry = reader.next_header
447
+ ::Archive.read_open_filename(file) do |reader|
448
+ while entry = reader.next_header
449
+ begin
459
450
  reader.extract(entry)
451
+ rescue Archive::Error => exception
452
+ # Nice how the error message doesn't include any information about
453
+ # what was having the problem.
454
+ message = exception.message.sub /^Extract archive failed: /, ''
455
+ new_exception =
456
+ Fig::RepositoryError.new(
457
+ "Could not extract #{entry.pathname} from #{file}: #{message}"
458
+ )
459
+
460
+ new_exception.set_backtrace exception.backtrace
461
+ raise new_exception
460
462
  end
461
463
  end
462
464
  end
@@ -465,9 +467,9 @@ class Fig::OperatingSystem
465
467
 
466
468
  def shell_exec(command)
467
469
  if Fig::OperatingSystem.windows?
468
- plain_exec( [ ENV['ComSpec'], '/c', command ] )
470
+ plain_exec [ ENV['ComSpec'], '/c', command ]
469
471
  else
470
- plain_exec( [ ENV['SHELL'], '-c', command ] )
472
+ plain_exec [ ENV['SHELL'], '-c', command ]
471
473
  end
472
474
  end
473
475