Class: Terraspace::Plugin::Finder
- Inherits:
-
Object
- Object
- Terraspace::Plugin::Finder
- Defined in:
- lib/terraspace/plugin/finder.rb
Instance Method Summary collapse
- #find_with(options) ⇒ Object
- #find_with_backend(backend) ⇒ Object
- #find_with_plugin(plugin) ⇒ Object
- #find_with_resource(resource) ⇒ Object
- #meta ⇒ Object
- #resource_map ⇒ Object
Instance Method Details
#find_with(options) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/terraspace/plugin/finder.rb', line 3 def find_with() result = if .key?(:plugin) find_with_plugin([:plugin]) elsif .key?(:backend) find_with_backend([:backend]) elsif .key?(:resource) find_with_resource([: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) ⇒ Object
18 19 20 21 22 |
# File 'lib/terraspace/plugin/finder.rb', line 18 def find_with_backend(backend) .find do |provider, data| data[:backend] == backend end end |
#find_with_plugin(plugin) ⇒ Object
24 25 26 27 28 |
# File 'lib/terraspace/plugin/finder.rb', line 24 def find_with_plugin(plugin) .find do |plugin_name, data| plugin_name == plugin end end |
#find_with_resource(resource) ⇒ Object
30 31 32 33 34 35 |
# 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 ⇒ Object
41 42 43 |
# File 'lib/terraspace/plugin/finder.rb', line 41 def Terraspace::Plugin. end |
#resource_map ⇒ Object
37 38 39 |
# File 'lib/terraspace/plugin/finder.rb', line 37 def resource_map Terraspace::Plugin.resource_map end |