Skip to content

Instantly share code, notes, and snippets.

@regularberry
Last active December 1, 2018 20:12
Show Gist options
  • Save regularberry/d446c087066bf1a90ec869c09b3989b1 to your computer and use it in GitHub Desktop.
Save regularberry/d446c087066bf1a90ec869c09b3989b1 to your computer and use it in GitHub Desktop.
{% macro methodSig method %}
func {{ method.name }}
{% if method.returnTypeName|!contains:"Void" %} -> {{method.returnTypeName}}{% endif %}
{% endmacro %}
{% for type in types.protocols %}
// sourcery:file:Mock{{ type.name }}.swift
import Foundation
class Mock{{ type.name }}: {{ type.name }} {
{% for method in type.allMethods %}
{% call methodSig method %}{
}
{% endfor %}
}
// sourcery:end
{% endfor %}
{% for type in types.protocols %}
// sourcery:file:{{ type.name}}.swift
import Foundation
protocol {{ type.name }} {
{% for method in type.allMethods %}
{% call methodSig method %}
{% endfor %}
}
struct Default{{ type.name }}: {{ type.name }} {
{% for method in type.allMethods %}
{% call methodSig method %}{
}
{% endfor %}
}
// sourcery:end
{% endfor %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment