moblues 0.0.1

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.
Files changed (87) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +16 -0
  3. data/.travis.yml +8 -0
  4. data/Gemfile +3 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +44 -0
  7. data/Rakefile +4 -0
  8. data/bin/moblues +5 -0
  9. data/lib/extensions/hash.rb +9 -0
  10. data/lib/moblues/cli.rb +26 -0
  11. data/lib/moblues/data_model/attribute.rb +15 -0
  12. data/lib/moblues/data_model/entity.rb +17 -0
  13. data/lib/moblues/data_model/relationship.rb +17 -0
  14. data/lib/moblues/data_model.rb +3 -0
  15. data/lib/moblues/generator/base.rb +65 -0
  16. data/lib/moblues/generator/human.rb +25 -0
  17. data/lib/moblues/generator/human_header.h.erb +4 -0
  18. data/lib/moblues/generator/human_implementation.m.erb +4 -0
  19. data/lib/moblues/generator/machine.rb +36 -0
  20. data/lib/moblues/generator/machine_header.h.erb +43 -0
  21. data/lib/moblues/generator/machine_implementation.m.erb +7 -0
  22. data/lib/moblues/generator/model.rb +23 -0
  23. data/lib/moblues/generator.rb +4 -0
  24. data/lib/moblues/reader/attribute.rb +23 -0
  25. data/lib/moblues/reader/entity.rb +34 -0
  26. data/lib/moblues/reader/model.rb +31 -0
  27. data/lib/moblues/reader/relationship.rb +22 -0
  28. data/lib/moblues/reader/type.rb +58 -0
  29. data/lib/moblues/reader.rb +5 -0
  30. data/lib/moblues/utils/model_resolver.rb +19 -0
  31. data/lib/moblues/version.rb +3 -0
  32. data/lib/moblues.rb +4 -0
  33. data/moblues.gemspec +33 -0
  34. data/spec/features/moblues_spec.rb +36 -0
  35. data/spec/moblues/cli_spec.rb +50 -0
  36. data/spec/moblues/data_model/attribute_spec.rb +30 -0
  37. data/spec/moblues/data_model/entity_spec.rb +48 -0
  38. data/spec/moblues/data_model/relationship_spec.rb +46 -0
  39. data/spec/moblues/generator/human_spec.rb +74 -0
  40. data/spec/moblues/generator/machine_spec.rb +86 -0
  41. data/spec/moblues/generator/model_spec.rb +27 -0
  42. data/spec/moblues/reader/attribute_spec.rb +22 -0
  43. data/spec/moblues/reader/entity_spec.rb +57 -0
  44. data/spec/moblues/reader/model_spec.rb +66 -0
  45. data/spec/moblues/reader/relationship_spec.rb +22 -0
  46. data/spec/moblues/reader/type_spec.rb +79 -0
  47. data/spec/moblues/utils/model_resolver_spec.rb +28 -0
  48. data/spec/resources/Model.xcdatamodeld/.xccurrentversion +8 -0
  49. data/spec/resources/Model.xcdatamodeld/Model 2.xcdatamodel/contents +28 -0
  50. data/spec/resources/Model.xcdatamodeld/Model.xcdatamodel/contents +18 -0
  51. data/spec/resources/expected/Author.h +4 -0
  52. data/spec/resources/expected/Author.m +4 -0
  53. data/spec/resources/expected/_Author.h +36 -0
  54. data/spec/resources/expected/_Author.m +9 -0
  55. data/spec/resources/expected/_Book.h +19 -0
  56. data/spec/resources/expected/_Book.m +6 -0
  57. data/spec/resources/expected/_Person.h +9 -0
  58. data/spec/resources/expected/_Person.m +6 -0
  59. data/spec/resources/expected/_Team.h +18 -0
  60. data/spec/resources/expected/_Team.m +5 -0
  61. data/spec/resources/expected/human/Playable.h +4 -0
  62. data/spec/resources/expected/human/Playable.m +4 -0
  63. data/spec/resources/expected/human/Playlist.h +5 -0
  64. data/spec/resources/expected/human/Playlist.m +4 -0
  65. data/spec/resources/expected/human/Track.h +4 -0
  66. data/spec/resources/expected/human/Track.m +4 -0
  67. data/spec/resources/expected/human/User.h +4 -0
  68. data/spec/resources/expected/human/User.m +4 -0
  69. data/spec/resources/expected/machine/_Playable.h +9 -0
  70. data/spec/resources/expected/machine/_Playable.m +6 -0
  71. data/spec/resources/expected/machine/_Playlist.h +28 -0
  72. data/spec/resources/expected/machine/_Playlist.m +6 -0
  73. data/spec/resources/expected/machine/_Track.h +14 -0
  74. data/spec/resources/expected/machine/_Track.m +7 -0
  75. data/spec/resources/expected/machine/_User.h +27 -0
  76. data/spec/resources/expected/machine/_User.m +8 -0
  77. data/spec/resources/factories/data_model/attribute_factory.rb +12 -0
  78. data/spec/resources/factories/data_model/entity_factory.rb +13 -0
  79. data/spec/resources/factories/data_model/relationship_factory.rb +14 -0
  80. data/spec/resources/fixtures.rb +34 -0
  81. data/spec/resources/tmp/.gitkeep +0 -0
  82. data/spec/resources/tmp/_Team.h +18 -0
  83. data/spec/resources/tmp/_Team.m +5 -0
  84. data/spec/resources/tmp/human/Playlist.h +5 -0
  85. data/spec/resources/tmp/human/Playlist.m +4 -0
  86. data/spec/spec_helper.rb +15 -0
  87. metadata +285 -0
