Sha256: 3ce13493869cb00233de84a2f709d997d70b06dd8362e21970dd8516231b4c86

Contents?: true

Size: 1.01 KB

Versions: 19

Compression:

Stored size: 1.01 KB

Contents

module SmallCage::Commands
  class Export < SmallCage::Commands::Base
    def execute
      target = Pathname.new(@opts[:path])
      unless target.exist?
        raise target.to_s + " does not exist."
      end
      
      loader = SmallCage::Loader.new(target)
      root = loader.root
      
      if @opts[:out].nil?
        out = root + ("./_smc/tmp/export/" + Time.now.strftime("%Y%m%d%H%M%S"))
      else
        out = Pathname.new(@opts[:out])
      end
      if out.exist?
        raise out.to_s + " already exist."
      end
      FileUtils.makedirs(out)
      out = out.realpath
      
      # TODO create empty directories
      loader.each_not_smc_file do |docpath|
        dir = Pathname.new(docpath.uri).parent
        outdir = out + ("." + dir.to_s)
        FileUtils.makedirs(outdir)
        FileUtils.cp(docpath.path, outdir)
        puts "A " + docpath.uri unless quiet?
      end

      unless quiet?
        puts "" 
        puts "All contents exported to:"
        puts " #{out.to_s}"
      end

    end

  end
end

Version data entries

19 entries across 19 versions & 2 rubygems

Version Path
bluemark-smallcage-0.1.3 lib/smallcage/commands/export.rb
bluemark-smallcage-0.1.4 lib/smallcage/commands/export.rb
bluemark-smallcage-0.1.5 lib/smallcage/commands/export.rb
smallcage-0.2.4 lib/smallcage/commands/export.rb
smallcage-0.2.3 lib/smallcage/commands/export.rb
smallcage-0.2.2 lib/smallcage/commands/export.rb
smallcage-0.2.1 lib/smallcage/commands/export.rb
smallcage-0.2.0 lib/smallcage/commands/export.rb
smallcage-0.1.9 lib/smallcage/commands/export.rb
smallcage-0.1.8 lib/smallcage/commands/export.rb
smallcage-0.1.7 lib/smallcage/commands/export.rb
smallcage-0.1.6 lib/smallcage/commands/export.rb
smallcage-0.1.5 lib/smallcage/commands/export.rb
smallcage-0.1.4 lib/smallcage/commands/export.rb
smallcage-0.1.0 lib/smallcage/commands/export.rb
smallcage-0.1.3 lib/smallcage/commands/export.rb
smallcage-0.0.9 lib/smallcage/commands/export.rb
smallcage-0.1.1 lib/smallcage/commands/export.rb
smallcage-0.1.2 lib/smallcage/commands/export.rb