project_generator 0.2.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -0
- data/README.md +34 -16
- data/lib/project_generator/command/process_files.rb +29 -16
- data/lib/project_generator/command.rb +1 -0
- data/lib/project_generator/version.rb +1 -1
- metadata +13 -183
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a1dcab66058a6cd84b61ccd208951a9e877d7f69c5eebfab360cba3e3d42a71
|
4
|
+
data.tar.gz: '003292eaf64344e334f168e58de549c15137bcc265265fdf459fb7f469212800'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0464c7d19cd2225af883d7767960b690c62cc6e35586a6eb1f6a89675525c9f7da3bd15e75408232cbb9c1cc56214613878b8d2c19c1fe963d362f5a6329201b
|
7
|
+
data.tar.gz: 51a6dffa735d66d0ca8c2ca1fdedd8ca1780f9a0d80dba2422defff43d7b3d21d4b77362cdd58d83a1d0c1ecd9d453ad01d5c8fcbdbb2605b019d72a0d59da5e
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,24 @@
|
|
2
2
|
|
3
3
|
## Unreleased
|
4
4
|
|
5
|
+
## 0.4.0 (2024-05-16)
|
6
|
+
|
7
|
+
* Replace indentation not only for template (ERB) files.
|
8
|
+
* Improve specs.
|
9
|
+
* Add Ruby 3.2 and 3.3 support.
|
10
|
+
* Move development dependencies from `gemspec` into `Gemfile`.
|
11
|
+
* Update development dependencies.
|
12
|
+
|
13
|
+
## 0.3.0 (2022-09-29)
|
14
|
+
|
15
|
+
* Drop Ruby 2.6 and 2.7.
|
16
|
+
They're not supported by new dependencies versions, let's move on.
|
17
|
+
* Add Ruby 3.1 support.
|
18
|
+
* Update output.
|
19
|
+
* Update dependencies.
|
20
|
+
* Resolve new RuboCop offenses.
|
21
|
+
* Improve CI.
|
22
|
+
|
5
23
|
## 0.2.0 (2021-11-10)
|
6
24
|
|
7
25
|
* Remove parameters and their inheritance.
|
data/README.md
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
[![Cirrus CI - Base Branch Build Status](https://img.shields.io/cirrus/github/AlexWayfer/project_generator?style=flat-square)](https://cirrus-ci.com/github/AlexWayfer/project_generator)
|
4
4
|
[![Codecov branch](https://img.shields.io/codecov/c/github/AlexWayfer/project_generator/main.svg?style=flat-square)](https://codecov.io/gh/AlexWayfer/project_generator)
|
5
5
|
[![Code Climate](https://img.shields.io/codeclimate/maintainability/AlexWayfer/project_generator.svg?style=flat-square)](https://codeclimate.com/github/AlexWayfer/project_generator)
|
6
|
-
[![Depfu](https://img.shields.io/depfu/AlexWayfer/project_generator?style=flat-square)](https://depfu.com/repos/github/AlexWayfer/project_generator)
|
7
6
|
[![Inline docs](https://inch-ci.org/github/AlexWayfer/project_generator.svg?branch=main)](https://inch-ci.org/github/AlexWayfer/project_generator)
|
8
7
|
[![Gem](https://img.shields.io/gem/v/project_generator.svg?style=flat-square)](https://rubygems.org/gems/project_generator)
|
9
8
|
[![License](https://img.shields.io/github/license/AlexWayfer/project_generator.svg?style=flat-square)](LICENSE.txt)
|
@@ -12,32 +11,51 @@ Base for various CLI generation tools.
|
|
12
11
|
|
13
12
|
## Installation
|
14
13
|
|
15
|
-
|
14
|
+
It's designed as a base for developers to build specific generation CLIs,
|
15
|
+
so the common way is to add this gem as a runtime gem dependency.
|
16
|
+
|
17
|
+
For now it even has no executables.
|
18
|
+
|
19
|
+
## Usage
|
16
20
|
|
17
21
|
```ruby
|
18
|
-
|
19
|
-
```
|
22
|
+
require 'project_generator'
|
20
23
|
|
21
|
-
|
24
|
+
## Your specific generator, like a gem generator
|
25
|
+
module GemGenerator
|
26
|
+
## Inherit it's `Command` (`clamp`s CLI) from `ProjectGenerator::Command`
|
27
|
+
class Command < ProjectGenerator::Command
|
28
|
+
## You have to define `NAME` and `TEMPLATE` parameters
|
29
|
+
parameter 'NAME', 'name of a new gem'
|
30
|
+
parameter 'TEMPLATE', 'template path of a new gem'
|
22
31
|
|
23
|
-
|
24
|
-
|
25
|
-
```
|
32
|
+
def execute
|
33
|
+
## You can execute logic of a specific generator wherever you want
|
26
34
|
|
27
|
-
|
35
|
+
check_target_directory
|
28
36
|
|
29
|
-
|
30
|
-
gem install project_generator
|
31
|
-
```
|
37
|
+
refine_template_parameter if git?
|
32
38
|
|
33
|
-
|
39
|
+
process_files
|
34
40
|
|
35
|
-
|
36
|
-
|
41
|
+
initialize_git
|
42
|
+
|
43
|
+
FileUtils.rm_r @git_tmp_dir if git?
|
37
44
|
|
38
|
-
|
45
|
+
done
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
39
49
|
```
|
40
50
|
|
51
|
+
Built-in options:
|
52
|
+
|
53
|
+
* `-i`, `--indentation`: indentation type in generated project (`tabs` or `spaces`).
|
54
|
+
|
55
|
+
_Note: please, write templates with tabs to have this option working,
|
56
|
+
because we can't safely transform number of spaces into tabs,
|
57
|
+
but we can transform tabs into spaces._
|
58
|
+
|
41
59
|
## Development
|
42
60
|
|
43
61
|
After checking out the repo, run `bundle install` to install dependencies.
|
@@ -61,27 +61,40 @@ module ProjectGenerator
|
|
61
61
|
def render_files
|
62
62
|
puts 'Rendering files...'
|
63
63
|
|
64
|
-
Dir.glob("#{@directory}
|
65
|
-
|
66
|
-
content =
|
67
|
-
ERB.new(File.read(template_file), trim_mode: '-').result(@render_variables.get_binding)
|
64
|
+
Dir.glob("#{@directory}/**/*", File::FNM_DOTMATCH).each do |file_path|
|
65
|
+
next unless File.file? file_path
|
68
66
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
## TODO: Don't convert files refined in `.editorconfig`
|
73
|
-
## TODO: Convert spaces to tabs
|
74
|
-
content.gsub!(/^\t+/) { |tabs| ' ' * tabs.count("\t") } if indentation == 'spaces'
|
67
|
+
render_file file_path
|
68
|
+
end
|
69
|
+
end
|
75
70
|
|
76
|
-
|
77
|
-
|
71
|
+
def render_file(file_path)
|
72
|
+
## Read file content
|
73
|
+
content = File.read file_path
|
78
74
|
|
79
|
-
|
80
|
-
|
75
|
+
pathname = Pathname.new file_path
|
76
|
+
|
77
|
+
if pathname.extname == '.erb'
|
78
|
+
## Read a template file content and render it
|
79
|
+
content = ERB.new(content, trim_mode: '-').result(@render_variables.get_binding)
|
81
80
|
|
82
|
-
|
83
|
-
|
81
|
+
new_file_path = pathname.sub_ext('')
|
82
|
+
|
83
|
+
## Remove template file, save owner and permissions
|
84
|
+
File.rename file_path, new_file_path
|
85
|
+
|
86
|
+
## Remove `.erb` ext from file name
|
87
|
+
file_path = new_file_path
|
84
88
|
end
|
89
|
+
|
90
|
+
## Replace tabs with spaces if necessary
|
91
|
+
## TODO: Take number of spaces from `.editorconfig` file
|
92
|
+
## TODO: Don't convert files refined in `.editorconfig`
|
93
|
+
## TODO: Convert spaces to tabs
|
94
|
+
content.gsub!(/^\t+/) { |tabs| ' ' * tabs.count("\t") } if indentation == 'spaces'
|
95
|
+
|
96
|
+
## Update file content
|
97
|
+
File.write file_path, content
|
85
98
|
end
|
86
99
|
end
|
87
100
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: project_generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Popov
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: alt_memery
|
@@ -58,182 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '5.0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: pry-byebug
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '3.9'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '3.9'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: bundler
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '2.0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '2.0'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: bundler-audit
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - "~>"
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: 0.9.0
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - "~>"
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: 0.9.0
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: gem_toys
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - "~>"
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: 0.11.0
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - "~>"
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: 0.11.0
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: toys
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - "~>"
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: 0.12.0
|
132
|
-
type: :development
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - "~>"
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: 0.12.0
|
139
|
-
- !ruby/object:Gem::Dependency
|
140
|
-
name: inifile
|
141
|
-
requirement: !ruby/object:Gem::Requirement
|
142
|
-
requirements:
|
143
|
-
- - "~>"
|
144
|
-
- !ruby/object:Gem::Version
|
145
|
-
version: '3.0'
|
146
|
-
type: :development
|
147
|
-
prerelease: false
|
148
|
-
version_requirements: !ruby/object:Gem::Requirement
|
149
|
-
requirements:
|
150
|
-
- - "~>"
|
151
|
-
- !ruby/object:Gem::Version
|
152
|
-
version: '3.0'
|
153
|
-
- !ruby/object:Gem::Dependency
|
154
|
-
name: rspec
|
155
|
-
requirement: !ruby/object:Gem::Requirement
|
156
|
-
requirements:
|
157
|
-
- - "~>"
|
158
|
-
- !ruby/object:Gem::Version
|
159
|
-
version: '3.9'
|
160
|
-
type: :development
|
161
|
-
prerelease: false
|
162
|
-
version_requirements: !ruby/object:Gem::Requirement
|
163
|
-
requirements:
|
164
|
-
- - "~>"
|
165
|
-
- !ruby/object:Gem::Version
|
166
|
-
version: '3.9'
|
167
|
-
- !ruby/object:Gem::Dependency
|
168
|
-
name: simplecov
|
169
|
-
requirement: !ruby/object:Gem::Requirement
|
170
|
-
requirements:
|
171
|
-
- - "~>"
|
172
|
-
- !ruby/object:Gem::Version
|
173
|
-
version: 0.21.0
|
174
|
-
type: :development
|
175
|
-
prerelease: false
|
176
|
-
version_requirements: !ruby/object:Gem::Requirement
|
177
|
-
requirements:
|
178
|
-
- - "~>"
|
179
|
-
- !ruby/object:Gem::Version
|
180
|
-
version: 0.21.0
|
181
|
-
- !ruby/object:Gem::Dependency
|
182
|
-
name: simplecov-cobertura
|
183
|
-
requirement: !ruby/object:Gem::Requirement
|
184
|
-
requirements:
|
185
|
-
- - "~>"
|
186
|
-
- !ruby/object:Gem::Version
|
187
|
-
version: '1.4'
|
188
|
-
type: :development
|
189
|
-
prerelease: false
|
190
|
-
version_requirements: !ruby/object:Gem::Requirement
|
191
|
-
requirements:
|
192
|
-
- - "~>"
|
193
|
-
- !ruby/object:Gem::Version
|
194
|
-
version: '1.4'
|
195
|
-
- !ruby/object:Gem::Dependency
|
196
|
-
name: rubocop
|
197
|
-
requirement: !ruby/object:Gem::Requirement
|
198
|
-
requirements:
|
199
|
-
- - "~>"
|
200
|
-
- !ruby/object:Gem::Version
|
201
|
-
version: 1.22.0
|
202
|
-
type: :development
|
203
|
-
prerelease: false
|
204
|
-
version_requirements: !ruby/object:Gem::Requirement
|
205
|
-
requirements:
|
206
|
-
- - "~>"
|
207
|
-
- !ruby/object:Gem::Version
|
208
|
-
version: 1.22.0
|
209
|
-
- !ruby/object:Gem::Dependency
|
210
|
-
name: rubocop-performance
|
211
|
-
requirement: !ruby/object:Gem::Requirement
|
212
|
-
requirements:
|
213
|
-
- - "~>"
|
214
|
-
- !ruby/object:Gem::Version
|
215
|
-
version: '1.0'
|
216
|
-
type: :development
|
217
|
-
prerelease: false
|
218
|
-
version_requirements: !ruby/object:Gem::Requirement
|
219
|
-
requirements:
|
220
|
-
- - "~>"
|
221
|
-
- !ruby/object:Gem::Version
|
222
|
-
version: '1.0'
|
223
|
-
- !ruby/object:Gem::Dependency
|
224
|
-
name: rubocop-rspec
|
225
|
-
requirement: !ruby/object:Gem::Requirement
|
226
|
-
requirements:
|
227
|
-
- - "~>"
|
228
|
-
- !ruby/object:Gem::Version
|
229
|
-
version: '2.0'
|
230
|
-
type: :development
|
231
|
-
prerelease: false
|
232
|
-
version_requirements: !ruby/object:Gem::Requirement
|
233
|
-
requirements:
|
234
|
-
- - "~>"
|
235
|
-
- !ruby/object:Gem::Version
|
236
|
-
version: '2.0'
|
68
|
+
version: '5.0'
|
237
69
|
description: 'Base for various CLI generation tools.
|
238
70
|
|
239
71
|
'
|
@@ -255,32 +87,30 @@ homepage: https://github.com/AlexWayfer/project_generator
|
|
255
87
|
licenses:
|
256
88
|
- MIT
|
257
89
|
metadata:
|
90
|
+
rubygems_mfa_required: 'true'
|
258
91
|
bug_tracker_uri: https://github.com/AlexWayfer/project_generator/issues
|
259
|
-
changelog_uri: https://github.com/AlexWayfer/project_generator/blob/v0.
|
260
|
-
documentation_uri: http://www.rubydoc.info/gems/project_generator/0.
|
92
|
+
changelog_uri: https://github.com/AlexWayfer/project_generator/blob/v0.4.0/CHANGELOG.md
|
93
|
+
documentation_uri: http://www.rubydoc.info/gems/project_generator/0.4.0
|
261
94
|
homepage_uri: https://github.com/AlexWayfer/project_generator
|
262
95
|
source_code_uri: https://github.com/AlexWayfer/project_generator
|
263
96
|
wiki_uri: https://github.com/AlexWayfer/project_generator/wiki
|
264
|
-
post_install_message:
|
97
|
+
post_install_message:
|
265
98
|
rdoc_options: []
|
266
99
|
require_paths:
|
267
100
|
- lib
|
268
101
|
required_ruby_version: !ruby/object:Gem::Requirement
|
269
102
|
requirements:
|
270
|
-
- - "
|
271
|
-
- !ruby/object:Gem::Version
|
272
|
-
version: '2.6'
|
273
|
-
- - "<"
|
103
|
+
- - "~>"
|
274
104
|
- !ruby/object:Gem::Version
|
275
|
-
version: '
|
105
|
+
version: '3.0'
|
276
106
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
277
107
|
requirements:
|
278
108
|
- - ">="
|
279
109
|
- !ruby/object:Gem::Version
|
280
110
|
version: '0'
|
281
111
|
requirements: []
|
282
|
-
rubygems_version: 3.
|
283
|
-
signing_key:
|
112
|
+
rubygems_version: 3.5.10
|
113
|
+
signing_key:
|
284
114
|
specification_version: 4
|
285
115
|
summary: Base for various CLI generation tools
|
286
116
|
test_files: []
|