Class: GitDump::Version

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/git_dump/version.rb,
lib/git_dump/version/base.rb,
lib/git_dump/version/builder.rb

Overview

Reading version

Defined Under Namespace

Modules: Base Classes: Builder

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Base

#[], #each, #each_recursive

Constructor Details

#initialize(repo, id, sha, attributes = {}) ⇒ Version



26
27
28
29
30
31
32
# File 'lib/git_dump/version.rb', line 26

def initialize(repo, id, sha, attributes = {})
  @repo, @id, @sha = repo, id, sha
  @time = attributes[:time]
  @commit_time = attributes[:commit_time]
  @annotation = attributes[:annotation]
  @description = attributes[:description]
end

Instance Attribute Details

#annotationObject (readonly)

Returns the value of attribute annotation.



25
26
27
# File 'lib/git_dump/version.rb', line 25

def annotation
  @annotation
end

#commit_timeObject (readonly)

Returns the value of attribute commit_time.



25
26
27
# File 'lib/git_dump/version.rb', line 25

def commit_time
  @commit_time
end

#descriptionObject (readonly)

Returns the value of attribute description.



25
26
27
# File 'lib/git_dump/version.rb', line 25

def description
  @description
end

#idObject (readonly)

Returns the value of attribute id.



24
25
26
# File 'lib/git_dump/version.rb', line 24

def id
  @id
end

#repoObject (readonly)

Returns the value of attribute repo.



24
25
26
# File 'lib/git_dump/version.rb', line 24

def repo
  @repo
end

#shaObject (readonly)

Returns the value of attribute sha.



24
25
26
# File 'lib/git_dump/version.rb', line 24

def sha
  @sha
end

#timeObject (readonly)

Returns the value of attribute time.



24
25
26
# File 'lib/git_dump/version.rb', line 24

def time
  @time
end

Class Method Details

.by_id(repo, id) ⇒ Object



20
21
22
# File 'lib/git_dump/version.rb', line 20

def self.by_id(repo, id)
  list(repo).find{ |version| version.id == id }
end

.list(repo) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/git_dump/version.rb', line 9

def self.list(repo)
  repo.tag_entries.map do |entry|
    Version.new(repo, entry[:name], entry[:sha], {
      :time => entry[:author_time],
      :commit_time => entry[:commit_time],
      :annotation => entry[:tag_message],
      :description => entry[:commit_message],
    })
  end
end

Instance Method Details

#inspectObject



45
46
47
# File 'lib/git_dump/version.rb', line 45

def inspect
  "#<#{self.class} id=#{@id} sha=#{@sha} tree=#{@tree.inspect}>"
end

#push(url, options = {}) ⇒ Object

Send this version to repo at url Use :progress => true to show progress



36
37
38
# File 'lib/git_dump/version.rb', line 36

def push(url, options = {})
  repo.push(url, id, options)
end

#removeObject

Remove this version



41
42
43
# File 'lib/git_dump/version.rb', line 41

def remove
  repo.remove_tag(id)
end