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

Returns a new instance of Version.



28
29
30
31
32
33
34
35
36
# File 'lib/git_dump/version.rb', line 28

def initialize(repo, id, sha, attributes = {})
  fail ArgumentError, 'Expected Repo' unless repo.is_a?(Repo)

  @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.



27
28
29
# File 'lib/git_dump/version.rb', line 27

def annotation
  @annotation
end

#commit_timeObject (readonly)

Returns the value of attribute commit_time.



27
28
29
# File 'lib/git_dump/version.rb', line 27

def commit_time
  @commit_time
end

#descriptionObject (readonly)

Returns the value of attribute description.



27
28
29
# File 'lib/git_dump/version.rb', line 27

def description
  @description
end

#idObject (readonly)

Returns the value of attribute id.



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

def id
  @id
end

#repoObject (readonly)

Returns the value of attribute repo.



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

def repo
  @repo
end

#shaObject (readonly)

Returns the value of attribute sha.



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

def sha
  @sha
end

#timeObject (readonly)

Returns the value of attribute time.



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

def time
  @time
end

Class Method Details

.by_id(repo, id) ⇒ Object



22
23
24
# File 'lib/git_dump/version.rb', line 22

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

.list(repo) ⇒ Object



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

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



49
50
51
# File 'lib/git_dump/version.rb', line 49

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



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

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

#removeObject

Remove this version



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

def remove
  repo.remove_tag(id)
end