rename 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
File without changes
@@ -0,0 +1,53 @@
1
+ module Rename
2
+ module Generators
3
+ class AppToGenerator < Rails::Generators::Base
4
+ argument :new_name, :type => :string, :default => "#{Rails.application.class.parent}"
5
+
6
+ def app_to
7
+ old_root_directory = "#{Rails.root}"
8
+ old_name = Regexp.escape("#{Rails.application.class.parent}")
9
+ rename_to = new_name.downcase.gsub(/\s/, "_").camelize.capitalize
10
+ new_root_directory = old_root_directory.gsub(/\/#{old_name.downcase}/, "/#{new_name.downcase}")
11
+
12
+ changes = list_of_changes(rename_to, old_name)
13
+
14
+ #Inside the application
15
+ in_root do
16
+ for change in changes
17
+ if change[0] == 'environments'
18
+ for env_name in ['development', 'production', 'test']
19
+ change[0] = "config/environments/#{env_name}.rb"
20
+ replace_on_file(change)
21
+ end
22
+ else
23
+ replace_on_file(change)
24
+ end
25
+ end
26
+ end
27
+ puts "Renaming directory"
28
+ File.rename "#{old_root_directory}", "#{new_root_directory}"
29
+ end
30
+
31
+ private
32
+ def list_of_changes(rename_to, old_name)
33
+ return [
34
+ ['Rakefile', /(#{old_name})(::Application.load_tasks)/mi, "#{rename_to}::Application.load_tasks"],
35
+ ['config.ru', /(run) (#{old_name})(::Application)/mi, "run #{rename_to}::Application"],
36
+ ['config/routes.rb', /(#{old_name})(::Application.routes)/mi, "#{rename_to}::Application.routes"],
37
+ ['config/application.rb', /(module) (#{old_name})/mi, "module #{rename_to}"],
38
+ ['config/environment.rb', /(#{old_name})(::Application.initialize!)/mi, "#{rename_to}::Application.initialize!"],
39
+ ['config/initializers/secret_token.rb', /(#{old_name})(::Application.config.secret_token)/mi, "#{rename_to}::Application.config.secret_token"],
40
+ ['config/initializers/session_store.rb', /(#{old_name})(::Application.config.session_store)/mi, "#{rename_to}::Application.config.session_store"],
41
+ ['environments', /(#{old_name})(::Application.configure)/mi, "#{rename_to}::Application.configure"]
42
+ ]
43
+ end
44
+
45
+ def replace_on_file(change)
46
+ gsub_file change[0], change[1] do |match|
47
+ change[2]
48
+ end
49
+ end
50
+ end
51
+
52
+ end
53
+ end
@@ -1,3 +1,3 @@
1
1
  module Rename
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/rename.gemspec CHANGED
@@ -7,11 +7,11 @@ Gem::Specification.new do |gem|
7
7
  gem.authors = ["Morshed Alam"]
8
8
  gem.email = ["morshed201@gmail.com"]
9
9
  gem.homepage = "https://github.com/get/Rename.git"
10
- gem.description = 'This library allows you to rename Rails3 application name by using a single command'
10
+ gem.description = 'This library allows you to rename Rails3 application by using a single command'
11
11
  gem.summary = 'A library to rename your rails3 application'
12
12
 
13
13
  gem.add_dependency "rails", ">= 3.0.0"
14
- #gem.rubyforge_project = "rename"
14
+ gem.rubyforge_project = "rename"
15
15
 
16
16
  gem.files = `git ls-files`.split("\n")
17
17
  gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
@@ -0,0 +1,8 @@
1
+ require 'test_helper'
2
+
3
+ class RenameTest < ActiveSupport::TestCase
4
+ # Replace this with your real tests.
5
+ test "the truth" do
6
+ assert true
7
+ end
8
+ end
@@ -0,0 +1,3 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'active_support'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rename
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-04-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &72441010 !ruby/object:Gem::Requirement
16
+ requirement: &80633620 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,9 +21,9 @@ dependencies:
21
21
  version: 3.0.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *72441010
25
- description: This library allows you to rename Rails3 application name by using a
26
- single command
24
+ version_requirements: *80633620
25
+ description: This library allows you to rename Rails3 application by using a single
26
+ command
27
27
  email:
28
28
  - morshed201@gmail.com
29
29
  executables: []
@@ -35,9 +35,13 @@ files:
35
35
  - LICENSE
36
36
  - README.md
37
37
  - Rakefile
38
+ - lib/generators/rename/app_name/USAGE
39
+ - lib/generators/rename/app_name/app_name_generator.rb
38
40
  - lib/rename.rb
39
41
  - lib/rename/version.rb
40
42
  - rename.gemspec
43
+ - tests/rename_test.rb
44
+ - tests/test_helper.rb
41
45
  homepage: https://github.com/get/Rename.git
42
46
  licenses: []
43
47
  post_install_message:
@@ -57,7 +61,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
57
61
  - !ruby/object:Gem::Version
58
62
  version: '0'
59
63
  requirements: []
60
- rubyforge_project:
64
+ rubyforge_project: rename
61
65
  rubygems_version: 1.8.17
62
66
  signing_key:
63
67
  specification_version: 3