Module: JCF

Defined in:
lib/jcf.rb,
lib/jcf/cf.rb,
lib/jcf/cli.rb,
lib/jcf/metric.rb,
lib/jcf/cf/base.rb,
lib/jcf/cf/user.rb,
lib/jcf/version.rb,
lib/jcf/cf/quota.rb,
lib/jcf/cf/space.rb,
lib/jcf/cli/errors.rb,
lib/jcf/cf/services.rb,
lib/jcf/cli/command.rb,
lib/jcf/cli/commands.rb,
lib/jcf/plugins/aws_s3.rb,
lib/jcf/cf/organization.rb,
lib/jcf/cf/service_plan.rb,
lib/jcf/plugins/aws_rds.rb,
lib/jcf/cf/relationships.rb,
lib/jcf/cf/service_broker.rb,
lib/jcf/cf/service_instance.rb,
lib/jcf/cf/service_offering.rb,
lib/jcf/cli/commands/plugins.rb,
lib/jcf/cli/commands/version.rb,
lib/jcf/cli/commands/cf/quota.rb,
lib/jcf/cli/commands/cf/users.rb,
lib/jcf/cli/output_formatters.rb,
lib/jcf/cli/commands/cf/spaces.rb,
lib/jcf/cli/commands/cf/metrics.rb,
lib/jcf/cli/commands/cf/services.rb,
lib/jcf/cli/output_formatters/csv.rb,
lib/jcf/cli/output_formatters/json.rb,
lib/jcf/cli/output_formatters/text.rb,
lib/jcf/cli/commands/cf/organizations.rb,
lib/jcf/cli/commands/cf/service_plans.rb,
lib/jcf/cli/commands/cf/service_brokers.rb,
lib/jcf/cli/commands/cf/service_instances.rb,
lib/jcf/cli/commands/cf/service_offerings.rb

Defined Under Namespace

Modules: CF, CLI, Plugins Classes: Error, Metric

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.cacheObject



13
14
15
# File 'lib/jcf/cli.rb', line 13

def self.cache
  @cache ||= MiniCache::Store.new
end

.plugin(plugin) ⇒ Object



17
18
19
20
21
22
# File 'lib/jcf/cli.rb', line 17

def self.plugin(plugin)
  plugin = JCF::Plugins.load_plugin(plugin) if plugin.is_a?(Symbol)
  validate_plugin!(plugin)
  plugin.load_dependencies(self, *args, &block) if plugin.respond_to?(:load_dependencies)
  plugin.configure(self, *args, &block) if plugin.respond_to?(:configure)
end

.rootObject



9
10
11
# File 'lib/jcf/cli.rb', line 9

def self.root
  File.expand_path("..", __dir__)
end

.validate_plugin!(plugin) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
# File 'lib/jcf/cli.rb', line 24

def self.validate_plugin!(plugin)
  puts "Validating plugin (#{plugin}) implementation conforms to interface" if ENV["DEBUG"]

  %i[metrics names values].each do |method|
    raise "Plugin does not conform to interface (missing method \"#{method}\")" \
      unless plugin.new(name: nil).respond_to?(method)
  end
rescue JCF::CLI::NotLoggedInError => e
  puts e.message
  exit 1
end