Class: Gifts::RepoTable

Inherits:
TableBase show all
Defined in:
lib/gifts/repo_table.rb

Instance Method Summary collapse

Methods inherited from TableBase

#initialize

Constructor Details

This class inherits a constructor from Gifts::TableBase

Instance Method Details

#add(path) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/gifts/repo_table.rb', line 16

def add(path)
  path  = File.expand_path(path)

  git_repo = Grit::Repo.new(path)
  db_repo = table[path] || table.add(path, path: path)

  db_commits = @db.commits.add(git_repo, db_repo)

  # update last commit key
  db_repo.last_commit_key = db_commits.first.key if db_commits.count > 0
  pp "add", db_commits.count, db_repo.last_commit_key

  db_repo
end

#define_schemaObject



7
8
9
10
11
12
13
14
# File 'lib/gifts/repo_table.rb', line 7

def define_schema
  Groonga::Schema.define do |schema|
    schema.create_table(table_name, type: :hash) do |table|
      table.string("path")
      table.string("last_commit_key")
    end
  end
end

#table_nameObject



3
4
5
# File 'lib/gifts/repo_table.rb', line 3

def table_name
  "repo"
end