Class: Bundler::Plugin::API

Inherits:
Object
  • Object
show all
Defined in:
lib/bundler/plugin/api.rb,
lib/bundler/plugin/api/source.rb

Defined Under Namespace

Modules: Source

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &blk) ⇒ Object



67
68
69
70
71
72
73
# File 'lib/bundler/plugin/api.rb', line 67

def method_missing(name, *args, &blk)
  return Bundler.send(name, *args, &blk) if Bundler.respond_to?(name)

  return SharedHelpers.send(name, *args, &blk) if SharedHelpers.respond_to?(name)

  super
end

Class Method Details

.command(command, cls = self) ⇒ Object

The plugins should declare that they handle a command through this helper.

Parameters:

  • command (String)

    being handled by them

  • (optional) (Class)

    class that handles the command. If not provided, the ‘self` class will be used.



33
34
35
# File 'lib/bundler/plugin/api.rb', line 33

def self.command(command, cls = self)
  Plugin.add_command command, cls
end

.hook(event, &block) ⇒ Object



48
49
50
# File 'lib/bundler/plugin/api.rb', line 48

def self.hook(event, &block)
  Plugin.add_hook(event, &block)
end

.source(source, cls = self) ⇒ Object

The plugins should declare that they provide a installation source through this helper.

Parameters:

  • the (String)

    source type they provide

  • (optional) (Class)

    class that handles the source. If not provided, the ‘self` class will be used.



43
44
45
46
# File 'lib/bundler/plugin/api.rb', line 43

def self.source(source, cls = self)
  cls.send :include, Bundler::Plugin::API::Source
  Plugin.add_source source, cls
end

Instance Method Details

#cache_dirPathname

The cache dir to be used by the plugins for storage

Returns:

  • (Pathname)

    path of the cache dir



55
56
57
# File 'lib/bundler/plugin/api.rb', line 55

def cache_dir
  Plugin.cache.join("plugins")
end

#respond_to_missing?(name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


75
76
77
78
# File 'lib/bundler/plugin/api.rb', line 75

def respond_to_missing?(name, include_private = false)
  SharedHelpers.respond_to?(name, include_private) ||
    Bundler.respond_to?(name, include_private) || super
end

#tmp(*names) ⇒ Pathname

A tmp dir to be used by plugins Accepts names that get concatenated as suffix

Returns:

  • (Pathname)

    object for the new directory created



63
64
65
# File 'lib/bundler/plugin/api.rb', line 63

def tmp(*names)
  Bundler.tmp(["plugin", *names].join("-"))
end