fig 1.20.0 → 1.20.1.beta.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0eba6113bed095e62bb10c9ce380218a6c2bc683
4
- data.tar.gz: 94e175251848a3aced8fde64a97f53077864cf50
3
+ metadata.gz: 59f6abac1b2793dce7c2a2974021998253e12090
4
+ data.tar.gz: a7a55b9cf2bea84d2ba98bd0ef1b9575c494a866
5
5
  SHA512:
6
- metadata.gz: f5c08a97c1edc70361abbaabbe3c9af162cc455bc01d690370ad895820bfe97b6073869adf84ca7f6a49bade00ba196f4f55f2177787cf94d10af908f089540c
7
- data.tar.gz: 310fdd7c162cf1585ecd72a198298f8c73eefa58bd3a85cf2c308b291e1395c841a4c47bab757c8dab3685a08701ef5a7447380c040033256981f017724c020d
6
+ metadata.gz: 1680cd332d919e89d43279d0a024b9e88d52851ac12bea47e4308a79822e4496ef17abf7029997f94d425adbfaeca65dd9125e05458cf0cec316c42c112572c6
7
+ data.tar.gz: ac15f4423774e6fae1cb90cf4426c5b41c6db81d46de28a1631565e9df46f1c883687a00f899ca4c0e595efb5314db5704d1e90acda477558832d4d2186aa5f0
data/Changes CHANGED
@@ -1,3 +1,12 @@
1
+ v1.20.1.beta.1 - 2014/10/8
2
+
3
+ Bug fixes:
4
+
5
+ - During publishing, now checks asset names after file name globbing, not
6
+ before. Also, archive names are checked for extraction support prior to
7
+ writing to remote repository. (Yes, that's the archive /names/ and not the
8
+ archive /files/.)
9
+
1
10
  v1.20.0 - 2014/10/7
2
11
 
3
12
  New features:
data/lib/fig.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Fig
2
- VERSION = '1.20.0'
2
+ VERSION = '1.20.1.beta.1'
3
3
  end
@@ -56,14 +56,16 @@ class Fig::RepositoryPackagePublisher
56
56
 
57
57
  def publish_package()
58
58
  derive_publish_metadata()
59
- validate_asset_names()
60
59
 
61
60
  temp_dir = publish_temp_dir()
62
61
  @operating_system.delete_and_recreate_directory(temp_dir)
63
- @operating_system.delete_and_recreate_directory(@local_directory_for_package)
62
+ @operating_system.delete_and_recreate_directory(
63
+ @local_directory_for_package
64
+ )
64
65
 
65
66
  fig_file = File.join(temp_dir, Fig::Repository::PACKAGE_FILE_IN_REPO)
66
- content, published_package = derive_definition_file
67
+ content, published_package =
68
+ derive_definition_file_and_create_resource_archive
67
69
  @operating_system.write(fig_file, content)
68
70
 
69
71
  publish_package_contents
@@ -101,34 +103,11 @@ class Fig::RepositoryPackagePublisher
101
103
  return Etc.getlogin()
102
104
  end
103
105
 
104
- def validate_asset_names()
105
- asset_statements = @text_assembler.asset_input_statements
106
-
107
- asset_names = Set.new()
108
- asset_statements.each do
109
- |statement|
110
-
111
- asset_name = statement.asset_name()
112
- if not asset_name.nil?
113
- if asset_name == Fig::Repository::RESOURCES_FILE
114
- Fig::Logging.fatal \
115
- %Q<You cannot have an asset with the name "#{Fig::Repository::RESOURCES_FILE}"#{statement.position_string()} due to Fig implementation details.>
116
- end
117
-
118
- if asset_names.include?(asset_name)
119
- Fig::Logging.fatal \
120
- %Q<Found multiple archives with the name "#{asset_name}"#{statement.position_string()}. If these were allowed, archives would overwrite each other.>
121
- raise Fig::RepositoryError.new
122
- else
123
- asset_names.add(asset_name)
124
- end
125
- end
126
- end
127
- end
128
-
129
- def derive_definition_file()
106
+ def derive_definition_file_and_create_resource_archive()
130
107
  add_package_metadata_comments()
