lanekit 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +21 -14
- data/lib/lanekit/version.rb +1 -1
- data/lib/lanekit.rb +78 -8
- data/lib/template/model.h.erb +1 -1
- data/lib/template/model.m.erb +4 -7
- data/lib/template/model_fixture.h.erb +16 -0
- data/lib/template/model_fixture.m.erb +30 -0
- data/lib/template/model_test.h.erb +10 -0
- data/lib/template/model_test.m.erb +51 -0
- metadata +9 -5
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YzI4ZDM1ZGM3MjhkYjRmYjU1NzkxZGM1ZDdmYzM2MjBjZTUyODgzOA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MDIxOTc1ZTM4NjdiOTk2NTZjYzk2NWFjMGE1YjY0M2RiZjgzNTU5Zg==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OTY4N2M1NmQxYmIzOWEwODlhOTMzMmI4YWU2OTU2YzBlY2VmYzlhMzQ5OTBm
|
10
|
+
Zjc5ZjkzODViMWY3MDJhZGMwYzFhYjI2MjRmMDE5MDFiNzkzNGRkMzc3YTMw
|
11
|
+
MWE2NTAwOTJkMjE3ZjljOGE4ZWUzY2JlMTNiZWQ4YWI4MDdiYjQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YmFiZDM3NWQ4YzY3NGE0NjhjOWI3ZmQyNDkxZGIxODhjMDNhYzAyMTllZDRh
|
14
|
+
NDU4ZGZhODkzMTU4N2JiNDE1MTY0OTMxNDJhMTMzYTg2ZjZjNTliYmRmNjBj
|
15
|
+
MGYyYzBhNjU2OGJlNjcyMzE0YjYzN2E4NjYzMzBlNGRhYmMwY2Q=
|
data/README.md
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
## LaneKit
|
2
2
|
|
3
|
-
|
3
|
+
|
4
|
+
LaneKit is a code generator for iOS Objective-C models for integration with RestKit. It includes support
|
5
|
+
for unit testing with SenTestingKit including fixtures and tests. LaneKit is a command line app written
|
6
|
+
in Ruby and packaged as a Ruby Gem.
|
4
7
|
|
5
8
|
- [Source code for LaneKit](https://github.com/LarryAasen/LaneKit/zipball/master) from [GitHub](http://github.com).
|
6
9
|
- Questions? [Stack Overflow](http://stackoverflow.com/questions/tagged/lanekit) is the best place to find answers.
|
@@ -17,12 +20,18 @@ LaneKit is a Ruby command line app that creates iOS Objective-C models for integ
|
|
17
20
|
## Example Usage
|
18
21
|
|
19
22
|
### Add a new model called Video to an existing Xcode project.
|
20
|
-
|
21
|
-
$ lanekit generate model Video duration:string headline:string image:string location:string
|
22
|
-
|
23
|
-
create Classes/
|
24
|
-
create Classes/
|
25
|
-
|
23
|
+
|
24
|
+
$ lanekit generate model Video duration:string headline:string id:integer image:string location:string
|
25
|
+
|
26
|
+
create Classes/Models
|
27
|
+
create Classes/Tests/Fixtures
|
28
|
+
create Classes/Tests/Models
|
29
|
+
create Classes/Models/Video.h
|
30
|
+
create Classes/Models/Video.m
|
31
|
+
create Classes/Tests/Fixtures/VideoFixtures.h
|
32
|
+
create Classes/Tests/Fixtures/VideoFixtures.m
|
33
|
+
create Classes/Tests/Models/VideoTest.h
|
34
|
+
create Classes/Tests/Models/VideoTest.m
|
26
35
|
|
27
36
|
and here is the Objective-C header file that was generated by LaneKit:
|
28
37
|
|
@@ -30,10 +39,10 @@ and here is the Objective-C header file that was generated by LaneKit:
|
|
30
39
|
//
|
31
40
|
// Video.h
|
32
41
|
//
|
33
|
-
// This model was created on 2013-
|
42
|
+
// This model was created on 2013-08-10 by LaneKit v0.1.7.
|
34
43
|
//
|
35
44
|
// The following LaneKit command was used to generate this model:
|
36
|
-
// lanekit generate model Video duration:string headline:string image:string location:string
|
45
|
+
// lanekit generate model Video duration:string headline:string id:integer image:string location:string
|
37
46
|
//
|
38
47
|
|
39
48
|
#import <Foundation/Foundation.h>
|
@@ -44,6 +53,7 @@ and here is the Objective-C header file that was generated by LaneKit:
|
|
44
53
|
|
45
54
|
@property (nonatomic,strong) NSString *duration;
|
46
55
|
@property (nonatomic,strong) NSString *headline;
|
56
|
+
@property (nonatomic,strong) NSNumber *id;
|
47
57
|
@property (nonatomic,strong) NSString *image;
|
48
58
|
@property (nonatomic,strong) NSString *location;
|
49
59
|
|
@@ -59,16 +69,12 @@ and here is the Objective-C .m file that was generated by LaneKit:
|
|
59
69
|
//
|
60
70
|
// Video.m
|
61
71
|
//
|
62
|
-
// This model was created on 2013-
|
63
|
-
//
|
72
|
+
// This model was created on 2013-08-10 by LaneKit v0.1.7.
|
64
73
|
//
|
65
74
|
|
66
75
|
#import "Video.h"
|
67
|
-
#import "MobileCoreServices/MobileCoreServices.h"
|
68
|
-
#import "SystemConfiguration/SystemConfiguration.h"
|
69
76
|
#import "RestKit.h"
|
70
77
|
|
71
|
-
|
72
78
|
@implementation Video
|
73
79
|
|
74
80
|
+ (void)initialize
|
@@ -83,6 +89,7 @@ and here is the Objective-C .m file that was generated by LaneKit:
|
|
83
89
|
return @{
|
84
90
|
@"duration": @"duration",
|
85
91
|
@"headline": @"headline",
|
92
|
+
@"id": @"id",
|
86
93
|
@"image": @"image",
|
87
94
|
@"location": @"location"
|
88
95
|
};
|
data/lib/lanekit/version.rb
CHANGED
data/lib/lanekit.rb
CHANGED
@@ -49,16 +49,54 @@ module LaneKit
|
|
49
49
|
end
|
50
50
|
type
|
51
51
|
end
|
52
|
+
|
53
|
+
def self.objective_c_type_fixture_value(type_name)
|
54
|
+
if type_name == "array"
|
55
|
+
value = "@[]"
|
56
|
+
elsif type_name == "date"
|
57
|
+
value = "NSDate.new"
|
58
|
+
elsif type_name == "integer"
|
59
|
+
value = "[NSNumber numberWithInteger:1]"
|
60
|
+
elsif type_name == "string"
|
61
|
+
value = "@\"MyString\""
|
62
|
+
elsif type_name
|
63
|
+
value = "nil"
|
64
|
+
else
|
65
|
+
value = "nil"
|
66
|
+
end
|
67
|
+
value
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.objective_c_type_unit_test_assert(model_name, name, type_name)
|
71
|
+
if type_name == "array"
|
72
|
+
assert = "STAssertNotNil(#{model_name}.#{name}, @\"#{name} is nil\")"
|
73
|
+
elsif type_name == "date"
|
74
|
+
assert = "STAssertNotNil(#{model_name}.#{name}, @\"#{name} is nil\")"
|
75
|
+
elsif type_name == "integer"
|
76
|
+
assert = "STAssertTrue(#{model_name}.#{name}.integerValue == #{self.objective_c_type_fixture_value(type_name)}.integerValue, @\"#{name} not #{self.objective_c_type_fixture_value(type_name)}\")"
|
77
|
+
elsif type_name == "string"
|
78
|
+
assert = "STAssertTrue([#{model_name}.#{name} isEqualToString:#{self.objective_c_type_fixture_value(type_name)}], @\"#{name} not correct value\")"
|
79
|
+
elsif type_name
|
80
|
+
assert = "STAssertNotNil(#{model_name}.#{name}, @\"#{name} is nil\")"
|
81
|
+
else
|
82
|
+
assert = "STAssertNotNil(#{model_name}.#{name}, @\"#{name} is nil\")"
|
83
|
+
end
|
84
|
+
assert
|
85
|
+
end
|
52
86
|
|
53
87
|
module Generators
|
54
88
|
|
55
89
|
class Generate < Thor
|
56
90
|
include Thor::Actions
|
57
91
|
|
58
|
-
desc "model [name] [name:type:relationship, name:type:relationship, ...] where type is [date|integer|string|<class_name>] and relationship (optional) is []", "Generates an Objective-C model for RestKit"
|
92
|
+
desc "model [name] [name:type:relationship, name:type:relationship, ...] where type is [date|integer|string|<class_name>] and relationship (optional) is []", "Generates an Objective-C model for RestKit including unit tests"
|
59
93
|
def model(model_name, *attributes)
|
60
94
|
@model_name = LaneKit.derive_model_name(model_name)
|
61
|
-
|
95
|
+
|
96
|
+
@model_file_name = LaneKit.derive_file_name(@model_name)
|
97
|
+
@model_fixtures_file_name = "#{@model_file_name}Fixtures"
|
98
|
+
@model_tests_file_name = "#{@model_file_name}Test"
|
99
|
+
|
62
100
|
@class_name = LaneKit.derive_class_name(@model_name)
|
63
101
|
@lanekit_version = VERSION;
|
64
102
|
|
@@ -72,7 +110,10 @@ module LaneKit
|
|
72
110
|
:type => type,
|
73
111
|
:name => name,
|
74
112
|
:objective_c_type => objective_c_type,
|
75
|
-
:relationship => relationship
|
113
|
+
:relationship => relationship,
|
114
|
+
:relationship_fixtures_file_name => "#{relationship}Fixtures",
|
115
|
+
:fixture_value => LaneKit.objective_c_type_fixture_value(type),
|
116
|
+
:unit_test_assert => LaneKit.objective_c_type_unit_test_assert(@model_name, name, type)
|
76
117
|
}
|
77
118
|
@any_relationships = relationship ? true : @any_relationships
|
78
119
|
}
|
@@ -95,7 +136,11 @@ module LaneKit
|
|
95
136
|
no_commands {
|
96
137
|
def initialize_stuff
|
97
138
|
@model_date = Date.today.to_s
|
98
|
-
|
139
|
+
|
140
|
+
@models_folder = "Classes/Models"
|
141
|
+
@tests_fixtures_folder = "Classes/Tests/Fixtures"
|
142
|
+
@tests_models_folder = "Classes/Tests/Models"
|
143
|
+
|
99
144
|
@template_folder = File.expand_path('../template', __FILE__)
|
100
145
|
@using_core_data = false
|
101
146
|
end
|
@@ -106,20 +151,45 @@ module LaneKit
|
|
106
151
|
|
107
152
|
def create_model_folders
|
108
153
|
empty_directory @models_folder
|
154
|
+
empty_directory @tests_fixtures_folder
|
155
|
+
empty_directory @tests_models_folder
|
109
156
|
end
|
110
157
|
|
111
158
|
def create_model_files(model_name)
|
112
159
|
# Files are created lowercase
|
113
160
|
# Class names are camel case, videodata => VideoData
|
114
|
-
|
161
|
+
|
162
|
+
# 1) Create the Models
|
115
163
|
# Create the .h file
|
116
164
|
source = "model.h.erb"
|
117
|
-
target = File.join(@models_folder, "#{@
|
165
|
+
target = File.join(@models_folder, "#{@model_file_name}.h")
|
118
166
|
template(source,target)
|
119
167
|
|
120
168
|
# Create the .m file
|
121
169
|
source = "model.m.erb"
|
122
|
-
target = File.join(@models_folder, "#{@
|
170
|
+
target = File.join(@models_folder, "#{@model_file_name}.m")
|
171
|
+
template(source,target)
|
172
|
+
|
173
|
+
# 2) Create the Model Test Fixtures
|
174
|
+
# Create the .h file
|
175
|
+
source = "model_fixture.h.erb"
|
176
|
+
target = File.join(@tests_fixtures_folder, "#{@model_fixtures_file_name}.h")
|
177
|
+
template(source,target)
|
178
|
+
|
179
|
+
# Create the .m file
|
180
|
+
source = "model_fixture.m.erb"
|
181
|
+
target = File.join(@tests_fixtures_folder, "#{@model_fixtures_file_name}.m")
|
182
|
+
template(source,target)
|
183
|
+
|
184
|
+
# 3) Create the Model Tests
|
185
|
+
# Create the .h file
|
186
|
+
source = "model_test.h.erb"
|
187
|
+
target = File.join(@tests_models_folder, "#{@model_tests_file_name}.h")
|
188
|
+
template(source,target)
|
189
|
+
|
190
|
+
# Create the .m file
|
191
|
+
source = "model_test.m.erb"
|
192
|
+
target = File.join(@tests_models_folder, "#{@model_tests_file_name}.m")
|
123
193
|
template(source,target)
|
124
194
|
end
|
125
195
|
|
@@ -134,7 +204,7 @@ end
|
|
134
204
|
|
135
205
|
module LaneKit
|
136
206
|
class CLI < Thor
|
137
|
-
desc "generate", "Generate a model compatible with RestKit"
|
207
|
+
desc "generate", "Generate a model compatible with RestKit that includes unit tests"
|
138
208
|
|
139
209
|
# register(class_name, subcommand_alias, usage_list_string, description_string)
|
140
210
|
register(LaneKit::Generators::Generate, "generate", "generate", "Runs a generator")
|
data/lib/template/model.h.erb
CHANGED
data/lib/template/model.m.erb
CHANGED
@@ -1,15 +1,12 @@
|
|
1
1
|
//
|
2
|
-
// <%=@
|
2
|
+
// <%=@model_file_name%>.m
|
3
3
|
//
|
4
4
|
// This model was created on <%=@model_date%> by LaneKit v<%=@lanekit_version%>.
|
5
5
|
//
|
6
|
-
//
|
7
6
|
|
8
|
-
#import "<%=@
|
9
|
-
#import "
|
10
|
-
#import "
|
11
|
-
#import "RestKit.h"
|
12
|
-
<% @attributes.each do |attribute| %><% if attribute[:relationship] %>#import "<%=attribute[:relationship]%>.h"<%end%><%end%>
|
7
|
+
#import "<%=@model_file_name%>.h"
|
8
|
+
#import "RestKit.h"<% @attributes.each do |attribute| %><% if attribute[:relationship] %>
|
9
|
+
#import "<%=attribute[:relationship]%>.h"<%end%><%end%>
|
13
10
|
|
14
11
|
@implementation <%=@class_name%>
|
15
12
|
|
@@ -0,0 +1,16 @@
|
|
1
|
+
//
|
2
|
+
// <%=@model_fixtures_file_name%>.h
|
3
|
+
//
|
4
|
+
// This model fixture was created on <%=@model_date%> by LaneKit v<%=@lanekit_version%>.
|
5
|
+
//
|
6
|
+
|
7
|
+
#import <Foundation/Foundation.h>
|
8
|
+
#import "<%=@model_file_name%>.h"<% @attributes.each do |attribute| %><% if attribute[:relationship] %>
|
9
|
+
#import "<%=attribute[:relationship]%>.h"<%end%><%end%>
|
10
|
+
|
11
|
+
@interface <%=@class_name%>Fixtures : NSObject
|
12
|
+
|
13
|
+
+ (<%=@class_name%> *)one;
|
14
|
+
+ (<%=@class_name%> *)two;
|
15
|
+
|
16
|
+
@end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
//
|
2
|
+
// <%=@model_fixtures_file_name%>.m
|
3
|
+
//
|
4
|
+
// This model fixture was created on <%=@model_date%> by LaneKit v<%=@lanekit_version%>.
|
5
|
+
//
|
6
|
+
|
7
|
+
#import "<%=@model_fixtures_file_name%>.h"<% @attributes.each do |attribute| %><% if attribute[:relationship] %>
|
8
|
+
#import "<%=attribute[:relationship_fixtures_file_name]%>.h"<%end%><%end%>
|
9
|
+
|
10
|
+
@implementation <%=@class_name%>Fixtures
|
11
|
+
|
12
|
+
+ (<%=@class_name%> *)one
|
13
|
+
{
|
14
|
+
<%=@class_name%> *<%=@model_name%> = <%=@class_name%>.new;
|
15
|
+
|
16
|
+
<% @attributes.each_with_index do |attribute, index| %><% if attribute[:relationship] %> <%=@model_name%>.<%=attribute[:name]%> = @[<%=attribute[:relationship]%>Fixtures.one];<% else %><%=@model_name%>.<%=attribute[:name]%> = <%=attribute[:fixture_value]%>;<% end %>
|
17
|
+
<% end %>
|
18
|
+
return <%=@model_name%>;
|
19
|
+
}
|
20
|
+
|
21
|
+
+ (<%=@class_name%> *)two
|
22
|
+
{
|
23
|
+
<%=@class_name%> *<%=@model_name%> = <%=@class_name%>.new;
|
24
|
+
|
25
|
+
<% @attributes.each_with_index do |attribute, index| %><% if attribute[:relationship] %> <%=@model_name%>.<%=attribute[:name]%> = @[<%=attribute[:relationship]%>Fixtures.one, <%=attribute[:relationship]%>Fixtures.two];<% else %> <%=@model_name%>.<%=attribute[:name]%> = <%=attribute[:fixture_value]%>;<% end %>
|
26
|
+
<% end %>
|
27
|
+
return <%=@model_name%>;
|
28
|
+
}
|
29
|
+
|
30
|
+
@end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
//
|
2
|
+
// <%=@model_tests_file_name%>.m
|
3
|
+
//
|
4
|
+
// This model test was created on <%=@model_date%> by LaneKit v<%=@lanekit_version%>.
|
5
|
+
//
|
6
|
+
|
7
|
+
#import "<%=@model_tests_file_name%>.h"
|
8
|
+
#import "<%=@model_fixtures_file_name%>.h"
|
9
|
+
|
10
|
+
@implementation <%=@class_name%>Test
|
11
|
+
|
12
|
+
- (void)setUp
|
13
|
+
{
|
14
|
+
[super setUp];
|
15
|
+
|
16
|
+
// Set-up code here.
|
17
|
+
}
|
18
|
+
|
19
|
+
- (void)tearDown
|
20
|
+
{
|
21
|
+
// Tear-down code here.
|
22
|
+
|
23
|
+
[super tearDown];
|
24
|
+
}
|
25
|
+
|
26
|
+
- (void)test<%=@class_name%>NewOne
|
27
|
+
{
|
28
|
+
<%=@class_name%> *<%=@model_name%> = <%=@class_name%>Fixtures.one;
|
29
|
+
STAssertNotNil(<%=@model_name%>, @"<%=@model_name%> is nil");
|
30
|
+
|
31
|
+
<% @attributes.each_with_index do |attribute, index| %><% if !attribute[:relationship] %> <%=attribute[:unit_test_assert]%>;<% end %>
|
32
|
+
<% end %>}
|
33
|
+
|
34
|
+
- (void)test<%=@class_name%>NewTwo
|
35
|
+
{
|
36
|
+
<%=@class_name%> *<%=@model_name%> = <%=@class_name%>Fixtures.two;
|
37
|
+
STAssertNotNil(<%=@model_name%>, @"<%=@model_name%> is nil");
|
38
|
+
|
39
|
+
<% @attributes.each_with_index do |attribute, index| %><% if !attribute[:relationship] %> <%=attribute[:unit_test_assert]%>;<% end %>
|
40
|
+
<% end %>}
|
41
|
+
|
42
|
+
- (void)testMapping
|
43
|
+
{
|
44
|
+
RKObjectMapping *requestMapping = [<%=@class_name%> requestMapping];
|
45
|
+
STAssertNotNil(requestMapping, @"[<%=@class_name%> requestMapping] returned nil.");
|
46
|
+
|
47
|
+
RKObjectMapping *responseMapping = [<%=@class_name%> responseMapping];
|
48
|
+
STAssertNotNil(responseMapping, @"[<%=@class_name%> responseMapping] returned nil.");
|
49
|
+
}
|
50
|
+
|
51
|
+
@end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lanekit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Larry Aasen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -38,7 +38,7 @@ dependencies:
|
|
38
38
|
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.5.5
|
41
|
-
description:
|
41
|
+
description: a code generator for iOS Objective-C models for integration with RestKit.
|
42
42
|
email:
|
43
43
|
- larryaasen@gmail.com
|
44
44
|
executables:
|
@@ -50,6 +50,10 @@ files:
|
|
50
50
|
- lib/lanekit.rb
|
51
51
|
- lib/template/model.h.erb
|
52
52
|
- lib/template/model.m.erb
|
53
|
+
- lib/template/model_fixture.h.erb
|
54
|
+
- lib/template/model_fixture.m.erb
|
55
|
+
- lib/template/model_test.h.erb
|
56
|
+
- lib/template/model_test.m.erb
|
53
57
|
- bin/lanekit
|
54
58
|
- README.md
|
55
59
|
- LICENSE
|
@@ -76,6 +80,6 @@ rubyforge_project:
|
|
76
80
|
rubygems_version: 2.0.3
|
77
81
|
signing_key:
|
78
82
|
specification_version: 4
|
79
|
-
summary: LaneKit is a
|
80
|
-
|
83
|
+
summary: LaneKit is a code generator for iOS Objective-C models for integration with
|
84
|
+
RestKit.
|
81
85
|
test_files: []
|