class Terraspace::Plugin::Finder
Public Instance Methods
find_with(options)
click to toggle source
# File lib/terraspace/plugin/finder.rb, line 3 def find_with(options) result = if options.key?(:plugin) find_with_plugin(options[:plugin]) elsif options.key?(:backend) find_with_backend(options[:backend]) elsif options.key?(:resource) find_with_resource(options[:resource]) else raise "Must provide backend, plugin, or resource option." end return unless result raw = Hash[*result] # convert result to Hash instead of an Array Meta.new(raw) end
find_with_backend(backend)
click to toggle source
# File lib/terraspace/plugin/finder.rb, line 18 def find_with_backend(backend) meta.find do |provider, data| data[:backend] == backend end end
find_with_plugin(plugin)
click to toggle source
# File lib/terraspace/plugin/finder.rb, line 24 def find_with_plugin(plugin) meta.find do |plugin_name, data| plugin_name == plugin end end
find_with_resource(resource)
click to toggle source
# File lib/terraspace/plugin/finder.rb, line 30 def find_with_resource(resource) map = resource_map base = resource.split('_').first # google_compute_firewall => google, aws_security_group => aws plugin = map[base] || base find_with_plugin(plugin) end
meta()
click to toggle source
# File lib/terraspace/plugin/finder.rb, line 41 def meta Terraspace::Plugin.meta end
resource_map()
click to toggle source
# File lib/terraspace/plugin/finder.rb, line 37 def resource_map Terraspace::Plugin.resource_map end