lib/travis/client/repository.rb in travis-1.2.8 vs lib/travis/client/repository.rb in travis-1.3.0
- old
+ new
@@ -62,10 +62,14 @@
payload = session.get_raw("/repos/#{id}/key")
Key.new(payload.fetch('key'))
end
end
+ def name
+ slug[/[^\/]+$/]
+ end
+
def public_key=(key)
key = Key.new(key) unless key.is_a? Key
set_attribute(:public_key, key)
end
@@ -100,9 +104,22 @@
builds(:number => number.to_s).first
end
def recent_builds
builds({})
+ end
+
+ def last_on_branch(name = nil)
+ return branch(name) if name
+ attributes['last_on_branch'] ||= session.get('branches', :repository_id => id)['branches']
+ end
+
+ def branches
+ last_on_branch.map { |b| { b.commit.branch => b } }.inject(:merge)
+ end
+
+ def branch(name)
+ last_on_branch.detect { |b| b.commit.branch == name.to_s }
end
def each_build(params = nil, &block)
return enum_for(__method__, params) unless block_given?
params ||= {}