gyro 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +19 -9
- data/lib/gyro/generator/liquid/liquid.rb +0 -2
- data/lib/gyro/log.rb +21 -4
- data/lib/gyro/parser/xcdatamodel/entity.rb +1 -1
- data/lib/gyro/parser/xcdatamodel/relationship.rb +2 -2
- data/lib/gyro/template.rb +72 -24
- data/lib/gyro/version.rb +1 -1
- data/lib/templates/{android → android-java}/README.md +7 -7
- data/lib/templates/{android → android-java}/entity.liquid +3 -0
- data/lib/templates/{android → android-java}/entity_filename.liquid +0 -0
- data/lib/templates/{android → android-java}/enum.liquid +0 -0
- data/lib/templates/{android → android-java}/enum_filename.liquid +0 -0
- data/lib/templates/{android → android-java}/inc/_attributes_enum.liquid +0 -0
- data/lib/templates/{android → android-java}/inc/_attributes_getter_setter.liquid +0 -0
- data/lib/templates/{android → android-java}/inc/_attributes_properties.liquid +7 -0
- data/lib/templates/{android → android-java}/inc/_enum_getter_setter.liquid +0 -0
- data/lib/templates/{android → android-java}/inc/_primitives.liquid +0 -0
- data/lib/templates/{android → android-java}/inc/_relationships_enum.liquid +0 -0
- data/lib/templates/{android → android-java}/inc/_relationships_getter_setter.liquid +0 -0
- data/lib/templates/{android → android-java}/inc/_relationships_properties.liquid +0 -0
- data/lib/templates/{android → android-java}/inc/_type_converter.liquid +0 -0
- data/lib/templates/{android → android-java}/inc/_wrapper_type_converter.liquid +0 -0
- data/lib/templates/android-kotlin/README.md +1 -1
- data/lib/templates/android.alias +10 -0
- data/lib/templates/swift3-variant/README.md +3 -1
- data/lib/templates/swift3/README.md +1 -1
- data/lib/templates/swift3/inc/_attributes_enum.liquid +1 -1
- data/lib/templates/swift3/inc/_attributes_properties.liquid +7 -9
- data/lib/templates/swift3/inc/_optional_attribute_property.liquid +2 -2
- data/lib/templates/swift4.alias +6 -0
- metadata +18 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e5f08df0670a25b7dc526fa689e6c92ae3e510f
|
4
|
+
data.tar.gz: f46dabd9dc80b7eb665af3cf3b732c3d647784c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c73b447c3038e8c3a3b949984e6bb600519c2fe2dbbb44b9a989d4e31ce61bb384a594a68e1ebac0d2a149af557c7e482d9d70ac574d4ab25e37e891b6c2f2db
|
7
|
+
data.tar.gz: 8f16dae895a213e8e637ded30569eff086e2ce7d33cf88ddebd02dc34cad3fd27d729c9fbfa1bcb5581baa477725460c0f1d172c0e7764bf8fce47d900e062ec
|
data/README.md
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
[![build circle ci](https://img.shields.io/circleci/project/github/NijiDigital/gyro.svg?style=flat-square)](https://circleci.com/gh/NijiDigital/gyro)
|
6
6
|
[![Twitter](https://img.shields.io/badge/twitter-@Niji_Digital-blue.svg?style=flat-square)](http://twitter.com/Niji_Digital)
|
7
7
|
|
8
|
-
Gyro is a tool to generate [Realm](https://realm.io) model classes, for both Android (Java) and iOS/macOS (Swift), from an `.xcdatamodel` file.
|
8
|
+
Gyro is a tool to generate [Realm](https://realm.io) model classes, for both Android (Java & Kotlin) and iOS/macOS (Swift), from an `.xcdatamodel` file.
|
9
9
|
|
10
10
|
---
|
11
11
|
<center><table><tr>
|
@@ -42,7 +42,7 @@ _Alternativly, you could also clone this repository anywhere you want on your ma
|
|
42
42
|
|
43
43
|
```bash
|
44
44
|
gem build gyro.gemspec
|
45
|
-
gem install gyro
|
45
|
+
gem install gyro-*.gem
|
46
46
|
```
|
47
47
|
|
48
48
|
## Usage
|
@@ -58,13 +58,21 @@ gyro --model <model> --template <template-name> --output <output-dir> --param <k
|
|
58
58
|
|
59
59
|
`<template-name>` is the name of the template. Below you have the list of templates.
|
60
60
|
|
61
|
-
If you want additional information about templates you can go to the documentation for each :
|
62
61
|
|
63
|
-
|
64
|
-
|
65
|
-
-
|
66
|
-
|
67
|
-
-
|
62
|
+
## Templates
|
63
|
+
|
64
|
+
You can use `gyro -l` to list the names of all the bundled templates available.
|
65
|
+
|
66
|
+
If you want additional information about a specific template, you can use `gyro -i <template_name>` to print its README documentation, which is also directly accessible on GitHub via the following links:
|
67
|
+
|
68
|
+
- [android-java](lib/templates/android-java/README.md) (Java)
|
69
|
+
- _Note: `android` is an alias name for the [android-java](lib/templates/android-java/README.md) template_
|
70
|
+
- [android-kotlin](lib/templates/android-kotlin/README.md) (Kotlin)
|
71
|
+
- [swift3](lib/templates/swift3/README.md) (Swift 3 & 4)
|
72
|
+
- _Note: `swift4` is an alias name for the [swift3](lib/templates/swift3/README.md) template_
|
73
|
+
- [decodable](lib/templates/decodable/README.md) (for Anviking's `Decodable` pod)
|
74
|
+
- [swift3-variant](lib/templates/swift3-variant/README.md) _(Deprecated, only for use with the `object-mapper` template)_
|
75
|
+
- [object-mapper](lib/templates/object-mapper/README.md) _(Deprecated)_
|
68
76
|
|
69
77
|
## Annotating your `xcdatamodel`
|
70
78
|
|
@@ -76,7 +84,9 @@ _To define a User Info key in Xcode's xcdatamodel editor, select the entity or a
|
|
76
84
|
|
77
85
|
With the help of these "user infos", you will be able to give Gyro extra information about your model classes. For example, you can tell which attribute is the primary key, the attributes to ignore, the JSON mappings, …
|
78
86
|
|
79
|
-
|
87
|
+
### 📖 Documentation of User Info Keys
|
88
|
+
|
89
|
+
For more information about each "user infos" keys supported, you can see the 📖 [dedicated documentation here](UserInfoKeys.md).
|
80
90
|
|
81
91
|
## License
|
82
92
|
|
@@ -21,7 +21,6 @@ module Gyro
|
|
21
21
|
|
22
22
|
# PUBLIC METHODS #######################################################
|
23
23
|
|
24
|
-
# rubocop:disable Metrics/AbcSize
|
25
24
|
def initialize(template_dir, output_dir, params)
|
26
25
|
Gyro::Log.title('Generating Model')
|
27
26
|
|
@@ -38,7 +37,6 @@ module Gyro
|
|
38
37
|
enum_fn_tpl = template_dir + 'filename.liquid' unless enum_fn_tpl.exist?
|
39
38
|
@enum_filename_template = load_template(enum_fn_tpl, true)
|
40
39
|
end
|
41
|
-
# rubocop:enable Metrics/AbcSize
|
42
40
|
|
43
41
|
def generate(xcdatamodel)
|
44
42
|
generate_entities(xcdatamodel)
|
data/lib/gyro/log.rb
CHANGED
@@ -22,19 +22,19 @@ module Gyro
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def self.title(str) # bg yellow
|
25
|
-
puts "\n
|
25
|
+
puts "\n#{str.colorize(:gray, :blue)}" unless @quiet
|
26
26
|
end
|
27
27
|
|
28
28
|
def self.error(str)
|
29
|
-
puts "
|
29
|
+
puts "! #{str}".colorize(:red, :bold) unless @quiet
|
30
30
|
end
|
31
31
|
|
32
32
|
def self.info(str)
|
33
|
-
puts "
|
33
|
+
puts "> #{str}".colorize(:yellow, :bold) unless @quiet
|
34
34
|
end
|
35
35
|
|
36
36
|
def self.success(str)
|
37
|
-
puts "
|
37
|
+
puts "√ #{str}".colorize(:green, :bold) unless @quiet
|
38
38
|
end
|
39
39
|
|
40
40
|
def self.fail!(message, stacktrace: false)
|
@@ -44,3 +44,20 @@ module Gyro
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
47
|
+
|
48
|
+
# Extending Ruby's String type to allow colorization via ANSI control codes
|
49
|
+
#
|
50
|
+
class String
|
51
|
+
ANSI_COLORS = %i[black red green yellow blue magenta cyan gray white].freeze
|
52
|
+
ANSI_MODES = %i[normal bold faint italic underline blink].freeze
|
53
|
+
|
54
|
+
def colorize(fg = :white, *options)
|
55
|
+
fg_code = 30 + (ANSI_COLORS.index(fg) || 7)
|
56
|
+
other_codes = options.map do |opt|
|
57
|
+
bg = ANSI_COLORS.index(opt)
|
58
|
+
bg.nil? ? ANSI_MODES.index(opt) : 40 + bg
|
59
|
+
end
|
60
|
+
codes = [fg_code, *other_codes].compact.join(';')
|
61
|
+
"\e[#{codes}m#{self}\e[0m"
|
62
|
+
end
|
63
|
+
end
|
@@ -36,7 +36,7 @@ module Gyro
|
|
36
36
|
|
37
37
|
def to_h
|
38
38
|
{
|
39
|
-
'attributes' => attributes.values.map(&:to_h),
|
39
|
+
'attributes' => attributes.values.sort_by { |a| a.name == identity_attribute ? '__' : a.name }.map(&:to_h),
|
40
40
|
'relationships' => relationships.values.map(&:to_h),
|
41
41
|
'name' => name,
|
42
42
|
'parent' => parent,
|
@@ -26,7 +26,7 @@ module Gyro
|
|
26
26
|
alias realm_ignored? realm_ignored
|
27
27
|
alias json_ignored? json_ignored
|
28
28
|
|
29
|
-
# rubocop:disable Metrics/AbcSize
|
29
|
+
# rubocop:disable Metrics/AbcSize
|
30
30
|
def initialize(relationship_xml, entity_name)
|
31
31
|
@entity_name = entity_name
|
32
32
|
@name = relationship_xml.attributes['name'].to_s
|
@@ -51,7 +51,7 @@ module Gyro
|
|
51
51
|
'support_annotation' => support_annotation,
|
52
52
|
'realm_ignored' => realm_ignored, 'destination' => destination, 'inverse' => inverse? }
|
53
53
|
end
|
54
|
-
# rubocop:enable Metrics/AbcSize
|
54
|
+
# rubocop:enable Metrics/AbcSize
|
55
55
|
|
56
56
|
def to_s
|
57
57
|
"\tRelationship => name=#{@name} | type=#{@type} | optional=#{@optional} | deletion_rule=#{@deletion_rule}\n"
|
data/lib/gyro/template.rb
CHANGED
@@ -17,52 +17,100 @@ module Gyro
|
|
17
17
|
#
|
18
18
|
module Template
|
19
19
|
def self.print_list
|
20
|
-
Gyro::Template.directory.children.
|
21
|
-
|
20
|
+
Gyro::Template.directory.children.sort_by(&:basename).each do |entry|
|
21
|
+
alias_name, target = Gyro::Template.resolve_alias(entry)
|
22
|
+
if alias_name
|
23
|
+
puts [
|
24
|
+
' - '.colorize(:gray, :faint),
|
25
|
+
alias_name.colorize(:gray),
|
26
|
+
' (alias for '.colorize(:gray, :faint),
|
27
|
+
target.colorize(:gray),
|
28
|
+
')'.colorize(:gray, :faint)
|
29
|
+
].join
|
30
|
+
elsif entry.directory?
|
31
|
+
puts ' - ' + entry.basename.to_s
|
32
|
+
end
|
22
33
|
end
|
23
34
|
end
|
24
35
|
|
25
36
|
def self.print_infos(template)
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
Gyro::Template.directory + template + 'README.md'
|
30
|
-
end
|
37
|
+
template_dir = Gyro::Template.find(template, false)
|
38
|
+
Gyro::Log.fail!("No template found at path or for name '#{template}'.") unless template_dir
|
39
|
+
readme = template_dir + 'README.md'
|
31
40
|
|
32
41
|
Gyro::Log.fail!("No README.md found for template #{template}.") unless readme.exist?
|
33
42
|
puts readme.read
|
34
43
|
end
|
35
44
|
|
45
|
+
# Returns the Pathname representing the directory where all bundled templates are located
|
46
|
+
#
|
36
47
|
def self.directory
|
37
48
|
Pathname.new(File.dirname(__FILE__)) + '../templates'
|
38
49
|
end
|
39
50
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
51
|
+
# @param [Pathname] entry
|
52
|
+
# The alias to resolve
|
53
|
+
# @return [(String, String)]
|
54
|
+
# A 2-items array of [the alias name, the alias target name]
|
55
|
+
# Or nil if the entry does not correspond to a valid template alias
|
56
|
+
#
|
57
|
+
def self.resolve_alias(entry)
|
58
|
+
return nil unless entry.exist?
|
59
|
+
return nil if entry.extname != '.alias'
|
60
|
+
base = entry.basename('.alias').to_s
|
61
|
+
target = entry.open(&:readline).chomp # Only read the first line of the file, the rest is ignored
|
62
|
+
return nil if File.basename(target) != target || target.include?('..') # Security measure
|
63
|
+
[base, target]
|
64
|
+
end
|
65
|
+
|
66
|
+
# Resolve alias by name
|
67
|
+
#
|
68
|
+
# @return [(String, String)]
|
69
|
+
# A 2-items array of [the alias name, the alias target name]
|
70
|
+
# Or nil if the name does not correspond to a valid template alias
|
71
|
+
#
|
72
|
+
def self.resolve_alias_name(name)
|
73
|
+
path = Gyro::Template.directory + (name + '.alias')
|
74
|
+
resolve_alias(path)
|
75
|
+
end
|
76
|
+
|
77
|
+
# @param [String] template_param
|
78
|
+
# The name or path of the template to find
|
79
|
+
# @return [Pathname]
|
80
|
+
# The path to the template corresponding to that name or path
|
81
|
+
#
|
82
|
+
def self.find(template_param, fail_on_error = true)
|
83
|
+
template = if template_param.include?('/')
|
84
|
+
find_by_path(template_param)
|
85
|
+
else
|
86
|
+
find_by_name(template_param)
|
87
|
+
end
|
88
|
+
if template.nil? && fail_on_error
|
89
|
+
Gyro::Log.fail!('You need to specify a valid template directory or name' \
|
90
|
+
' using the --template parameter (see --help for more info)')
|
45
91
|
end
|
92
|
+
template
|
46
93
|
end
|
47
94
|
|
95
|
+
# @param [String] path
|
96
|
+
# The path to the template to find
|
97
|
+
# @return [Pathname]
|
98
|
+
# The path to the template corresponding to that name or path
|
99
|
+
#
|
48
100
|
def self.find_by_path(path)
|
49
101
|
template_dir = Pathname.new(path)
|
50
|
-
unless template_dir.exist?
|
51
|
-
Gyro::Log.fail!('You need to specify existing template directory using --template option' \
|
52
|
-
' (see --help for more info)')
|
53
|
-
end
|
54
|
-
|
55
102
|
return template_dir if template_dir.directory?
|
56
|
-
return template_dir.dirname if template_dir.file?
|
57
|
-
Gyro::Log.fail!('You need to specify right template directory using --template option' \
|
58
|
-
' (see --help for more info)')
|
59
103
|
end
|
60
104
|
|
105
|
+
# @param [String] name
|
106
|
+
# The name of the template to find among the templates bundled with gyro
|
107
|
+
# @return [Pathname]
|
108
|
+
# The path to the template corresponding to that name or path
|
109
|
+
#
|
61
110
|
def self.find_by_name(name)
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
' (see --help for more info)')
|
111
|
+
_, target = Gyro::Template.resolve_alias_name(name)
|
112
|
+
template_dir = Gyro::Template.directory + (target || name)
|
113
|
+
return template_dir if template_dir.directory?
|
66
114
|
end
|
67
115
|
end
|
68
116
|
end
|
data/lib/gyro/version.rb
CHANGED
@@ -2,13 +2,13 @@
|
|
2
2
|
|
3
3
|
| Name | Description |
|
4
4
|
| --------- | ----------------- |
|
5
|
-
| Folder name | templates/android |
|
6
|
-
| Invocation example | `gyro -m <model> -t android …` |
|
5
|
+
| Folder name | templates/android-java |
|
6
|
+
| Invocation example | `gyro -m <model> -t android-java …` |
|
7
7
|
| Language | Java |
|
8
8
|
|
9
9
|
If you want to use this template you need to work with `Realm`.
|
10
10
|
|
11
|
-
#
|
11
|
+
# Characteristics
|
12
12
|
|
13
13
|
In this template you have additional parameters to inject constants :
|
14
14
|
|
@@ -22,25 +22,25 @@ In this template you have additional parameters to inject constants :
|
|
22
22
|
Package exemple :
|
23
23
|
|
24
24
|
```bash
|
25
|
-
gyro -m <model> -t android -o <output> --param package:com.gyro.model.realm
|
25
|
+
gyro -m <model> -t android-java -o <output> --param package:com.gyro.model.realm
|
26
26
|
```
|
27
27
|
|
28
28
|
Use wrappers exemple :
|
29
29
|
|
30
30
|
```bash
|
31
|
-
gyro -m <model> -t android -o <output> --param use_wrappers:true
|
31
|
+
gyro -m <model> -t android-java -o <output> --param use_wrappers:true
|
32
32
|
```
|
33
33
|
|
34
34
|
Support annotations exemple :
|
35
35
|
|
36
36
|
```bash
|
37
|
-
gyro -m <model> -t android -o <output> --param support_annotations:true
|
37
|
+
gyro -m <model> -t android-java -o <output> --param support_annotations:true
|
38
38
|
```
|
39
39
|
|
40
40
|
And you can combine options :
|
41
41
|
|
42
42
|
```bash
|
43
|
-
gyro -m <model> -t android -o <output> --param package:com.gyro.model.realm --param support_annotations:true --param use_wrappers:true
|
43
|
+
gyro -m <model> -t android-java -o <output> --param package:com.gyro.model.realm --param support_annotations:true --param use_wrappers:true
|
44
44
|
```
|
45
45
|
|
46
46
|
|
@@ -30,6 +30,9 @@ import io.realm.annotations.Index;
|
|
30
30
|
{%- if entity.has_primary_key == true %}
|
31
31
|
import io.realm.annotations.PrimaryKey;
|
32
32
|
{%- endif %}
|
33
|
+
{%- if entity.has_required == true %}
|
34
|
+
import io.realm.annotations.Required;
|
35
|
+
{%- endif %}
|
33
36
|
|
34
37
|
{% if entity.comment.size > 0 -%}
|
35
38
|
/**
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -25,9 +25,16 @@
|
|
25
25
|
{%- endif %}
|
26
26
|
{%- endcapture %}
|
27
27
|
|
28
|
+
{%- capture isPrimitives %}
|
29
|
+
{%- include 'inc/primitives' %}
|
30
|
+
{%- endcapture %}
|
31
|
+
|
28
32
|
{%- assign name = attribute.name -%}
|
29
33
|
{%- if name == primary_key %}
|
30
34
|
@PrimaryKey
|
35
|
+
{%- endif -%}
|
36
|
+
{%- if attribute.optional == false and attribute.realm_ignored == false and name != primary_key and isPrimitives == "false" %}
|
37
|
+
@Required
|
31
38
|
{%- endif -%}
|
32
39
|
{%- if attribute.indexed == true %}
|
33
40
|
@Index
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,10 @@
|
|
1
|
+
android-java
|
2
|
+
|
3
|
+
=== Note ===
|
4
|
+
|
5
|
+
The template named 'android-java' was originally just named `android`
|
6
|
+
and was written in Java before Kotlin even existed.
|
7
|
+
|
8
|
+
So this alias exists mainly for compatibility reasons, so that people
|
9
|
+
who used `-t android` in previous versions of `gyro` can still continue
|
10
|
+
to do so and that this new update of gyro doesn't break their setup.
|
@@ -10,7 +10,7 @@
|
|
10
10
|
|
11
11
|
When you need to work with `ObjectMapper` and `Realm` together
|
12
12
|
|
13
|
-
#
|
13
|
+
# Characteristics
|
14
14
|
|
15
15
|
In this template optional Realm objects (Attributes - RealmOptional - or Relationships - List<> -) are var properties :
|
16
16
|
|
@@ -32,6 +32,8 @@ In this template optional Realm objects (Attributes - RealmOptional - or Relatio
|
|
32
32
|
{%- endif %}
|
33
33
|
```
|
34
34
|
|
35
|
+
This is not recommanded by Realm, and not conform to the Realm documentation (and can lead to bad behaviors with Realm if you happen to affect a new `List` or `RealmOptional` instance to those properties) but sadly this is required to work with the deprecated `ObjectMapper` template.
|
36
|
+
|
35
37
|
# Generated Code
|
36
38
|
|
37
39
|
`Product.swift`
|
@@ -11,7 +11,7 @@
|
|
11
11
|
This template is the reference for swift 3 with Realm generation code. This template is compatible with swift 4.
|
12
12
|
You can use it when you need to work with `Realm`
|
13
13
|
|
14
|
-
#
|
14
|
+
# Characteristics
|
15
15
|
|
16
16
|
In this template optional Realm objects (Attributes - RealmOptional - or Relationships - List<> -) are `let` properties (conform to the Realm documentation) :
|
17
17
|
|
@@ -6,7 +6,7 @@
|
|
6
6
|
{%- if attribute.comment.size > 0 %}
|
7
7
|
/** {{ attribute.comment }} **/
|
8
8
|
{%- endif %}
|
9
|
-
case {{ attribute.name }} = "{{ attribute.name | escape_quotes }}"
|
9
|
+
case {{ attribute.name }} = "{{ attribute.name | escape_quotes }}"{% if attribute.name == entity.identity_attribute %} /* Primary Key */{% endif %}
|
10
10
|
{%- endif %}
|
11
11
|
{%- endfor %}
|
12
12
|
}
|
@@ -13,15 +13,13 @@
|
|
13
13
|
{%- if attribute.enum_values.size > 0 -%}
|
14
14
|
{%- comment -%} ******* GENERATE ENUM ATTRIBUTE PROPERTY ******* {% endcomment -%}
|
15
15
|
{%- include 'inc/enum_attribute_property' -%}
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
{%- endif -%}
|
24
|
-
{%- endif -%}
|
16
|
+
{%- else -%}{%- if attribute.optional == true -%}
|
17
|
+
{% comment -%} ******* GENERATE OPTIONAL ATTRIBUTE PROPERTY ******* {% endcomment -%}
|
18
|
+
{%- include 'inc/optional_attribute_property' -%}
|
19
|
+
{%- else -%}
|
20
|
+
{%- comment -%} ******* GENERATE DEFAULT ATTRIBUTE PROPERTY ******* {% endcomment %}
|
21
|
+
@objc dynamic var {{ attribute.name }}: {{ convert_type }} = {{ default_value }} {%- if attribute.name == entity.identity_attribute %} /* Primary Key */{% endif -%}
|
22
|
+
{%- endif -%}{%- endif -%}
|
25
23
|
{%- endif -%}
|
26
24
|
{%- endfor -%}
|
27
25
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
{%- if attribute.is_number == true or attribute.is_bool == true %}
|
2
|
-
let {{ attribute.name }} = RealmOptional<{{ convert_type }}>()
|
2
|
+
let {{ attribute.name }} = RealmOptional<{{ convert_type }}>(){%- if attribute.name == entity.identity_attribute %} /* Primary Key */{% endif -%}
|
3
3
|
{%- else %}
|
4
|
-
@objc dynamic var {{ attribute.name }}: {{ convert_type }}?
|
4
|
+
@objc dynamic var {{ attribute.name }}: {{ convert_type }}?{%- if attribute.name == entity.identity_attribute %} /* Primary Key */{% endif -%}
|
5
5
|
{%- endif -%}
|
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.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- NijiDigital
|
@@ -80,6 +80,21 @@ 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-java/README.md
|
84
|
+
- lib/templates/android-java/entity.liquid
|
85
|
+
- lib/templates/android-java/entity_filename.liquid
|
86
|
+
- lib/templates/android-java/enum.liquid
|
87
|
+
- lib/templates/android-java/enum_filename.liquid
|
88
|
+
- lib/templates/android-java/inc/_attributes_enum.liquid
|
89
|
+
- lib/templates/android-java/inc/_attributes_getter_setter.liquid
|
90
|
+
- lib/templates/android-java/inc/_attributes_properties.liquid
|
91
|
+
- lib/templates/android-java/inc/_enum_getter_setter.liquid
|
92
|
+
- lib/templates/android-java/inc/_primitives.liquid
|
93
|
+
- lib/templates/android-java/inc/_relationships_enum.liquid
|
94
|
+
- lib/templates/android-java/inc/_relationships_getter_setter.liquid
|
95
|
+
- lib/templates/android-java/inc/_relationships_properties.liquid
|
96
|
+
- lib/templates/android-java/inc/_type_converter.liquid
|
97
|
+
- lib/templates/android-java/inc/_wrapper_type_converter.liquid
|
83
98
|
- lib/templates/android-kotlin/README.md
|
84
99
|
- lib/templates/android-kotlin/entity.liquid
|
85
100
|
- lib/templates/android-kotlin/entity_filename.liquid
|
@@ -94,21 +109,7 @@ files:
|
|
94
109
|
- lib/templates/android-kotlin/inc/_type_converter.liquid
|
95
110
|
- lib/templates/android-kotlin/inc/_type_defaults.liquid
|
96
111
|
- lib/templates/android-kotlin/inc/_type_primitives.liquid
|
97
|
-
- lib/templates/android
|
98
|
-
- lib/templates/android/entity.liquid
|
99
|
-
- lib/templates/android/entity_filename.liquid
|
100
|
-
- lib/templates/android/enum.liquid
|
101
|
-
- lib/templates/android/enum_filename.liquid
|
102
|
-
- lib/templates/android/inc/_attributes_enum.liquid
|
103
|
-
- lib/templates/android/inc/_attributes_getter_setter.liquid
|
104
|
-
- lib/templates/android/inc/_attributes_properties.liquid
|
105
|
-
- lib/templates/android/inc/_enum_getter_setter.liquid
|
106
|
-
- lib/templates/android/inc/_primitives.liquid
|
107
|
-
- lib/templates/android/inc/_relationships_enum.liquid
|
108
|
-
- lib/templates/android/inc/_relationships_getter_setter.liquid
|
109
|
-
- lib/templates/android/inc/_relationships_properties.liquid
|
110
|
-
- lib/templates/android/inc/_type_converter.liquid
|
111
|
-
- lib/templates/android/inc/_wrapper_type_converter.liquid
|
112
|
+
- lib/templates/android.alias
|
112
113
|
- lib/templates/decodable/README.md
|
113
114
|
- lib/templates/decodable/entity.liquid
|
114
115
|
- lib/templates/decodable/entity_filename.liquid
|
@@ -153,6 +154,7 @@ files:
|
|
153
154
|
- lib/templates/swift3/inc/_relationship_properties.liquid
|
154
155
|
- lib/templates/swift3/inc/_relationships_enum.liquid
|
155
156
|
- lib/templates/swift3/inc/_type_converter.liquid
|
157
|
+
- lib/templates/swift4.alias
|
156
158
|
homepage: https://github.com/NijiDigital/gyro
|
157
159
|
licenses:
|
158
160
|
- Apache-2.0
|