Sha256: 57f85ec17358076b33877df7746e5b14bf0fc39e8f3b6bf9e8621c9ad9acd81b

Contents?: true

Size: 1.46 KB

Versions: 6

Compression:

Stored size: 1.46 KB

Contents

module PoolParty    
  class GitResource
        
    virtual_resource(:git) do
      
      def loaded(opts={}, parent=self)
        has_git_repos
      end
            
      def has_git_repos
        has_package(:name => "git-core")
        has_exec({:name => key, :requires => [get_directory("#{working_dir}"), get_package("git-core")] }) do
          command requires_user ? "git clone #{requires_user}@#{source} #{working_dir}" : "cd #{working_dir} && git clone #{source}"
          cwd "#{working_dir if working_dir}"
          creates creates_dir
        end
        has_exec(:name => "update-#{name}") do
          cwd ::File.dirname( creates_dir )
          command "git pull"
        end                
      end
      
      def at(dir)
        working_dir dir
        has_directory(:name => "#{dir}", :requires => get_directory("#{::File.dirname(dir)}"))
      end
      
      def to(dir)
        at(dir)
      end
      
      def creates_dir
        "#{::File.join( working_dir, ::File.basename(source, ::File.extname(source)) )}/.git"
      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
        "git-#{name}"
      end
      
    end
    
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
auser-poolparty-0.2.84 lib/poolparty/plugins/git.rb
auser-poolparty-0.2.85 lib/poolparty/plugins/git.rb
auser-poolparty-0.2.88 lib/poolparty/plugins/git.rb
auser-poolparty-0.2.89 lib/poolparty/plugins/git.rb
auser-poolparty-0.2.90 lib/poolparty/plugins/git.rb
poolparty-0.2.84 lib/poolparty/plugins/git.rb