Class: PrePackager::Content
- Inherits:
-
Object
- Object
- PrePackager::Content
- Includes:
- Executor
- Defined in:
- lib/pre-packager.rb
Constant Summary collapse
- @@LINK_BASE_DEFAULT =
'/usr/local/bin'
Instance Method Summary collapse
-
#initialize(context) ⇒ Content
constructor
A new instance of Content.
- #link(file, options) ⇒ Object
Methods included from Executor
Constructor Details
#initialize(context) ⇒ Content
Returns a new instance of Content.
46 47 48 |
# File 'lib/pre-packager.rb', line 46 def initialize context @context = context end |
Instance Method Details
#link(file, options) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/pre-packager.rb', line 50 def link file, link_base = File.join @context.root, @@LINK_BASE_DEFAULT FileUtils.mkdir_p link_base target = File.join @context.base, @context.name, file linkname = Pathname.new(file).basename.to_s linkname = @context.name if [:use_name] create_link = proc { |name| File.join link_base, name} execute "ln -sf #{target} #{create_link.call(linkname)}" execute("ln -sf #{linkname} #{create_link.call([:alias])}") if [:alias] # File.symlink File.join(file), File.join(@path, @@LINK_BASE_DEFAULT, link) end |