Class: Terraspace::Compiler::Backend
- Inherits:
-
Object
- Object
- Terraspace::Compiler::Backend
- Extended by:
- Memoist
- Defined in:
- lib/terraspace/compiler/backend.rb,
lib/terraspace/compiler/backend/parser.rb
Defined Under Namespace
Classes: Parser
Constant Summary collapse
- @@created =
{}
Instance Method Summary collapse
- #backend ⇒ Object
- #backend_info ⇒ Object
- #backend_interface(name) ⇒ Object
- #backend_name ⇒ Object
- #cache_key ⇒ Object
- #create ⇒ Object
-
#initialize(mod) ⇒ Backend
constructor
A new instance of Backend.
Constructor Details
#initialize(mod) ⇒ Backend
Returns a new instance of Backend.
5 6 7 |
# File 'lib/terraspace/compiler/backend.rb', line 5 def initialize(mod) @mod = mod end |
Instance Method Details
#backend ⇒ Object
35 36 37 |
# File 'lib/terraspace/compiler/backend.rb', line 35 def backend Parser.new(@mod).result end |
#backend_info ⇒ Object
31 32 33 |
# File 'lib/terraspace/compiler/backend.rb', line 31 def backend_info backend.values.first # structure within the s3 or gcs key end |
#backend_interface(name) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/terraspace/compiler/backend.rb', line 40 def backend_interface(name) return unless name # IE: TerraspacePluginAws::Interfaces::Backend klass_name = Terraspace::Plugin.klass("Backend", backend: name) klass_name.constantize if klass_name rescue NameError end |
#backend_name ⇒ Object
27 28 29 |
# File 'lib/terraspace/compiler/backend.rb', line 27 def backend_name backend.keys.first # IE: s3, gcs, etc end |
#cache_key ⇒ Object
23 24 25 |
# File 'lib/terraspace/compiler/backend.rb', line 23 def cache_key @mod.build_dir end |
#create ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/terraspace/compiler/backend.rb', line 10 def create return if @@created[cache_key] # set immediately, since local storage wont reach bottom. # if fail for other backends, there will be an exception anyway @@created[cache_key] = true klass = backend_interface(backend_name) return unless klass # in case auto-creation is not supported for specific backend interface = klass.new(backend_info) interface.call end |