tara 0.5.0 → 0.6.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: 2617054a9d3083e73b54e1e80c40d8a657fcdfa9
4
- data.tar.gz: 8323289eb628caaf484509aab0e9b8c7fdd319a7
3
+ metadata.gz: 1784fce5a6faf5e5507684228b65c90d5f2339bb
4
+ data.tar.gz: e0c5d1d73c8057cd1bc9de4c22bd365da606356b
5
5
  SHA512:
6
- metadata.gz: e1b7e0c93f9052feeb74586d3b08189a13276ff4f12ac04285723885cd8945163f5256ef73b3f909c4a07b9e4f1d428546b113f32d17e9c425635f4e3f044b38
7
- data.tar.gz: 8dcf6b5c2eec3707c7ab07bf9495622145b9037c2069b9d924ae8e8442da5faaa1a073d0b7cb244c9b37a25e24af07bc7788c43dc1d8e6a3ed0c63ad7b914019
6
+ metadata.gz: e3504bc7febfbe67dfefd611ade399514de470b152fae96d675033d537a2b141353635d4e8f96aa1ee470a34a99a12b1d102d5d067b1174cfad66e5cb1363159
7
+ data.tar.gz: c78a5c896ab9bb2468d86c2487688938250c71125c07f992d3ca281f42c9f32f4ab4d3c8c9243781ecabb3e76d149b50b87b14f620818f49f4f7313116e8d7eb
@@ -88,10 +88,10 @@ module Tara
88
88
  project_dir = Pathname.new(@config[:app_dir])
89
89
  package_dir = Pathname.new(tmp_dir)
90
90
  build_dir = Pathname.new(@config[:build_dir])
91
- install_dependencies(package_dir, fetcher)
92
91
  copy_source(project_dir, package_dir)
93
92
  copy_executables(project_dir, package_dir)
94
93
  create_gem_shims(package_dir)
94
+ install_dependencies(package_dir, fetcher)
95
95
  Dir.chdir(tmp_dir) do
96
96
  create_archive(build_dir)
97
97
  end
@@ -150,7 +150,6 @@ module Tara
150
150
  unless (dirname = relative_file.dirname) == DOT_PATH
151
151
  FileUtils.mkdir_p(package_dir.join(dirname))
152
152
  end
153
- FileUtils.cp_r(file, package_dir.join(relative_file))
154
153
  else
155
154
  unless (dirname = relative_file.dirname) == DOT_PATH
156
155
  FileUtils.mkdir_p(package_dir.join(dirname))
@@ -8,8 +8,9 @@ module Tara
8
8
  @fetcher = fetcher
9
9
  @without_groups = options[:without_groups]
10
10
  @app_dir = Pathname.new(options[:app_dir])
11
- @bundle_env = 'BUNDLE_IGNORE_CONFIG=1' if options[:bundle_ignore_config]
11
+ @bundle_env = bundle_env(options[:bundle_ignore_config])
12
12
  @shell = options[:shell] || Shell
13
+ @build_command = options[:build_command]
13
14
  end
14
15
 
15
16
  def execute
@@ -21,37 +22,43 @@ module Tara
21
22
  strip_leftovers
22
23
  strip_java_files
23
24
  strip_git_files
24
- create_bundler_config
25
+ strip_empty_directories
25
26
  end
26
27
 
27
28
  private
28
29
 
30
+ def bundle_env(ignore_config)
31
+ env = {'BUNDLE_GEMFILE' => 'lib/vendor/Gemfile'}
32
+ env['BUNDLE_IGNORE_CONFIG'] = '1' if ignore_config
33
+ env
34
+ end
35
+
29
36
  def bundler_command
30
37
  @bundler_command ||= begin
