Sha256: b3a8493821b91e679e000717a4916f7115bdf77b3b0d475187099e8b7ccde2be

Contents?: true

Size: 1.64 KB

Versions: 6

Compression:

Stored size: 1.64 KB

Contents

module HybridPlatformsConductor

  module HpcPlugins

    module PlatformHandler

      class ServerlessChef < HybridPlatformsConductor::PlatformHandler

        # Small class that can get a Ruby DSL file and return all DSL calls that have been made to it
        class DslParser

          # List of calls made by parsing the source file
          # Array
          attr_reader :calls

          # Constructor
          #
          # Parameters::
          # * *calls* (Array): List of calls to complement [default = []]
          def initialize(calls = [])
            @calls = calls
          end

          # Parse a file and get all its DSL calls
          #
          # Parameters::
          # * *source* (String): File to parse
          def parse(source)
            instance_eval(File.read(source), source)
          end

          # Intercept all missing methods
          #
          # Parameters::
          # * *method_name* (Symbol): The missing method being called
          def method_missing(method_name, *args, &block)
            sub_calls = []
            @calls << {
              method: method_name,
              args: args,
              block: block,
              calls_on_result: sub_calls
            }
            DslParser.new(sub_calls)
          end

          # Make sure we register the methods we handle in method_missing
          #
          # Parameters::
          # * *name* (Symbol): The missing method name
          # * *include_private* (Boolean): Should we include private methods in the search?
          def respond_to_missing?(_name, _include_private)
            true
          end

        end

      end

    end

  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
hybrid_platforms_conductor-33.9.5 lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef/dsl_parser.rb
hybrid_platforms_conductor-33.9.4 lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef/dsl_parser.rb
hybrid_platforms_conductor-33.9.2 lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef/dsl_parser.rb
hybrid_platforms_conductor-33.9.1 lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef/dsl_parser.rb
hybrid_platforms_conductor-33.9.0 lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef/dsl_parser.rb
hybrid_platforms_conductor-33.8.4 lib/hybrid_platforms_conductor/hpc_plugins/platform_handler/serverless_chef/dsl_parser.rb