Class: LockJar::Runtime

Inherits:
Object
  • Object
show all
Includes:
Install, List, Load, Singleton
Defined in:
lib/lock_jar/runtime.rb,
lib/lock_jar/runtime/list.rb,
lib/lock_jar/runtime/load.rb,
lib/lock_jar/runtime/lock.rb,
lib/lock_jar/runtime/install.rb

Defined Under Namespace

Modules: Install, List, Load Classes: Lock

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Install

#install

Methods included from List

#build_lockfile, #dependencies_from_lockfile, #list

Methods included from Load

#load

Constructor Details

#initializeRuntime

Returns a new instance of Runtime.


39
40
41
42
# File 'lib/lock_jar/runtime.rb', line 39

def initialize
  @config = Config.load_config_file
  @current_resolver = nil
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config


37
38
39
# File 'lib/lock_jar/runtime.rb', line 37

def config
  @config
end

#current_resolverObject (readonly)

Returns the value of attribute current_resolver


37
38
39
# File 'lib/lock_jar/runtime.rb', line 37

def current_resolver
  @current_resolver
end

Instance Method Details

#lock(jarfile_or_dsl, opts = {}, &blk) ⇒ Object


44
45
46
# File 'lib/lock_jar/runtime.rb', line 44

def lock(jarfile_or_dsl, opts = {}, &blk)
  Lock.new(self).lock(jarfile_or_dsl, opts, &blk)
end

#optsObject


48
49
50
# File 'lib/lock_jar/runtime.rb', line 48

def opts
  current_resolver.opts if current_resolver
end

#reset!Object


70
71
72
# File 'lib/lock_jar/runtime.rb', line 70

def reset!
  @current_resolver = nil
end

#resolver(opts = {}) ⇒ Object


52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/lock_jar/runtime.rb', line 52

def resolver(opts = {})
  # XXX: Caches the resolver by the options. Passing in nil opts will replay
  #      from the cache. This need to change.
  if !opts.nil?
    opts[:local_repo] = File.expand_path(opts[:local_repo]) if opts[:local_repo]
  elsif @current_resolver
    opts = @current_resolver.opts
  else
    opts = {}
  end

  if @current_resolver.nil? || opts != @current_resolver.opts
    @current_resolver = LockJar::Resolver.new(config, opts)
  end

  @current_resolver
end