rename 1.0.6 → 1.0.9
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 +5 -5
- data/README.md +1 -1
- data/lib/generators/rename/shared/common_methods.rb +33 -5
- data/lib/rename/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 59dcefa0ad39fd863840b89bfaa4b6d79395009d63c489243fbea126496a901a
|
4
|
+
data.tar.gz: 3125cd4d95bb1d153ae31f2c6e21e8a6cce0232ccbe7d3115307de3215a5bb2f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc304eb7f357c6b8adc6ed8daefd10460c417df186050574035b4c63ea7ede4a555fff2e1355cf4e6e03d7e4459c88a6ba7b980acebe4b4b18c5b1cdd8848bb1
|
7
|
+
data.tar.gz: 7af04e3ac1bfb29ca8596d40dfad2434ccc4578d16a53d8bc3d1edaedb4f9b464171fdde8fa924891d99afa7da6612ebbca1c9486948f7cd342b68867c232918
|
data/README.md
CHANGED
@@ -18,9 +18,17 @@ module CommonMethods
|
|
18
18
|
change_app_directory
|
19
19
|
end
|
20
20
|
|
21
|
+
def app_parent
|
22
|
+
if Rails.version.to_f >= 3.3
|
23
|
+
Rails.application.class.to_s.deconstantize
|
24
|
+
else
|
25
|
+
Rails.application.class.parent.name
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
21
29
|
def prepare_app_vars
|
22
30
|
@new_key = new_name.gsub(/\W/, '_')
|
23
|
-
@old_module_name =
|
31
|
+
@old_module_name = app_parent
|
24
32
|
@new_module_name = @new_key.squeeze('_').camelize
|
25
33
|
@new_dir = new_name.gsub(/[&%*@()!{}\[\]'\\\/"]+/, '')
|
26
34
|
@new_path = Rails.root.to_s.split('/')[0...-1].push(@new_dir).join('/')
|
@@ -37,7 +45,7 @@ module CommonMethods
|
|
37
45
|
raise Thor::Error, '[Error] Please give a name which does not match any of the reserved Rails keywords.'
|
38
46
|
elsif Object.const_defined?(@new_module_name)
|
39
47
|
raise Thor::Error, "[Error] Constant #{@new_module_name} is already in use, please choose another name."
|
40
|
-
elsif
|
48
|
+
elsif file_exist?(@new_path)
|
41
49
|
raise Thor::Error, '[Error] Already in use, please choose another name.'
|
42
50
|
end
|
43
51
|
end
|
@@ -45,7 +53,7 @@ module CommonMethods
|
|
45
53
|
# rename_app_to_new_app_module
|
46
54
|
def apply_new_module_name
|
47
55
|
in_root do
|
48
|
-
puts 'Search and replace module in...'
|
56
|
+
puts 'Search and replace module in files...'
|
49
57
|
|
50
58
|
#Search and replace module in to file
|
51
59
|
Dir['*', 'config/**/**/*.rb', '.{rvmrc}'].each do |file|
|
@@ -57,6 +65,22 @@ module CommonMethods
|
|
57
65
|
replace_into_file('config/initializers/session_store.rb', /(('|")_.*_session('|"))/i, "'_#{@new_key}_session'")
|
58
66
|
#Rename database
|
59
67
|
replace_into_file('config/database.yml', /#{@old_module_name.underscore}/i, @new_name.underscore)
|
68
|
+
#Rename into channel and job queue
|
69
|
+
%w(config/cable.yml config/environments/production.rb).each do |file|
|
70
|
+
replace_into_file(file, /#{@old_module_name.underscore}_production/, "#{@new_module_name.underscore}_production")
|
71
|
+
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
|
77
|
+
old_package_name_regex = /\Wname\W *: *\W(?<name>[-_\p{Alnum}]+)\W *, */i
|
78
|
+
new_package_name = %("name":"#{@new_module_name.underscore}",)
|
79
|
+
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)
|
60
84
|
end
|
61
85
|
end
|
62
86
|
|
@@ -72,6 +96,10 @@ module CommonMethods
|
|
72
96
|
@reserved_names = %w[application destroy benchmarker profiler plugin runner test]
|
73
97
|
end
|
74
98
|
|
99
|
+
def file_exist?(name)
|
100
|
+
File.respond_to?(:exist?) ? File.exist?(name) : File.exists?(name)
|
101
|
+
end
|
102
|
+
|
75
103
|
def rename_references
|
76
104
|
puts 'Renaming references...'
|
77
105
|
old_basename = File.basename(Dir.getwd)
|
@@ -82,7 +110,7 @@ module CommonMethods
|
|
82
110
|
end
|
83
111
|
|
84
112
|
gem_set_file = '.ruby-gemset'
|
85
|
-
replace_into_file(gem_set_file, old_basename, @new_dir) if
|
113
|
+
replace_into_file(gem_set_file, old_basename, @new_dir) if file_exist?(gem_set_file)
|
86
114
|
end
|
87
115
|
end
|
88
116
|
|
@@ -100,7 +128,7 @@ module CommonMethods
|
|
100
128
|
end
|
101
129
|
|
102
130
|
def replace_into_file(file, search_exp, replace)
|
103
|
-
return if File.directory?(file)
|
131
|
+
return if File.directory?(file) || !file_exist?(file)
|
104
132
|
|
105
133
|
begin
|
106
134
|
gsub_file file, search_exp, replace
|
data/lib/rename/version.rb
CHANGED
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.
|
4
|
+
version: 1.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Morshed Alam
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-04-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -52,7 +52,7 @@ dependencies:
|
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
|
-
description:
|
55
|
+
description:
|
56
56
|
email:
|
57
57
|
- morshed201@gmail.com
|
58
58
|
executables: []
|
@@ -79,7 +79,7 @@ homepage: https://github.com/morshedalam/rename
|
|
79
79
|
licenses:
|
80
80
|
- MIT
|
81
81
|
metadata: {}
|
82
|
-
post_install_message:
|
82
|
+
post_install_message:
|
83
83
|
rdoc_options: []
|
84
84
|
require_paths:
|
85
85
|
- lib
|
@@ -95,8 +95,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
95
|
version: '0'
|
96
96
|
requirements: []
|
97
97
|
rubyforge_project: rename
|
98
|
-
rubygems_version: 2.
|
99
|
-
signing_key:
|
98
|
+
rubygems_version: 2.7.11
|
99
|
+
signing_key:
|
100
100
|
specification_version: 4
|
101
101
|
summary: Rename your Rails application using a single command.
|
102
102
|
test_files: []
|