Class: Orchparty::Transformations::Mixin
- Inherits:
-
Object
- Object
- Orchparty::Transformations::Mixin
- Defined in:
- lib/orchparty/transformations/mixin.rb
Instance Method Summary collapse
- #resolve_chart_name(mixin, application) ⇒ Object
- #resolve_mixin(mix, application, ast) ⇒ Object
- #transform(ast) ⇒ Object
- #transform_application(application, ast) ⇒ Object
- #transform_mixin(mixin, application, ast) ⇒ Object
Instance Method Details
#resolve_chart_name(mixin, application) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/orchparty/transformations/mixin.rb', line 19 def resolve_chart_name(mixin, application) # warn "ERROR: #{mixin} #{application}" if mixin.services[:_mixin_temp_name] mixin.services[application.name.to_s] = mixin.services.delete('_mixin_temp_name') mixin.services[application.name.to_s][:name] = application.name.to_s mixin._service_order.delete('_mixin_temp_name') mixin._service_order << application.name.to_s end mixin end |
#resolve_mixin(mix, application, ast) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/orchparty/transformations/mixin.rb', line 44 def resolve_mixin(mix, application, ast) mixin = if mix.include? '.' mixin_name, mixin_service_name = mix.split('.') if ast._mixins[mixin_name] ast._mixins[mixin_name]._mixins[mixin_service_name] else warn "ERROR: Could not find mixin '#{mixin_name}'." exit 1 end else application._mixins[mix] end if mixin.nil? warn "ERROR: Could not find mixin '#{mix}'." exit 1 end transform_mixin(mixin, application, ast) end |
#transform(ast) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/orchparty/transformations/mixin.rb', line 6 def transform(ast) ast.applications.transform_values! do |application| current = AST.application application._mix.each do |mixin_name| mixin = application._mixins[mixin_name] || ast._mixins[mixin_name] mixin = resolve_chart_name(mixin, application) current = current.deep_merge_concat(mixin) end transform_application(current.deep_merge_concat(application), ast) end ast end |
#transform_application(application, ast) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/orchparty/transformations/mixin.rb', line 30 def transform_application(application, ast) application.services = application.services.transform_values! do |service| current = AST.service service.delete(:_mix).compact.each do |mix| current = current.deep_merge_concat(resolve_mixin(mix, application, ast)) rescue StandardError warn "problems with #{mix}" raise end current.deep_merge_concat(service) end application end |
#transform_mixin(mixin, application, ast) ⇒ Object
63 64 65 66 67 68 69 70 |
# File 'lib/orchparty/transformations/mixin.rb', line 63 def transform_mixin(mixin, application, ast) current = AST.application_mixin mixin[:_mix].each do |mix| current = current.deep_merge_concat(resolve_mixin(mix, application, ast)) end current.deep_merge_concat(mixin) end |