Class: DockerDistribution::Helpers

Inherits:
Object
  • Object
show all
Defined in:
lib/docker_distribution/helpers.rb

Class Method Summary collapse

Class Method Details

.canonical?(ref) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/docker_distribution/helpers.rb', line 29

def canonical?(ref)
  ref.respond_to?(:digest)
end

.empty?(object) ⇒ Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/docker_distribution/helpers.rb', line 57

def empty?(object)
  object == "" || object.nil?
end

.familiar?(ref) ⇒ Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/docker_distribution/helpers.rb', line 37

def familiar?(ref)
  ref.respond_to?(:familiar)
end

.familiar_match(pattern, ref) ⇒ Object



18
19
20
21
22
23
# File 'lib/docker_distribution/helpers.rb', line 18

def familiar_match(pattern, ref)
  string_match = File.fnmatch(pattern, familiar_string(ref), File::FNM_PATHNAME)
  name_match = File.fnmatch(pattern, familiar_name(ref), File::FNM_PATHNAME)

  string_match || name_match
end

.familiar_name(named) ⇒ Object



6
7
8
9
10
# File 'lib/docker_distribution/helpers.rb', line 6

def familiar_name(named)
  return named.familiar.name if named.respond_to?(:familiar)

  named.name
end

.familiar_string(named) ⇒ Object



12
13
14
15
16
# File 'lib/docker_distribution/helpers.rb', line 12

def familiar_string(named)
  return named.familiar.to_s if named.respond_to?(:familiar)

  named.to_s
end

.from(str, index) ⇒ Object



49
50
51
# File 'lib/docker_distribution/helpers.rb', line 49

def from(str, index)
  str[index..]
end

.name_only?(ref) ⇒ Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/docker_distribution/helpers.rb', line 41

def name_only?(ref)
  named?(ref) && !tagged?(ref) && !canonical?(ref)
end

.named?(ref) ⇒ Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/docker_distribution/helpers.rb', line 33

def named?(ref)
  ref.respond_to?(:name)
end

.normalized_named?(ref) ⇒ Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/docker_distribution/helpers.rb', line 45

def normalized_named?(ref)
  named?(ref) && familiar?(ref)
end

.tagged?(ref) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/docker_distribution/helpers.rb', line 25

def tagged?(ref)
  ref.respond_to?(:tag)
end

.to(str, index) ⇒ Object



53
54
55
# File 'lib/docker_distribution/helpers.rb', line 53

def to(str, index)
  str[0...index]
end