@@ -0,0 +1,79 @@
1
+ require 'spec_helper'
2
+ require 'moblues/reader/type'
3
+
4
+ describe Moblues::Reader::Type do
5
+ describe '#map_type_str' do
6
+ shared_examples 'map_type_str' do |string, type|
7
+ it "returns #{type} for #{string}" do
8
+ expect(subject.map_type_str(string)).to eq(type)
9
+ end
10
+ end
11
+
12
+ it_behaves_like 'map_type_str', 'String', :string
13
+ it_behaves_like 'map_type_str', 'Integer 16', :number
14
+ it_behaves_like 'map_type_str', 'Integer 32', :number
15
+ it_behaves_like 'map_type_str', 'Integer 64', :number
16
+ it_behaves_like 'map_type_str', 'Boolean', :number
17
+ it_behaves_like 'map_type_str', 'Date', :date
18
+ it_behaves_like 'map_type_str', 'Binary', :data
19
+ it_behaves_like 'map_type_str', 'Transformable', :id
20
+
21
+ it 'raises an exception when the type is unknown' do
22
+ expect { subject.map_type_str('Unknown Type') }.to raise_exception(ArgumentError)
23
+ end
24
+ end
25
+
26
+ describe '#property_type' do
27
+ shared_examples 'property_type' do |type, property_type|
28
+ it "returns #{property_type} for #{type}" do
29
+ expect(subject.property_type(type)).to eq(property_type)
30
+ end
31
+ end
32
+
33
+ it_behaves_like 'property_type', :string, 'NSString *'
34
+ it_behaves_like 'property_type', :number, 'NSNumber *'
35
+ it_behaves_like 'property_type', :date, 'NSDate *'
36
+ it_behaves_like 'property_type', :data, 'NSData *'
37
+ it_behaves_like 'property_type', :id, 'id '
38
+
39
+ it 'raises an exception when the type is unknown' do
40
+ expect { subject.property_type(:unknown) }.to raise_exception(ArgumentError)
41
+ end
42
+ end
43
+
44
+ describe '#property_attributes' do
45
+ shared_examples 'property_attributes' do |type, attrs|
46
+ it "returns #{attrs} for #{type}" do
47
+ expect(subject.property_attributes(type)).to eq(attrs)
48
+ end
49
+ end
50
+
51
+ it_behaves_like 'property_attributes', :string, %w(nonatomic copy)
52
+ it_behaves_like 'property_attributes', :number, %w(nonatomic strong)
53
+ it_behaves_like 'property_attributes', :date, %w(nonatomic strong)
54
+ it_behaves_like 'property_attributes', :data, %w(nonatomic strong)
55
+ it_behaves_like 'property_attributes', :id, %w(nonatomic strong)
56
+
57
+ it 'raises an exception when the type is unknown' do
58
+ expect { subject.property_attributes(:unknown) }.to raise_exception(ArgumentError)
59
+ end
60
+ end
61
+
62
+ describe '#relationship_type' do
63
+ shared_examples 'relationship_type' do |rel, type|
64
+ it "returns #{type} for #{rel}" do
65
+ expect(subject.relationship_type(rel)).to eq(type)
66
+ end
67
+ end
68
+
69
+ it_behaves_like 'relationship_type',
70
+ Moblues::DataModel::Relationship.new(name: '', destination_entity: 'Dest'),
71
+ 'Dest *'
72
+ it_behaves_like 'relationship_type',
73
+ Moblues::DataModel::Relationship.new(name: '', destination_entity: 'Dest', to_many: true),
74
+ 'NSSet *'
75
+ it_behaves_like 'relationship_type',
76
+ Moblues::DataModel::Relationship.new(name: '', destination_entity: 'Dest', to_many: true, ordered: true),
77
+ 'NSOrderedSet *'
78
+ end
79
+ end
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+ require 'moblues/utils/model_resolver'
3
+
4
+ module Moblues
5
+ module Utils
6
+ describe ModelResolver do
7
+ describe '#resolve_model' do
8
+ context 'when model is nil' do
9
+ it 'raises an ArgumentError' do
10
+ expect { subject.resolve_model(nil) }.to raise_exception(ArgumentError)
11
+ end
12
+ end
13
+
14
+ context 'when the model does not exist' do
15
+ it 'raises an exception' do
16
+ expect { subject.resolve_model('this/does/not/exist') }.to raise_exception(ArgumentError, 'this/does/not/exist not found')
17
+ end
18
+ end
19
+
20
+ context 'when the model exists' do
21
+ it 'returns the path to the Model contents' do
22
+ expect(subject.resolve_model(Fixtures.xcdatamodeld)).to eq('spec/resources/Model.xcdatamodeld/Model 2.xcdatamodel/contents')
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>_XCCurrentVersionName</key>
6
+ <string>Model 2.xcdatamodel</string>
7
+ </dict>
8
+ </plist>
@@ -0,0 +1,28 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
+ <model userDefinedModelVersionIdentifier="2.0" type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="6252" systemVersion="14B25" minimumToolsVersion="Xcode 4.3" macOSVersion="Automatic" iOSVersion="Automatic">
3
+ <entity name="Playable" syncable="YES">
4
+ <attribute name="permalink" optional="YES" attributeType="String" syncable="YES"/>
5
+ <attribute name="title" optional="YES" attributeType="String" syncable="YES"/>
6
+ </entity>
7
+ <entity name="Playlist" parentEntity="Playable" syncable="YES">
8
+ <relationship name="tracks" optional="YES" toMany="YES" deletionRule="Nullify" ordered="YES" destinationEntity="Track" inverseName="playlist" inverseEntity="Track" syncable="YES"/>
9
+ <relationship name="user" maxCount="1" deletionRule="Nullify" destinationEntity="User" inverseName="playlists" inverseEntity="User" syncable="YES"/>
10
+ </entity>
11
+ <entity name="Track" parentEntity="Playable" syncable="YES">
12
+ <attribute name="duration" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
13
+ <relationship name="playlist" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Playlist" inverseName="tracks" inverseEntity="Playlist" syncable="YES"/>
14
+ <relationship name="user" maxCount="1" deletionRule="Nullify" destinationEntity="User" inverseName="tracks" inverseEntity="User" syncable="YES"/>
15
+ </entity>
16
+ <entity name="User" syncable="YES">
17
+ <attribute name="dob" optional="YES" attributeType="Date" syncable="YES"/>
18
+ <attribute name="name" optional="YES" attributeType="String" syncable="YES"/>
19
+ <relationship name="playlists" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="Playlist" inverseName="user" inverseEntity="Playlist" syncable="YES"/>
20
+ <relationship name="tracks" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="Track" inverseName="user" inverseEntity="Track" syncable="YES"/>
21
+ </entity>
22
+ <elements>
23
+ <element name="Track" positionX="198" positionY="18" width="128" height="88"/>
24
+ <element name="User" positionX="-11" positionY="72" width="128" height="103"/>
25
+ <element name="Playable" positionX="252" positionY="-97" width="128" height="73"/>
26
+ <element name="Playlist" positionX="412" positionY="117" width="128" height="73"/>
27
+ </elements>
28
+ </model>
@@ -0,0 +1,18 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2
+ <model userDefinedModelVersionIdentifier="1.0" type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="6252" systemVersion="14B25" minimumToolsVersion="Xcode 4.3" macOSVersion="Automatic" iOSVersion="Automatic">
3
+ <entity name="Track" syncable="YES">
4
+ <attribute name="duration" optional="YES" attributeType="Integer 32" defaultValueString="0" syncable="YES"/>
5
+ <attribute name="title" optional="YES" attributeType="String" syncable="YES"/>
6
+ <attribute name="url" optional="YES" attributeType="Transformable" syncable="YES"/>
7
+ <relationship name="user" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="User" inverseName="tracks" inverseEntity="User" syncable="YES"/>
8
+ </entity>
9
+ <entity name="User" syncable="YES">
10
+ <attribute name="dob" optional="YES" attributeType="Date" syncable="YES"/>
11
+ <attribute name="name" optional="YES" attributeType="String" syncable="YES"/>
12
+ <relationship name="tracks" optional="YES" toMany="YES" deletionRule="Nullify" destinationEntity="Track" inverseName="user" inverseEntity="Track" syncable="YES"/>
13
+ </entity>
14
+ <elements>
15
+ <element name="User" positionX="-45" positionY="0" width="128" height="88"/>
16
+ <element name="Track" positionX="207" positionY="-15" width="128" height="103"/>
17
+ </elements>
18
+ </model>
@@ -0,0 +1,4 @@
1
+ #import "_Author.h"
2
+
3
+ @interface Author : _Author
4
+ @end
@@ -0,0 +1,4 @@
1
+ #import "Author.h"
2
+
3
+ @implementation Author
4
+ @end
@@ -0,0 +1,36 @@
1
+ #import <Foundation/Foundation.h>
2
+ #import <CoreData/CoreData.h>
3
+
4
+ #import "Person.h"
5
+
6
+ @class Book;
7
+ @class Publisher;
8
+
9
+ @interface _Author : Person
10
+ @property (nonatomic, strong) NSDate *dob;
11
+ @property (nonatomic, copy) NSString *name;
12
+
13
+ @property (nonatomic, strong) NSOrderedSet *books;
14
+ @property (nonatomic, strong) NSSet *essays;
15
+ @property (nonatomic, strong) Publisher *publisher;
16
+ @end
17
+
18
+ @interface _Author (CoreDataGeneratedAccessors)
19
+
20
+ - (void)insertObject:(Book *)value inBooksAtIndex:(NSUInteger)index;
21
+ - (void)removeObjectFromBooksAtIndex:(NSUInteger)index;
22
+ - (void)insertBooks:(NSArray *)values atIndexes:(NSIndexSet *)indexes;
23
+ - (void)removeBooksAtIndexes:(NSIndexSet *)indexes;
24
+ - (void)replaceObjectInBooksAtIndex:(NSUInteger)index withObject:(Book *)value;
25
+ - (void)replaceBooksAtIndexes:(NSIndexSet *)indexes withBooks:(NSArray *)values;
26
+ - (void)addBooksObject:(Book *)value;
27
+ - (void)removeBooksObject:(Book *)value;
28
+ - (void)addBooks:(NSOrderedSet *)values;
29
+ - (void)removeBooks:(NSOrderedSet *)values;
30
+
31
+ - (void)addEssaysObject:(Book *)value;
32
+ - (void)removeEssaysObject:(Book *)value;
33
+ - (void)addEssays:(NSSet *)values;
34
+ - (void)removeEssays:(NSSet *)values;
35
+
36
+ @end
@@ -0,0 +1,9 @@
1
+ #import "_Author.h"
2
+
3
+ @implementation _Author
4
+ @dynamic dob;
5
+ @dynamic name;
6
+ @dynamic books;
7
+ @dynamic essays;
8
+ @dynamic publisher;
9
+ @end
@@ -0,0 +1,19 @@
1
+ #import <Foundation/Foundation.h>
2
+ #import <CoreData/CoreData.h>
3
+
4
+ @class Edition;
5
+
6
+ @interface _Book : NSManagedObject
7
+ @property (nonatomic, copy) NSString *name;
8
+
9
+ @property (nonatomic, strong) NSSet *editions;
10
+ @end
11
+
12
+ @interface _Book (CoreDataGeneratedAccessors)
13
+
14
+ - (void)addEditionsObject:(Edition *)value;
15
+ - (void)removeEditionsObject:(Edition *)value;
16
+ - (void)addEditions:(NSSet *)values;
17
+ - (void)removeEditions:(NSSet *)values;
18
+
19
+ @end
@@ -0,0 +1,6 @@
1
+ #import "_Book.h"
2
+
3
+ @implementation _Book
4
+ @dynamic name;
5
+ @dynamic editions;
6
+ @end
@@ -0,0 +1,9 @@
1
+ #import <Foundation/Foundation.h>
2
+ #import <CoreData/CoreData.h>
3
+
4
+
5
+ @interface _Person : NSManagedObject
6
+ @property (nonatomic, copy) NSString *name;
7
+ @property (nonatomic, strong) NSDate *dob;
8
+
9
+ @end
@@ -0,0 +1,6 @@
1
+ #import "_person.h"
2
+
3
+ @implementation _Person
4
+ @dynamic name;
5
+ @dynamic dob;
6
+ @end
@@ -0,0 +1,18 @@
1
+ #import <Foundation/Foundation.h>
2
+ #import <CoreData/CoreData.h>
3
+
4
+ @class Person;
5
+
6
+ @interface _Team : NSManagedObject
7
+
8
+ @property (nonatomic, strong) NSSet *teamMembers;
9
+ @end
10
+
11
+ @interface _Team (CoreDataGeneratedAccessors)
12
+
13
+ - (void)addTeamMembersObject:(Person *)value;
14
+ - (void)removeTeamMembersObject:(Person *)value;
15
+ - (void)addTeamMembers:(NSSet *)values;
16
+ - (void)removeTeamMembers:(NSSet *)values;
17
+
18
+ @end
@@ -0,0 +1,5 @@
1
+ #import "_Team.h"
2
+
3
+ @implementation _Team
4
+ @dynamic teamMembers;
5
+ @end
@@ -0,0 +1,4 @@
1
+ #import "_Playable.h"
2
+
3
+ @interface Playable : _Playable
4
+ @end
@@ -0,0 +1,4 @@
1
+ #import "Playable.h"
2
+
3
+ @implementation Playable
4
+ @end
@@ -0,0 +1,5 @@
1
+ #import "_Playlist.h"
2
+
3
+ @interface Playlist : _Playlist
4
+ /* some modifications that should not be erased */
5
+ @end
@@ -0,0 +1,4 @@
1
+ #import "Playlist.h"
2
+
3
+ @implementation Playlist
4
+ @end
@@ -0,0 +1,4 @@
1
+ #import "_Track.h"
2
+
3
+ @interface Track : _Track
4
+ @end
@@ -0,0 +1,4 @@
1
+ #import "Track.h"
2
+
3
+ @implementation Track
4
+ @end
@@ -0,0 +1,4 @@
1
+ #import "_User.h"
2
+
3
+ @interface User : _User
4
+ @end
@@ -0,0 +1,4 @@
1
+ #import "User.h"
2
+
3
+ @implementation User
4
+ @end
@@ -0,0 +1,9 @@
1
+ #import <Foundation/Foundation.h>
2
+ #import <CoreData/CoreData.h>
3
+
4
+
5
+ @interface _Playable : NSManagedObject
6
+ @property (nonatomic, copy) NSString *permalink;
7
+ @property (nonatomic, copy) NSString *title;
8
+
9
+ @end
@@ -0,0 +1,6 @@
1
+ #import "_Playable.h"
2
+
3
+ @implementation _Playable
4
+ @dynamic permalink;
5
+ @dynamic title;
6
+ @end
@@ -0,0 +1,28 @@
1
+ #import <Foundation/Foundation.h>
2
+ #import <CoreData/CoreData.h>
3
+
4
+ #import "Playable.h"
5
+
6
+ @class Track;
7
+ @class User;
8
+
9
+ @interface _Playlist : Playable
10
+
11
+ @property (nonatomic, strong) NSOrderedSet *tracks;
12
+ @property (nonatomic, strong) User *user;
13
+ @end
14
+
15
+ @interface _Playlist (CoreDataGeneratedAccessors)
16
+
17
+ - (void)insertObject:(Track *)value inTracksAtIndex:(NSUInteger)index;
18
+ - (void)removeObjectFromTracksAtIndex:(NSUInteger)index;
19
+ - (void)insertTracks:(NSArray *)values atIndexes:(NSIndexSet *)indexes;
20
+ - (void)removeTracksAtIndexes:(NSIndexSet *)indexes;
21
+ - (void)replaceObjectInTracksAtIndex:(NSUInteger)index withObject:(Track *)value;
22
+ - (void)replaceTracksAtIndexes:(NSIndexSet *)indexes withTracks:(NSArray *)values;
23
+ - (void)addTracksObject:(Track *)value;
24
+ - (void)removeTracksObject:(Track *)value;
25
+ - (void)addTracks:(NSOrderedSet *)values;
26
+ - (void)removeTracks:(NSOrderedSet *)values;
27
+
28
+ @end
@@ -0,0 +1,6 @@
1
+ #import "_Playlist.h"
2
+
3
+ @implementation _Playlist
4
+ @dynamic tracks;
5
+ @dynamic user;
6
+ @end
@@ -0,0 +1,14 @@
1
+ #import <Foundation/Foundation.h>
2
+ #import <CoreData/CoreData.h>
3
+
4
+ #import "Playable.h"
5
+
6
+ @class Playlist;
7
+ @class User;
8
+
9
+ @interface _Track : Playable
10
+ @property (nonatomic, strong) NSNumber *duration;
11
+
12
+ @property (nonatomic, strong) Playlist *playlist;
13
+ @property (nonatomic, strong) User *user;
14
+ @end
@@ -0,0 +1,7 @@
1
+ #import "_Track.h"
2
+
3
+ @implementation _Track
4
+ @dynamic duration;
5
+ @dynamic playlist;
6
+ @dynamic user;
7
+ @end
@@ -0,0 +1,27 @@
1
+ #import <Foundation/Foundation.h>
2
+ #import <CoreData/CoreData.h>
3
+
4
+ @class Playlist;
5
+ @class Track;
6
+
7
+ @interface _User : NSManagedObject
8
+ @property (nonatomic, strong) NSDate *dob;
9
+ @property (nonatomic, copy) NSString *name;
10
+
11
+ @property (nonatomic, strong) NSSet *playlists;
12
+ @property (nonatomic, strong) NSSet *tracks;
13
+ @end
14
+
15
+ @interface _User (CoreDataGeneratedAccessors)
16
+
17
+ - (void)addPlaylistsObject:(Playlist *)value;
18
+ - (void)removePlaylistsObject:(Playlist *)value;
19
+ - (void)addPlaylists:(NSSet *)values;
20
+ - (void)removePlaylists:(NSSet *)values;
21
+
22
+ - (void)addTracksObject:(Track *)value;
23
+ - (void)removeTracksObject:(Track *)value;
24
+ - (void)addTracks:(NSSet *)values;
25
+ - (void)removeTracks:(NSSet *)values;
26
+
27
+ @end
@@ -0,0 +1,8 @@
1
+ #import "_User.h"
2
+
3
+ @implementation _User
4
+ @dynamic dob;
5
+ @dynamic name;
6
+ @dynamic playlists;
7
+ @dynamic tracks;
8
+ @end
@@ -0,0 +1,12 @@
1
+ require 'factory_girl'
2
+
3
+ require 'moblues/data_model/attribute'
4
+
5
+ FactoryGirl.define do
6
+ factory :attribute, class: Moblues::DataModel::Attribute do
7
+ name 'attribute'
8
+ type :string
9
+
10
+ initialize_with { new(name: name, type: type) }
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ require 'factory_girl'
2
+
3
+ require 'moblues/data_model/entity'
4
+
5
+ FactoryGirl.define do
6
+ factory :entity, class: Moblues::DataModel::Entity do
7
+ name 'relationship'
8
+ association :attribute, strategy: :build
9
+ association :relationship, strategy: :build
10
+
11
+ initialize_with { new(name: name, attributes: [ attribute ], relationships: [ relationship ]) }
12
+ end
13
+ end
@@ -0,0 +1,14 @@
1
+ require 'factory_girl'
2
+
3
+ require 'moblues/data_model/relationship'
4
+
5
+ FactoryGirl.define do
6
+ factory :relationship, class: Moblues::DataModel::Relationship do
7
+ name 'relationship'
8
+ destination_entity 'DestinationEntity'
9
+ to_many true
10
+ ordered true
11
+
12
+ initialize_with { new(name: name, destination_entity: destination_entity, to_many: to_many, ordered: ordered) }
13
+ end
14
+ end
@@ -0,0 +1,34 @@
1
+ module Fixtures
2
+ extend self
3
+
4
+ def xcdatamodeld
5
+ 'spec/resources/Model.xcdatamodeld'
6
+ end
7
+
8
+ def expected_dir
9
+ 'spec/resources/expected'
10
+ end
11
+
12
+ def generated_dir
13
+ 'spec/resources/tmp'
14
+ end
15
+
16
+ def generated_file_content(name)
17
+ read_file(generated_dir, name)
18
+ end
19
+
20
+ def expected_content(name)
21
+ read_file(expected_dir, name)
22
+ end
23
+
24
+ def read_file(directory, file)
25
+ File.read(File.join(directory, file))
26
+ end
27
+
28
+ def delete_tmp_files(files)
29
+ files.each { |file|
30
+ path = File.join(generated_dir, file)
31
+ File.delete(path) if File.exists?(path)
32
+ }
33
+ end
34
+ end
File without changes
@@ -0,0 +1,18 @@
1
+ #import <Foundation/Foundation.h>
2
+ #import <CoreData/CoreData.h>
3
+
4
+ @class Person;
5
+
6
+ @interface _Team : NSManagedObject
7
+
8
+ @property (nonatomic, strong) NSSet *teamMembers;
9
+ @end
10
+
11
+ @interface _Team (CoreDataGeneratedAccessors)
12
+
13
+ - (void)addTeamMembersObject:(Person *)value;
14
+ - (void)removeTeamMembersObject:(Person *)value;
15
+ - (void)addTeamMembers:(NSSet *)values;
16
+ - (void)removeTeamMembers:(NSSet *)values;
17
+
18
+ @end
@@ -0,0 +1,5 @@
1
+ #import "_Team.h"
2
+
3
+ @implementation _Team
4
+ @dynamic teamMembers;
5
+ @end
@@ -0,0 +1,5 @@
1
+ #import "_Playlist.h"
2
+
3
+ @interface Playlist : _Playlist
4
+ /* some modifications that should not be erased */
5
+ @end
@@ -0,0 +1,4 @@
1
+ #import "Playlist.h"
2
+
3
+ @implementation Playlist
4
+ @end
@@ -0,0 +1,15 @@
1
+ require 'codeclimate-test-reporter'
2
+ CodeClimate::TestReporter.start
3
+
4
+ require 'moblues'
5
+ require 'rspec'
6
+ require 'rspec/mocks'
7
+ require 'factory_girl'
8
+ require 'resources/fixtures'
9
+ require 'resources/factories/data_model/attribute_factory'
10
+ require 'resources/factories/data_model/relationship_factory'
11
+ require 'resources/factories/data_model/entity_factory'
12
+
13
+ RSpec.configure do |config|
14
+ config.include FactoryGirl::Syntax::Methods
15
+ end