gem_generator 0.3.1 → 0.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
  SHA256:
3
- metadata.gz: 7f3a231a663b783f7bf00b7faecbe2e0ba9a83758889f737850464d8787417b1
4
- data.tar.gz: 284e0c140d77a1601e7c4c0d8ede966761de87252ea4bdede6a40fdeddf3da80
3
+ metadata.gz: 6956a329ffd0c4b6c7801bfd8657785fdd7704c322a918073548bf20439d9276
4
+ data.tar.gz: b505f669f07e023116a27aae3adcf46c581911dc7174fe651a6122e4d055720e
5
5
  SHA512:
6
- metadata.gz: 8c93e384412e88394adf30eb9dd7e4ad80ef8d1b4cd6206d77cb46d4fe75e01fc9fab8086a91c7710fb6ee680dd9816b99f3f0785fb95da01b295d6f7859084c
7
- data.tar.gz: 16b39763cafaa19b5fe6f760d6106d0e0df9d898bfba0197ce883a1c4f0a5d352a64e60984daf34b8d24e4333dbfec636352181e944885cfcf9d976f131df82c
6
+ metadata.gz: 76cb9bb214bb3bb143002e04952578b7cd59c42586f20d5a1696aa5a135aa836192bb39e9d87f03e85f37a7b0b9dccbef9ce0261a7f809864a8445356c63c030
7
+ data.tar.gz: cc873f780fcc393ad9943b511a003039d74c8eeb6a8de47c20ccb17a91bb2cba9be535a9b921edc43177857d86ebe9812996e4a34dcc4efcf3f3c0dbf1cc3816
data/CHANGELOG.md CHANGED
@@ -2,9 +2,21 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.4.0 (2022-10-21)
6
+
7
+ * Drop Ruby 2.6 and 2.7 support.
8
+ * Add Ruby 3.1 for CI.
9
+ * Update dependencies.
10
+ * Change RSpec output format to `doc`.
11
+
12
+ ## 0.3.2 (2021-11-10)
13
+
14
+ * Update `project_generator`.
15
+ Add custom parameters.
16
+
5
17
  ## 0.3.1 (2021-11-07)
6
18
 
7
- * Require runtime depepndencies.
19
+ * Require runtime dependencies.
8
20
 
9
21
  ## 0.3.0 (2021-11-01)
10
22
 
@@ -1,42 +1,28 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'yaml'
4
- require 'memery'
5
3
  require 'gorilla_patch/blank'
6
- require 'gorilla_patch/inflections'
7
4
 
8
5
  module GemGenerator
9
6
  ## Main CLI command for Gem Generator
10
- class Command < Clamp::Command
7
+ class Command < ProjectGenerator::Command
11
8
  ## Private instance methods for processing template files (copying, renaming, rendering)
12
9
  module ProcessFiles
13
10
  ## Class for a single object which should be a scope in render
14
- class RenderVariables
15
- include Memery
16
-
11
+ class RenderVariables < ProjectGenerator::Command::ProcessFiles::RenderVariables
17
12
  using GorillaPatch::Blank
18
- using GorillaPatch::Inflections
19
13
 
20
- attr_reader :name, :indentation, :summary
14
+ attr_reader :summary
21
15
 
22
16
  def initialize(name, namespace_option, indentation, summary)
23
- @name = name
17
+ super name, indentation
18
+
24
19
  @namespace_option = namespace_option
25
- @indentation = indentation
26
20
  @summary = summary
27
21
 
28
22
  ## Call to be sure that this is checked before author fields
29
23
  github_namespace
30
24
  end
31
25
 
32
- ## `public :binding` and `send :binding` return caller binding
33
- ## This is from ERB documentation: https://ruby-doc.org/core-2.7.2/Binding.html
34
- # rubocop:disable Naming/AccessorMethodName
35
- def get_binding
36
- binding
37
- end
38
- # rubocop:enable Naming/AccessorMethodName
39
-
40
26
  memoize def summary_string
41
27
  quote = summary.include?("'") ? '"' : "'"