131
- add_output_statements_and_create_resource_archive()
108
+ assemble_output_statements_and_accumulate_assets()
109
+ validate_asset_names()
110
+ create_resource_archive()
132
111
  add_unparsed_text()
133
112
 
134
113
  file_content, explanations = @text_assembler.assemble_package_definition()
@@ -136,7 +115,7 @@ class Fig::RepositoryPackagePublisher
136
115
  explanations.each {|explanation| Fig::Logging.info explanation}
137
116
  end
138
117
 
139
- published_package = nil
118
+ to_be_published_package = nil
140
119
  begin
141
120
  unparsed_package = Fig::NotYetParsedPackage.new
142
121
  unparsed_package.descriptor = @descriptor
@@ -146,7 +125,7 @@ class Fig::RepositoryPackagePublisher
146
125
  unparsed_package.source_description = '<package to be published>'
147
126
  unparsed_package.unparsed_text = file_content
148
127
 
149
- published_package =
128
+ to_be_published_package =
150
129
  Fig::Parser.new(nil, false).parse_package(unparsed_package)
151
130
  rescue Fig::PackageParseError => error
152
131
  raise \
@@ -154,7 +133,7 @@ class Fig::RepositoryPackagePublisher
154
133
  "#{error}\n\nGenerated contents:\n#{file_content}"
155
134
  end
156
135
 
157
- return file_content, published_package
136
+ return file_content, to_be_published_package
158
137
  end
159
138
 
160
139
  def add_package_metadata_comments()
@@ -353,19 +332,9 @@ class Fig::RepositoryPackagePublisher
353
332
  return reference
354
333
  end
355
334
 
356
- # Deals with Archive and Resource statements. It downloads any remote
357
- # files (those where the statement references a URL as opposed to a local
358
- # file) and then copies all files into the local repository and the remote
359
- # repository (if not a local-only publish).
360
- def add_output_statements_and_create_resource_archive()
361
- assemble_output_statements()
362
- create_resource_archive()
363
-
364
- return
365
- end
366
-
367
- def assemble_output_statements()
368
- @resource_paths = []
335
+ def assemble_output_statements_and_accumulate_assets()
336
+ @local_resource_paths = []
337
+ @asset_names_with_associated_input_statements = {}
369
338
 
370
339
  @text_assembler.input_statements.each do
371
340
  |statement|
@@ -382,39 +351,121 @@ class Fig::RepositoryPackagePublisher
382
351
 
383
352
  def add_asset_to_output_statements(asset_statement)
384
353
  if Fig::URL.is_url? asset_statement.location
385
- @text_assembler.add_output asset_statement
354
+ add_output_asset_statement_based_upon_input_statement(
355
+ asset_statement, asset_statement
356
+ )
386
357
  elsif asset_statement.is_a? Fig::Statement::Archive
387
358
  if asset_statement.requires_globbing?
388
359
  expand_globs_from( [asset_statement.location] ).each do
389
360
  |file|
390
361
 
