Sha256: 15fbfde127f0d5ae35c065e39b785f4a524916794ce4c29e157e21b292f906e6

Contents?: true

Size: 1.41 KB

Versions: 5

Compression:

Stored size: 1.41 KB

Contents

module Soybean
  module Generators
    class ServiceGenerator
      attr_reader :path, :wsdl_location, :wsdl

      def initialize(path, wsdl, spec_dir)
        @path, @wsdl_location = path, wsdl
        @wsdl = import_wsdl
        @spec_dir = spec_dir
        @schemes = @wsdl.importedschema.keys
      end

      def schemes
        @schemes.map { |url| TypesGenerator.new(url) }
      end

      def generate
        (schemes + mappings + interface + model + specs + middleware).map do |generator|
          yield generator.fullpath(path), generator.generate, generator
        end
      end

      def mappings
        @mappings ||= schemes.map { |gen| MappingGenerator.new(gen.xsd, @wsdl) }
      end

      def interface
        @interface ||= [InterfaceGenerator.new(@wsdl)]
      end

      def model
        @model ||= [ModelGenerator.new(@wsdl)]
      end

      def middleware
        @middleware ||= model.map { |m| MiddlewareGenerator.new(m) }
      end

      def specs
        @specs ||= model.map { |m| ModelSpecGenerator.new(m, @spec_dir) }
      end

      protected

      def dirs
        @dirs ||= %w{types mappings models interfaces}.inject(HashWithIndifferentAccess.new) do |dirs, dir|
          dirs[dir.singularize] = Pathname.new @base.empty_directory(File.join(destination_dir, dir))
          dirs
        end
      end

      def import_wsdl
        WSDL::Importer.import(@wsdl_location)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
soybean-2.4.3 lib/soybean/generators/service_generator.rb
soybean-2.4.2 lib/soybean/generators/service_generator.rb
soybean-2.4.1 lib/soybean/generators/service_generator.rb
soybean-2.4.0 lib/soybean/generators/service_generator.rb
soybean-2.3.0 lib/soybean/generators/service_generator.rb