gyro 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3f72b04e5d34ad6d93bb6a96d8c206be24d8f0f9
4
- data.tar.gz: be4c052362fa59db8bad14c5e3a0946004b36b02
3
+ metadata.gz: 2fc533a0c50dcdf240cbd07626f0ea83dbaea4f3
4
+ data.tar.gz: 0ac64d46fb1bd357f964396e3961359231ba62cc
5
5
  SHA512:
6
- metadata.gz: fc6c81d67e271ceabddacab4e1a88c303af9a49040af39d3f1b8b48a11632733364edabd4f2d294b09aa9a8b0254ace8532c465b360d4ce809eba4bda8b214b1
7
- data.tar.gz: 377f9d34d0a560f07e0af33c5a693ac5ff0579ebf70ecafc128dfff7a3abaf87c1c49448bd194f0e3d4f2554e6d274ab03d374e5cb86f1a20a69ff8c8c7c1b24
6
+ metadata.gz: fc2256f1fefc840d738345bfa2dfecd61020c0f3795c937f1a0bbcd458c7b2348e54df5f99e0b1e524aaa8f0400d14abddf7b105d4079a7fa8c8c3ba5bd97693
7
+ data.tar.gz: 3705920540f76e3d0c53fb2c311d500b95f412de79370ec40212d7fe32d9f6f8e6dad410524f1db411d991727a532273dc82186621d9399efbbf22b523bcdec0
data/lib/gyro/version.rb CHANGED
@@ -15,5 +15,5 @@
15
15
  # Gyro Version
16
16
  #
17
17
  module Gyro
18
- VERSION = '1.2.0'.freeze
18
+ VERSION = '1.3.0'.freeze
19
19
  end