42
28
  "#{quote}#{summary}#{quote}"
@@ -46,22 +32,6 @@ module GemGenerator
46
32
  summary.match?(/[.?!]$/) ? summary : "#{summary}."
47
33
  end
48
34
 
49
- memoize def path
50
- name.tr('-', '/')
51
- end
52
-
53
- memoize def title
54
- name.split(/[-_]/).map(&:camelize).join(' ')
55
- end
56
-
57
- memoize def module_name
58
- path.camelize
59
- end
60
-
61
- memoize def modules
62
- module_name.split('::')
63
- end
64
-
65
35
  memoize def version_constant
66
36
  "#{module_name}::VERSION"
67
37
  end
@@ -142,8 +112,6 @@ module GemGenerator
142
112
  config_file
143
113
  end
144
114
  end
145
-
146
- private_constant :RenderVariables
147
115
  end
148
116
  end
149
117
  end
@@ -4,73 +4,19 @@ require_relative 'process_files/render_variables'
4
4
 
5
5
  module GemGenerator
6
6
  ## Main CLI command for Gem Generator
7
- class Command < Clamp::Command
7
+ class Command < ProjectGenerator::Command
8
8
  ## Private instance methods for processing template files (copying, renaming, rendering)
9
9
  module ProcessFiles
10
- private
11
-
12
- def process_files
13
- copy_files
14
-
15
- begin
16
- @render_variables = RenderVariables.new name, namespace, indentation, @summary
17
-
18
- rename_files
19
-
20
- render_files
21
- rescue SystemExit => e
22
- FileUtils.rm_r @directory
23
- raise e
24
- end
25
- end
26
-
27
- def copy_files
28
- puts 'Copying files...'
29
-
30
- FileUtils.cp_r template, @directory
31
-
32
- FileUtils.rm_rf "#{@directory}/.git"
33
- end
34
-
35
- def rename_files
36
- puts 'Renaming files...'
10
+ RENAME_FILES_PLACEHOLDERS = {
11
+ name: 'gem_name',
12
+ path: 'gem_path'
13
+ }.freeze
37
14
 
38
- { 'gem_name' => @render_variables.name, 'gem_path' => @render_variables.path }
39
- .each do |template_name, real_name|
40
- Dir["#{@directory}/**/*#{template_name}*"].each do |file_name|
41
- new_file_name =
42
- @directory + file_name.delete_prefix(@directory).gsub(template_name, real_name)
43
-
44
- FileUtils.mkdir_p File.dirname new_file_name
45
-
46
- File.rename file_name, new_file_name
47
- end
48
- end
49
- end
50
-
51
- def render_files
52
- puts 'Rendering files...'
53
-
54
- Dir.glob("#{@directory}/**/*.erb", File::FNM_DOTMATCH).each do |template_file|
55
- ## Read a template file content and render it
56
- content =
57
- ERB.new(File.read(template_file), trim_mode: '-').result(@render_variables.get_binding)
58
-
59
- ## Replace tabs with spaces if necessary
60
- content.gsub!(/^\t+/) { |tabs| ' ' * tabs.count("\t") } if indentation == 'spaces'
61
-
62
- ## Render variables in file name
63
- real_pathname = Pathname.new(template_file).sub_ext('')
64
-
65
- ## Rename template file
66
- File.rename template_file, real_pathname
15
+ private
67
16
 
68
- ## Update file content
69
- File.write real_pathname, content
70
- end
17
+ def initialize_render_variables
18
+ self.class::RenderVariables.new name, namespace, indentation, @summary
71
19
  end
72
20
  end
73
-
74
- private_constant :ProcessFiles
75
21
  end
76
22
  end
@@ -1,11 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'bundler'
4
- require 'clamp'
5
- require 'erb'
6
- require 'fileutils'
7
- require 'pathname'
8
- require 'tmpdir'
4
+ require 'project_generator'
9
5
 
10
6
  require_relative 'command/process_files'
11
7
 
@@ -14,35 +10,16 @@ Clamp.allow_options_after_parameters = true
14
10
 
15
11
  module GemGenerator
