rename 1.0.2 → 1.0.3

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: 155ecb453a28d3b078737371377490c7c8800a69
4
- data.tar.gz: b5a517bf0b0e6d32c9754b99b067f0fe79e70c34
3
+ metadata.gz: da1e3eaf1e62827e6562036b535ec15fbe79a66c
4
+ data.tar.gz: 1ada5e52d2937365dc6c98a7fb81435a2f1d7bbb
5
5
  SHA512:
6
- metadata.gz: f17b0a28d5fb6adb411adeb2053e746d382ff3ccdc9801ef662bc6b9d0ad45e0be0de24e390ad4891ada86686808bef88fbe3861acc7662138e30b082ace5528
7
- data.tar.gz: c0ddcf0dcb21fc7d48b88b46b13a1d2f8279edb3a7e3487cc26f2bfdf0b7e2c151d32c6330d0c6810f28031cd71108159f6ba685ba9e1d81d9b073ba66fc315d
6
+ metadata.gz: 80f35bdc31a513c22c286a4c057766af2bf2a353edccb9c6c21a83bc775eafe0b268b884d66f43c74f1c9c0eeb4422d4e6035778eefd5506fdcc6c4d7e94ea0c
7
+ data.tar.gz: b92ebd0b7dcf0b1565399f55703448592fc9e49c3746dd1e8a6c1f10810fd84a81ec8fab3cf87721464c3ed22e21aaeebe14ad98febffd6f8f8fb525179023a8
data/README.md CHANGED
@@ -1,20 +1,22 @@
1
1
  # Rename
2
2
 
3
- This Gem allows you to rename a Rails3 application by using a single command.
3
+ This gem allows you to rename your Rails application by using a single command.
4
4
 
5
+ Tested up to Rails 5.
5
6
 
6
7
  ## Installation
7
8
 
8
9
  Add this line to your application's Gemfile:
9
10
 
10
- <pre><code>gem 'rename'</code></pre>
11
-
11
+ ```ruby
12
+ gem 'rename'
13
+ ```
12
14
 
13
15
  ## Usage
14
16
 
15
- <pre><code>rails g rename:app_to New-Name
16
- </code></pre>
17
-
17
+ ```
18
+ rails g rename:into New-Name
19
+ ```
18
20
 
19
21
 
20
22
  ## Contributing
@@ -1 +1 @@
1
- rails g rename:app_to NewName
1
+ rails g rename:app_to NewName
@@ -1,128 +1,20 @@
1
+ require File.expand_path('../../../rename/common_methods', File.dirname(__FILE__))
2
+
1
3
  module Rename
2
4
  module Generators
3
5
  class Error < Thor::Error
4
6
  end
5
7
 
6
8
  class AppToGenerator < Rails::Generators::Base
7
- desc 'Rename rails application'
8
-
9
- argument :new_name, :type => :string, :default => ''
9
+ include CommonMethods
10
10
 
11
11
  def app_to
12
+ warn "[DEPRECATION] `app_to` is deprecated. Please use `into` instead."
13
+
12
14
  valid?
13
15
  new_app_module
14
16
  new_app_directory
15
17
  end
