rename 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,6 +7,7 @@ module Rename
7
7
  return if !valid_app_name?
8
8
  new_module_name()
9
9
  new_basename()
10
+ puts "Done!"
10
11
  end
11
12
 
12
13
  private
@@ -38,35 +39,35 @@ module Rename
38
39
 
39
40
  #Search and replace module in to file
40
41
  Dir["*", "config/**/**/*.rb", ".{rvmrc}"].each do |file|
41
- search_and_replace_module_into_file(file, search_exp, module_name)
42
+ replace_into_file(file, search_exp, module_name)
42
43
  end
43
44
 
44
45
  #Rename session key
45
46
  session_key_file = 'config/initializers/session_store.rb'
46
47
  search_exp = /((\'|\")_.*_session(\'|\"))/i
47
48
  session_key = "'_#{module_name.gsub(/[^0-9A-Za-z_]/, '_').downcase}_session'"
48
- search_and_replace_module_into_file(session_key_file, search_exp, session_key)
49
+ replace_into_file(session_key_file, search_exp, session_key)
49
50
  end
50
51
  end
51
52
 
52
53
  def new_basename()
53
54
  basename = new_name.gsub(/[^0-9A-Za-z_]/, '-')
54
-
55
55
  change_basename(basename)
56
56
  change_directory_name(basename)
57
-
58
- puts "Done!"
59
57
  end
60
58
 
61
59
  def change_basename(basename)
62
60
  puts "Renaming basename..."
63
61
 
62
+ old_basename = File.basename(Dir.getwd)
63
+
64
64
  in_root do
65
65
  Dir.glob(".idea/*", File::FNM_DOTMATCH).each do |file|
66
- search_and_replace_module_into_file(file, File.basename(Dir.getwd), basename)
66
+ replace_into_file(file, old_basename, basename)
67
67
  end
68
68
 
69
- search_and_replace_module_into_file(".ruby-gemset", File.basename(Dir.getwd), basename)
69
+ gemset_file = ".ruby-gemset"
70
+ replace_into_file(gemset_file, old_basename, basename) if File.exist?(gemset_file)
70
71
  end
71
72
  end
72
73
 
@@ -80,11 +81,11 @@ module Rename
80
81
  end
81
82
  end
82
83
 
83
- def search_and_replace_module_into_file(file, search_exp, new_module_name)
84
+ def replace_into_file(file, search_exp, replace)
84
85
  return if File.directory?(file)
85
86
 
86
87
  begin
87
- gsub_file file, search_exp, new_module_name
88
+ gsub_file file, search_exp, replace
88
89
  rescue Exception => ex
89
90
  puts "Error: #{ex.message}"
90
91
  end
@@ -1,3 +1,3 @@
1
1
  module Rename
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
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.8
4
+ version: 0.0.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2013-06-02 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &75130420 !ruby/object:Gem::Requirement
16
+ requirement: &77937290 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: 3.0.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *75130420
24
+ version_requirements: *77937290
25
25
  description: This library allows you to rename Rails3 application by using a single
26
26
  command
27
27
  email: