Sha256: 8ed6163f724063e8b07e9e66823988a638ad2f7da5f135615d132e2b242ab3e3

Contents?: true

Size: 1.45 KB

Versions: 290

Compression:

Stored size: 1.45 KB

Contents

require 'travis/client'

module Travis
  module Client
    class User < Entity
      # @!parse attr_reader :login, :name, :email, :gravatar_id, :locale, :is_syncing, :synced_at, :correct_scopes
      attributes :login, :name, :email, :gravatar_id, :locale, :is_syncing, :synced_at, :correct_scopes, :channels
      inspect_info :login

      one  :user
      many :users

      def synced_at=(time)
        set_attribute(:synced_at, time(time))
      end

      def sync
        session.post_raw('/users/sync')
        reload
      end

      def channels
        load_attribute(:is_syncing) # dummy to trigger load, as channels might not be included
        attributes['channels'] ||= ['common']
      end

      def permissions
        attributes['permissions'] ||= begin
          repos = session.get('/users/permissions')
          repos.each_value { |r| r.compact! }
          repos
        end
      end

      def repositories
        permissions['permissions']
      end

      def push_access
        permissions['push']
      end

      def pull_access
        permissions['pull']
      end

      def admin_access
        permissions['admin']
      end

      def push_access?(repo)
        push_access.include? repo
      end

      def pull_access?(repo)
        pull_access.include? repo
      end

      def admin_access?(repo)
        admin_access.include? repo
      end

      alias syncing? is_syncing
      alias correct_scopes? correct_scopes
    end
  end
end

Version data entries

290 entries across 290 versions & 3 rubygems

Version Path
travis-1.8.14.travis.1178.9 lib/travis/client/user.rb
travis-1.8.14.travis.1175.9 lib/travis/client/user.rb
travis-1.8.14.travis.1172.9 lib/travis/client/user.rb
travis-1.8.14.travis.1164.9 lib/travis/client/user.rb
travis-1.8.14.travis.1163.9 lib/travis/client/user.rb
travis-1.8.14.travis.1162.9 lib/travis/client/user.rb
travis-1.8.14.travis.1160.9 lib/travis/client/user.rb
travis-1.8.13 lib/travis/client/user.rb
travis-1.8.14.travis.1156.9 lib/travis/client/user.rb
travis-1.8.14.travis.1155.9 lib/travis/client/user.rb
travis-1.8.13.travis.1152.9 lib/travis/client/user.rb
travis-1.8.13.travis.1148.9 lib/travis/client/user.rb
travis-1.8.12 lib/travis/client/user.rb
travis-1.8.13.travis.1141.9 lib/travis/client/user.rb
travis-1.8.12.travis.1136.9 lib/travis/client/user.rb
travis-1.8.12.travis.1135.9 lib/travis/client/user.rb
travis-1.8.12.travis.1125.9 lib/travis/client/user.rb
travis-1.8.12.pre.rc1 lib/travis/client/user.rb
travis-1.8.12.travis.1116.9 lib/travis/client/user.rb
travis-1.8.12.travis.1111.9 lib/travis/client/user.rb