Sha256: f8b8638534da8ea824f438756b0773b0413bc1b7aa56100ad2d0ae5f4b981b9d

Contents?: true

Size: 1.35 KB

Versions: 34

Compression:

Stored size: 1.35 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'] ||= session.get('/users/permissions')
      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

34 entries across 34 versions & 1 rubygems

Version Path
travis-1.6.8.travis.453.6 lib/travis/client/user.rb
travis-1.6.8.travis.452.6 lib/travis/client/user.rb
travis-1.6.8.travis.451.6 lib/travis/client/user.rb
travis-1.6.8.travis.450.6 lib/travis/client/user.rb
travis-1.6.8.travis.449.6 lib/travis/client/user.rb
travis-1.6.8.travis.447.6 lib/travis/client/user.rb
travis-1.6.7.travis.446.6 lib/travis/client/user.rb
travis-1.6.7 lib/travis/client/user.rb
travis-1.6.7.travis.445.6 lib/travis/client/user.rb
travis-1.6.7.travis.443.6 lib/travis/client/user.rb
travis-1.6.7.travis.442.6 lib/travis/client/user.rb
travis-1.6.7.travis.441.6 lib/travis/client/user.rb
travis-1.6.7.travis.434.6 lib/travis/client/user.rb
travis-1.6.7.travis.431.6 lib/travis/client/user.rb
travis-1.6.7.travis.428.9 lib/travis/client/user.rb
travis-1.6.7.travis.427.9 lib/travis/client/user.rb
travis-1.6.7.travis.426.8 lib/travis/client/user.rb
travis-1.6.7.travis.425.8 lib/travis/client/user.rb
travis-1.6.7.travis.422.4 lib/travis/client/user.rb
travis-1.6.7.travis.420.4 lib/travis/client/user.rb