Sha256: 25b2cf6169872ba84f1d56b6e2a3cd703f5b287a7cdb4bb592d19b08588c62e6

Contents?: true

Size: 1.03 KB

Versions: 19

Compression:

Stored size: 1.03 KB

Contents

module Githug
  class Repository

    attr_accessor :grit

    def initialize(location = ".")
      @grit = Grit::Repo.new(location)
    rescue Grit::InvalidGitRepositoryError
      @grit = nil
    end

    def reset
      dont_delete = ["..", ".", ".profile.yml"]
      if File.basename(Dir.pwd) == "git_hug"
        Dir.entries(Dir.pwd).each do |file|
          FileUtils.rm_rf(file) unless dont_delete.include?(file)
        end
      end
      create_gitignore
    end

    def create_gitignore
      Dir.chdir("git_hug") if File.exists?("./git_hug")
      File.open(".gitignore", "w") do |file|
        file.puts(".profile.yml")
        file.puts(".gitignore")
      end
    end

    def valid?
      !@grit.nil?
    end

    # Initialize a Git repo. If the repo already exists, do nothing.
    def init(location = ".")
      @grit = Grit::Repo.init(location)
    end

    def method_missing(method, *args, &block)
      if @grit && @grit.respond_to?(method)
        return @grit.send(method, *args, &block)
      end
      super
    end


  end
end

Version data entries

19 entries across 19 versions & 2 rubygems

Version Path
githug-0.5.1 lib/githug/repository.rb
mygithug-0.5.1 lib/githug/repository.rb
githug-0.5.0 lib/githug/repository.rb
githug-0.4.8 lib/githug/repository.rb
githug-0.4.7 lib/githug/repository.rb
githug-0.4.6 lib/githug/repository.rb
githug-0.4.5 lib/githug/repository.rb
githug-0.4.4 lib/githug/repository.rb
githug-0.4.3 lib/githug/repository.rb
githug-0.4.2 lib/githug/repository.rb
githug-0.4.1 lib/githug/repository.rb
githug-0.4.0 lib/githug/repository.rb
githug-0.3.5 lib/githug/repository.rb
githug-0.3.4 lib/githug/repository.rb
githug-0.3.3 lib/githug/repository.rb
githug-0.3.2 lib/githug/repository.rb
githug-0.3.1 lib/githug/repository.rb
githug-0.3.0 lib/githug/repository.rb
githug-0.2.12 lib/githug/repository.rb