iosgen 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.coveralls.yml +1 -0
- data/.gitignore +37 -0
- data/.hound.yml +6 -0
- data/.rubocop.yml +7 -0
- data/Gemfile +19 -0
- data/Gemfile.lock +110 -0
- data/Guardfile +16 -0
- data/LICENSE +22 -0
- data/README.md +158 -0
- data/Rakefile +28 -0
- data/bin/iosgen +6 -0
- data/iosgen.gemspec +29 -0
- data/lib/ios_gen/base/action.rb +15 -0
- data/lib/ios_gen/base/base_factory.rb +73 -0
- data/lib/ios_gen/base/interactor.rb +15 -0
- data/lib/ios_gen/base/property.rb +13 -0
- data/lib/ios_gen/base/view_controller.rb +15 -0
- data/lib/ios_gen/base/view_model.rb +16 -0
- data/lib/ios_gen/generator/base_generator.rb +61 -0
- data/lib/ios_gen/generator/objc/action_formatter.rb +35 -0
- data/lib/ios_gen/generator/objc/interactor_formatter.rb +68 -0
- data/lib/ios_gen/generator/objc/objc_formatter.rb +30 -0
- data/lib/ios_gen/generator/objc/view_controller_formatter.rb +37 -0
- data/lib/ios_gen/generator/objc/view_model_formatter.rb +88 -0
- data/lib/ios_gen/ios_gen_thor.rb +17 -0
- data/lib/iosgen.rb +5 -0
- data/spec/ios_gen/base/action_spec.rb +50 -0
- data/spec/ios_gen/base/base_factory_spec.rb +238 -0
- data/spec/ios_gen/base/interactor_spec.rb +60 -0
- data/spec/ios_gen/base/property_spec.rb +26 -0
- data/spec/ios_gen/base/view_controller_spec.rb +18 -0
- data/spec/ios_gen/base/view_model_spec.rb +70 -0
- data/spec/ios_gen/generator/base_generator_spec.rb +84 -0
- data/spec/ios_gen/generator/objc/action_formatter_spec.rb +88 -0
- data/spec/ios_gen/generator/objc/interactor_formatter_spec.rb +79 -0
- data/spec/ios_gen/generator/objc/objc_formatter_spec.rb +52 -0
- data/spec/ios_gen/generator/objc/view_controller_formatter_spec.rb +52 -0
- data/spec/ios_gen/generator/objc/view_model_formatter_spec.rb +125 -0
- data/spec/ios_gen/generator/spec.json +58 -0
- data/spec/spec_helper.rb +8 -0
- data/templates/objc/Interactor.h.erb +11 -0
- data/templates/objc/Interactor.m.erb +13 -0
- data/templates/objc/InteractorProtocol.h.erb +9 -0
- data/templates/objc/UIViewController.h.erb +8 -0
- data/templates/objc/UIViewController.m.erb +31 -0
- data/templates/objc/ViewModel.h.erb +9 -0
- data/templates/objc/ViewModel.m.erb +13 -0
- data/templates/objc/ViewModelProtocol.h.erb +16 -0
- metadata +178 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 54af41a931ad710b1218b819fc0fab4ef855fed7
|
4
|
+
data.tar.gz: c96ae8055f0e22112cb4160bebe639658a6261af
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7a1d520dd3d80397184285077d0da59748f9a8013dabf624de41966a812fbf873f570334b5f3b6ef1ba3a2bda431243b006d22430a086e33c9c966c4358d54af
|
7
|
+
data.tar.gz: dc9d05489f95f8f755ae981934f2bfb94c8000540342bea722ee29904fd08ab078eeb9ad29af658ebe11facdaf980dd367becb9082dd659295ac9f2f336643b7
|
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
data/.gitignore
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/test/tmp/
|
9
|
+
/test/version_tmp/
|
10
|
+
/tmp/
|
11
|
+
|
12
|
+
## Specific to RubyMotion:
|
13
|
+
.dat*
|
14
|
+
.repl_history
|
15
|
+
build/
|
16
|
+
|
17
|
+
## Documentation cache and generated files:
|
18
|
+
/.yardoc/
|
19
|
+
/_yardoc/
|
20
|
+
/doc/
|
21
|
+
/rdoc/
|
22
|
+
|
23
|
+
## Environment normalisation:
|
24
|
+
/.bundle/
|
25
|
+
/lib/bundler/man/
|
26
|
+
|
27
|
+
# for a library or gem, you might want to ignore these files since the code is
|
28
|
+
# intended to run in multiple environments; otherwise, check them in:
|
29
|
+
# Gemfile.lock
|
30
|
+
# .ruby-version
|
31
|
+
# .ruby-gemset
|
32
|
+
|
33
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
34
|
+
.rvmrc
|
35
|
+
|
36
|
+
# OSX
|
37
|
+
.DS_Store
|
data/.hound.yml
ADDED
data/.rubocop.yml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gem 'simplecov', require: false
|
4
|
+
gem 'coveralls', require: false
|
5
|
+
gem 'colorize', '~> 0.7.4'
|
6
|
+
gem 'thor', '~> 0.19.1'
|
7
|
+
|
8
|
+
group :test do
|
9
|
+
gem 'rake'
|
10
|
+
gem 'rspec'
|
11
|
+
end
|
12
|
+
|
13
|
+
group :development do
|
14
|
+
gem 'guard'
|
15
|
+
gem 'guard-rspec'
|
16
|
+
gem 'guard-rubocop'
|
17
|
+
gem 'pry'
|
18
|
+
gem 'json'
|
19
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
ast (2.0.0)
|
5
|
+
astrolabe (1.3.0)
|
6
|
+
parser (>= 2.2.0.pre.3, < 3.0)
|
7
|
+
celluloid (0.16.0)
|
8
|
+
timers (~> 4.0.0)
|
9
|
+
coderay (1.1.0)
|
10
|
+
colorize (0.7.5)
|
11
|
+
coveralls (0.7.1)
|
12
|
+
multi_json (~> 1.3)
|
13
|
+
rest-client
|
14
|
+
simplecov (>= 0.7)
|
15
|
+
term-ansicolor
|
16
|
+
thor
|
17
|
+
diff-lcs (1.2.5)
|
18
|
+
docile (1.1.5)
|
19
|
+
ffi (1.9.6)
|
20
|
+
formatador (0.2.5)
|
21
|
+
guard (2.10.4)
|
22
|
+
formatador (>= 0.2.4)
|
23
|
+
listen (~> 2.7)
|
24
|
+
lumberjack (~> 1.0)
|
25
|
+
nenv (~> 0.1)
|
26
|
+
pry (>= 0.9.12)
|
27
|
+
thor (>= 0.18.1)
|
28
|
+
guard-compat (1.2.0)
|
29
|
+
guard-rspec (4.5.0)
|
30
|
+
guard (~> 2.1)
|
31
|
+
guard-compat (~> 1.1)
|
32
|
+
rspec (>= 2.99.0, < 4.0)
|
33
|
+
guard-rubocop (1.2.0)
|
34
|
+
guard (~> 2.0)
|
35
|
+
rubocop (~> 0.20)
|
36
|
+
hitimes (1.2.2)
|
37
|
+
json (1.8.1)
|
38
|
+
listen (2.8.4)
|
39
|
+
celluloid (>= 0.15.2)
|
40
|
+
rb-fsevent (>= 0.9.3)
|
41
|
+
rb-inotify (>= 0.9)
|
42
|
+
lumberjack (1.0.9)
|
43
|
+
method_source (0.8.2)
|
44
|
+
mime-types (2.4.3)
|
45
|
+
multi_json (1.10.1)
|
46
|
+
nenv (0.1.1)
|
47
|
+
netrc (0.10.2)
|
48
|
+
parser (2.2.0.pre.8)
|
49
|
+
ast (>= 1.1, < 3.0)
|
50
|
+
slop (~> 3.4, >= 3.4.5)
|
51
|
+
powerpack (0.0.9)
|
52
|
+
pry (0.10.1)
|
53
|
+
coderay (~> 1.1.0)
|
54
|
+
method_source (~> 0.8.1)
|
55
|
+
slop (~> 3.4)
|
56
|
+
rainbow (2.0.0)
|
57
|
+
rake (10.4.2)
|
58
|
+
rb-fsevent (0.9.4)
|
59
|
+
rb-inotify (0.9.5)
|
60
|
+
ffi (>= 0.5.0)
|
61
|
+
rest-client (1.7.2)
|
62
|
+
mime-types (>= 1.16, < 3.0)
|
63
|
+
netrc (~> 0.7)
|
64
|
+
rspec (3.1.0)
|
65
|
+
rspec-core (~> 3.1.0)
|
66
|
+
rspec-expectations (~> 3.1.0)
|
67
|
+
rspec-mocks (~> 3.1.0)
|
68
|
+
rspec-core (3.1.7)
|
69
|
+
rspec-support (~> 3.1.0)
|
70
|
+
rspec-expectations (3.1.2)
|
71
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
72
|
+
rspec-support (~> 3.1.0)
|
73
|
+
rspec-mocks (3.1.3)
|
74
|
+
rspec-support (~> 3.1.0)
|
75
|
+
rspec-support (3.1.2)
|
76
|
+
rubocop (0.28.0)
|
77
|
+
astrolabe (~> 1.3)
|
78
|
+
parser (>= 2.2.0.pre.7, < 3.0)
|
79
|
+
powerpack (~> 0.0.6)
|
80
|
+
rainbow (>= 1.99.1, < 3.0)
|
81
|
+
ruby-progressbar (~> 1.4)
|
82
|
+
ruby-progressbar (1.7.1)
|
83
|
+
simplecov (0.9.1)
|
84
|
+
docile (~> 1.1.0)
|
85
|
+
multi_json (~> 1.0)
|
86
|
+
simplecov-html (~> 0.8.0)
|
87
|
+
simplecov-html (0.8.0)
|
88
|
+
slop (3.6.0)
|
89
|
+
term-ansicolor (1.3.0)
|
90
|
+
tins (~> 1.0)
|
91
|
+
thor (0.19.1)
|
92
|
+
timers (4.0.1)
|
93
|
+
hitimes
|
94
|
+
tins (1.3.3)
|
95
|
+
|
96
|
+
PLATFORMS
|
97
|
+
ruby
|
98
|
+
|
99
|
+
DEPENDENCIES
|
100
|
+
colorize (~> 0.7.4)
|
101
|
+
coveralls
|
102
|
+
guard
|
103
|
+
guard-rspec
|
104
|
+
guard-rubocop
|
105
|
+
json
|
106
|
+
pry
|
107
|
+
rake
|
108
|
+
rspec
|
109
|
+
simplecov
|
110
|
+
thor (~> 0.19.1)
|
data/Guardfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
guard 'rspec', cmd: 'rspec --color --format doc' do
|
2
|
+
# watch /lib/ files
|
3
|
+
watch(/^lib\/(.+)\.rb$/) do |m|
|
4
|
+
"spec/#{m[1]}_spec.rb"
|
5
|
+
end
|
6
|
+
|
7
|
+
# watch /spec/ files
|
8
|
+
watch(/^spec\/(.+)\.rb$/) do |m|
|
9
|
+
"spec/#{m[1]}.rb"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
guard :rubocop do
|
14
|
+
watch(/.+\\.rb$/)
|
15
|
+
watch(/(?:.+\/)?\.rubocop\.yml$/) { |m| File.dirname(m[0]) }
|
16
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Francisco J. Belchi
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1,158 @@
|
|
1
|
+
Clean iOS architecture generator
|
2
|
+
================================
|
3
|
+
[![Build Status](https://travis-ci.org/fjbelchi/clean-iOS-architecture-generator.svg)](https://travis-ci.org/fjbelchi/clean-iOS-architecture-generator)
|
4
|
+
[![Coverage Status](https://coveralls.io/repos/fjbelchi/clean-iOS-architecture-generator/badge.png)](https://coveralls.io/r/fjbelchi/clean-iOS-architecture-generator)
|
5
|
+
[![Code Climate](https://codeclimate.com/github/fjbelchi/clean-iOS-architecture-generator/badges/gpa.svg)](https://codeclimate.com/github/fjbelchi/clean-iOS-architecture-generator)
|
6
|
+
|
7
|
+
Ruby script to generate a clean iOS architecture based on a spec file written in json format.
|
8
|
+
Having the following components, the script will generate files according and it will add some logic in order to save development time.
|
9
|
+
|
10
|
+
In the [roadmap](https://github.com/fjbelchi/clean-iOS-architecture-generator/issues) there are features like estimations and creation of tickets in Github Issues and others management tools.
|
11
|
+
|
12
|
+
Working in progress project
|
13
|
+
|
14
|
+
## Components
|
15
|
+
|
16
|
+
#### Property
|
17
|
+
```json
|
18
|
+
{
|
19
|
+
"Type": "NSIndexPath *",
|
20
|
+
"Name": "selectedIndexPath"
|
21
|
+
}
|
22
|
+
```
|
23
|
+
|
24
|
+
#### Action
|
25
|
+
```json
|
26
|
+
{
|
27
|
+
"description": "Dismiss the ViewController when the button is tapped",
|
28
|
+
"return_type": "void",
|
29
|
+
"name": "didTapOnCloseButton:",
|
30
|
+
"arguments": [{
|
31
|
+
"type" : "UIButton *",
|
32
|
+
"name" : "closeButton"
|
33
|
+
}]
|
34
|
+
}
|
35
|
+
```
|
36
|
+
|
37
|
+
#### Interactor
|
38
|
+
```json
|
39
|
+
{
|
40
|
+
"description" : "Api Interactions required by Notification ViewModel",
|
41
|
+
"name": "FJBNotificationsApiInteractor",
|
42
|
+
"properties": [],
|
43
|
+
"actions": [
|
44
|
+
{
|
45
|
+
"description": "Perform API request to mark a notification as read",
|
46
|
+
"return_type": "void",
|
47
|
+
"name": "markNotificationAsRead:onCompletionBlock:",
|
48
|
+
"arguments": [
|
49
|
+
{
|
50
|
+
"type": "NSString *",
|
51
|
+
"name": "notificationId"
|
52
|
+
},
|
53
|
+
{
|
54
|
+
"type": "void(^)()",
|
55
|
+
"name": "completionBlock"
|
56
|
+
}
|
57
|
+
]
|
58
|
+
}
|
59
|
+
]
|
60
|
+
}
|
61
|
+
```
|
62
|
+
|
63
|
+
#### ViewModel
|
64
|
+
```json
|
65
|
+
{
|
66
|
+
"description" : "State of NotificationViewController and perform bussiness logic",
|
67
|
+
"name": "FJBNotificationsViewModel",
|
68
|
+
"properties": [],
|
69
|
+
"actions": [],
|
70
|
+
"interactors": []
|
71
|
+
}
|
72
|
+
```
|
73
|
+
|
74
|
+
#### UIViewController
|
75
|
+
```json
|
76
|
+
"view_controller": {
|
77
|
+
"description": "ViewController to show the list of notifications",
|
78
|
+
"name": "FJBNotificationsViewController"
|
79
|
+
}
|
80
|
+
```
|
81
|
+
|
82
|
+
#### Example of Spec.json
|
83
|
+
|
84
|
+
```json
|
85
|
+
{
|
86
|
+
"view_controller": {
|
87
|
+
"description": "ViewController to show the list of notifications",
|
88
|
+
"name": "FJBNotificationViewController",
|
89
|
+
"view_model": {
|
90
|
+
"description" : "State of NotificationViewController and perform bussiness logic",
|
91
|
+
"name": "FJBNotificationsViewModel",
|
92
|
+
"properties": [
|
93
|
+
{
|
94
|
+
"type": "NSIndexPath *",
|
95
|
+
"name": "selectedIndexPath"
|
96
|
+
}
|
97
|
+
],
|
98
|
+
"actions": [
|
99
|
+
{
|
100
|
+
"description": "Dismiss the ViewController when the button is tapped",
|
101
|
+
"return_type": "void",
|
102
|
+
"name": "didTapOnCloseButton"
|
103
|
+
},
|
104
|
+
{
|
105
|
+
"description": "Mark notification as read when the notification is selected",
|
106
|
+
"return_type": "void",
|
107
|
+
"name": "didTapAtIndexPath:",
|
108
|
+
"arguments": [
|
109
|
+
{
|
110
|
+
"type": "NSIndexPath *",
|
111
|
+
"name": "indexPath"
|
112
|
+
}
|
113
|
+
]
|
114
|
+
}
|
115
|
+
],
|
116
|
+
"interactors": [
|
117
|
+
{
|
118
|
+
"description" : "Api Interactions required by Notification ViewModel",
|
119
|
+
"name": "FJBNotificationsApiInteractor",
|
120
|
+
"properties": [],
|
121
|
+
"actions": [
|
122
|
+
{
|
123
|
+
"description": "Perform API request to mark a notification as read",
|
124
|
+
"return_type": "void",
|
125
|
+
"name": "markNotificationAsRead:onCompletionBlock:",
|
126
|
+
"arguments": [
|
127
|
+
{
|
128
|
+
"type": "NSString *",
|
129
|
+
"name": "notificationId"
|
130
|
+
},
|
131
|
+
{
|
132
|
+
"type": "^()",
|
133
|
+
"name": "completionBlock"
|
134
|
+
}
|
135
|
+
]
|
136
|
+
}
|
137
|
+
]
|
138
|
+
}
|
139
|
+
]
|
140
|
+
}
|
141
|
+
}
|
142
|
+
}
|
143
|
+
```
|
144
|
+
|
145
|
+
#### Output
|
146
|
+
```shell
|
147
|
+
$ ./iosgen.rb spec ../spec/ios_gen/generator/spec.json
|
148
|
+
../spec/ios_gen/generator/spec.json
|
149
|
+
[+] Created FJBNotificationsViewController.h
|
150
|
+
[+] Created FJBNotificationsViewController.m
|
151
|
+
[+] Created FJBNotificationsViewModelProtocol.h
|
152
|
+
[+] Created FJBNotificationsViewModel.h
|
153
|
+
[+] Created FJBNotificationsViewModel.m
|
154
|
+
[+] Created FJBNotificationsApiInteractorProtocol.h
|
155
|
+
[+] Created FJBNotificationsApiInteractor.h
|
156
|
+
[+] Created FJBNotificationsApiInteractor.m
|
157
|
+
|
158
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'rspec/core/rake_task'
|
2
|
+
require 'rubocop/rake_task'
|
3
|
+
|
4
|
+
RSpec::Core::RakeTask.new(:spec) do |task|
|
5
|
+
task.rspec_opts = ['--color', '--format', 'progress']
|
6
|
+
end
|
7
|
+
|
8
|
+
desc 'Run RuboCop on the lib directory'
|
9
|
+
RuboCop::RakeTask.new(:rubocop) do |task|
|
10
|
+
task.patterns = ['lib/**/*.rb']
|
11
|
+
# only show the files with failures
|
12
|
+
task.formatters = ['files']
|
13
|
+
# don't abort rake on failure
|
14
|
+
task.fail_on_error = false
|
15
|
+
end
|
16
|
+
|
17
|
+
RuboCop::RakeTask.new do |task|
|
18
|
+
task.requires << 'rubocop-rspec'
|
19
|
+
end
|
20
|
+
|
21
|
+
desc 'Run RSpec with code coverage'
|
22
|
+
task :coverage do
|
23
|
+
Rake::Task['spec'].execute
|
24
|
+
`rake spec COVERAGE=true`
|
25
|
+
`open coverage/index.html`
|
26
|
+
end
|
27
|
+
|
28
|
+
task default: :spec
|
data/bin/iosgen
ADDED
data/iosgen.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = 'iosgen'
|
5
|
+
s.version = '1.0.0'
|
6
|
+
s.summary = 'Clean iOS architecture generator'
|
7
|
+
s.description = 'Code generator to build a clean iOS architecture'
|
8
|
+
s.authors = ['Francisco J. Belchi']
|
9
|
+
s.email = 'dev@fjbelchi.com'
|
10
|
+
s.homepage = 'http://www.fjbelchi.com'
|
11
|
+
s.license = 'MIT'
|
12
|
+
|
13
|
+
# Files
|
14
|
+
s.files = `git ls-files -z`.split("\x0")
|
15
|
+
s.executables = s.files.grep(/^bin/) { |f| File.basename(f) }
|
16
|
+
s.test_files = s.files.grep(/^(test|spec|features)/)
|
17
|
+
s.require_paths = ['lib']
|
18
|
+
|
19
|
+
# Dependencies
|
20
|
+
s.add_development_dependency 'rake'
|
21
|
+
s.add_development_dependency 'rspec'
|
22
|
+
s.add_development_dependency 'bundler', '~> 1.0'
|
23
|
+
s.add_dependency 'thor'
|
24
|
+
s.add_dependency 'colorize'
|
25
|
+
|
26
|
+
# Documentation
|
27
|
+
s.rdoc_options = ['--charset=UTF-8']
|
28
|
+
s.extra_rdoc_files = ['README.md']
|
29
|
+
end
|