nidyx 0.2.2 → 0.2.3

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: 7e11dd4c1a128f7bc0710298931654abeea27dc4
4
- data.tar.gz: e3961e8433db99a3be62e680f67aceba40e324f4
3
+ metadata.gz: a53778a9adf9de3c62d1ffdb974284a02cdca740
4
+ data.tar.gz: b36f6615c8225250204b96490cfc4b4f0dc8c18b
5
5
  SHA512:
6
- metadata.gz: 53b523b9a753819ea6562be0d5ff3154ce13ce8073b206a71fbe90952d7ee0a07522c5d491d0fac8d2de0bfc38890deea74faa7c4d093901871b3609f11ef111
7
- data.tar.gz: c45145bbfa67322c24d3ab70aa46b0a6a38c65c5d2f9f1577ea8cb02d198cc75255a0e8186894a2f66e6b2b1dd85e8503eb512d13608d73dc53c6f261f57e448
6
+ metadata.gz: fea4e6facf4778988a0d5b7bd704555983a3bbf3f3877a04317570e3285413276b943f850dd976d6ea49d4a37c341b565e0c408fe9b3d93e2ef11a2f4a132f04
7
+ data.tar.gz: c631e3569bfbdb2a42deb3f36b81a57c326029574badd44105fc4c252569b8cc8c3ec6ee0385feff6d3dfa1f739285fca090034ecf158931600bf09cf449d735
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2014 Chris Knadler
3
+ Copyright (c) 2016 Chris Knadler
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Nidyx [![Gem Version](https://badge.fury.io/rb/nidyx.svg)](http://badge.fury.io/rb/nidyx) [![Build Status](https://travis-ci.org/cknadler/nidyx.svg?branch=master)](https://travis-ci.org/cknadler/nidyx) [![Code Climate](https://codeclimate.com/github/cknadler/nidyx/badges/gpa.svg)](https://codeclimate.com/github/cknadler/nidyx) [![Documentation](https://inch-ci.org/github/cknadler/nidyx.svg?branch=master)](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.
@@ -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
@@ -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
- interface.imports += Nidyx::ObjCUtils.filter_standard_types(model.dependencies.to_a)
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, :comments, :json_model
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,3 +1,3 @@
1
1
  module Nidyx
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
@@ -0,0 +1,5 @@
1
+ {{#has_class_forward_declarations?}}
2
+ {{#class_forward_declarations}}
3
+ @class {{.}};
4
+ {{/class_forward_declarations}}
5
+ {{/has_class_forward_declarations?}}
@@ -1,10 +1,9 @@
1
1
  {{> top_info}}
2
2
  {{> imports}}
3
- {{#json_model?}}
4
- @protocol {{name}}
5
- @end
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}}
@@ -0,0 +1,5 @@
1
+ {{#has_protocol_declarations?}}
2
+ {{#protocol_declarations}}
3
+ @protocol {{.}}; @end
4
+ {{/protocol_declarations}}
5
+ {{/has_protocol_declarations?}}
@@ -0,0 +1,5 @@
1
+ {{#has_protocol_forward_declarations?}}
2
+ {{#protocol_forward_declarations}}
3
+ @protocol {{.}};
4
+ {{/protocol_forward_declarations}}
5
+ {{/has_protocol_forward_declarations?}}
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.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-02-28 00:00:00.000000000 Z
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.1
124
+ rubygems_version: 2.4.5
122
125
  signing_key:
123
126
  specification_version: 4
124
127
  summary: JSON Schema -> Objective-C models