nidyx 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +1 -1
- data/lib/nidyx/objc/constants.rb +9 -9
- data/lib/nidyx/objc/mapper.rb +3 -1
- data/lib/nidyx/objc/model_base.rb +19 -1
- data/lib/nidyx/parse_constants.rb +14 -14
- data/lib/nidyx/version.rb +1 -1
- data/templates/objc/class_forward_declarations.mustache +5 -0
- data/templates/objc/interface.mustache +3 -4
- data/templates/objc/protocol_declarations.mustache +5 -0
- data/templates/objc/protocol_forward_declarations.mustache +5 -0
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a53778a9adf9de3c62d1ffdb974284a02cdca740
|
4
|
+
data.tar.gz: b36f6615c8225250204b96490cfc4b4f0dc8c18b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fea4e6facf4778988a0d5b7bd704555983a3bbf3f3877a04317570e3285413276b943f850dd976d6ea49d4a37c341b565e0c408fe9b3d93e2ef11a2f4a132f04
|
7
|
+
data.tar.gz: c631e3569bfbdb2a42deb3f36b81a57c326029574badd44105fc4c252569b8cc8c3ec6ee0385feff6d3dfa1f739285fca090034ecf158931600bf09cf449d735
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Nidyx [](http://badge.fury.io/rb/nidyx) [](https://travis-ci.org/cknadler/nidyx) [](https://codeclimate.com/github/cknadler/nidyx) [](https://inch-ci.org/github/cknadler/nidyx)
|
2
2
|
|
3
|
-
[JSON Schema][JSONSchema] ⇒ Model
|
3
|
+
[JSON Schema][JSONSchema] ⇒ Model
|
4
4
|
|
5
5
|
Nidyx generates Objective-C models from JSON Schema. It can also generate
|
6
6
|
models with [JSONModel](https://github.com/icanzilb/JSONModel) support.
|
data/lib/nidyx/objc/constants.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
module Nidyx
|
2
2
|
module ObjCConstants
|
3
3
|
|
4
|
-
PRIMITIVE_ATTRIBUTES = "assign, nonatomic"
|
5
|
-
OBJECT_ATTRIBUTES = "strong, nonatomic"
|
4
|
+
PRIMITIVE_ATTRIBUTES = "assign, nonatomic".freeze
|
5
|
+
OBJECT_ATTRIBUTES = "strong, nonatomic".freeze
|
6
6
|
|
7
7
|
ATTRIBUTES = {
|
8
8
|
:array => OBJECT_ATTRIBUTES,
|
@@ -14,7 +14,7 @@ module Nidyx
|
|
14
14
|
:string => OBJECT_ATTRIBUTES,
|
15
15
|
:object => OBJECT_ATTRIBUTES,
|
16
16
|
:id => OBJECT_ATTRIBUTES
|
17
|
-
}
|
17
|
+
}.freeze
|
18
18
|
|
19
19
|
# Objective-C types
|
20
20
|
# :object intentionally omitted
|
@@ -27,7 +27,7 @@ module Nidyx
|
|
27
27
|
:number_obj => "NSNumber",
|
28
28
|
:string => "NSString",
|
29
29
|
:id => "id"
|
30
|
-
}
|
30
|
+
}.freeze
|
31
31
|
|
32
32
|
# Hash and Array intentionally omitted
|
33
33
|
ENUM_TYPES = {
|
@@ -37,14 +37,14 @@ module Nidyx
|
|
37
37
|
Float => :number,
|
38
38
|
TrueClass => :boolean,
|
39
39
|
FalseClass => :boolean
|
40
|
-
}
|
40
|
+
}.freeze
|
41
41
|
|
42
|
-
OBJECTS = Set.new [:array, :number_obj, :string, :object, :id]
|
42
|
+
OBJECTS = Set.new [:array, :number_obj, :string, :object, :id].freeze
|
43
43
|
|
44
|
-
SIMPLE_NUMBERS = Set.new [:unsigned, :integer, :number]
|
44
|
+
SIMPLE_NUMBERS = Set.new [:unsigned, :integer, :number].freeze
|
45
45
|
|
46
|
-
BOXABLE_NUMBERS = SIMPLE_NUMBERS + [:boolean]
|
46
|
+
BOXABLE_NUMBERS = SIMPLE_NUMBERS + [:boolean].freeze
|
47
47
|
|
48
|
-
FORBIDDEN_PROPERTY_PREFIXES = ["new", "copy"]
|
48
|
+
FORBIDDEN_PROPERTY_PREFIXES = ["new", "copy"].freeze
|
49
49
|
end
|
50
50
|
end
|
data/lib/nidyx/objc/mapper.rb
CHANGED
@@ -28,7 +28,9 @@ module Nidyx
|
|
28
28
|
def self.map_interface(model, options)
|
29
29
|
interface = Nidyx::ObjCInterface.new(model.name, options)
|
30
30
|
interface.properties = model.properties.map { |p| Nidyx::ObjCProperty.new(p) }
|
31
|
-
|
31
|
+
dependencies = Nidyx::ObjCUtils.filter_standard_types(model.dependencies.to_a)
|
32
|
+
interface.class_forward_declarations += dependencies
|
33
|
+
interface.protocol_forward_declarations += dependencies
|
32
34
|
interface
|
33
35
|
end
|
34
36
|
|
@@ -2,7 +2,9 @@ require "mustache"
|
|
2
2
|
|
3
3
|
module Nidyx
|
4
4
|
class ObjCModelBase < Mustache
|
5
|
-
attr_accessor :name, :file_name, :author, :owner, :project, :imports,
|
5
|
+
attr_accessor :name, :file_name, :author, :owner, :project, :imports,
|
6
|
+
:class_forward_declarations, :protocol_forward_declarations,
|
7
|
+
:protocol_declarations, :comments, :json_model
|
6
8
|
|
7
9
|
self.template_path = File.join(__FILE__, "../../../../templates/objc")
|
8
10
|
|
@@ -14,12 +16,28 @@ module Nidyx
|
|
14
16
|
@comments = options[:comments]
|
15
17
|
@json_model = options[:objc][:json_model] if options[:objc]
|
16
18
|
@imports = []
|
19
|
+
@class_forward_declarations = []
|
20
|
+
@protocol_forward_declarations = []
|
21
|
+
@protocol_declarations = []
|
22
|
+
@protocol_declarations << name if @json_model
|
17
23
|
end
|
18
24
|
|
19
25
|
def has_imports?
|
20
26
|
!self.imports.empty?
|
21
27
|
end
|
22
28
|
|
29
|
+
def has_class_forward_declarations?
|
30
|
+
!self.class_forward_declarations.empty?
|
31
|
+
end
|
32
|
+
|
33
|
+
def has_protocol_forward_declarations?
|
34
|
+
!self.protocol_forward_declarations.empty?
|
35
|
+
end
|
36
|
+
|
37
|
+
def has_protocol_declarations?
|
38
|
+
!self.protocol_declarations.empty?
|
39
|
+
end
|
40
|
+
|
23
41
|
def no_owner?
|
24
42
|
!self.owner
|
25
43
|
end
|
@@ -4,27 +4,27 @@ module Nidyx
|
|
4
4
|
###
|
5
5
|
# Schema key definitions
|
6
6
|
###
|
7
|
-
REF_KEY = "$ref"
|
8
|
-
ENUM_KEY = "enum"
|
9
|
-
TYPE_KEY = "type"
|
10
|
-
DESCRIPTION_KEY = "description"
|
11
|
-
REQUIRED_KEY = "required"
|
12
|
-
PROPERTIES_KEY = "properties"
|
13
|
-
NAME_OVERRIDE_KEY = "nameOverride"
|
14
|
-
ITEMS_KEY = "items"
|
15
|
-
MINIMUM_KEY = "minimum"
|
16
|
-
ANY_OF_KEY = "anyOf"
|
7
|
+
REF_KEY = "$ref".freeze
|
8
|
+
ENUM_KEY = "enum".freeze
|
9
|
+
TYPE_KEY = "type".freeze
|
10
|
+
DESCRIPTION_KEY = "description".freeze
|
11
|
+
REQUIRED_KEY = "required".freeze
|
12
|
+
PROPERTIES_KEY = "properties".freeze
|
13
|
+
NAME_OVERRIDE_KEY = "nameOverride".freeze
|
14
|
+
ITEMS_KEY = "items".freeze
|
15
|
+
MINIMUM_KEY = "minimum".freeze
|
16
|
+
ANY_OF_KEY = "anyOf".freeze
|
17
17
|
|
18
18
|
###
|
19
19
|
# Internal schema key definitions
|
20
20
|
###
|
21
|
-
DERIVED_NAME = "__derivedName"
|
22
|
-
COLLECTION_TYPES_KEY = "__collectionTypes"
|
21
|
+
DERIVED_NAME = "__derivedName".freeze
|
22
|
+
COLLECTION_TYPES_KEY = "__collectionTypes".freeze
|
23
23
|
|
24
24
|
###
|
25
25
|
# Object types
|
26
26
|
###
|
27
|
-
OBJECT_TYPE = "object"
|
28
|
-
ARRAY_TYPE = "array"
|
27
|
+
OBJECT_TYPE = "object".freeze
|
28
|
+
ARRAY_TYPE = "array".freeze
|
29
29
|
end
|
30
30
|
end
|
data/lib/nidyx/version.rb
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
{{> top_info}}
|
2
2
|
{{> imports}}
|
3
|
-
{{
|
4
|
-
|
5
|
-
|
3
|
+
{{> class_forward_declarations}}
|
4
|
+
{{> protocol_forward_declarations}}
|
5
|
+
{{> protocol_declarations}}
|
6
6
|
|
7
|
-
{{/json_model?}}
|
8
7
|
@interface {{name}}{{#json_model?}} : JSONModel{{/json_model?}}
|
9
8
|
{{#properties}}
|
10
9
|
{{#desc}}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nidyx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Knadler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mustache
|
@@ -86,9 +86,12 @@ files:
|
|
86
86
|
- lib/nidyx/property.rb
|
87
87
|
- lib/nidyx/reader.rb
|
88
88
|
- lib/nidyx/version.rb
|
89
|
+
- templates/objc/class_forward_declarations.mustache
|
89
90
|
- templates/objc/implementation.mustache
|
90
91
|
- templates/objc/imports.mustache
|
91
92
|
- templates/objc/interface.mustache
|
93
|
+
- templates/objc/protocol_declarations.mustache
|
94
|
+
- templates/objc/protocol_forward_declarations.mustache
|
92
95
|
- templates/objc/top_info.mustache
|
93
96
|
- test/nidyx/core_ext/test_string.rb
|
94
97
|
- test/nidyx/objc/test_model_base.rb
|
@@ -118,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
121
|
version: '0'
|
119
122
|
requirements: []
|
120
123
|
rubyforge_project:
|
121
|
-
rubygems_version: 2.5
|
124
|
+
rubygems_version: 2.4.5
|
122
125
|
signing_key:
|
123
126
|
specification_version: 4
|
124
127
|
summary: JSON Schema -> Objective-C models
|