file-dependencies 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OGVkNDBkYmY4NWM4N2UxOTRiODhiM2QwN2QwZGM2ZjEwM2Q4YzFiZQ==
4
+ NzI1MDZhM2QzZjQwMWE2M2I4OGYwMGU0ZmYwOGNlYjk0ZTRkMDdjNg==
5
5
  data.tar.gz: !binary |-
6
- YmZjNmFlMWU3YWFiOGYwNWU4NjM0ZWI0Yjc5Y2U1YjBlM2JkNjlkYw==
6
+ MTg1NGY3ZWMzOTEyNjcwNTJjMjhkYzEwOWFjNWUyMTIwMDZkZTA4Zg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YWJlMmU3NmI5OTdiNTUxNjQ3Y2E2NWZjMzE0YWYwNjQxMTNlZGJkM2E1YjIw
10
- MzdiN2IyN2Q2Y2YxNTVhNDAzODU4MWY0ZTNjZDVkZDcxNDY2NTFiZmEzMjEx
11
- ZjAxMjY4YWQ4YzU2ZTBkZDRjZWU3MjUxMDY0YmNjMmM1ZTAyNDg=
9
+ NzFlNWNiZGM0MDJiYWM0YjdlNDdlMGFlOWZkM2E4NjdhZjExNTQzMDcwY2Nj
10
+ MmEwNGEyODZmZjYzOWE1YTUxMDZmOTBlOWM1ZGNkMjBlYTRhNzk1MDYwMTUx
11
+ ZGJjMDRlZTMzY2YxZDVkNWQ2MGI4MDgyMTc3NTg4MTZmMDQwMTE=
12
12
  data.tar.gz: !binary |-
13
- NGMxMDlmMzg0MTgzNjVlYjQxM2Q0MjI1YjE4OWUzNjU4ZWQ0MGI1YjkwYTA5
14
- NGVmMzg1MjYxYTZmNDBjYjk1YjMwZmI0MTZiMzEzMDA0MGFiNmVlY2UxMGIw
15
- OWVlMjZlMzg5NmU0NWNmNTUwNGM5OTcwNzE0NGNlZWJiYmQ3Mzk=
13
+ ZDBlOTZmNDdhOGJlN2Y0NjkwMTFmMWRjMGUwNTVhNTQ5ODA0YWQ0OTNiZjcw
14
+ MWE4MWJjN2Y0ODNhMDFiMTIwZjkyZDdkMTg3NDRmNWVmM2FhZWY3ZmMzNzRk
15
+ N2MwMWY1NTk2YTc2MWRjYWNiZDAwZjg3YmU2ZDEyODcxYzQ1Yzg=
data/.gitignore CHANGED
@@ -7,3 +7,5 @@ target
7
7
  build.log
8
8
  *.swp
9
9
  coverage/
10
+ .bundle
11
+ .vendor
@@ -12,7 +12,7 @@ module FileDependencies
12
12
  file_list = JSON.load(vendor_file_content)
13
13
  FileDependencies.process_downloads(file_list, ::File.join(dir, target), tmpdir)
14
14
  else
15
- puts "vendor.json not found, looked for the file at #{vendor_file}"
15
+ puts "vendor.json not found, looked for the file at #{vendor_file}" if $DEBUG
16
16
  end
17
17
  end # def process_vendor
18
18
  module_function :process_vendor
@@ -23,11 +23,11 @@ module FileDependencies
23
23
  full_target = file['target'] ? ::File.join(target, file['target']) : target
24
24
  download = FileDependencies::File.fetch_file(file['url'], file['sha1'], tmpdir)
25
25
  if (res = download.match(/(\S+?)(\.tar\.gz|\.tgz)$/))
26
- prefix = res.captures.first.gsub("#{tmpdir}/", '')
27
26
  FileDependencies::Archive.untar(download) do |entry|
27
+ prefix = file['include_tar_prefix'] ? '' : ::File.join(entry.full_name.split(::File::SEPARATOR).first, '')
28
28
  next unless FileDependencies::Archive.extract_file?(entry.full_name, file['extract'], file['exclude'], prefix)
29
29
  if file['flatten'] == true
30
- ::File.join(full_target, entry.full_name.split("/").last)
30
+ ::File.join(full_target, ::File.basename(entry.full_name))
31
31
  else
32
32
  ::File.join(full_target, entry.full_name.gsub(prefix, ''))
33
33
  end
@@ -35,7 +35,7 @@ module FileDependencies
35
35
  elsif download =~ /.gz$/
36
36
  FileDependencies::Archive.ungzip(download, full_target)
37
37
  else
38
- FileUtils.mv(download, ::File.join(full_target, download.split("/").last))
38
+ FileUtils.mv(download, ::File.join(full_target, ::File.basename(download)))
39
39
  end
40
40
  end
41
41
  end # def download
@@ -5,7 +5,7 @@ module FileDependencies
5
5
  # :nodoc:
6
6
  module Archive
7
7
  def ungzip(file, outdir)
8
- output = ::File.join(outdir, file.gsub('.gz', '').split("/").last)
8
+ output = ::File.join(outdir, file.gsub('.gz', '').split(::File::SEPARATOR).last)
9
9
  tgz = Zlib::GzipReader.new(::File.open(file))
10
10
  begin
11
11
  ::File.open(output, "w") do |out|
@@ -1,5 +1,5 @@
1
1
  # Note to authors: this should not include dashes because 'gem' barfs if
2
2
  # you include a dash in the version string.
3
3
  module FileDependencies
