Class: Licensee::Projects::GitHubProject

Inherits:
Project
  • Object
show all
Defined in:
lib/licensee/projects/github_project.rb

Overview

Scans a remote GitHub repository for license-related files (via API).

Defined Under Namespace

Classes: RepoNotFound

Constant Summary collapse

GITHUB_REPO_PATTERN =

If there’s any trailing data (e.g. ‘.git`) this pattern will ignore it: we’re going to use the API rather than clone the repo.

%r{https://github.com/([^/]+/([^/]+(?=\.git)|[^/]+)).*}

Constants inherited from Project

Project::HASH_METHODS

Instance Attribute Summary collapse

Attributes inherited from Project

#detect_packages, #detect_readme

Instance Method Summary collapse

Methods inherited from Project

#build_license_files, #license, #license_file, #license_files, #licenses, #matched_file, #matched_files, #package_file, #readme_file

Methods included from HashHelper

#serialize_hash_value, #to_h

Constructor Details

#initialize(github_url, ref: nil, **args) ⇒ GitHubProject

Returns a new instance of GitHubProject.

Raises:

  • (ArgumentError)


25
26
27
28
29
30
31
32
# File 'lib/licensee/projects/github_project.rb', line 25

def initialize(github_url, ref: nil, **args)
  @repo = github_url[GITHUB_REPO_PATTERN, 1]
  raise ArgumentError, "Not a github URL: #{github_url}" unless @repo

  @ref = ref

  super(**args)
end

Instance Attribute Details

#refObject (readonly)

Returns the value of attribute ref.



16
17
18
# File 'lib/licensee/projects/github_project.rb', line 16

def ref
  @ref
end

#repoObject (readonly)

Returns the value of attribute repo.



16
17
18
# File 'lib/licensee/projects/github_project.rb', line 16

def repo
  @repo
end