Sha256: 08646955b757fe426e5b89706a1ba6f48d9d3f225037788d0187d408978f7d4c

Contents?: true

Size: 1.76 KB

Versions: 1

Compression:

Stored size: 1.76 KB

Contents

module PoolParty    
  class Deploydirectory
        
    virtual_resource(:deploydirectory) do
      
      def loaded(opts={}, parent=self)
        package_directory
        execute_on_master do
          unpack_directory
        end
        has_rsync_mirror(:dir => cwd)
      end
            
      def package_directory
        path = ::File.join( Base.tmp_path, "#{::File.basename(from_dir)}.tar.gz" )
        # cd /Users/auser/Sites/work/citrusbyte/internal/gems/pool-party/poolparty/spec/poolparty/plugins/ && tar -czf plugins.tar.gz . && mv plugins.tar.gz /tmp/poolparty && cd /tmp/poolparty
        cmd = "cd #{::File.expand_path(from_dir)} && tar -czf #{name.dir_safe}.tar.gz . && mv #{name.dir_safe}.tar.gz #{Base.tmp_path}"
        `#{cmd}` unless testing
      end
      
      def unpack_directory         
        has_exec({:name => "deploy-directory-#{name}", :requires => get_directory("#{cwd}"), :cwd => cwd}) do
          command "cd #{parent.cwd}; tar -zxf #{Base.remote_storage_path}/#{parent.name.dir_safe}.tar.gz && rm #{Base.tmp_path}/#{parent.name.dir_safe}.tar.gz"
        end
      end
      
      def from(dir)
        from_dir (dir.include?(" ") ? dir.gsub(/[ ]/, '') : dir)
      end
      
      def to(dir)
        cwd dir
        has_directory(:name => "#{dir}", :requires => get_directory("#{::File.dirname(dir)}"))
      end
      
      # Since git is not a native type, we have to say which core resource
      # it is using to be able to require it
      def class_type_name
        "exec"
      end
      
      # Because we are requiring an exec, instead of a built-in package of the git, we have to overload
      # the to_s method and prepend it with the same name as above
      def key
        "deploy-directory-#{name}"
      end
      
    end
    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
auser-poolparty-0.2.58 lib/poolparty/plugins/deploydirectory.rb