Sha256: 1d2e8220d5c004c8bc310903fe42c65d40c003e7d15a6269bb45214e91566ec1

Contents?: true

Size: 947 Bytes

Versions: 6

Compression:

Stored size: 947 Bytes

Contents

module ScaffoldParser
  module Scaffolders
    class XSD
      class Parser
        module Handlers
          module Utils
            def indent(lines_or_string)
              if lines_or_string.is_a? Array
                lines_or_string.map { |line| indent_string(line) }
              else
                indent_string(lines_or_string)
              end
            end

            def indent_string(string)
              string == "\n" ? string : string.prepend('  ')
            end

            def single_quote(string)
              string.to_s.gsub('"', '\'')
            end

            def wrap_in_namespace(klass, namespace)
              return klass unless namespace

              lines = klass.lines
              indented = indent(lines)

              indented.unshift "module #{namespace}\n"
              indented << "\nend"

              indented.join
            end
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
scaffold_parser-0.10.0 lib/scaffold_parser/scaffolders/xsd/parser/handlers/utils.rb
scaffold_parser-0.9.1 lib/scaffold_parser/scaffolders/xsd/parser/handlers/utils.rb
scaffold_parser-0.9.0 lib/scaffold_parser/scaffolders/xsd/parser/handlers/utils.rb
scaffold_parser-0.8.0 lib/scaffold_parser/scaffolders/xsd/parser/handlers/utils.rb
scaffold_parser-0.7.0 lib/scaffold_parser/scaffolders/xsd/parser/handlers/utils.rb
scaffold_parser-0.6.0 lib/scaffold_parser/scaffolders/xsd/parser/handlers/utils.rb