lib/reponaut/github.rb in reponaut-1.1.1 vs lib/reponaut/github.rb in reponaut-1.2.0

- old
+ new

@@ -17,11 +17,11 @@ def initialize(username) @username = username end def repos - JSON.parse(repo_data).map { |e| Repository.new(e) } + JSON.parse(repo_data).map { |e| Repository.new(self, e) } end def to_s username end @@ -42,19 +42,29 @@ data['http_interactions'][0]['response']['body']['string'] end end class Repository - def initialize(data) + def initialize(service, data) + @service = service @data = data end def source? !fork? end + def upstream + return nil unless fork? + @service.class.get("/repos/#{full_name}")['parent']['full_name'] + end + def to_s full_name + end + + def <=>(other) + name.downcase <=> other.name.downcase end def method_missing(symbol, *args) if @data.include?(symbol.to_s) @data[symbol.to_s]