Sha256: abad6ec6ee5a8895a9e06cdd2eb3aef325d934f45604d6d3f65c93131d70cb3e

Contents?: true

Size: 1.06 KB

Versions: 4

Compression:

Stored size: 1.06 KB

Contents

# encoding: utf-8

module BitBucket
  class Repos::Components < API

    # List components
    #
    # = Examples
    #  bitbucket = BitBucket.new
    #  bitbucket.repos.components.list 'user-name', 'repo-name'
    #  bitbucket.repos.components.list 'user-name', 'repo-name' { |component| ... }
    #
    def list(user_name, repo_name, params={})
      update_and_validate_user_repo_params(user_name, repo_name)
      normalize! params

      response = get_request("/2.0/repositories/#{user}/#{repo.downcase}/components", params)
      return response['values'] unless block_given?
      response['values'].each { |el| yield el }
    end
    alias :all :list

    # Get a component by it's ID
    #
    # = Examples
    #  bitbucket = BitBucket.new
    #  bitbucket.repos.components.get 'user-name', 'repo-name', 1
    #
    def get(user_name, repo_name, component_id, params={})
      update_and_validate_user_repo_params(user_name, repo_name)
      normalize! params

      get_request("/2.0/repositories/#{user}/#{repo.downcase}/components/#{component_id}", params)
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
zz_bitbucket_rest_api-0.1.11 lib/bitbucket_rest_api/repos/components.rb
zz_bitbucket_rest_api-0.1.10 lib/bitbucket_rest_api/repos/components.rb
zz_bitbucket_rest_api-0.1.9 lib/bitbucket_rest_api/repos/components.rb
zz_bitbucket_rest_api-0.1.8 lib/bitbucket_rest_api/repos/components.rb