Class: Tara::Archive
- Inherits:
-
Object
- Object
- Tara::Archive
- Defined in:
- lib/tara/archive.rb
Overview
Packs an application along with a Ruby runtime and dependencies into a TAR archive.
The archive will include the source code of your project (which is assumed to be in the ‘lib` directory), wrapper scripts for each executable (assumed to be in the `bin` directory), and all gems that aren’t in the ‘test` or `development` groups in your project’s Gemfile.
Class Method Summary collapse
-
.create(config = {}) ⇒ String
Short for ‘Archive.new(config).create`.
Instance Method Summary collapse
-
#create ⇒ String
Create an archive using the instance’s configuration.
-
#initialize(config = {}) ⇒ Archive
constructor
Create a new instance of ‘Archive` with the specified configuration.
Constructor Details
#initialize(config = {}) ⇒ Archive
Create a new instance of ‘Archive` with the specified configuration.
Tara attempts to use sane defaults in most of all cases, for example like assuming that the source code is in the ‘lib` directory of your project, that the name of the application is the same as the project directory.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/tara/archive.rb', line 60 def initialize(config={}) @config = config @config[:app_dir] ||= Dir.pwd @config[:app_name] ||= File.basename(@config[:app_dir]) @config[:build_dir] ||= File.join(@config[:app_dir], 'build') @config[:download_dir] ||= File.join(@config[:build_dir], 'downloads') @config[:archive_name] ||= @config[:app_name] + '.tgz' @config[:files] ||= %w[lib/**/*.rb] @config[:executables] ||= %w[bin/*] @config[:gem_executables] ||= [] @config[:target] ||= 'linux-x86_64' @config[:traveling_ruby_version] ||= '20150210' @config[:without_groups] ||= %w[development test] end |
Class Method Details
.create(config = {}) ⇒ String
Short for ‘Archive.new(config).create`
79 80 81 |
# File 'lib/tara/archive.rb', line 79 def self.create(config={}) new(config).create end |
Instance Method Details
#create ⇒ String
Create an archive using the instance’s configuration.
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/tara/archive.rb', line 88 def create Dir.mktmpdir do |tmp_dir| project_dir = Pathname.new(@config[:app_dir]) package_dir = Pathname.new(tmp_dir) build_dir = Pathname.new(@config[:build_dir]) copy_source(project_dir, package_dir) copy_executables(project_dir, package_dir) create_gem_shims(package_dir) install_dependencies(package_dir, fetcher) Dir.chdir(tmp_dir) do create_archive(build_dir) end File.join(build_dir, @config[:archive_name]) end end |