Class: Bundler::Alive::Status

Inherits:
Object
  • Object
show all
Defined in:
lib/bundler/alive/status.rb

Overview

Represents Status

Constant Summary collapse

REPOSITORY_URL_UNKNOWN =

Value of repository URL unknown

"unknown"
ALIVE_UNKNOWN =

Value off alive unknown

"unknown"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, repository_url:, alive:, checked_at:) ⇒ Status

Creates instance of Status

Parameters:

Raises:

  • (ArgumentError)


27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/bundler/alive/status.rb', line 27

def initialize(name:, repository_url:, alive:, checked_at:)
  raise ArgumentError if !repository_url.nil? && !repository_url.instance_of?(SourceCodeRepositoryUrl)

  repository_url = REPOSITORY_URL_UNKNOWN if repository_url.nil?
  alive = ALIVE_UNKNOWN if alive.nil?

  @name = name
  @repository_url = repository_url
  @alive = alive
  @checked_at = checked_at

  freeze
end

Instance Attribute Details

#aliveObject (readonly)

Returns the value of attribute alive.



15
16
17
# File 'lib/bundler/alive/status.rb', line 15

def alive
  @alive
end

#checked_atObject (readonly)

Returns the value of attribute checked_at.



15
16
17
# File 'lib/bundler/alive/status.rb', line 15

def checked_at
  @checked_at
end

#nameObject (readonly)

Returns the value of attribute name.



15
16
17
# File 'lib/bundler/alive/status.rb', line 15

def name
  @name
end

#repository_urlObject (readonly)

Returns the value of attribute repository_url.



15
16
17
# File 'lib/bundler/alive/status.rb', line 15

def repository_url
  @repository_url
end

Instance Method Details

#reportString

Reports not alive gem

Returns:

  • (String)


66
67
68
69
70
71
72
# File 'lib/bundler/alive/status.rb', line 66

def report
  <<~REPORT
    Name: #{name}
    URL: #{decorated_repository_url}

  REPORT
end

#to_hHash

Returns Hash of status.

Returns:

  • (Hash)

    Hash of status



53
54
55
56
57
58
59
# File 'lib/bundler/alive/status.rb', line 53

def to_h
  {
    repository_url: decorated_repository_url,
    alive: decorated_alive,
    checked_at: checked_at || ""
  }
end

#unknown?Boolean

Is status of alive unknown?

Returns:

  • (Boolean)


46
47
48
# File 'lib/bundler/alive/status.rb', line 46

def unknown?
  alive == ALIVE_UNKNOWN
end