@@ -0,0 +1,54 @@
1
+ # Android Template Information
2
+
3
+ | Name | Description |
4
+ | --------- | ----------------- |
5
+ | Folder name | templates/android-kotlin |
6
+ | Invocation example | `gyro -m <model> -t android-kotlin …` |
7
+ | Language | Kotlin |
8
+
9
+ If you want to use this template you need to work with `Realm`.
10
+
11
+ # Caracteristics
12
+
13
+ In this template you have additional parameters to inject constants :
14
+
15
+ - package (ex : **com.gyro.model.realm**)
16
+
17
+ # Usage
18
+
19
+
20
+ Package exemple :
21
+
22
+ ```bash
23
+ gyro -m <model> -t android-kotlin -o <output> --param package:com.gyro.model.realm
24
+ ```
25
+
26
+
27
+ # Generated Code
28
+
29
+ `FidelityCard.kt`:
30
+
31
+ ```kotlin
32
+ package com.gyro.model.realm
33
+
34
+ /* DO NOT EDIT | Generated by gyro */
35
+
36
+ import io.realm.RealmObject
37
+
38
+ class FidelityCard: RealmObject() {
39
+
40
+ object Attributes {
41
+ const val IDENTIFIER: String = "identifier";
42
+ const val POINTS: String = "points";
43
+ }
44
+
45
+ object Relationships {
46
+ const val USER: String = "user";
47
+ }
48
+
49
+ private var identifier: Short = 0;
50
+ private var points: Integer = 0;
51
+ private var user: User? = null;
52
+ }
53
+ ```
54
+
@@ -0,0 +1,52 @@
1
+ {%- if params.package.size > 0 -%}
2
+ package {{ params.package }}
3
+ {%- endif %}
4
+
5
+ /* DO NOT EDIT | Generated by gyro */
6
+ {{ empty_line }}
7
+
8
+ {%- comment %} ******* IMPORTS ******* {% endcomment -%}
9
+ {%- if entity.has_json_key_path == true %}
10
+ import com.google.gson.annotations.SerializedName
11
+ {% comment %} *** Empty line *** {% endcomment %}
12
+ {%- endif %}
13
+ {%- if entity.has_date_attribute == true %}
14
+ import java.util.Date
15
+ {%- endif %}
16
+ {%- if entity.has_list_relationship == true %}
17
+ import java.util.List
18
+ {%- endif %}
19
+ {%- if entity.has_date_attribute == true or entity.has_list_relationship == true %}
20
+ {{ empty_line }}
21
+ {%- endif %}
22
+ {%- if entity.has_list_attributes == true %}
23
+ import io.realm.RealmList
24
+ {%- endif %}
25
+ import io.realm.RealmObject
26
+ {%- if entity.has_ignored == true %}
27
+ import io.realm.annotations.Ignore
28
+ {%- endif %}
29
+ {%- if entity.has_indexed_attributes == true %}
30
+ import io.realm.annotations.Index
31
+ {%- endif %}
32
+ {%- if entity.has_primary_key == true %}
33
+ import io.realm.annotations.PrimaryKey
34
+ {%- endif %}
35
+ {%- if entity.has_required == true %}
36
+ import io.realm.annotations.Required
37
+ {%- endif %}
38
+
39
+ {% if entity.comment.size > 0 -%}
40
+ /**
41
+ * {{ entity.comment }}
42
+ */
43
+ {% endif %}
44
+ {%- assign primary_key = entity.identity_attribute -%}
45
+ open class {{ entity.name }} : RealmObject() {
46
+
47
+ {%- include 'inc/attributes_enum' %}
48
+ {%- include 'inc/relationships_enum' %}
49
+ {% include 'inc/attributes_properties' %}
50
+ {%- include 'inc/relationships_properties' %}
51
+ {%- include 'inc/enum_getter_setter' %}
52
+ }
@@ -0,0 +1 @@
1
+ {{params.prefix}}{{name}}.kt
@@ -0,0 +1,29 @@
1
+ {%- if attribute.enum_type.size > 0 -%}
2
+
3
+ {%- if params.package.size > 0 -%}
4
+ package {{ params.package }}
5
+ {%- endif %}
6
+
7
+ /* DO NOT EDIT | Generated by gyro */
8
+ {{ empty_line }}
9
+
10
+ enum class {{ attribute.enum_type }}(val jsonValue: String) {
11
+ {% for value in attribute.enum_values %}
12
+ {% if attribute.enum_values.size > 0 %}
13
+ {%- assign jsonKey = value -%}
14
+ {%- if attribute.json_values.size > 0 and attribute.json_values[forloop.index0] -%}
15
+ {%- assign jsonKey = attribute.json_values[forloop.index0] -%}
16
+ {%- endif -%}
17
+ {{ value | snake_case | upcase | strip }}("{{ jsonKey }}")
18
+ {%- if forloop.last == true -%};{%- else -%},{%- endif -%}
19
+ {%- endif -%}
20
+ {%- endfor %}
21
+
22
+ companion object {
23
+ @JvmStatic
24
+ fun get(jsonValue: String): {{ attribute.enum_type }}? {
25
+ return {{ attribute.enum_type }}.values().firstOrNull { it.jsonValue == jsonValue }
26
+ }
27
+ }
28
+ }
29
+ {%- endif %}
@@ -0,0 +1 @@
1
+ {{params.prefix}}{{name}}.kt
@@ -0,0 +1,13 @@
1
+ {%- if entity.attributes.size > 0 %}
2
+
3
+ object Attributes {
4
+ {%- for attribute in entity.attributes -%}
5
+ {%- if attribute.realm_ignored == false or attribute.read_only == false -%}
6
+ {%- if attribute.comment.size > 0 %}
7
+ // {{ attribute.comment }}
8
+ {%- endif %}
9
+ const val {{ attribute.name | snake_case | upcase }}: String = "{{ attribute.name }}"
10
+ {%- endif -%}
11
+ {%- endfor %}
12
+ }
13
+ {%- endif -%}
@@ -0,0 +1,60 @@
1
+ {% for attribute in entity.attributes -%}
2
+ {%- if attribute.realm_read_only.size == 0 -%}
3
+ {%- comment %} ******* CONVERT TYPE CAPTURE ******* {% endcomment -%}
4
+ {%- capture convert_type -%}
5
+ {%- if attribute.realm_read_only.size == 0 and attribute.enum_type.size > 0 -%}
6
+ String
7
+ {%- else -%}
8
+ {%- include 'inc/type_converter' -%}
9
+ {%- endif -%}
10
+ {%- endcapture -%}
11
+
12
+ {%- capture is_primitive %}
13
+ {%- if attribute.realm_read_only.size == 0 and attribute.enum_type.size > 0 -%}
14
+ false
15
+ {%- else -%}
16
+ {%- include 'inc/type_primitives' -%}
17
+ {%- endif -%}
18
+ {%- endcapture -%}
19
+
20
+ {%- capture default_value %}
21
+ {%- if attribute.default.size > 0 %} =
22
+ {%- if convert_type == "Boolean" %}
23
+ {%- if attribute.default == "YES" %} true {%- else %} false {%- endif %}
24
+ {%- elsif convert_type == "String" %} "{{ attribute.default }}"
25
+ {%- else %} {{ attribute.default }}
26
+ {%- endif %}
27
+ {%- elsif attribute.enum_type.size > 0 %} =
28
+ {%- if attribute.optional == true %} null
29
+ {%- else %} "{{ attribute.enum_values.first }}"
30
+ {%- endif -%}
31
+ {%- else %} =
32
+ {%- if attribute.optional == true and is_primitive == "false" %} null
33
+ {%- else %} {% include 'inc/type_defaults' -%}
34
+ {%- endif %}
35
+ {%- endif %}
36
+ {%- endcapture %}
37
+
38
+ {%- capture nullable_type %}
39
+ {%- if attribute.optional == true %}?{%- endif -%}
40
+ {%- endcapture %}
41
+
42
+ {%- assign name = attribute.name -%}
43
+ {%- if name == primary_key %}
44
+ @PrimaryKey
45
+ {%- endif -%}
46
+ {%- if attribute.optional == false and attribute.realm_ignored == false and name != primary_key and is_primitive == "false" %}
47
+ @Required
48
+ {%- endif -%}
49
+ {%- if attribute.indexed == true %}
50
+ @Index
51
+ {%- endif -%}
52
+ {%- if attribute.realm_ignored == true %}
53
+ @Ignore
54
+ {%- endif -%}
55
+ {%- if attribute.json_key_path.size > 0 %}
56
+ @SerializedName("{{ attribute.json_key_path }}")
57
+ {%- endif %}
58
+ var {{ name }}: {{ convert_type }}{{ nullable_type }}{{ default_value }}
59
+ {%- endif -%}
60
+ {%- endfor -%}
@@ -0,0 +1,13 @@
1
+ {%- for attribute in entity.attributes %}
2
+
3
+ {%- if attribute.realm_read_only.size == 0 and attribute.enum_type.size > 0 %}
4
+ {%- assign name = attribute.name %}
5
+
6
+ fun get{{ name | titleize }}Enum(): {{ attribute.enum_type }}? = {{ attribute.enum_type }}.get({{ name }})
7
+
8
+ fun set{{ name | titleize }}Enum({{ name }}: {{ attribute.enum_type }}) {
9
+ this.{{ name }} = {{ name }}.jsonValue
10
+ }
11
+ {%- endif -%}
12
+
13
+ {%- endfor -%}
@@ -0,0 +1,30 @@
1
+ {%- capture convert_type %}
2
+ {%- if attribute.realm_read_only.size == 0 and attribute.enum_type.size > 0 -%}
3
+ String
4
+ {%- else -%}
5
+ {%- if params.use_wrappers.size > 0 and attribute.optional == true -%}
6
+ {%- include 'inc/wrapper_type_converter' -%}
7
+ {%- else -%}
8
+ {%- include 'inc/type_converter' -%}
9
+ {%- endif %}
10
+ {%- endif %}
11
+ {%- endcapture %}
12
+
13
+ {%- case convert_type -%}
14
+ {%- when 'integer_16' or 'short' -%}
15
+ true
16
+ {%- when 'integer_32' or 'int' -%}
17
+ true
18
+ {%- when 'integer_64' or 'long' -%}
19
+ true
20
+ {%- when 'double' or 'decimal' -%}
21
+ true
22
+ {%- when 'float' -%}
23
+ true
24
+ {%- when 'boolean' -%}
25
+ true
26
+ {%- when 'binary' -%}
27
+ true
28
+ {%- else -%}
29
+ false
30
+ {%- endcase -%}
@@ -0,0 +1,10 @@
1
+ {%- if entity.relationships.size > 0 and entity.has_only_inverse == false %}
2
+
3
+ object Relationships {
4
+ {%- for relationship in entity.relationships -%}
5
+ {%- if relationship.inverse == false %}
6
+ const val {{ relationship.name | snake_case | upcase }}: String = "{{ relationship.name }}"
7
+ {%- endif -%}
8
+ {%- endfor %}
9
+ }
10
+ {%- endif -%}
@@ -0,0 +1,27 @@
1
+ {%- for relationship in entity.relationships -%}
2
+ {%- capture relationship_type -%}
3
+ {%- if relationship.realm_read_only.size == 0 and relationship.enum_type.size > 0 -%}
4
+ String
5
+ {%- else -%}
6
+ {%- if relationship.destination.size == 0 -%}
7
+ {%- if relationship.type != "to_many" -%}
8
+ {{ relationship.inverse_type }}
9
+ {%- else -%}
10
+ RealmList<{{ relationship.inverse_type }}>
11
+ {%- endif -%}
12
+ {%- else -%}
13
+ List<{{ relationship.destination }}>
14
+ {%- endif -%}
15
+ {%- endif -%}
16
+ {%- endcapture -%}
17
+
18
+ {%- if relationship.inverse == false -%}
19
+ {%- if relationship.realm_ignored == true %}
20
+ @Ignore
21
+ {%- endif -%}
22
+ {%- if relationship.json_key_path.size > 0 %}
23
+ @SerializedName("{{ relationship.json_key_path }}")
24
+ {%- endif %}
25
+ var {{ relationship.name }}: {{ relationship_type }}? = null
26
+ {%- endif -%}
27
+ {%- endfor -%}
@@ -0,0 +1,22 @@
1
+ {%- case attribute.type -%}
2
+ {%- when 'integer_16' -%}
3
+ Short
4
+ {%- when 'integer_32' -%}
5
+ Int
6
+ {%- when 'integer_64' -%}
7
+ Long
8
+ {%- when 'double' or 'decimal' -%}
9
+ Double
10
+ {%- when 'float' -%}
11
+ Float
12
+ {%- when 'string' -%}
13
+ String
14
+ {%- when 'boolean' -%}
15
+ Boolean
16
+ {%- when 'date' -%}
17
+ Date
18
+ {%- when 'binary' -%}
19
+ ByteArray
20
+ {%- else -%}
21
+ String
22
+ {%- endcase -%}
@@ -0,0 +1,22 @@
1
+ {%- case attribute.type -%}
2
+ {%- when 'integer_16' -%}
3
+ 0
4
+ {%- when 'integer_32' -%}
5
+ 0
6
+ {%- when 'integer_64' -%}
7
+ 0l
8
+ {%- when 'double' or 'decimal' -%}
9
+ 0.0
10
+ {%- when 'float' -%}
11
+ 0.0f
12
+ {%- when 'string' -%}
13
+ ""
14
+ {%- when 'boolean' -%}
15
+ false
16
+ {%- when 'date' -%}
17
+ Date()
18
+ {%- when 'binary' -%}
19
+ ByteArray()
20
+ {%- else -%}
21
+ ""
22
+ {%- endcase -%}
@@ -0,0 +1,22 @@
1
+ {%- case attribute.type -%}
2
+ {%- when 'integer_16' -%}
3
+ true
4
+ {%- when 'integer_32' -%}
5
+ true
6
+ {%- when 'integer_64' -%}
7
+ true
8
+ {%- when 'double' or 'decimal' -%}
9
+ true
10
+ {%- when 'float' -%}
11
+ true
12
+ {%- when 'string' -%}
13
+ false
14
+ {%- when 'boolean' -%}
15
+ true
16
+ {%- when 'date' -%}
17
+ false
18
+ {%- when 'binary' -%}
19
+ false
20
+ {%- else -%}
21
+ false
22
+ {%- endcase -%}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gyro
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - NijiDigital
@@ -80,6 +80,20 @@ files:
80
80
  - lib/gyro/parser/xcdatamodel/xcdatamodel.rb