16
12
  ## Main CLI command for Gem Generator
17
- class Command < Clamp::Command
13
+ class Command < ProjectGenerator::Command
18
14
  include ProcessFiles
19
15
 
20
16
  parameter 'NAME', 'name of a new gem'
21
17
  parameter 'TEMPLATE', 'template path of a new gem'
22
18
 
23
19
  option ['-n', '--namespace'], 'NAME', 'use NAME as repository namespace'
24
- option ['-i', '--indentation'], 'TYPE', 'type of indentation (tabs or spaces)',
25
- default: 'tabs' do |value|
26
- ## TODO: Add something like `:variants` to Clamp
27
- unless %w[tabs spaces].include? value
28
- raise ArgumentError, 'Only `tabs` or `spaces` values acceptable'
29
- end
30
-
31
- value
32
- end
33
-
34
- option '--git', :flag, 'use TEMPLATE as GitHub path (clone and generate from it)',
35
- default: false
36
-
37
- attr_reader(
38
- :path, :title, :modules, :version_constant, :github_path, :github_uri,
39
- :author_name, :author_email
40
- )
41
20
 
42
21
  def execute
43
- @directory = File.expand_path name
44
-
45
- signal_usage_error 'the target directory already exists' if Dir.exist? @directory
22
+ check_target_directory
46
23
 
47
24
  ## Prevent error like '"FIXME" or "TODO" is not a description' for `bundle install`
48
25
  @summary = ask_for_summary
@@ -53,18 +30,11 @@ module GemGenerator
53
30
 
54
31
  install_dependencies
55
32
 
56
- ## If there is no `gem_generator` config — `render` asks `git config`
57
- ## Also do `git add .` after all renders
58
33
  initialize_git
59
34
 
60
35
  FileUtils.rm_r @git_tmp_dir if git?
61
36
 
62
- puts 'Done.'
63
-
64
- puts <<~HELP
65
- To checkout into a new directory:
66
- cd #{name}
67
- HELP
37
+ done
68
38
  end
69
39
 
70
40
  private
@@ -88,21 +58,6 @@ module GemGenerator
88
58
  result
89
59
  end
90
60
 
91
- def refine_template_parameter
92
- @git_tmp_dir = Dir.mktmpdir
93
- `git clone -q https://github.com/#{template}.git #{@git_tmp_dir}`
94
- self.template = File.join @git_tmp_dir, 'template'
95
- end
96
-
97
- def initialize_git
98
- puts 'Initializing git...'
99
-
100
- Dir.chdir name do
101
- system 'git init'
102
- system 'git add .'
103
- end
104
- end
105
-
106
61
  def install_dependencies
107
62
  puts 'Installing dependencies...'
108
63
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GemGenerator
4
- VERSION = '0.3.1'
4
+ VERSION = '0.4.0'
5
5
  end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gem_generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Popov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-11-07 00:00:00.000000000 Z
11
+ date: 2022-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: alt_memery
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '2.0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '2.0'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: bundler
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -39,33 +25,33 @@ dependencies:
39
25
  - !ruby/object:Gem::Version
40
26
  version: '2.0'
41
27
  - !ruby/object:Gem::Dependency
42
- name: clamp
28
+ name: gorilla_patch
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  requirements:
45
31
  - - "~>"
46
32
  - !ruby/object:Gem::Version
47
- version: '1.3'
33
+ version: '5.0'
48
34
  type: :runtime
49
35
  prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
38
  - - "~>"
53
39
  - !ruby/object:Gem::Version
54
- version: '1.3'
40
+ version: '5.0'
55
41
  - !ruby/object:Gem::Dependency
56
- name: gorilla_patch
42
+ name: project_generator
57
43
  requirement: !ruby/object:Gem::Requirement
58
44
  requirements:
59
45
  - - "~>"
60
46
  - !ruby/object:Gem::Version
61
- version: '4.0'
47
+ version: 0.3.0
62
48
  type: :runtime
63
49
  prerelease: false
64
50
  version_requirements: !ruby/object:Gem::Requirement
