Class: DtkCommon::GitRepo

Inherits:
Object
  • Object
show all
Defined in:
lib/git_repo.rb,
lib/git_repo/adapters/rugged.rb

Direct Known Subclasses

Branch

Defined Under Namespace

Classes: Adapter, Branch

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(repo_path) ⇒ GitRepo

Returns a new instance of GitRepo.



26
27
28
29
# File 'lib/git_repo.rb', line 26

def initialize(repo_path)
  @repo_path = repo_path
  @adapters = Hash.new
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/git_repo.rb', line 42

def method_missing(method_name,*args,&block)
  if adapter_name = self.class.find_adapter_name(method_name)
    
    adapter = (@adapters[adapter_name] ||= Hash.new)[branch_index()] ||= self.class.load_and_return_adapter_class(adapter_name).new(*adapter_initialize_args())
    execution_wrapper do
      adapter.send(method_name,*args,&block)
    end
  else
    super
  end
end

Class Method Details

.implements_method?(method_name) ⇒ Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/git_repo.rb', line 58

def self.implements_method?(method_name)
  !!find_adapter_name(method_name)
end

Instance Method Details

#respond_to?(method_name) ⇒ Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/git_repo.rb', line 54

def respond_to?(method_name)
  super(method_name) or self.class.find_adapter_name(method_name)
end