81
81
  - lib/gyro/template.rb
82
82
  - lib/gyro/version.rb
83
+ - lib/templates/android-kotlin/README.md
84
+ - lib/templates/android-kotlin/entity.liquid
85
+ - lib/templates/android-kotlin/entity_filename.liquid
86
+ - lib/templates/android-kotlin/enum.liquid
87
+ - lib/templates/android-kotlin/enum_filename.liquid
88
+ - lib/templates/android-kotlin/inc/_attributes_enum.liquid
89
+ - lib/templates/android-kotlin/inc/_attributes_properties.liquid
90
+ - lib/templates/android-kotlin/inc/_enum_getter_setter.liquid
91
+ - lib/templates/android-kotlin/inc/_primitives.liquid
92
+ - lib/templates/android-kotlin/inc/_relationships_enum.liquid
93
+ - lib/templates/android-kotlin/inc/_relationships_properties.liquid
94
+ - lib/templates/android-kotlin/inc/_type_converter.liquid
95
+ - lib/templates/android-kotlin/inc/_type_defaults.liquid
96
+ - lib/templates/android-kotlin/inc/_type_primitives.liquid
83
97
  - lib/templates/android/README.md
84
98
  - lib/templates/android/entity.liquid
85
99
  - lib/templates/android/entity_filename.liquid