Class: ROM::Git::Gateway

Inherits:
ROM::Gateway
  • Object
show all
Defined in:
lib/rom/git/gateway.rb

Instance Method Summary collapse

Constructor Details

#initialize(path, options = {}) ⇒ Gateway

Returns a new instance of Gateway.



7
8
9
10
11
12
13
# File 'lib/rom/git/gateway.rb', line 7

def initialize(path, options = {})
  super()
  @path = path
  @options = options
  @datasets = {}
  reset_data
end

Instance Method Details

#[](name) ⇒ Object



15
16
17
# File 'lib/rom/git/gateway.rb', line 15

def [](name)
  @datasets[name]
end

#dataset(name) ⇒ Object



19
20
21
# File 'lib/rom/git/gateway.rb', line 19

def dataset(name)
  @datasets[name] = Dataset.new(@connection, path: @path, options: @options, gateway: self)
end

#dataset?(name) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/rom/git/gateway.rb', line 23

def dataset?(name)
  @datasets.key?(name)
end

#reset_dataObject



27
28
29
30
31
32
33
34
# File 'lib/rom/git/gateway.rb', line 27

def reset_data
  repo   = Rugged::Repository.new(@path)
  walker = Rugged::Walker.new(repo)
  branch = (@options || {}).fetch(:branch, 'refs/head/master')
  ref    = repo.references[branch]

  @connection = ref.log rescue []
end