rename 1.0.10 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1639c5917067e70fac97db3b66637cf571f13be880d3237d522aa3ddbe217f26
4
- data.tar.gz: 567d8ee3c28f6cd9db39e71a410f6669da4b2ca545c00e7d6f8800106790e2df
3
+ metadata.gz: 04cb7ca7a219f63bd6fd8da695d5e0ea96ee758434705f742151afa0f43ad453
4
+ data.tar.gz: b89e1988ddcd6516e6ac8c73f2b2944554e5368457719ea2f13dd8f6919e4f84
5
5
  SHA512:
6
- metadata.gz: a889d0c18954dc474161dbcdc75f6c4926834f52517b97f9463eed48e96d12fb96ff3bddb2fc8c212a37cde26764a56823500a5137925c6a9ce69cf526843dac
7
- data.tar.gz: a2350d8b99ed51207029c693dc5f42aa6de66e036facd69355efae190c0848dbad0ff262e99aaa4bd173cc2d69f82ee5499745a347858e05d17cda37c0a7c243
6
+ metadata.gz: a40212bc260a48a7daeb3ffeef3d59acfd4dbeb7fd5e4886c45d3f90d4c78d739dbc9fc8ddb7ece0243ce53833741d7731f3e5e312d43759f49fa716c7e92edd
7
+ data.tar.gz: 4b59761975f027efbff227a9a31b7f44b9c61d356e44fd3a08f3cc1f51f63224a7e033b11c8c937a0f5139b1ee80154b51c332b48e7732fc91bd0ff8d1ceef59
data/README.md CHANGED
@@ -18,6 +18,46 @@ gem 'rename'
18
18
  rails g rename:into New-Name