31
- command = "#{@bundle_env} bundle install --jobs 4 --path vendor"
38
+ command = 'bundle install --jobs 4 --path . --gemfile lib/vendor/Gemfile'
32
39
  command << %( --without #{@without_groups.join(' ')}) if @without_groups.any?
33
40
  command
34
41
  end
35
42
  end
36
43
 
37
44
  def bundle_gems
38
- FileUtils.mkdir_p(lib_path)
39
- Dir.mktmpdir do |tmpdir|
40
- copy_gem_files(Pathname.new(tmpdir))
41
- Dir.chdir(tmpdir) do
42
- Bundler.with_clean_env do
43
- @shell.exec(bundler_command)
44
- end
45
- Dir['vendor/*/*/cache/*'].each do |cached_file|
46
- FileUtils.rm_rf(cached_file)
47
- end
48
- Dir['vendor/ruby/*/extensions/*'].each do |ext_file|
49
- FileUtils.rm_rf(ext_file)
50
- end
51
- %w[o so bundle].each do |ext|
52
- find_and_remove_files('vendor/ruby/*/gems', %(*.#{ext}))
45
+ FileUtils.mkdir_p(vendor_path)
46
+ copy_gem_files(vendor_path)
47
+ Dir.chdir(@package_dir) do
48
+ Bundler.with_clean_env do
49
+ @shell.exec_with_env(bundler_command, @bundle_env)
50
+ if @build_command
51
+ @shell.exec_with_env(@build_command, @bundle_env)
53
52
  end
54
- FileUtils.cp_r('vendor', lib_path, preserve: true)
53
+ end
54
+ Dir['lib/vendor/*/*/cache/*'].each do |cache_file|
55
+ FileUtils.rm_rf(cache_file)
56
+ end
57
+ Dir['lib/vendor/ruby/*/extensions/*'].each do |ext_file|
58
+ FileUtils.rm_rf(ext_file)
59
+ end
60
+ %w[o so bundle].each do |ext|
61
+ find_and_remove_files('lib/vendor/ruby/*/gems', %(*.#{ext}))
55
62
  end
56
63
  end
57
64
  end
@@ -88,16 +95,6 @@ module Tara
88
95
  end
89
96
  end
90
97
 
91
- def create_bundler_config
92
- copy_gem_files(vendor_path)
93
- FileUtils.mkdir_p(bundle_path)
94
- File.open(bundle_path.join('config'), 'w+') do |f|
95
- f.puts(%(BUNDLE_PATH: .))
96
- f.puts(%(BUNDLE_WITHOUT: #{@without_groups.join(':')})) if @without_groups.any?
97
- f.puts(%(BUNDLE_DISABLE_SHARED_GEMS: '1'))
98
- end
99
- end
100
-
101
98
  def strip_tests
102
99
  strip_from_gems(%w[tests test spec])
103
100
  end
@@ -131,6 +128,10 @@ module Tara
131
128
  end
132
129
  end
133
130
 
131
+ def strip_empty_directories
132
+ @shell.exec(%(find #{@package_dir} -type d -empty -delete 2> /dev/null || true))
133
+ end
134
+
134
135
  def find_and_remove_files(dir, glob)
135
136
  @shell.exec(%(find #{dir} -name "#{glob}" -type f -exec rm -f "{}" \\; 2> /dev/null || true))
136
137
  end
@@ -151,10 +152,6 @@ module Tara
151
152
  @ruby_vendor_path ||= vendor_path.join('ruby')
152
153
  end
153
154
 
154
- def bundle_path
155
- @bundle_path ||= vendor_path.join('.bundle')
156
- end
157
-
158
155
  def ruby_path
159
156
  @ruby_path ||= lib_path.join('ruby')
160
157
  end
@@ -10,6 +10,12 @@ module Tara
10
10
  raise ExecError, %(Command `#{command}` failed with output: #{output})
11
11
  end
12
12
  output
13
+ rescue Errno::ENOENT => e
14
+ raise ExecError, %(Command `#{command}` failed with output: #{e.message})
15
+ end
16
+
17
+ def self.exec_with_env(command, env)
18
+ self.exec(env.map { |k, v| [k, v].join('=') }.join(' ') << ' ' << command)
13
19
  end
14
20
  end
15
21
  end
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Tara
4
- VERSION = '0.5.0'
4
+ VERSION = '0.6.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tara
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mathias Söderberg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-19 00:00:00.000000000 Z
11
+ date: 2015-12-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Tara packs your Ruby app into a standalone archive with gems and a Ruby
14
14
  runtime