Class: Resource::Link
Instance Method Summary collapse
-
#initialize(source, &block) ⇒ Link
constructor
A new instance of Link.
- #run ⇒ Object
Methods inherited from Base
inherited, #not_if, #set_base_defaults, #should_skip?, #unix_mode
Methods included from ClassAttr
Methods included from BlockAttr
Constructor Details
#initialize(source, &block) ⇒ Link
Returns a new instance of Link.
7 8 9 10 11 12 |
# File 'lib/resource/link.rb', line 7 def initialize source, &block set_base_defaults @source = source @to = 'no_target' self.instance_eval(&block) end |
Instance Method Details
#run ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/resource/link.rb', line 14 def run Execution.block 'Building Link', "#{@source} ~> #{@to}", @owner do |b| b.always_run @always_run b.run "mkdir -p #{::File.dirname(@to)}" b.run "mkdir -p #{::File.dirname(@source)}" unless ::File.exist?(::File.dirname(@source)) b.run "touch #{@source}" b.run "rm -rf #{@source}" b.run "ln -s #{@to} #{@source}" end end |