Class: Commit

Inherits:
Object
  • Object
show all
Includes:
DataMapper::Resource
Defined in:
lib/models/commit.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.download!Object



37
38
39
40
41
42
43
44
# File 'lib/models/commit.rb', line 37

def self.download!
  last_commit = last
  last_sha = last_commit ? last_commit.sha : nil
  Grudge::Repository.latest_commits_since(last_sha) do |repo_commit|
    Commit.create!(:sha => repo_commit.sha,
      :committed_at => repo_commit.committer_date)
  end
end

.lastObject

Helpers



23
# File 'lib/models/commit.rb', line 23

def self.last; first(:order => [:committed_at.desc]); end


25
# File 'lib/models/commit.rb', line 25

def self.popular; first(20, :order => [:score.desc]); end

.recentObject



24
# File 'lib/models/commit.rb', line 24

def self.recent; first(20, :order => [:committed_at.desc]); end

.search(sha) ⇒ Object



27
28
29
30
# File 'lib/models/commit.rb', line 27

def self.search(sha)
  object = Grudge::Repository.object(sha)
  first(:sha => object.sha) if object
end

.unpopularObject



26
# File 'lib/models/commit.rb', line 26

def self.unpopular; first(20, :order => [:score.asc]); end

Instance Method Details

#author_nameObject

Repository delegation methods



34
# File 'lib/models/commit.rb', line 34

def author_name; repository_object.author.name; end

#awesome!Object



13
# File 'lib/models/commit.rb', line 13

def awesome!; vote!(Vote.awesome); end

#awesome?Boolean

Returns:

  • (Boolean)


15
# File 'lib/models/commit.rb', line 15

def awesome?; score > 0; end

#awesome_scoreObject



14
# File 'lib/models/commit.rb', line 14

def awesome_score; vote_score(:score.gt); end

#messageObject



35
# File 'lib/models/commit.rb', line 35

def message; repository_object.message; end

#suck!Object



17
# File 'lib/models/commit.rb', line 17

def suck!; vote!(Vote.suck); end

#suck?Boolean

Returns:

  • (Boolean)


19
# File 'lib/models/commit.rb', line 19

def suck?; score < 0; end

#suck_scoreObject



18
# File 'lib/models/commit.rb', line 18

def suck_score; vote_score(:score.lt); end