generamba 1.3.0 → 1.4.0

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: 332df03b4189ec266771fed0a46ac00c293cfd8e
4
- data.tar.gz: 1cd1b1d225d848aaba37f174a1dc83ade3910c6a
3
+ metadata.gz: 24caf4143f4768fca7cbfd8a18a313430d1fa939
4
+ data.tar.gz: 34b32af6b64878ea9f7eb9270068abc3db2b7319
5
5
  SHA512:
6
- metadata.gz: 03f54f9ef17ce0c0990741abf416e9739aa3f730911f4e32766effc3407059997deac415e87cd13d5a18d0f9a3dc24bb8bd7fa577bbaafec2e89b9ca22ba8c9b
7
- data.tar.gz: f32faebc7eebe5d40df08fa06593d92dde3381270c86aa464e47a9dcbee00bc1a92c5c8e3a3ad0a0038d14bb516db9f1f37ded6abfc8b4556b76e23f8a43fcee
6
+ metadata.gz: d980760d382847b92e4f29ada83d3aee1b28e6b608589d1ba637dfddcc6e4bd9096433be824c3415ced6185ae52f5ad1dd4b75a981436e2da34b614b9795f62a
7
+ data.tar.gz: 521afeb37243599c6e0ee235e03ee44b67045b8d4c948c7b90810a5ace0799e54f341476aed582d9720c42a74d94252cdc6418b4861692d778015a06fd0ceedd
data/.gitignore CHANGED
@@ -1,9 +1,4 @@
1
- .idea/.name
2
- .idea/Generamba.iml
3
- .idea/misc.xml
4
- .idea/modules.xml
5
- .idea/vcs.xml
6
- .idea/workspace.xml
1
+ .idea/*
7
2
  .rakeTasks
8
3
  encodings.xml
9
4
  Gemfile.lock
data/README.md CHANGED
@@ -1,4 +1,6 @@
1
- ### Overview
1
+ <p align="center">
2
+ <img src="http://i.imgur.com/1AwoVaN.png"/>
3
+ </p>
2
4
 
3
5
  [![Build Status](https://travis-ci.org/rambler-digital-solutions/Generamba.svg)](https://travis-ci.org/rambler-digital-solutions/Generamba)
4
6
  [![Gem Version](https://badge.fury.io/rb/generamba.svg)](https://badge.fury.io/rb/generamba)
@@ -6,7 +8,12 @@
6
8
 
7
9
  **Generamba** is a code generator made for working with Xcode. Primarily it is designed to generate VIPER modules but it is quite easy to customize it for generation of any other classes (both in Objective-C and Swift).
8
10
 
9
- *We keep evolving Generamba:* [changelog](https://github.com/rambler-digital-solutions/Generamba/blob/develop/CHANGELOG.md), [release notes](https://github.com/rambler-digital-solutions/Generamba/releases).
11
+ *We keep evolving Generamba:*
12
+ - [Vision](https://github.com/rambler-digital-solutions/Generamba/blob/develop/VISION.md),
13
+ - [Changelog](https://github.com/rambler-digital-solutions/Generamba/blob/develop/CHANGELOG.md),
14
+ - [Release notes](https://github.com/rambler-digital-solutions/Generamba/releases).
15
+
16
+ Besides it, we started work on 2.0 version with powerful DSL and plugins. Check the [release roadmap](https://github.com/rambler-digital-solutions/Generamba/blob/develop/docs/2.x/roadmap.md)!
10
17
 
11
18
  ![Generamba Screenshot](https://habrastorage.org/files/b98/770/b37/b98770b37dc54de98daf0e22fea38478.gif)
12
19
 
@@ -0,0 +1,41 @@
1
+ # Vision
2
+
3
+ Generamba is a tool with one primary role:
4
+
5
+ > Routine tasks automation through code generation.
6
+
7
+ At first it was designed to work only with Xcode - IDE for iOS/macOS, but as time passed we saw a lot of opportunities to use it in other circumstances, e.g. in frontend, Android and backend development.
8
+
9
+ ### What Is Generamba
10
+
11
+ The Generamba core is a simple generator that takes a [liquid](https://shopify.github.io/liquid/) template and a set of parameters as an input and produces a text snippet as an output. Everything else is built upon this simple concept.
12
+
13
+ There are a lot of IDE's, package managers and other stuff which is related to creating new code modules. We try to keep the core small but provide rich opportunities for integration with all these tools via plugins *(in development)* and templates *(ready to use)* systems.
14
+
15
+ ### General Aim
16
+
17
+ Our general aim is to provide a simple yet extensible way to generate any piece of code. The beginner should be able to create new code modules without complex configuration process. Generamba capabilities should grow as fast as the user needs, providing ways to validate the environment status, integrations with different file systems and IDEs, complex statements inside templates and so on.
18
+
19
+ ### Templates
20
+
21
+ Code templates are the fuel for Generamba. We use a [liquid](https://shopify.github.io/liquid/) markup, because of its beautiful syntax and the ability to implement really complex logic.
22
+
23
+ Templates may be private as well as adopted for public. We provide a number of ways to install them - using local paths, remote git repository, public or private catalogs.
24
+
25
+ We also maintain a [public catalog](https://github.com/rambler-digital-solutions/generamba-catalog) which has some popular templates for iOS/macOS projects.
26
+
27
+ ### Communication
28
+
29
+ We try to keep all the discussion about Generamba within [GitHub issues](https://github.com/rambler-digital-solutions/Generamba/issues). This attitude allows us to keep our processes and intentions transparent.
30
+
31
+ Besides it there is a private Telegram channel where maintainers discuss work questions. We are considering moving to Slack or Gitter at some point in the future - but we haven't grown big enough yet.
32
+
33
+ ### Contributions
34
+
35
+ Despite main maintainers are engineers from Rambler&Co team, we are glad to welcome external contributors. Generamba has evolved a lot since the first alpha release thanks to a lot of ideas from its users that came in the form of issues and pull requests.
36
+
37
+ The aim of our core team is to adopt Generamba possibilities to each user needs and provide him a way to extend its functionality himself.
38
+
39
+ ### ...
40
+
41
+ The structure and idea of *VISION.md* file was taken from the [Danger](https://github.com/danger/danger) project and [@orta](https://github.com/orta).
@@ -0,0 +1,365 @@
1
+ # Generamba 2.0 Roadmap
2
+ ### Overview
3
+
4
+ The main aim of 2.0 release is to decouple Generamba from iOS/macOS development and make it available for other areas as well: backend, frontend, Android.
5
+
6
+ We'll definitely break the backwards compatibility with *Rambafile* and templates created for the 1.x Generamba versions. To simplify the upgrading process we're considering writing some automatic migration tools.
7
+
8
+ ### High-Level Tasks
9
+
10
+ * Switch *Rambafile* from `yml` to a custom DSL format.
11
+ * Wrap repetitive tasks into *ramba*'s - the nearest analogs are *lane*'s from `fastlane`.
12
+ * Introduce the concept of two types of *plugins*: system (validation, save) and general-purpose.
13
+ * Allow the usage of different types of hooks - `before`, `after`, `error`.
14
+ * Add validation plugins, that are available to check the environment before code generation.
15
+ * Extract the saving logic from the Generamba core to plugins, both to filesystem and Xcode.
16
+ * Add saving plugins, that are available to process the text snippet created by generamba and save it somewhere.
17
+ * Extract the validation logic from the Generamba core to plugins, both for CocoaPods and Carthage.
18
+
19
+ ### Generamba Flow
20
+
21
+ A typical generation process consists of three steps:
22
+ * validation
23
+ * generation
24
+ * saving
25
+
26
+ #### Validation
27
+
28
+ That step is used to validate the environment status before code generation. It's a perfect place to implement logic of checking the required packages versions, the presence of system libraries, git status and so on.
29
+
30
+ If one of checks returns an error, the overall validation process doesn't stop until all of validation methods execute. This is crucial for a smooth user experience.
31
+
32
+ #### Generation
33
+
34
+ That's the core functionality of Generamba. A user provides a template name and some options which are used as an input. After the generation Generamba produces a text snippet as an output.
35
+
36
+ There can be multiple generation actions as well. All of them are executed in the writing order and their results are stored in-memory.
37
+
38
+ #### Saving
39
+
40
+ This step defines what to do with a generation output. The most obvious options are to store it as a file in some directory on the disk, embed it in your IDE, upload somewhere or print in log.
41
+
42
+ If there are multiple saving actions, each of them is applied to each generation output. They are executed in the writing order.
43
+
44
+ ### DSL
45
+
46
+ #### Basic Rambafile Structure
47
+
48
+ The main building block of *Rambafile* is `ramba`:
49
+
50
+ ```
51
+ desc "Creates a new Xcode project"
52
+ ramba :viper_module do
53
+ # Detailed description of generation steps
54
+ end
55
+ ```
56
+
57
+ The *Rambafile* may be monolithic as well as decomposed to multiple files. This is available via special functions:
58
+ - `ramba_import_local('path')` - imports the contents of `Rambafile` stored locally.
59
+ - `ramba_import_git('git', 'branch')` - imports the contents of Rambafile stored in remote git repository.
60
+
61
+ #### Setting Options
62
+
63
+ A user can set options in any part of *Rambafile* structure. It's important to note, that option, defined on the next level of method hierarchy, overwrites it's previous declaration. That allows to have a default value for some key and redefine it in each `ramba`.
64
+ ```
65
+ set :project_name, 'MyProject'
66
+
67
+ ramba :viper_module do
68
+ set :project_name, 'MyProject'
69
+ end
70
+ ```
71
+
72
+ It's also available to set an option using lambda:
73
+ ```
74
+ set :date_string, -> {
75
+ "Current date: #{Date.now}"
76
+ }
77
+ ```
78
+
79
+ > How options are set in Rambafile...
80
+ >
81
+
82
+ Besides `ramba` -specific options, there are template-specific options as well. They may correspond to a specific template and be defined in the *.rambaspec* file.
83
+
84
+ > The saving action for Xcode should behave differently depending on whether a generated file it's a code file or some resource. So, there is a special option for each file of Xcode templates:
85
+ > `- {name: Router/RouterTests.m, path: Tests/Router/router_tests.m.liquid, is_resource: false}`
86
+
87
+ #### Hooks
88
+
89
+ There are multiple types of hooks, which make possible to perform some action or redefine an option in certain moments of generation cycle.
90
+
91
+ ##### `before` hooks
92
+
93
+ A user can specify a hook, that'll execute before a specific `ramba`:
94
+ ```
95
+ before :viper_module do
96
+ # Some logic here...
97
+ end
98
+ ```
99
+
100
+ It's also possible to write a hook that'll execute before each `ramba`:
101
+ ```
102
+ before_each do |ramba_name|
103
+ # Some logic here...
104
+ end
105
+ ```
106
+
107
+ ##### `after` hooks
108
+
109
+ A user can specify a hook, that'll execute after a specific `ramba`:
110
+ ```
111
+ after :viper_module do
112
+ # Some logic here...
113
+ end
114
+ ```
115
+
116
+ It's also possible to write a hook that'll execute after each `ramba`:
117
+ ```
118
+ after_each do |ramba_name|
119
+ # Some logic here...
120
+ end
121
+ ```
122
+
123
+ ##### `error` hooks
124
+
125
+ If any action returns an error, it's possible to customize the resulting behavior for a specific `ramba` :
126
+ ```
127
+ error :viper_module do
128
+ # Some logic here...
129
+ end
130
+ ```
131
+ It's also possible to write a hook that'll execute in case of error in any `ramba`:
132
+ ```
133
+ error_each do |ramba_name|
134
+ # Some logic here...
135
+ end
136
+ ```
137
+
138
+ #### `ramba` structure
139
+
140
+ As we've already mentioned, `ramba` consists of three main steps. Multiple actions in each step are executed in the writing order.
141
+
142
+ ##### Validation actions
143
+
144
+ ```
145
+ ramba :viper_module do
146
+ ...
147
+ validate :validate_plugin_name do
148
+ set :some_option, 'some_value'
149
+ any_custom_action()
150
+ end
151
+ ...
152
+ end
153
+ ```
154
+
155
+ This notation means the following steps:
156
+ - The lambda passed to the validate action is executed.
157
+ - The plugin with name `validate_plugin_name` is called with options modified by lambda.
158
+
159
+ The notation can be simplified to:
160
+ ```
161
+ validate :validate_plugin_name
162
+ ```
163
+
164
+ ##### Generation actions
165
+
166
+ ```
167
+ ramba :viper_module do
168
+ ...
169
+ gen :viper_module do
170
+ set :some_option, 'some_value'
171
+ any_custom_action(parameter1)
172
+ end
173
+ ...
174
+ end
175
+ ```
176
+
177
+ This notation means the following steps:
178
+ - The lambda passed to the gen action is executed.
179
+ * The `gen` command is called with a template *viper_module* and options modified by lambda.
180
+
181
+ The notation can be simplified to:
182
+ ```
183
+ gen :viper_module
184
+ ```
185
+
186
+ ##### Saving actions
187
+
188
+ ```
189
+ ramba :viper_module do
190
+ ...
191
+ save :save_plugin_name do
192
+ set :some_option, 'some_value'
193
+ any_custom_action()
194
+ end
195
+ ...
196
+ end
197
+ ```
198
+
199
+ This notation means the following steps:
200
+ - The lambda passed to the saving action is executed.
201
+ - The plugin with name `save_plugin_name` is called with options modified by lambda.
202
+
203
+ The notation can be simplified to:
204
+ ```
205
+ save :save_plugin_name
206
+ ```
207
+
208
+ ##### Custom Actions
209
+
210
+ Besides system plugins (validation and saving), a user can create a general-purpose plugin which contains some specific reusable logic. E.g. a plugin which clears the environment - calls `git reset`, uninstalls some packages and so on. It's called simply by calling it's name:
211
+ ```
212
+ ramba :viper_module do
213
+ ...
214
+ any_custom_action()
215
+ ...
216
+ end
217
+ ```
218
+
219
+ ##### Templates and Catalogs
220
+
221
+ Templates and tempalte catalogs, used for code generation, can be specified right in the `ramba`'s.
222
+
223
+ ```
224
+ ramba :viper_module do
225
+ catalog 'https://github.com/user/catalog', branch:'develop'
226
+ template 'viper_ios', version:'1.2.5'
227
+ template 'viper_ios2', path:'/local_templates'
228
+ end
229
+ ```
230
+
231
+ - `catalog` keyword specifies a custom template catalog (like https://github.com/rambler-digital-solutions/generamba-catalog).
232
+ - `branch` parameter specifies a concrete catalog branch
233
+ - `template` keyword declares a template that needs to be installed
234
+ - `version` parameter specifies a concrete template version.
235
+ - `path` parameter specifies a local path to the template.
236
+ - `git` parameter specifies a remote repository path to a template.
237
+ - `branch` parameter is used together with `git` to specify a branch.
238
+
239
+ The `generamba template install` command aggregates all of the templates from the `Rambafile` and installs them in a `.generamba` hidden directory. When a user triggers some `ramba`, templates are loaded from this directory. The only exception are local templates - they are always installed from the specified in the `Rambafile` local path.
240
+
241
+ ### Plugins
242
+
243
+ The main ideas behind plugin system are:
244
+
245
+ - Increase code reusability between different projects,
246
+ * Keep the Generamba core as simple as possible,
247
+ * Abstract from specific implementations of different IDEs,
248
+ * Allow users to easily extend Generamba functionality for their needs.
249
+
250
+ As we've already mentioned, there are two types of plugins:
251
+
252
+ - System plugins - validation and saving,
253
+ * Custom plugins.
254
+
255
+ The main difference between them is how system calls them during `ramba` execution.
256
+
257
+ #### Plugin Structure
258
+
259
+ ```
260
+ module Generamba
261
+ module Plugins
262
+ class CocoaPodsPackageVersionValidationPlugin < ValidationPlugin
263
+ # The main body of a plugin
264
+ def self.run(params)
265
+ # Loads Podfile
266
+ # Analyzez dependencies version
267
+ # Compares these versions to the passed options
268
+ end
269
+
270
+ # The description of what this plugin does
271
+ def self.description
272
+ 'Verifies dependencies version in the project Podfile'
273
+ end
274
+
275
+ # Explicitly declaring available plugin options
276
+ def self.available_options
277
+ [
278
+ Generamba::ConfigItem.new(key: :package_versions,
279
+ description: "The hash with dependencies names and required versions",
280
+ default_value: [])
281
+ ]
282
+ end
283
+
284
+ # Declaring the output parameters
285
+ def self.output
286
+ [
287
+ ['COCOAPODS_CHECK_RESULT', 'The result of dependency checking']
288
+ ]
289
+ end
290
+
291
+ # Who created this plugin
292
+ def self.authors
293
+ ["etolstoy"]
294
+ end
295
+ end
296
+ end
297
+ end
298
+ ```
299
+
300
+ The same structure applies to other kinds of plugins. The only difference is the base class for the plugin - it can be `ValidationPlugin`, `SavingPlugin`, `Plugin`.
301
+
302
+ We've borrowed the plugin structure from `fastlane`.
303
+
304
+ #### Plugin Distribution
305
+
306
+ To avoid over-engineering in this version plugins will be distributed together with Generamba binary. If there'll be a lot of community-created plugins, will think about switching to other distribution system.
307
+
308
+ It's also possible to store plugins near the `Rambafile` in a separate directory `/plugins`. They'll be loaded by Generamba automatically.
309
+
310
+ ### Rambafile Example
311
+
312
+ ```
313
+ ramba_import_local('path')
314
+ ramba_import_git('git', 'branch')
315
+
316
+ set :project_name, 'LiveJournal'
317
+
318
+ before :viper_module do
319
+ set :company, 'Rambler&Co'
320
+ set :xcodeproj_path, 'LiveJournal.xcodeproj'
321
+ set :project_targets, ['LiveJournal1', 'LiveJournal2']
322
+ set :test_target, 'LiveJournalTests'
323
+ end
324
+
325
+ desc "Creates a simple VIPER module"
326
+ ramba :viper_module do
327
+ validate :plugin_validate_name do
328
+ set :some_option, '456'
329
+ any_custom_action()
330
+ end
331
+
332
+ gen :template_name do
333
+ set :some_option, '123'
334
+ any_custom_action(parameter1)
335
+ end
336
+
337
+ save :file_system do
338
+ set :some_option, '789'
339
+ end
340
+
341
+ save :xcode_proj
342
+ end
343
+
344
+ desc "Creates a new Xcode project"
345
+ ramba :create_project do
346
+ sh("liftoff") # Calling a shell script which invokes a 'liftoff' utility
347
+ add_pods(["Typhoon", "MagicalRecord"])
348
+
349
+ gen :app_delegate
350
+ gen :core_data_stack
351
+
352
+ save :file_system
353
+ save :xcode_proj
354
+ end
355
+
356
+ # It's called after each 'ramba' execution
357
+ after_each do |ramba_name|
358
+ # Some logic here
359
+ end
360
+
361
+ # It's called in case of an error in any 'ramba'
362
+ error :viper_module do
363
+ # Some error handling logic here
364
+ end
365
+ ```
@@ -21,8 +21,8 @@ Gem::Specification.new do |spec|
21
21
  spec.required_ruby_version = '>= 2.2'
22
22
 
23
23
  spec.add_runtime_dependency 'thor', '0.19.1'
24
- spec.add_runtime_dependency 'xcodeproj', '1.2.0'
25
- spec.add_runtime_dependency 'liquid', '3.0.6'
24
+ spec.add_runtime_dependency 'xcodeproj', '1.4.2'
25
+ spec.add_runtime_dependency 'liquid', '4.0.0'
26
26
  spec.add_runtime_dependency 'git', '1.2.9.1'
27
27
  spec.add_runtime_dependency 'cocoapods-core', '1.0.1'
28
28
  spec.add_runtime_dependency 'terminal-table', '1.4.5'
@@ -32,7 +32,7 @@ module Generamba
32
32
  spec[TEMPLATE_NAME_KEY] != nil &&
33
33
  spec[TEMPLATE_AUTHOR_KEY] != nil &&
34
34
  spec[TEMPLATE_VERSION_KEY] != nil &&
35
- spec[TEMPLATE_CODE_FILES_KEY] != nil
35
+ (spec[TEMPLATE_CODE_FILES_KEY] != nil || spec[TEMPLATE_TEST_FILES_KEY] != nil)
36
36
  return is_spec_valid
37
37
  end
38
38
 
@@ -1,5 +1,5 @@
1
1
  module Generamba
2
- VERSION = '1.3.0'
3
- RELEASE_DATE = '05.10.2016'
2
+ VERSION = '1.4.0'
3
+ RELEASE_DATE = '25.12.2016'
4
4
  RELEASE_LINK = "https://github.com/rambler-digital-solutions/Generamba/releases/tag/#{VERSION}"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: generamba
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Egor Tolstoy
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-10-05 00:00:00.000000000 Z
13
+ date: 2016-12-25 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: thor
@@ -32,28 +32,28 @@ dependencies:
32
32
  requirements:
33
33
  - - '='
34
34
  - !ruby/object:Gem::Version
35
- version: 1.2.0
35
+ version: 1.4.2
36
36
  type: :runtime
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
40
  - - '='
41
41
  - !ruby/object:Gem::Version
42
- version: 1.2.0
42
+ version: 1.4.2
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: liquid
45
45
  requirement: !ruby/object:Gem::Requirement
46
46
  requirements:
47
47
  - - '='
48
48
  - !ruby/object:Gem::Version
49
- version: 3.0.6
49
+ version: 4.0.0
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
53
53
  requirements:
54
54
  - - '='
55
55
  - !ruby/object:Gem::Version
56
- version: 3.0.6
56
+ version: 4.0.0
57
57
  - !ruby/object:Gem::Dependency
58
58
  name: git
59
59
  requirement: !ruby/object:Gem::Requirement
@@ -184,9 +184,11 @@ files:
184
184
  - LICENSE.txt
185
185
  - README.md
186
186
  - Rakefile
187
+ - VISION.md
187
188
  - bin/console
188
189
  - bin/generamba
189
190
  - bin/setup
191
+ - docs/2.x/roadmap.md
190
192
  - generamba.gemspec
191
193
  - lib/generamba.rb
192
194
  - lib/generamba/cli/cli.rb