16
-
17
- protected
18
-
19
- def app_name
20
- @app_name = new_name.gsub(/\W/, '_').squeeze('_').camelize
21
- end
22
-
23
- def app_key
24
- @app_key = new_name.gsub(/\W/, '_').downcase
25
- end
26
-
27
- def app_dir
28
- @app_dir = new_name.gsub(/[&%*@()!{}\[\]'\\\/"]+/, '')
29
- end
30
-
31
- def app_path
32
- @app_path = Rails.root.to_s.split('/')[0...-1].push(app_dir).join('/')
33
- end
34
-
35
- def reserved_names
36
- @reserved_names = %w[application destroy benchmarker profiler plugin runner test]
37
- end
38
-
39
- def valid?
40
- if new_name.blank?
41
- raise Error, "Application name can't be blank."
42
- elsif new_name =~ /^\d/
43
- raise Error, "Invalid application name #{new_name}. Please give a name which does not start with numbers."
44
- end
45
-
46
- valid_new_app_name?
47
- valid_new_app_dir?
48
- end
49
-
50
- def valid_new_app_name?
51
- if app_name.size < 1
52
- raise Error, "Invalid application name #{app_name}. Please enter at least one alphabet."
53
- elsif reserved_names.include?(app_name.downcase)
54
- raise Error, "Invalid application name #{app_name}. Please give a name which does not match one of the reserved rails words."
55
- elsif Object.const_defined?(app_name)
56
- raise Error, "Invalid application name #{app_name}, constant #{app_name} is already in use. Please choose another application name."
57
- end
58
- end
59
-
60
- def valid_new_app_dir?
61
- if File.exists?(app_path)
62
- raise Error, "Invalid application name #{app_dir}, already in use. Please choose another application name."
63
- end
64
- end
65
-
66
- # rename_app_to_new_app_module
67
- def new_app_module
68
- mod = "#{Rails.application.class.parent}"
69
-
70
- in_root do
71
- puts 'Search and replace module in to...'
72
-
73
- #Search and replace module in to file
74
- Dir['*', 'config/**/**/*.rb', '.{rvmrc}'].each do |file|
75
- replace_into_file(file, /(#{mod}*)/m, app_name)
76
- end
77
-
78
- #Rename session key
79
- session_key_file = 'config/initializers/session_store.rb'
80
- search_exp = /(('|")_.*_session('|"))/i
81
- session_key = "'_#{app_key}_session'"
82
- replace_into_file(session_key_file, search_exp, session_key)
83
- end
84
- end
85
-
86
- # rename_app_to_new_app_directory
87
- def new_app_directory
88
- rename_references
89
- rename_directory
90
- end
91
-
92
- def rename_references
93
- puts 'Renaming references...'
94
- old_basename = File.basename(Dir.getwd)
95
-
96
- in_root do
97
- Dir.glob('.idea/*', File::FNM_DOTMATCH).each do |file|
98
- replace_into_file(file, old_basename, app_dir)
99
- end
100
-
101
- gem_set_file = '.ruby-gemset'
102
- replace_into_file(gem_set_file, old_basename, app_dir) if File.exist?(gem_set_file)
103
- end
104
- end
105
-
106
- def rename_directory
107
- print 'Renaming directory...'
108
- begin
109
- File.rename(Rails.root.to_s, app_path)
110
- puts 'Done!'
111
- puts "New application path is '#{app_path}'"
112
- rescue Exception => ex
113
- puts "Error:#{ex.inspect}"
114
- end
115
- end
116
-
117
- def replace_into_file(file, search_exp, replace)
118
- return if File.directory?(file)
119
-
120
- begin
121
- gsub_file file, search_exp, replace
122
- rescue Exception => ex
123
- puts "Error: #{ex.message}"
124
- end
125
- end
126
18
  end
127
19
  end
128
20
  end
@@ -0,0 +1 @@
1
+ rails g rename:into NewName
@@ -0,0 +1,18 @@
1
+ require File.expand_path('../../../rename/common_methods', File.dirname(__FILE__))
2
+
3
+ module Rename
4
+ module Generators
5
+ class Error < Thor::Error
6
+ end
7
+
8
+ class IntoGenerator < Rails::Generators::Base
9
+ include CommonMethods
10
+
11
+ def into
12
+ valid?
13
+ new_app_module
14
+ new_app_directory
15
+ end
16
+ end
17
+ end
18
+ end
@@ -1 +1,3 @@
1
- require "rename/version"
1
+ module Rename
2
+ autoload :VERSION, 'active_admin/version'
3
+ end
@@ -0,0 +1,121 @@
1
+ require 'active_support/concern'
2
+
3
+ module CommonMethods
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ desc 'Rename your Rails application'
8
+
9
+ argument :new_name, :type => :string, :default => ''
10
+ end
11
+
12
+ protected
13
+
14
+ def app_name
15
+ @app_name = new_name.gsub(/\W/, '_').squeeze('_').camelize
16
+ end
17
+
18
+ def app_key
19
+ @app_key = new_name.gsub(/\W/, '_').downcase
20
+ end
21
+
22
+ def app_dir
23
+ @app_dir = new_name.gsub(/[&%*@()!{}\[\]'\\\/"]+/, '')
24
+ end
25
+
26
+ def app_path
27
+ @app_path = Rails.root.to_s.split('/')[0...-1].push(app_dir).join('/')
28
+ end
29
+
30
+ def reserved_names
31
+ @reserved_names = %w[application destroy benchmarker profiler plugin runner test]
32
+ end
33
+
34
+ def valid?
35
+ if new_name.blank?
36
+ raise Error, "Application name can't be blank."
37
+ elsif new_name =~ /^\d/
38
+ raise Error, "Invalid application name #{new_name}. Please give a name which does not start with numbers."
39
+ end
40
+
41
+ valid_new_app_name?
42
+ valid_new_app_dir?
43
+ end
44
+
45
+ def valid_new_app_name?
46
+ if app_name.size < 1
47
+ raise Error, "Invalid application name #{app_name}. Please enter at least one alphabet."
48
+ elsif reserved_names.include?(app_name.downcase)
49
+ raise Error, "Invalid application name #{app_name}. Please give a name which does not match one of the reserved Rails keywords."
50
+ elsif Object.const_defined?(app_name)
51
+ raise Error, "Invalid application name #{app_name}, constant #{app_name} is already in use. Please choose another application name."
52
+ end
53
+ end
54
+
55
+ def valid_new_app_dir?
56
+ if File.exists?(app_path)
57
+ raise Error, "Invalid application name #{app_dir}, already in use. Please choose another application name."
58
+ end
59
+ end
60
+
61
+ # rename_app_to_new_app_module
62
+ def new_app_module
63
+ mod = "#{Rails.application.class.parent}"
64
+
65
+ in_root do
66
+ puts 'Search and replace module in...'
67
+
68
+ #Search and replace module in to file
69
+ Dir['*', 'config/**/**/*.rb', '.{rvmrc}'].each do |file|
70
+ replace_into_file(file, /(#{mod}*)/m, app_name)
71
+ end
72
+
73
+ #Rename session key
74
+ session_key_file = 'config/initializers/session_store.rb'
75
+ search_exp = /(('|")_.*_session('|"))/i
76
+ session_key = "'_#{app_key}_session'"
77
+ replace_into_file(session_key_file, search_exp, session_key)
78
+ end
79
+ end
80
+
81
+ # rename_app_to_new_app_directory
82
+ def new_app_directory
83
+ rename_references
84
+ rename_directory
85
+ end
86
+
87
+ def rename_references
88
+ puts 'Renaming references...'
89
+ old_basename = File.basename(Dir.getwd)
90
+
91
+ in_root do
92
+ Dir.glob('.idea/*', File::FNM_DOTMATCH).each do |file|
93
+ replace_into_file(file, old_basename, app_dir)
94
+ end
95
+
96
+ gem_set_file = '.ruby-gemset'
97
+ replace_into_file(gem_set_file, old_basename, app_dir) if File.exist?(gem_set_file)
98
+ end
99
+ end
100
+
101
+ def rename_directory
102
+ print 'Renaming directory...'
103
+ begin
104
+ File.rename(Rails.root.to_s, app_path)
105
+ puts 'Done!'
106
+ puts "New application path is '#{app_path}'"
107
+ rescue Exception => ex
108
+ puts "Error:#{ex.inspect}"
109
+ end
110
+ end
111
+
112
+ def replace_into_file(file, search_exp, replace)
113
+ return if File.directory?(file)
114
+
115
+ begin
116
+ gsub_file file, search_exp, replace
117
+ rescue Exception => ex
118
+ puts "Error: #{ex.message}"
119
+ end
120
+ end
121
+ end
@@ -1,3 +1,3 @@
1
1
  module Rename
2
- VERSION = '1.0.2'
2
+ VERSION = '1.0.3'
3
3
  end
@@ -2,18 +2,20 @@
2
2
  require File.expand_path('../lib/rename/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
- gem.name = 'rename'
6
- gem.version = Rename::VERSION
7
- gem.authors = ['Morshed Alam']
8
- gem.email = %w(morshed201@gmail.com)
9
- gem.homepage = 'https://github.com/morshedalam/rename'
10
- gem.description = 'This library allows you to rename rails application using a single command'
11
- gem.summary = 'A library to rename your rails3 application'
5
+ gem.name = 'rename'
6
+ gem.version = Rename::VERSION
7
+ gem.license = 'MIT'
8
+ gem.authors = ['Morshed Alam']
9
+ gem.email = %w(morshed201@gmail.com)
10
+ gem.homepage = 'https://github.com/morshedalam/rename'
11
+ gem.summary = 'Rename your Rails application using a single command.'
12
12
 
13
- gem.add_dependency 'rails','>= 3.0.0'
13
+ gem.add_dependency 'rails', '>= 3.0.0'
14
+ gem.add_dependency 'thor', '= 0.19.1'
15
+ gem.add_runtime_dependency 'activesupport'
14
16
  gem.rubyforge_project = 'rename'
15
17
 
16
18
  gem.files = `git ls-files`.split("\n")
17
- gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ gem.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
18
20
  gem.require_paths = %w(lib)
19
- end
21
+ end
metadata CHANGED
@@ -1,52 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rename
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Morshed Alam
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-30 00:00:00.000000000 Z
11
+ date: 2017-01-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 3.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 3.0.0
27
- description: This library allows you to rename rails application using a single command
27
+ - !ruby/object:Gem::Dependency
28
+ name: thor
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 0.19.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 0.19.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: activesupport
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description:
28
56
  email:
29
57
  - morshed201@gmail.com
30
58
  executables: []
31
59
  extensions: []
32
60
  extra_rdoc_files: []
33
61
  files:
34
- - .gitignore
62
+ - ".gitignore"
35
63
  - Gemfile
36
64
  - LICENSE
37
65
  - README.md
38
66
  - Rakefile
39
67
  - TO DO
40
- - application.rb
41
68
  - lib/generators/rename/app_to/USAGE
42
69
  - lib/generators/rename/app_to/app_to_generator.rb
70
+ - lib/generators/rename/into/USAGE
71
+ - lib/generators/rename/into/into_generator.rb
43
72
  - lib/rename.rb
73
+ - lib/rename/common_methods.rb
44
74
  - lib/rename/version.rb
45
75
  - rename.gemspec
46
76
  - tests/rename_test.rb
47
77
  - tests/test_helper.rb
48
78
  homepage: https://github.com/morshedalam/rename
49
- licenses: []
79
+ licenses:
80
+ - MIT
50
81
  metadata: {}
51
82
  post_install_message:
52
83
  rdoc_options: []
@@ -54,18 +85,18 @@ require_paths:
54
85
  - lib
55
86
  required_ruby_version: !ruby/object:Gem::Requirement
56
87
  requirements:
57
- - - '>='
88
+ - - ">="
58
89
  - !ruby/object:Gem::Version
59
90
  version: '0'
60
91
  required_rubygems_version: !ruby/object:Gem::Requirement
61
92
  requirements:
62
- - - '>='
93
+ - - ">="
63
94
  - !ruby/object:Gem::Version
64
95
  version: '0'
65
96
  requirements: []
66
97
  rubyforge_project: rename
67
- rubygems_version: 2.0.7
98
+ rubygems_version: 2.5.1
68
99
  signing_key:
69
100
  specification_version: 4
70
- summary: A library to rename your rails3 application
101
+ summary: Rename your Rails application using a single command.
71
102
  test_files: []
@@ -1,67 +0,0 @@
1
- require File.expand_path('../boot', __FILE__)
2
-
3
- require 'rails/all'
4
-
5
- if defined?(Bundler)
6
- # If you precompile assets before deploying to production, use this line
7
- Bundler.require(*Rails.groups(:assets => %w(development test)))
8
- # If you want your assets lazily compiled in production, use this line
9
- # Bundler.require(:default, :assets, Rails.env)
10
- end
11
-
12
- Codelodge22222::Application.initialize!
13
-
14
- #Secret token
15
- Codelodge22222::Application.config.secret_token = '3544fef8fa99bb5c1939f786a3f8efd3dd7c5bac2081632368a97836b9d338c6d499d548641086ebf507b36c45db69f2b9ccaf98b981010ab2efbe3745d5bba6'
16
-
17
- module Codelodge222
18
- class Application < Rails::Application
19
- # Settings in config/environments/* take precedence over those specified here.
20
- # Application configuration should go into files in config/initializers
21
- # -- all .rb files in that directory are automatically loaded.
22
-
23
- # Custom directories with classes and modules you want to be autoloadable.
24
- # config.autoload_paths += %W(#{config.root}/extras)
25
-
26
- # Only load the plugins named here, in the order given (default is alphabetical).
27
- # :all can be used as a placeholder for all plugins not explicitly named.
28
- # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
29
-
30
- # Activate observers that should always be running.
31
- # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
32
-
33
- # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
34
- # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
35
- # config.time_zone = 'Central Time (US & Canada)'
36
-
37
- # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
38
- # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
39
- # config.i18n.default_locale = :de
40
-
41
- # Configure the default encoding used in templates for Ruby 1.9.
42
- config.encoding = "utf-8"
43
-
44
- # Configure sensitive parameters which will be filtered from the log file.
45
- config.filter_parameters += [:password]
46
-
47
- # Enable escaping HTML in JSON.
48
- config.active_support.escape_html_entities_in_json = true
49
-
50
- # Use SQL instead of Active Record's schema dumper when creating the database.
51
- # This is necessary if your schema can't be completely dumped by the schema dumper,
52
- # like if you have constraints or database-specific column types
53
- # config.active_record.schema_format = :sql
54
-
55
- # Enforce whitelist mode for mass assignment.
56
- # This will create an empty whitelist of attributes available for mass-assignment for all models
57
- # in your app. As such, your models will need to explicitly whitelist or blacklist accessible
58
- # parameters by using an attr_accessible or attr_protected declaration.
59
- config.active_record.whitelist_attributes = true
60
-
61
- # Enable the asset pipeline
62
- config.assets.enabled = true
63
-
64
- # Version of your assets, change this if you want to expire all your assets
65
- config.assets.version = '1.0'
66
- end
67
- end