65
51
  requirements:
66
52
  - - "~>"
67
53
  - !ruby/object:Gem::Version
68
- version: '4.0'
54
+ version: 0.3.0
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: pry-byebug
71
57
  requirement: !ruby/object:Gem::Requirement
@@ -114,28 +100,28 @@ dependencies:
114
100
  requirements:
115
101
  - - "~>"
116
102
  - !ruby/object:Gem::Version
117
- version: 0.11.0
103
+ version: 0.12.1
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
107
  requirements:
122
108
  - - "~>"
123
109
  - !ruby/object:Gem::Version
124
- version: 0.11.0
110
+ version: 0.12.1
125
111
  - !ruby/object:Gem::Dependency
126
112
  name: toys
127
113
  requirement: !ruby/object:Gem::Requirement
128
114
  requirements:
129
115
  - - "~>"
130
116
  - !ruby/object:Gem::Version
131
- version: 0.12.0
117
+ version: 0.13.1
132
118
  type: :development
133
119
  prerelease: false
134
120
  version_requirements: !ruby/object:Gem::Requirement
135
121
  requirements:
136
122
  - - "~>"
137
123
  - !ruby/object:Gem::Version
138
- version: 0.12.0
124
+ version: 0.13.1
139
125
  - !ruby/object:Gem::Dependency
140
126
  name: ffaker
141
127
  requirement: !ruby/object:Gem::Requirement
@@ -184,28 +170,28 @@ dependencies:
184
170
  requirements:
185
171
  - - "~>"
186
172
  - !ruby/object:Gem::Version
187
- version: '1.4'
173
+ version: '2.1'
188
174
  type: :development
189
175
  prerelease: false
190
176
  version_requirements: !ruby/object:Gem::Requirement
191
177
  requirements:
192
178
  - - "~>"
193
179
  - !ruby/object:Gem::Version
194
- version: '1.4'
180
+ version: '2.1'
195
181
  - !ruby/object:Gem::Dependency
196
182
  name: rubocop
197
183
  requirement: !ruby/object:Gem::Requirement
198
184
  requirements:
199
185
  - - "~>"
200
186
  - !ruby/object:Gem::Version
201
- version: 1.22.0
187
+ version: 1.37.0
202
188
  type: :development
203
189
  prerelease: false
204
190
  version_requirements: !ruby/object:Gem::Requirement
205
191
  requirements:
206
192
  - - "~>"
207
193
  - !ruby/object:Gem::Version
208
- version: 1.22.0
194
+ version: 1.37.0
209
195
  - !ruby/object:Gem::Dependency
210
196
  name: rubocop-performance
211
197
  requirement: !ruby/object:Gem::Requirement
@@ -256,8 +242,9 @@ homepage: https://github.com/AlexWayfer/gem_generator
256
242
  licenses:
257
243
  - MIT
258
244
  metadata:
245
+ rubygems_mfa_required: 'true'
259
246
  bug_tracker_uri: https://github.com/AlexWayfer/gem_generator/issues
260
- changelog_uri: https://github.com/AlexWayfer/gem_generator/blob/v0.3.1/CHANGELOG.md
247
+ changelog_uri: https://github.com/AlexWayfer/gem_generator/blob/v0.4.0/CHANGELOG.md
261
248
  homepage_uri: https://github.com/AlexWayfer/gem_generator
262
249
  source_code_uri: https://github.com/AlexWayfer/gem_generator
263
250
  post_install_message:
@@ -268,7 +255,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
268
255
  requirements:
269
256
  - - ">="
270
257
  - !ruby/object:Gem::Version
271
- version: '2.6'
258
+ version: '3.0'
272
259
  - - "<"
273
260
  - !ruby/object:Gem::Version
274
261
  version: '4'
@@ -278,7 +265,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
278
265
  - !ruby/object:Gem::Version
279
266
  version: '0'
280
267
  requirements: []
281
- rubygems_version: 3.2.22
268
+ rubygems_version: 3.3.7
282
269
  signing_key:
283
270
  specification_version: 4
284
271
  summary: Generator for gems