Sha256: 7918da4b46ec161d722ae2e31ffbc17331e126920c2ab90b10f5aac3fc2b9642

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true
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

1 entries across 1 versions & 1 rubygems

Version Path
bitbuckets-0.2.0 lib/bitbucket_rest_api/repos/components.rb