Class: CircleCi::ApiProjectResource

Inherits:
ApiResource show all
Defined in:
lib/circleci/api_project_resource.rb

Overview

Class for interacting with project API resources

Direct Known Subclasses

Build, Project

Constant Summary collapse

VALID_VCS_TYPES =
%w[github bitbucket].freeze
DEFAULT_VCS_TYPE =
VALID_VCS_TYPES.first.freeze

Instance Attribute Summary collapse

Attributes inherited from ApiResource

#conf, #project, #username

Instance Method Summary collapse

Methods inherited from ApiResource

default_config, #default_config

Constructor Details

#initialize(username = nil, project = nil, vcs_type = nil, build = nil, conf = nil) ⇒ CircleCi::Project

Initialize a new Project API interaction

Parameters:

  • username (String) (defaults to: nil)
    • The vcs username or org name for project

  • project (String) (defaults to: nil)
    • The project name

  • vcs_type (String) (defaults to: nil)
    • The vcs type i.e. github or bitbucket

  • build (String) (defaults to: nil)
    • The build number for a project

  • conf (CircleCi::Config) (defaults to: nil)
    • Optional config to use for request



22
23
24
25
26
# File 'lib/circleci/api_project_resource.rb', line 22

def initialize(username = nil, project = nil, vcs_type = nil, build = nil, conf = nil)
  super(username, project, conf)
  @vcs_type = VALID_VCS_TYPES.include?(vcs_type) ? vcs_type : DEFAULT_VCS_TYPE
  @build = build
end

Instance Attribute Details

#buildObject (readonly)

Returns the value of attribute build.



10
11
12
# File 'lib/circleci/api_project_resource.rb', line 10

def build
  @build
end

#vcs_typeObject (readonly)

Returns the value of attribute vcs_type.



10
11
12
# File 'lib/circleci/api_project_resource.rb', line 10

def vcs_type
  @vcs_type
end

Instance Method Details

#base_pathObject



28
29
30
# File 'lib/circleci/api_project_resource.rb', line 28

def base_path
  "/project/#{vcs_type}/#{username}/#{project}"
end