Class: Librarian::Mock::Source::Mock

Inherits:
Object
  • Object
show all
Includes:
Source::BasicApi
Defined in:
lib/librarian/mock/source/mock.rb,
lib/librarian/mock/source/mock/registry.rb

Defined Under Namespace

Classes: Registry

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Source::BasicApi

included

Constructor Details

#initialize(environment, name, options) ⇒ Mock


18
19
20
21
# File 'lib/librarian/mock/source/mock.rb', line 18

def initialize(environment, name, options)
  self.environment = environment
  @name = name
end

Instance Attribute Details

#environmentObject

Returns the value of attribute environment


14
15
16
# File 'lib/librarian/mock/source/mock.rb', line 14

def environment
  @environment
end

#nameObject (readonly)

Returns the value of attribute name


16
17
18
# File 'lib/librarian/mock/source/mock.rb', line 16

def name
  @name
end

Instance Method Details

#==(other) ⇒ Object


27
28
29
30
31
# File 'lib/librarian/mock/source/mock.rb', line 27

def ==(other)
  other &&
  self.class  == other.class &&
  self.name   == other.name
end

#fetch_dependencies(name, version, extra) ⇒ Object


71
72
73
74
75
# File 'lib/librarian/mock/source/mock.rb', line 71

def fetch_dependencies(name, version, extra)
  d = registry[name]
  m = d.find{|v| v[:version] == version.to_s}
  m[:dependencies]
end

#fetch_version(name, extra) ⇒ Object


67
68
69
# File 'lib/librarian/mock/source/mock.rb', line 67

def fetch_version(name, extra)
  extra
end

#install!(manifest) ⇒ Object


60
61
# File 'lib/librarian/mock/source/mock.rb', line 60

def install!(manifest)
end

#manifest(name, version, dependencies) ⇒ Object


45
46
47
48
49
50
# File 'lib/librarian/mock/source/mock.rb', line 45

def manifest(name, version, dependencies)
  manifest = Manifest.new(self, name)
  manifest.version = version
  manifest.dependencies = dependencies
  manifest
end

#manifests(name) ⇒ Object


52
53
54
55
56
57
58
# File 'lib/librarian/mock/source/mock.rb', line 52

def manifests(name)
  if d = registry[name]
    d.map{|v| manifest(name, v[:version], v[:dependencies])}
  else
    nil
  end
end

#registryObject


41
42
43
# File 'lib/librarian/mock/source/mock.rb', line 41

def registry
  environment.registry[name]
end

#to_lock_optionsObject


37
38
39
# File 'lib/librarian/mock/source/mock.rb', line 37

def to_lock_options
  {:remote => name}
end

#to_sObject


23
24
25
# File 'lib/librarian/mock/source/mock.rb', line 23

def to_s
  name
end

#to_spec_argsObject


33
34
35
# File 'lib/librarian/mock/source/mock.rb', line 33

def to_spec_args
  [name, {}]
end