Class: Deployments::Project

Inherits:
Object
  • Object
show all
Defined in:
lib/deployments/project.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Project

Returns a new instance of Project.



8
9
10
11
12
13
14
15
16
17
# File 'lib/deployments/project.rb', line 8

def initialize(path)
  @path = path
  @repo = Grit::Repo.new(path)

  versions = @repo.tags.map do |tag|
    Versionomy.parse(tag.name)
  end.sort

  @tag_names = versions.map {|v| v.to_s}
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



6
7
8
# File 'lib/deployments/project.rb', line 6

def path
  @path
end

#repoObject (readonly)

Returns the value of attribute repo.



6
7
8
# File 'lib/deployments/project.rb', line 6

def repo
  @repo
end

#tag_namesObject (readonly)

Returns the value of attribute tag_names.



6
7
8
# File 'lib/deployments/project.rb', line 6

def tag_names
  @tag_names
end

Instance Method Details

#commitsObject



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/deployments/project.rb', line 19

def commits
  commits = between_tags(repo) if has_commits_between_tags?

  (commits || repo.commits).inject({}) do |hash, commit|
    hash[commit.id] = {
      :message => commit.message,
      :created_at => commit.date.to_s
    }
    hash
  end
end

#previous_tagObject



35
36
37
38
39
40
# File 'lib/deployments/project.rb', line 35

def previous_tag
  tag_name = File.read(VERSION_FILE).strip if File.exists?(VERSION_FILE)
  tag_name ||= tag_names[tag_names.size - 2]

  find_repo_tag(tag_name)
end

#tagObject



31
32
33
# File 'lib/deployments/project.rb', line 31

def tag
  tag_names.last if has_tags?
end