4
- VERSION = '0.1.3'
4
+ VERSION = '0.1.4'
5
5
  end
@@ -15,11 +15,11 @@ describe FileDependencies do
15
15
  let(:tmpdir) { Stud::Temporary.directory }
16
16
  let(:target) { Stud::Temporary.directory }
17
17
 
18
- let(:file1) { Assist.generate_tarball('some/file' => 'content1', 'some/other/file' => 'content2', 'other' => 'content3') }
18
+ let(:file1) { Assist.generate_tarball('somefile1/some/file' => 'content1', 'somefile1/some/other/file' => 'content2', 'somefile1/other' => 'content3') }
19
19
  let(:file2) { Assist.generate_file('some_content') }
20
20
  let(:file3) { Assist.generate_gzip('some_content_for_gzip') }
21
21
  let(:file4) { Assist.generate_tarball('jars/some.jar' => 'content10', 'jars/someother.jar' => 'content11', 'somefile.txt' => 'bla') }
22
- let(:file5) { Assist.generate_tarball('src/types.db' => 'typesdb') }
22
+ let(:file5) { Assist.generate_tarball('mytarball/src/types.db' => 'typesdb') }
23
23
 
24
24
  let(:sha1) { FileDependencies::File.calculate_sha1(file1) }
25
25
  let(:sha2) { FileDependencies::File.calculate_sha1(file2) }
@@ -35,7 +35,7 @@ describe FileDependencies do
35
35
 
36
36
  let(:entries) { ['somefile2.txt', 'somefile3', 'some/file', 'some/other/file', 'other', 'jarfiles/jars/some.jar', 'jarfiles/jars/someother.jar', 'jarfiles/somefile.txt', 'types.db'] }
37
37
 
38
- let(:files) { [{ 'url' => url1, 'sha1' => sha1 }, { 'url' => url2, 'sha1' => sha2 }, { 'url' => url3, 'sha1' => sha3 }, { 'url' => url4, 'sha1' => sha4, 'extract' => [/\.jar/, /\.txt/], 'target' => 'jarfiles' }, { 'url' => url5, 'sha1' => sha5, 'flatten' => true }] }
38
+ let(:files) { [{ 'url' => url1, 'sha1' => sha1 }, { 'url' => url2, 'sha1' => sha2 }, { 'url' => url3, 'sha1' => sha3 }, { 'url' => url4, 'sha1' => sha4, 'extract' => [/\.jar/, /\.txt/], 'target' => 'jarfiles', 'include_tar_prefix' => true }, { 'url' => url5, 'sha1' => sha5, 'flatten' => true }] }
39
39
 
40
40
  it 'processes file list' do
41
41
  stub_request(:get, url1).to_return(:body => File.new(file1), :status => 200)
@@ -65,11 +65,11 @@ describe FileDependencies do
65
65
  let(:tmpdir) { Stud::Temporary.directory }
66
66
  let(:target) { Stud::Temporary.directory }
67
67
 
68
- let(:file1) { Assist.generate_tarball('some/file' => 'content1', 'some/other/file' => 'content2', 'other' => 'content3') }
68
+ let(:file1) { Assist.generate_tarball('somefile1/some/file' => 'content1', 'somefile1/some/other/file' => 'content2', 'somefile1/other' => 'content3') }
69
69
  let(:file2) { Assist.generate_file('some_content') }
70
70
  let(:file3) { Assist.generate_gzip('some_content_for_gzip') }
71
71
  let(:file4) { Assist.generate_tarball('jars/some.jar' => 'content10', 'jars/someother.jar' => 'content11', 'somefile.txt' => 'bla') }
72
- let(:file5) { Assist.generate_tarball('src/types.db' => 'typesdb') }
72
+ let(:file5) { Assist.generate_tarball('mytarball/src/types.db' => 'typesdb') }
73
73
 
74
74
  let(:sha1) { FileDependencies::File.calculate_sha1(file1) }
75
75
  let(:sha2) { FileDependencies::File.calculate_sha1(file2) }
@@ -83,7 +83,7 @@ describe FileDependencies do
83
83
  let(:url4) { 'http://www.example.com/somefile4.tar.gz' }
84
84
  let(:url5) { 'http://www.example.com/somefile5.tar.gz' }
85
85
 
86
- let(:files) { [{ 'url' => url1, 'sha1' => sha1 }, { 'url' => url2, 'sha1' => sha2 }, { 'url' => url3, 'sha1' => sha3 }, { 'url' => url4, 'sha1' => sha4, 'extract' => [/\.jar/, /\.txt/], 'target' => 'jarfiles' }, { 'url' => url5, 'sha1' => sha5, 'flatten' => true }].to_json }
86
+ let(:files) { [{ 'url' => url1, 'sha1' => sha1 }, { 'url' => url2, 'sha1' => sha2 }, { 'url' => url3, 'sha1' => sha3 }, { 'url' => url4, 'sha1' => sha4, 'extract' => [/\.jar/, /\.txt/], 'target' => 'jarfiles', 'include_tar_prefix' => true }, { 'url' => url5, 'sha1' => sha5, 'flatten' => true }].to_json }
87
87
 
88
88
  let(:vendorfile) { File.write(File.join(target, 'vendor.json'), files) }
89
89
  let(:entries) { ['somefile2.txt', 'somefile3', 'some/file', 'some/other/file', 'other', 'jarfiles/jars/some.jar', 'jarfiles/jars/someother.jar', 'jarfiles/somefile.txt', 'types.db'] }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: file-dependencies
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Pijnenburg