Sha256: d0cf7af2d17249a2c2fa32ebaf9057c76a21680ac1d8284c3c4a4118ab2b29b0

Contents?: true

Size: 736 Bytes

Versions: 12

Compression:

Stored size: 736 Bytes

Contents

module SmallCage::Commands
  class Clean
    def self.execute(opts)
      self.new(opts).execute
    end
    
    def initialize(opts)
      @opts = opts
    end
    
    def execute
      target = Pathname.new(@opts[:path])
      unless target.exist?
        raise "target directory or file does not exist.: " + target.to_s
      end
      
      loader = SmallCage::Loader.new(target)
      loader.each_smc_obj do |obj|
        if obj["path"].exist?
          obj["path"].delete 
          puts "D " + obj["uri"] unless @opts[:quiet]
        end
      end
      
      tmpdir = loader.root + "./_smc/tmp"
      if tmpdir.exist?
        FileUtils.rm_r(tmpdir)
        puts "D /_smc/tmp" unless @opts[:quiet]
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
bluemark-smallcage-0.1.3 lib/smallcage/commands/clean.rb
bluemark-smallcage-0.1.4 lib/smallcage/commands/clean.rb
bluemark-smallcage-0.1.5 lib/smallcage/commands/clean.rb
smallcage-0.1.7 lib/smallcage/commands/clean.rb
smallcage-0.1.6 lib/smallcage/commands/clean.rb
smallcage-0.1.5 lib/smallcage/commands/clean.rb
smallcage-0.1.4 lib/smallcage/commands/clean.rb
smallcage-0.1.0 lib/smallcage/commands/clean.rb
smallcage-0.0.9 lib/smallcage/commands/clean.rb
smallcage-0.1.2 lib/smallcage/commands/clean.rb
smallcage-0.1.3 lib/smallcage/commands/clean.rb
smallcage-0.1.1 lib/smallcage/commands/clean.rb