391
- @text_assembler.add_output(
362
+ add_output_asset_statement_based_upon_input_statement(
392
363
  Fig::Statement::Archive.new(
393
364
  nil,
394
365
  %Q<[synthetic statement created in #{__FILE__} line #{__LINE__}]>,
395
366
  file,
396
367
  false # No globbing
397
- )
368
+ ),
369
+ asset_statement
398
370
  )
399
371
  end
400
372
  else
401
- @text_assembler.add_output asset_statement
373
+ add_output_asset_statement_based_upon_input_statement(
374
+ asset_statement, asset_statement
375
+ )
402
376
  end
403
377
  elsif asset_statement.requires_globbing?
404
- @resource_paths.concat expand_globs_from( [asset_statement.location] )
378
+ @local_resource_paths.concat expand_globs_from(
379
+ [asset_statement.location]
380
+ )
405
381
  else
406
- @resource_paths << asset_statement.location
382
+ @local_resource_paths << asset_statement.location
407
383
  end
408
384
 
409
385
  return
410
386
  end
411
387
 
388
+ def add_output_asset_statement_based_upon_input_statement(
389
+ output_statement, input_statement
390
+ )
391
+ @text_assembler.add_output output_statement
392
+
393
+ asset_name = output_statement.asset_name
394
+
395
+ input_statements =
396
+ @asset_names_with_associated_input_statements[asset_name]
397
+ if input_statements.nil?
398
+ input_statements = []
399
+
400
+ @asset_names_with_associated_input_statements[asset_name] =
401
+ input_statements
402
+ end
403
+
404
+ input_statements << input_statement
405
+
406
+ return
407
+ end
408
+
409
+ def validate_asset_names()
410
+ found_problem = false
411
+
412
+ @asset_names_with_associated_input_statements.keys.sort.each do
413
+ |asset_name|
414
+
415
+ statements = @asset_names_with_associated_input_statements[asset_name]
416
+
417
+ if asset_name == Fig::Repository::RESOURCES_FILE
418
+ Fig::Logging.fatal \
419
+ %Q<You cannot have an asset with the name "#{Fig::Repository::RESOURCES_FILE}"#{collective_position_string(statements)} due to Fig implementation details.>
420
+ found_problem = true
421
+ end
422
+
423
+ archive_statements =
424
+ statements.select { |s| s.is_a? Fig::Statement::Archive }
425
+ if (
426
+ not archive_statements.empty? \
427
+ and not (
428
+ asset_name =~ /\.tar\.gz$/ \
429
+ or asset_name =~ /\.tgz$/ \
430
+ or asset_name =~ /\.tar\.bz2$/ \
431
+ or asset_name =~ /\.zip$/
432
+ )
433
+ )
434
+ Fig::Logging.fatal \
435
+ %Q<Unknown archive type "#{asset_name}"#{collective_position_string(archive_statements)}.>
436
+ found_problem = true
437
+ end
438
+
439
+ if statements.size > 1
440
+ Fig::Logging.fatal \
441
+ %Q<Found multiple assets with the name "#{asset_name}"#{collective_position_string(statements)}. If these were allowed, assets would overwrite each other.>
442
+ found_problem = true
443
+ end
444
+ end
445
+
446
+ if found_problem
447
+ raise Fig::RepositoryError.new
448
+ end
449
+ end
450
+
451
+ def collective_position_string(statements)
452
+ return (
453
+ statements.map {
454
+ |statement|
455
+
456
+ position_string = statement.position_string
457
+
458
+ position_string.empty? ? '<unknown>' : position_string.strip
459
+ }
460
+ ).join(', ')
461
+ end
462
+
412
463
  def create_resource_archive()
413
- if @resource_paths.size > 0
414
- check_asset_paths(@resource_paths)
464
+ if @local_resource_paths.size > 0
465
+ check_asset_paths(@local_resource_paths)
415
466
 
416
467
  file = File.join publish_temp_dir, Fig::Repository::RESOURCES_FILE
417
- @operating_system.create_archive(file, @resource_paths)
468
+ @operating_system.create_archive(file, @local_resource_paths)
418
469
  Fig::AtExit.add { FileUtils.rm_f(file) }
419
470
 
420
471
  @text_assembler.add_output(
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fig
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.20.0
4
+ version: 1.20.1.beta.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Foemmel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-07 00:00:00.000000000 Z
11
+ date: 2014-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -404,9 +404,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
404
404
  version: 1.9.2
405
405
  required_rubygems_version: !ruby/object:Gem::Requirement
406
406
  requirements:
407
- - - ">="
407
+ - - ">"
408
408
  - !ruby/object:Gem::Version
409
- version: '0'
409
+ version: 1.3.1
410
410
  requirements: []
411
411
  rubyforge_project:
412
412
  rubygems_version: 2.2.2