19
19
  ```
20
20
 
21
+ ## Applied
22
+
23
+ ```
24
+ Search and replace exact module name to...
25
+ Gemfile
26
+ Gemfile.lock
27
+ README.md
28
+ Rakefile
29
+ config.ru
30
+ config/application.rb
31
+ config/boot.rb
32
+ config/environment.rb
33
+ config/environments/development.rb
34
+ config/environments/production.rb
35
+ config/environments/test.rb
36
+ config/importmap.rb
37
+ config/initializers/assets.rb
38
+ config/initializers/content_security_policy.rb
39
+ config/initializers/filter_parameter_logging.rb
40
+ config/initializers/inflections.rb
41
+ config/initializers/permissions_policy.rb
42
+ config/puma.rb
43
+ config/routes.rb
44
+ app/views/layouts/application.html.erb
45
+ app/views/layouts/application.html.haml
46
+ app/views/layouts/application.html.slim
47
+ README.md
48
+ README.markdown
49
+ README.mdown
50
+ README.mkdn
51
+ Search and replace underscore seperated module name to...
52
+ config/initializers/session_store.rb
53
+ config/database.yml
54
+ config/cable.yml
55
+ config/environments/production.rb
56
+ package.json
57
+ Removing references...
58
+ .idea
59
+ Renaming directory...
60
+ ```
21
61
 
22
62
  ## Contributing
23
63
 
@@ -15,7 +15,8 @@ module CommonMethods
15
15
  prepare_app_vars
16
16
  validate_name_and_path?
17
17
  apply_new_module_name
18
- change_app_directory
18
+ remove_references
19
+ rename_directory
19
20
  end
20
21
 
21
22
  def app_parent
@@ -29,6 +30,7 @@ module CommonMethods
29
30
  def prepare_app_vars
30
31
  @new_key = new_name.gsub(/\W/, '_')
31
32
  @old_module_name = app_parent
33
+ @old_dir = File.basename(Dir.getwd)
32
34
  @new_module_name = @new_key.squeeze('_').camelize
33
35
  @new_dir = new_name.gsub(/[&%*@()!{}\[\]'\\\/"]+/, '')
34
36
  @new_path = Rails.root.to_s.split('/')[0...-1].push(@new_dir).join('/')
@@ -53,43 +55,36 @@ module CommonMethods
53
55
  # rename_app_to_new_app_module
54
56
  def apply_new_module_name
55
57
  in_root do
56
- puts 'Search and replace module in files...'
57
-
58
- #Search and replace module in to file
58
+ puts 'Search and replace exact module name...'
59
59
  Dir['*', 'config/**/**/*.rb', '.{rvmrc}'].each do |file|
60
60
  # file = File.join(Dir.pwd, file)
61
61
  replace_into_file(file, /(#{@old_module_name}*)/m, @new_module_name)
62
62
  end
63
+ #Application layout
64
+ %w(erb haml slim).each do |ext|
65
+ replace_into_file("app/views/layouts/application.html.#{ext}", /#{@old_module_name}/, @new_module_name)
66
+ end
67
+ #Readme
68
+ %w(md markdown mdown mkdn).each do |ext|
69
+ replace_into_file("README.#{ext}", /#{@old_module_name}/, @new_module_name)
70
+ end
63
71
 
64
- #Rename session key
72
+ puts 'Search and replace underscore seperated module name in files...'
73
+ #session key
65
74
  replace_into_file('config/initializers/session_store.rb', /(('|")_.*_session('|"))/i, "'_#{@new_key}_session'")
66
- #Rename database
75
+ #database
67
76
  replace_into_file('config/database.yml', /#{@old_module_name.underscore}/i, @new_name.underscore)
68
- #Rename into channel and job queue
77
+ #Channel and job queue
69
78
  %w(config/cable.yml config/environments/production.rb).each do |file|
70
79
  replace_into_file(file, /#{@old_module_name.underscore}_production/, "#{@new_module_name.underscore}_production")
71
80
  end
72
- #Application layout
73
- %w(erb haml).each do |file|
74
- replace_into_file("app/views/layouts/application.html.#{file}", /#{@old_module_name}/, @new_module_name)
75
- end
76
- # Update package.json name entry
81
+ # package.json name entry
77
82
  old_package_name_regex = /\Wname\W *: *\W(?<name>[-_\p{Alnum}]+)\W *, */i
78
- new_package_name = %("name":"#{@new_module_name.underscore}",)
83
+ new_package_name = %("name":"#{@new_module_name.underscore}",)
79
84
  replace_into_file('package.json', old_package_name_regex, new_package_name)
80
-
81
- puts 'Search and replace module in environment variables...'
82
- #Rename database
83
- replace_into_file('config/database.yml', /#{@old_module_name.underscore.upcase}/, @new_module_name.underscore.upcase)
84
85
  end
85
86
  end
86
87
 
87
- # rename_app_to_new_app_directory
88
- def change_app_directory
89
- rename_references
90
- rename_directory
91
- end
92
-
93
88
  private
94
89
 
95
90
  def reserved_names
@@ -100,18 +95,14 @@ module CommonMethods
100
95
  File.respond_to?(:exist?) ? File.exist?(name) : File.exists?(name)
101
96
  end
102
97
 
103
- def rename_references
104
- puts 'Renaming references...'
105
- old_basename = File.basename(Dir.getwd)
106
-
107
- in_root do
108
- Dir.glob('.idea/*', File::FNM_DOTMATCH).each do |file|
109
- replace_into_file(file, old_basename, @new_dir)
110
- end
98
+ def remove_references
99
+ print 'Removing references...'
111
100
 
112
- gem_set_file = '.ruby-gemset'
113
- replace_into_file(gem_set_file, old_basename, @new_dir) if file_exist?(gem_set_file)
101
+ begin
102
+ FileUtils.rm_r('.idea')
103
+ rescue Exception => ex
114
104
  end
105
+ puts 'Done!'
115
106
  end
116
107
 
117
108
  def rename_directory
@@ -119,6 +110,8 @@ module CommonMethods
119
110
 
120
111
  begin
121
112
  # FileUtils.mv Dir.pwd, app_path
113
+ gem_set_file = '.ruby-gemset'
114
+ replace_into_file(gem_set_file, @old_dir, @new_dir) if file_exist?(gem_set_file)
122
115
  File.rename(Rails.root.to_s, @new_path)
123
116
  puts 'Done!'
124
117
  puts "New application path is '#{@new_path}'"
@@ -1,3 +1,3 @@
1
1
  module Rename
2
- VERSION = '1.0.10'
2
+ VERSION = '1.1.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rename
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.10
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Morshed Alam
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-08 00:00:00.000000000 Z
11
+ date: 2024-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails