rails_magic_renamer 2.0.0.pre.alpha

Sign up to get free protection for your applications and to get access to all the features.
Files changed (164) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +2 -0
  3. data/.ruby-version +1 -0
  4. data/.travis.yml +6 -0
  5. data/CHANGELOG +4 -0
  6. data/Gemfile +4 -0
  7. data/Gemfile.lock +173 -0
  8. data/Guardfile +11 -0
  9. data/Manifest +8 -0
  10. data/README.md +59 -0
  11. data/ROADMAP.md +60 -0
  12. data/Rakefile +2 -0
  13. data/lib/rails_magic_renamer.rb +343 -0
  14. data/lib/rails_magic_renamer/exceptions.rb +35 -0
  15. data/lib/rails_magic_renamer/version.rb +3 -0
  16. data/rails_magic_renamer.gemspec +36 -0
  17. data/spec/rails_helper.rb +26 -0
  18. data/spec/rails_magic_renamer_spec.rb +22 -0
  19. data/spec/spec_helper.rb +17 -0
  20. data/spec/support/sample_app_rails_4/.gitignore +19 -0
  21. data/spec/support/sample_app_rails_4/.rspec +2 -0
  22. data/spec/support/sample_app_rails_4/Gemfile +58 -0
  23. data/spec/support/sample_app_rails_4/Gemfile.lock +249 -0
  24. data/spec/support/sample_app_rails_4/Guardfile +53 -0
  25. data/spec/support/sample_app_rails_4/LICENSE +21 -0
  26. data/spec/support/sample_app_rails_4/README.md +25 -0
  27. data/spec/support/sample_app_rails_4/README.nitrous.md +20 -0
  28. data/spec/support/sample_app_rails_4/Rakefile +6 -0
  29. data/spec/support/sample_app_rails_4/app/assets/images/rails.png +0 -0
  30. data/spec/support/sample_app_rails_4/app/assets/javascripts/application.js +17 -0
  31. data/spec/support/sample_app_rails_4/app/assets/javascripts/sessions.js.coffee +3 -0
  32. data/spec/support/sample_app_rails_4/app/assets/javascripts/static_pages.js.coffee +3 -0
  33. data/spec/support/sample_app_rails_4/app/assets/javascripts/users.js.coffee +3 -0
  34. data/spec/support/sample_app_rails_4/app/assets/stylesheets/application.css +13 -0
  35. data/spec/support/sample_app_rails_4/app/assets/stylesheets/custom.css.scss +246 -0
  36. data/spec/support/sample_app_rails_4/app/assets/stylesheets/sessions.css.scss +3 -0
  37. data/spec/support/sample_app_rails_4/app/assets/stylesheets/static_pages.css.scss +3 -0
  38. data/spec/support/sample_app_rails_4/app/assets/stylesheets/users.css.scss +3 -0
  39. data/spec/support/sample_app_rails_4/app/controllers/application_controller.rb +6 -0
  40. data/spec/support/sample_app_rails_4/app/controllers/concerns/.keep +0 -0
  41. data/spec/support/sample_app_rails_4/app/controllers/microposts_controller.rb +31 -0
  42. data/spec/support/sample_app_rails_4/app/controllers/relationships_controller.rb +21 -0
  43. data/spec/support/sample_app_rails_4/app/controllers/sessions_controller.rb +21 -0
  44. data/spec/support/sample_app_rails_4/app/controllers/static_pages_controller.rb +18 -0
  45. data/spec/support/sample_app_rails_4/app/controllers/users_controller.rb +80 -0
  46. data/spec/support/sample_app_rails_4/app/helpers/application_helper.rb +12 -0
  47. data/spec/support/sample_app_rails_4/app/helpers/sessions_helper.rb +49 -0
  48. data/spec/support/sample_app_rails_4/app/helpers/static_pages_helper.rb +2 -0
  49. data/spec/support/sample_app_rails_4/app/helpers/users_helper.rb +10 -0
  50. data/spec/support/sample_app_rails_4/app/mailers/.keep +0 -0
  51. data/spec/support/sample_app_rails_4/app/models/.keep +0 -0
  52. data/spec/support/sample_app_rails_4/app/models/comment.rb +5 -0
  53. data/spec/support/sample_app_rails_4/app/models/concerns/.keep +0 -0
  54. data/spec/support/sample_app_rails_4/app/models/micropost.rb +14 -0
  55. data/spec/support/sample_app_rails_4/app/models/organisation.rb +3 -0
  56. data/spec/support/sample_app_rails_4/app/models/relationship.rb +6 -0
  57. data/spec/support/sample_app_rails_4/app/models/user.rb +57 -0
  58. data/spec/support/sample_app_rails_4/app/models/user_comment.rb +5 -0
  59. data/spec/support/sample_app_rails_4/app/views/layouts/_footer.html.erb +13 -0
  60. data/spec/support/sample_app_rails_4/app/views/layouts/_header.html.erb +31 -0
  61. data/spec/support/sample_app_rails_4/app/views/layouts/_shim.html.erb +3 -0
  62. data/spec/support/sample_app_rails_4/app/views/layouts/application.html.erb +22 -0
  63. data/spec/support/sample_app_rails_4/app/views/microposts/_micropost.html.erb +11 -0
  64. data/spec/support/sample_app_rails_4/app/views/relationships/create.js.erb +2 -0
  65. data/spec/support/sample_app_rails_4/app/views/relationships/destroy.js.erb +2 -0
  66. data/spec/support/sample_app_rails_4/app/views/sessions/new.html.erb +19 -0
  67. data/spec/support/sample_app_rails_4/app/views/shared/_error_messages.html.erb +12 -0
  68. data/spec/support/sample_app_rails_4/app/views/shared/_feed.html.erb +6 -0
  69. data/spec/support/sample_app_rails_4/app/views/shared/_feed_item.html.erb +15 -0
  70. data/spec/support/sample_app_rails_4/app/views/shared/_micropost_form.html.erb +7 -0
  71. data/spec/support/sample_app_rails_4/app/views/shared/_stats.html.erb +15 -0
  72. data/spec/support/sample_app_rails_4/app/views/shared/_user_info.html.erb +12 -0
  73. data/spec/support/sample_app_rails_4/app/views/static_pages/about.html.erb +8 -0
  74. data/spec/support/sample_app_rails_4/app/views/static_pages/contact.html.erb +6 -0
  75. data/spec/support/sample_app_rails_4/app/views/static_pages/help.html.erb +8 -0
  76. data/spec/support/sample_app_rails_4/app/views/static_pages/home.html.erb +34 -0
  77. data/spec/support/sample_app_rails_4/app/views/static_pages/show.html.erb +0 -0
  78. data/spec/support/sample_app_rails_4/app/views/users/_follow.html.erb +5 -0
  79. data/spec/support/sample_app_rails_4/app/views/users/_follow_form.html.erb +9 -0
  80. data/spec/support/sample_app_rails_4/app/views/users/_unfollow.html.erb +5 -0
  81. data/spec/support/sample_app_rails_4/app/views/users/_user.html.erb +8 -0
  82. data/spec/support/sample_app_rails_4/app/views/users/edit.html.erb +27 -0
  83. data/spec/support/sample_app_rails_4/app/views/users/index.html.erb +10 -0
  84. data/spec/support/sample_app_rails_4/app/views/users/new.html.erb +24 -0
  85. data/spec/support/sample_app_rails_4/app/views/users/show.html.erb +24 -0
  86. data/spec/support/sample_app_rails_4/app/views/users/show_follow.html.erb +30 -0
  87. data/spec/support/sample_app_rails_4/bin/bundle +3 -0
  88. data/spec/support/sample_app_rails_4/bin/rails +4 -0
  89. data/spec/support/sample_app_rails_4/bin/rake +4 -0
  90. data/spec/support/sample_app_rails_4/config.ru +4 -0
  91. data/spec/support/sample_app_rails_4/config/application.rb +31 -0
  92. data/spec/support/sample_app_rails_4/config/boot.rb +4 -0
  93. data/spec/support/sample_app_rails_4/config/cucumber.yml +8 -0
  94. data/spec/support/sample_app_rails_4/config/database.yml +12 -0
  95. data/spec/support/sample_app_rails_4/config/environment.rb +7 -0
  96. data/spec/support/sample_app_rails_4/config/environments/development.rb +27 -0
  97. data/spec/support/sample_app_rails_4/config/environments/production.rb +79 -0
  98. data/spec/support/sample_app_rails_4/config/environments/test.rb +39 -0
  99. data/spec/support/sample_app_rails_4/config/initializers/backtrace_silencers.rb +7 -0
  100. data/spec/support/sample_app_rails_4/config/initializers/filter_parameter_logging.rb +4 -0
  101. data/spec/support/sample_app_rails_4/config/initializers/inflections.rb +16 -0
  102. data/spec/support/sample_app_rails_4/config/initializers/mime_types.rb +5 -0
  103. data/spec/support/sample_app_rails_4/config/initializers/secret_token.rb +22 -0
  104. data/spec/support/sample_app_rails_4/config/initializers/session_store.rb +3 -0
  105. data/spec/support/sample_app_rails_4/config/initializers/wrap_parameters.rb +14 -0
  106. data/spec/support/sample_app_rails_4/config/locales/en.yml +23 -0
  107. data/spec/support/sample_app_rails_4/config/routes.rb +17 -0
  108. data/spec/support/sample_app_rails_4/db/development.sqlite3 +0 -0
  109. data/spec/support/sample_app_rails_4/db/migrate/20130311191400_create_users.rb +10 -0
  110. data/spec/support/sample_app_rails_4/db/migrate/20130311194153_add_index_to_users_email.rb +5 -0
  111. data/spec/support/sample_app_rails_4/db/migrate/20130311201841_add_password_digest_to_users.rb +5 -0
  112. data/spec/support/sample_app_rails_4/db/migrate/20130314184954_add_remember_token_to_users.rb +6 -0
  113. data/spec/support/sample_app_rails_4/db/migrate/20130315015932_add_admin_to_users.rb +5 -0
  114. data/spec/support/sample_app_rails_4/db/migrate/20130315175534_create_microposts.rb +11 -0
  115. data/spec/support/sample_app_rails_4/db/migrate/20130315230445_create_relationships.rb +13 -0
  116. data/spec/support/sample_app_rails_4/db/migrate/20160424113439_create_comments.rb +8 -0
  117. data/spec/support/sample_app_rails_4/db/migrate/20160424113451_create_user_comments.rb +8 -0
  118. data/spec/support/sample_app_rails_4/db/migrate/20160424114701_create_organisations.rb +8 -0
  119. data/spec/support/sample_app_rails_4/db/migrate/20160424114727_add_organisation_id_to_users.rb +5 -0
  120. data/spec/support/sample_app_rails_4/db/schema.rb +67 -0
  121. data/spec/support/sample_app_rails_4/db/seeds.rb +7 -0
  122. data/spec/support/sample_app_rails_4/db/test.sqlite3 +0 -0
  123. data/spec/support/sample_app_rails_4/factory_girl.rb +7 -0
  124. data/spec/support/sample_app_rails_4/features/signing_in.feature +13 -0
  125. data/spec/support/sample_app_rails_4/features/step_definitions/authentication_steps.rb +30 -0
  126. data/spec/support/sample_app_rails_4/features/support/env.rb +59 -0
  127. data/spec/support/sample_app_rails_4/lib/assets/.keep +0 -0
  128. data/spec/support/sample_app_rails_4/lib/tasks/.keep +0 -0
  129. data/spec/support/sample_app_rails_4/lib/tasks/cucumber.rake +65 -0
  130. data/spec/support/sample_app_rails_4/lib/tasks/sample_data.rake +42 -0
  131. data/spec/support/sample_app_rails_4/log/.keep +0 -0
  132. data/spec/support/sample_app_rails_4/public/404.html +27 -0
  133. data/spec/support/sample_app_rails_4/public/422.html +26 -0
  134. data/spec/support/sample_app_rails_4/public/500.html +26 -0
  135. data/spec/support/sample_app_rails_4/public/assets/application-4962059d8f80f9bb096692bacc29c4e8.css +5091 -0
  136. data/spec/support/sample_app_rails_4/public/assets/application-4962059d8f80f9bb096692bacc29c4e8.css.gz +0 -0
  137. data/spec/support/sample_app_rails_4/public/assets/application-eeb856e3fe2c8f879c91d0e81d59cb40.js +12952 -0
  138. data/spec/support/sample_app_rails_4/public/assets/application-eeb856e3fe2c8f879c91d0e81d59cb40.js.gz +0 -0
  139. data/spec/support/sample_app_rails_4/public/assets/glyphicons-halflings-c806376f05e4ccabe2c5315a8e95667c.png +0 -0
  140. data/spec/support/sample_app_rails_4/public/assets/glyphicons-halflings-white-62b67d9edee3db90d18833087f848d6e.png +0 -0
  141. data/spec/support/sample_app_rails_4/public/assets/manifest-802de9eb1c853769101852422b620883.json +1 -0
  142. data/spec/support/sample_app_rails_4/public/assets/rails-231a680f23887d9dd70710ea5efd3c62.png +0 -0
  143. data/spec/support/sample_app_rails_4/public/favicon.ico +0 -0
  144. data/spec/support/sample_app_rails_4/public/robots.txt +5 -0
  145. data/spec/support/sample_app_rails_4/script/cucumber +10 -0
  146. data/spec/support/sample_app_rails_4/spec/controllers/relationships_controller_spec.rb +42 -0
  147. data/spec/support/sample_app_rails_4/spec/factories.rb +17 -0
  148. data/spec/support/sample_app_rails_4/spec/features/authentication_pages_spec.rb +155 -0
  149. data/spec/support/sample_app_rails_4/spec/features/micropost_pages_spec.rb +45 -0
  150. data/spec/support/sample_app_rails_4/spec/features/static_pages_spec.rb +64 -0
  151. data/spec/support/sample_app_rails_4/spec/features/user_pages_spec.rb +239 -0
  152. data/spec/support/sample_app_rails_4/spec/helpers/application_helper_spec.rb +18 -0
  153. data/spec/support/sample_app_rails_4/spec/models/comments_spec.rb +5 -0
  154. data/spec/support/sample_app_rails_4/spec/models/micropost_spec.rb +30 -0
  155. data/spec/support/sample_app_rails_4/spec/models/organisation_spec.rb +5 -0
  156. data/spec/support/sample_app_rails_4/spec/models/relationship_spec.rb +36 -0
  157. data/spec/support/sample_app_rails_4/spec/models/user_comments_spec.rb +5 -0
  158. data/spec/support/sample_app_rails_4/spec/models/user_spec.rb +108 -0
  159. data/spec/support/sample_app_rails_4/spec/spec_helper.rb +57 -0
  160. data/spec/support/sample_app_rails_4/spec/support/utilities.rb +21 -0
  161. data/spec/support/sample_app_rails_4/vendor/assets/javascripts/.keep +0 -0
  162. data/spec/support/sample_app_rails_4/vendor/assets/stylesheets/.keep +0 -0
  163. data/tasks/rspec.rake +4 -0
  164. metadata +534 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9bb535f11a05fa8ad225536765ad98ad0e6ad6b5
4
+ data.tar.gz: c10d8cbd4f4d5224380812e8a2f2fb1589765578
5
+ SHA512:
6
+ metadata.gz: 0c7342fa94c4d278b9a5854a7388882b9ca2387906db653b79821032c2726ffd316838c05874d3faea3ba3ef38e7ab30878ac26a394948bf26a45e0c4f387e80
7
+ data.tar.gz: 2d5356f4a6aeeb9d96eea8f154198173f69827759731a7a6099469c50d63a84013d008973ebf49fb126c2405dbf5ee890f49bb37ff33e44075f33bf9e79a6fd0
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ *.gem
2
+ tags
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.0.0
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - "1.9.3"
4
+ - "2.0.0"
5
+ - "2.1.2"
6
+ - rbx
data/CHANGELOG ADDED
@@ -0,0 +1,4 @@
1
+ v1.3. Support for rails_refactor to be put in your Gemfile
2
+ v1.2. Speed improvements and more robust with missing files (thanks Tricon)
3
+ v1.1. Updating README and usage information
4
+ v1.0. first version as a gem, thanks Andys!
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gemspec
4
+
data/Gemfile.lock ADDED
@@ -0,0 +1,173 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rails_magic_renamer (2.0)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ actionmailer (4.0.13)
10
+ actionpack (= 4.0.13)
11
+ mail (~> 2.5, >= 2.5.4)
12
+ actionpack (4.0.13)
13
+ activesupport (= 4.0.13)
14
+ builder (~> 3.1.0)
15
+ erubis (~> 2.7.0)
16
+ rack (~> 1.5.2)
17
+ rack-test (~> 0.6.2)
18
+ activemodel (4.0.13)
19
+ activesupport (= 4.0.13)
20
+ builder (~> 3.1.0)
21
+ activerecord (4.0.13)
22
+ activemodel (= 4.0.13)
23
+ activerecord-deprecated_finders (~> 1.0.2)
24
+ activesupport (= 4.0.13)
25
+ arel (~> 4.0.0)
26
+ activerecord-deprecated_finders (1.0.4)
27
+ activesupport (4.0.13)
28
+ i18n (~> 0.6, >= 0.6.9)
29
+ minitest (~> 4.2)
30
+ multi_json (~> 1.3)
31
+ thread_safe (~> 0.1)
32
+ tzinfo (~> 0.3.37)
33
+ arel (4.0.2)
34
+ builder (3.1.4)
35
+ capybara (2.1.0)
36
+ mime-types (>= 1.16)
37
+ nokogiri (>= 1.3.3)
38
+ rack (>= 1.0.0)
39
+ rack-test (>= 0.5.4)
40
+ xpath (~> 2.0)
41
+ codeclimate-test-reporter (0.5.0)
42
+ simplecov (>= 0.7.1, < 1.0.0)
43
+ coderay (1.1.1)
44
+ concurrent-ruby (1.0.1)
45
+ diff-lcs (1.2.5)
46
+ docile (1.1.5)
47
+ erubis (2.7.0)
48
+ factory_girl (4.5.0)
49
+ activesupport (>= 3.0.0)
50
+ factory_girl_rails (4.6.0)
51
+ factory_girl (~> 4.5.0)
52
+ railties (>= 3.0.0)
53
+ ffi (1.9.10)
54
+ formatador (0.2.5)
55
+ guard (2.13.0)
56
+ formatador (>= 0.2.4)
57
+ listen (>= 2.7, <= 4.0)
58
+ lumberjack (~> 1.0)
59
+ nenv (~> 0.1)
60
+ notiffany (~> 0.0)
61
+ pry (>= 0.9.12)
62
+ shellany (~> 0.0)
63
+ thor (>= 0.18.1)
64
+ guard-compat (1.2.1)
65
+ guard-rspec (4.6.4)
66
+ guard (~> 2.1)
67
+ guard-compat (~> 1.1)
68
+ rspec (>= 2.99.0, < 4.0)
69
+ i18n (0.7.0)
70
+ json (1.8.3)
71
+ listen (3.0.6)
72
+ rb-fsevent (>= 0.9.3)
73
+ rb-inotify (>= 0.9.7)
74
+ lumberjack (1.0.10)
75
+ mail (2.6.3)
76
+ mime-types (>= 1.16, < 3)
77
+ method_source (0.8.2)
78
+ mime-types (2.99.1)
79
+ mini_portile2 (2.0.0)
80
+ minitest (4.7.5)
81
+ multi_json (1.11.2)
82
+ nenv (0.3.0)
83
+ nokogiri (1.6.7.2)
84
+ mini_portile2 (~> 2.0.0.rc2)
85
+ notiffany (0.0.8)
86
+ nenv (~> 0.1)
87
+ shellany (~> 0.0)
88
+ pry (0.10.3)
89
+ coderay (~> 1.1.0)
90
+ method_source (~> 0.8.1)
91
+ slop (~> 3.4)
92
+ rack (1.5.5)
93
+ rack-test (0.6.3)
94
+ rack (>= 1.0)
95
+ rails (4.0.13)
96
+ actionmailer (= 4.0.13)
97
+ actionpack (= 4.0.13)
98
+ activerecord (= 4.0.13)
99
+ activesupport (= 4.0.13)
100
+ bundler (>= 1.3.0, < 2.0)
101
+ railties (= 4.0.13)
102
+ sprockets-rails (~> 2.0)
103
+ railties (4.0.13)
104
+ actionpack (= 4.0.13)
105
+ activesupport (= 4.0.13)
106
+ rake (>= 0.8.7)
107
+ thor (>= 0.18.1, < 2.0)
108
+ rake (10.5.0)
109
+ rb-fsevent (0.9.7)
110
+ rb-inotify (0.9.7)
111
+ ffi (>= 0.5.0)
112
+ rspec (2.99.0)
113
+ rspec-core (~> 2.99.0)
114
+ rspec-expectations (~> 2.99.0)
115
+ rspec-mocks (~> 2.99.0)
116
+ rspec-collection_matchers (1.1.2)
117
+ rspec-expectations (>= 2.99.0.beta1)
118
+ rspec-core (2.99.2)
119
+ rspec-expectations (2.99.2)
120
+ diff-lcs (>= 1.1.3, < 2.0)
121
+ rspec-mocks (2.99.4)
122
+ rspec-rails (2.99.0)
123
+ actionpack (>= 3.0)
124
+ activemodel (>= 3.0)
125
+ activesupport (>= 3.0)
126
+ railties (>= 3.0)
127
+ rspec-collection_matchers
128
+ rspec-core (~> 2.99.0)
129
+ rspec-expectations (~> 2.99.0)
130
+ rspec-mocks (~> 2.99.0)
131
+ shellany (0.0.1)
132
+ simplecov (0.11.2)
133
+ docile (~> 1.1.0)
134
+ json (~> 1.8)
135
+ simplecov-html (~> 0.10.0)
136
+ simplecov-html (0.10.0)
137
+ slop (3.6.0)
138
+ spork (0.9.2)
139
+ sprockets (3.5.2)
140
+ concurrent-ruby (~> 1.0)
141
+ rack (> 1, < 3)
142
+ sprockets-rails (2.3.3)
143
+ actionpack (>= 3.0)
144
+ activesupport (>= 3.0)
145
+ sprockets (>= 2.8, < 4.0)
146
+ sqlite3 (1.3.11)
147
+ thor (0.19.1)
148
+ thread_safe (0.3.5)
149
+ tzinfo (0.3.46)
150
+ xpath (2.0.0)
151
+ nokogiri (~> 1.3)
152
+
153
+ PLATFORMS
154
+ ruby
155
+
156
+ DEPENDENCIES
157
+ bundler (~> 1.3)
158
+ capybara
159
+ codeclimate-test-reporter
160
+ factory_girl
161
+ factory_girl_rails
162
+ guard
163
+ guard-rspec
164
+ rails (= 4.0.13)
165
+ rails_magic_renamer!
166
+ rake
167
+ rspec
168
+ rspec-rails
169
+ spork
170
+ sqlite3
171
+
172
+ BUNDLED WITH
173
+ 1.11.2
data/Guardfile ADDED
@@ -0,0 +1,11 @@
1
+ guard 'rspec', cmd: "rspec" do
2
+ # watch /lib/ files
3
+ watch(%r{^lib/(.+).rb$}) do |m|
4
+ "spec/#{m[1]}_spec.rb"
5
+ end
6
+
7
+ # watch /spec/ files
8
+ watch(%r{^spec/(.+).rb$}) do |m|
9
+ "spec/#{m[1]}.rb"
10
+ end
11
+ end
data/Manifest ADDED
@@ -0,0 +1,8 @@
1
+ CHANGELOG
2
+ Gemfile
3
+ Gemfile.lock
4
+ Manifest
5
+ README
6
+ Rakefile
7
+ lib/rails_magic_renamer.rb
8
+ lib/rails_magic_renamer/version.rb
data/README.md ADDED
@@ -0,0 +1,59 @@
1
+ [![Build Status](https://img.shields.io/travis/nickdowse/rails_magic_renamer.svg)](https://travis-ci.org/nickdowse/rails_magic_renamer)
2
+ [![Test Coverage](https://codeclimate.com/github/nickdowse/rails_magic_renamer/badges/coverage.svg)](https://codeclimate.com/github/nickdowse/rails_magic_renamer/coverage)
3
+
4
+
5
+ # RAILS MAGIC RENAMER
6
+
7
+ This repository is currently a work in progress, until the time that it's ready check out [https://github.com/jcrisp/rails_refactor](https://github.com/jcrisp/rails_refactor) for the original work. For a view of the direction this gem is going take a look at the ROADMAP.md. A quick overview: this gem aims to be an all in one set and forget gem for renaming models in rails projects, meaning you can pass it the model name you have, the model name you want it to be and it will rename files, rename models, update relationships, rename controllers, views, instances of the class, create new database migrations, and update the specs. Sounds scary? It won't run any DB migrations, so you can set it, and then if it works just commit the changes to source control and you're away.
8
+
9
+ ### Basic renames and refactorings for rails projects.
10
+ Although these are not perfect, they'll do a lot of the work for you
11
+ and save you time.
12
+
13
+ Before using, I recommend that you start from a clean repository state so
14
+ you can easily review changes.
15
+
16
+ To install:
17
+ `gem install rails_magic_renamer`
18
+
19
+ Before use, make sure you cd to the root of your rails project.
20
+
21
+ To rename an object open up `rails console` and run:
22
+
23
+ require 'rails_magic_renamer'
24
+ RailsMagicRenamer::Renamer.new("from_model", "to_model").rename
25
+
26
+ This will:
27
+
28
+ * rename the controller file & class name in file
29
+ * rename the controller spec file & class name in file
30
+ * rename the view directory
31
+ * rename the helper file & module name in file
32
+ * updates routes
33
+ * rename the model file & class name in file
34
+ * rename the spec file & class name in file
35
+ * rename the migration & class name & table names in file
36
+
37
+ # Contributing
38
+
39
+ We love your contributions to RailsMagicRenamer. Before submitting a pull request, please make sure that your changes are well tested.
40
+
41
+ Then, you'll need to install bundler and the gem dependencies:
42
+
43
+ `gem install bundler && bundle install`
44
+
45
+ You should now be able to run the local tests:
46
+
47
+ bundle exec rake
48
+
49
+ Interact with rails_magic_renamer by creating a RailsMagicRenamer instance, and then calling `rename` on that instance.
50
+
51
+ RailsMagicRenamer::Renamer.new("CurrentModelName", "NewModelName").rename
52
+
53
+ Started by James Crisp & Ryan Bigg pairing at RORO hack night 24 Nov 2010.
54
+ Thanks to Andrew Snow for help with Gemification.
55
+
56
+ Thanks to Tricon for some improvements and start on TextMate Bundle:
57
+ https://github.com/Tricon/rails-refactor.tmbundle
58
+
59
+ Any questions open an issue or hit me up on Twitter: [@nmdowse](https://twitter.com/nmdowse).
data/ROADMAP.md ADDED
@@ -0,0 +1,60 @@
1
+ # RAILS MAGIC RENAMER Roadmap
2
+
3
+ Currently the gem is not a set and forget tool, you still need to do a lot of manual renaming afterward the gem has done its work.
4
+
5
+ I would like this gem to rename much more comprehensively than it currently is, and as such will work towards completing these following steps, some of which have already been completed:
6
+
7
+ * Create a comprehensive fake rails app. - Yes
8
+
9
+ ### Model Checks - Done
10
+ * Check if there's already a model with the same name as what you're going to (file exists?) -> Yes
11
+ * Commit what we have in git - Yes
12
+ * Change model file name (campaign.rb -> distribution.rb) - Yes
13
+ * Update model folder (if necessary) (models/campaigns/.rb -> models/distributions/.rb) - Yes
14
+ * Update class reference (class Campaign -> class Distribution) - Yes
15
+ * Update has_one/has_many/belongs_to relationships (eg has_many :campaigns -> has_many :distributions) - Yes
16
+ * Update :through relationships - Yes
17
+ * Update relationships in classes that have a relationship with from - Yes
18
+ * Update all classes that inherit from Campaign (class EmailCampign < Campaign -> class EmailCampaign < Distribution) - Yes
19
+
20
+ ### Database checks
21
+ * Create rename_table migration for main model table - Yes
22
+ * Create rename_table migration for all relevant pivot/join tables - Yes
23
+ * Create migration to rename foreign keys (eg email.campaign_id -> email.distribution_id) - Yes
24
+ * Run migrations # TODO -> Add as an option
25
+
26
+ ### View checks - done
27
+ * Update view folder (views/campaigns/* -> views/distributions/*) - Yes
28
+
29
+ ### Controller checks - done
30
+ * Update controller file names (campaigns_controller.rb -> distributions_controller.rb) - Yes
31
+ * Update controller class names incl w/ namespacing (class Manage::CampaignsController < Manage::ApplicationController -> class Manage::DistributionsController < Manage::ApplicationController) - Yes
32
+
33
+ ### Routing/Path checks - done
34
+ * Update routes (namespace campaigns -> namespace distributions) -> Yes
35
+ * Update paths (edit_manage_organisation_pressroom_pressdoc_campaign_path -> edit_manage_organisation_pressroom_pressdoc_distribution_path) - done
36
+ * Update URLs (edit_manage_organisation_pressroom_pressdoc_campaign_url -> edit_manage_organisation_pressroom_pressdoc_distribution_url) - done
37
+
38
+ ### Global checks - done
39
+ * Change all references to that file (Campaign.blah_blah_blah -> Distribution.blah_blah_blah) (Global find and replace of `Campaign` to `Distribution`) - done
40
+ * Global find and replace of lower_case `campaign` to `distribution` - done
41
+ - Here make certain to skip database folder - done
42
+ - This will Change all references from model -> model (@pressdoc.campaigns -> @pressdoc.distributions) -> Similar to above where it takes the file and replaces all instances of 'campaigns' with 'campaign'. It will also update instance variables (@campaign -> @distribution) - done
43
+
44
+ # Spec checks
45
+ * Update specs (campaign_spec.rb -> distribution_spec.rb) - done
46
+ * Update factories (campaign_factory -> distribution_factory) - done
47
+ * Run specs # TODO
48
+
49
+ ### Other
50
+ * Update README to new name # TODO
51
+
52
+ Other notes:
53
+
54
+ Could be issues with relations in non-model files.
55
+
56
+ Eg company.campaigns in the orders controller
57
+
58
+ Here --^ look for all associations and check the type of the caller. Not strictly a necessity as the type of the caller is what matters most not the name (eg company vs c)
59
+
60
+ Check if app uses devise and then if current user is being changed change that as well? # TODO
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ Dir.glob('tasks/**/*.rake').each(&method(:import))
@@ -0,0 +1,343 @@
1
+ require 'rails_magic_renamer/version'
2
+ require 'rails_magic_renamer/exceptions'
3
+ require 'active_support/inflector'
4
+ require 'active_support/core_ext/string/inflections'
5
+
6
+ module RailsMagicRenamer
7
+
8
+ # called from rails console: RailsMagicRenamer::Renamer.new("ModelOne", "ModelTwo").rename
9
+ class Renamer
10
+
11
+ @@timestamp
12
+
13
+ def initialize(from, to)
14
+ from = from.to_s if !from.class != String
15
+ to = to.to_s if !to.class != String
16
+ @from, @to = from, to
17
+ FileUtils.cd('spec/support/sample_app_rails_4') if File.exist?('rails_magic_renamer.gemspec')
18
+ Rails.application.eager_load!
19
+
20
+ @@timestamp = Time.now.strftime("%Y%m%d%H%M%S").to_i
21
+ begin
22
+ valid_renamer?
23
+ rescue RenamerError => e
24
+ raise RailsMagicRenamer::InvalidObjectError.new(e.message)
25
+ end
26
+ end
27
+
28
+ # check that models can be renamed
29
+ def valid_renamer?
30
+ raise RailsMagicRenamer::RenameObjectUnderscoredError.new if renamer_contains_underscores?
31
+ raise RailsMagicRenamer::RenameFromObjectDoesNotExistError.new if !from_exists?
32
+ raise RailsMagicRenamer::RenameToObjectExistsError.new if to_exists?
33
+ # raise RailsMagicRenamer::RootDirectoryError.new if !in_root_directory?
34
+ return true
35
+ end
36
+
37
+ def renamer_contains_underscores?
38
+ @from.match("_") || @to.match("_")
39
+ end
40
+
41
+ def from_exists?
42
+ return Object.const_defined?("#{@from}")
43
+ end
44
+
45
+ def to_exists?
46
+ return Object.const_defined?(@to)
47
+ end
48
+
49
+ def in_root_directory?
50
+ File.exist?('./config/environment.rb')
51
+ end
52
+
53
+ # only entry point
54
+ def rename
55
+ Rails.application.eager_load!
56
+ @from = Object.const_get(@from)
57
+ @to = Object.const_set(@to, Class.new)
58
+ # here prevent factory girl from linting factories
59
+ if !Dir.glob('**/factory_girl.rb').empty?
60
+ file = Dir.glob('**/factory_girl.rb').first
61
+ replace_in_file(file, "FactoryGirl.lint", "# FactoryGirl.lint")
62
+ end
63
+ rename_models
64
+ rename_controllers
65
+ rename_views
66
+ rename_helpers
67
+ rename_routes
68
+ rename_specs
69
+ rename_assets
70
+ rename_everything_else
71
+ end
72
+
73
+ def rename_models
74
+ # commit any changes to git if is uncommitted and git is installed
75
+ `git add -A && git commit -m "Code before RailsMagicRenamer renaming"` if !`git status | grep "On branch"`.empty? && !in_test_mode?
76
+ to_model_file = @to.to_s.underscore + ".rb"
77
+
78
+ rename_relations
79
+
80
+ # move model file
81
+ `mv app/models/#{@from.to_s.underscore}.rb app/models/#{to_model_file}` # here test for success?
82
+
83
+ # move model container file (eg app/models/companies/*.rb)
84
+ if File.directory?(@from.to_s.underscore)
85
+ `mv app/models/#{@from.to_s.underscore} app/models/#{@to.to_s.underscore}`
86
+ end
87
+
88
+ replace("app/models/#{to_model_file}")
89
+
90
+ end
91
+
92
+ def rename_relations
93
+ relations = @from.reflect_on_all_associations
94
+ relations.each do |relation|
95
+ if File.exist?("app/models/#{relation.name}.rb")
96
+ replace("app/models/#{relation.name}.rb")
97
+ elsif relation.class_name.to_s.underscore != relation.name.to_s && File.exist?("app/models/#{relation.class_name.to_s.underscore}.rb")
98
+ replace("app/models/#{relation.class_name.to_s.underscore}.rb")
99
+ end
100
+ if relation.macro == :belongs_to
101
+ puts "Relation macro #{relation.name} is a belongs_to updating the foreign key here"
102
+ elsif relation.macro == :has_many
103
+ puts "Relation macro #{relation.name} is a has_many updating the foreign key here"
104
+ if !relation.options.has_key?(:through)
105
+ # renaming the through relationship here
106
+ # if relation is UserComment etc (eg a join table)
107
+ if relation.class_name.to_s.match(@from.to_s) && File.exist?("app/models/#{relation.class_name.underscore}.rb")
108
+ # here rename UserComment class name to PosterComment: UserComment -> PosterComment
109
+ replace_in_file("app/models/#{relation.class_name.underscore}.rb", relation.class_name, relation.class_name.to_s.gsub(@from.to_s.pluralize, @to.to_s.pluralize).gsub(@from.to_s, @to.to_s))
110
+ # move user_comment.rb -> poster_comment.rb
111
+ `mv "app/models/#{relation.class_name.underscore}.rb" app/models/#{relation.class_name.underscore.gsub(@from.to_s.underscore.pluralize, @to.to_s.underscore.pluralize).gsub(@from.to_s.underscore, @to.to_s.underscore)}.rb`
112
+ # Replace user_comments with poster_comments everywhere it might be used:
113
+ rename_in_app_lib_rake_spec(relation.name.to_s, relation.name.to_s.gsub(@from.to_s.underscore.pluralize, @to.to_s.underscore.pluralize).gsub(@from.to_s.underscore, @to.to_s.underscore))
114
+ # here create migration to rename table
115
+ if Object.const_defined?(relation.class_name) && Object.const_get(relation.class_name).column_names.include?("#{@from.to_s.underscore}_id")
116
+ generate_rename_column_migration(relation, "#{@from.to_s.underscore}_id")
117
+ end
118
+ generate_rename_table_migration_from_relation(relation)
119
+ else
120
+ # here create a migration to rename user_id if user_id exists
121
+ if Object.const_defined?(relation.class_name) && Object.const_get(relation.class_name).column_names.include?("#{@from.to_s.underscore}_id")
122
+ generate_rename_column_migration(relation, "#{@from.to_s.underscore}_id")
123
+ end
124
+ end
125
+ else
126
+ # renaming the actual relationship here
127
+ puts "Has many, through #{relation.options[:through]}"
128
+ if File.exist?("app/models/#{relation.class_name.underscore}.rb")
129
+ # replace user_comments -> poster_comments in comments.rb
130
+ replace_in_file("app/models/#{relation.class_name.underscore}.rb", relation.options[:through].to_s, relation.options[:through].to_s.gsub(@from.to_s.underscore, @to.to_s.underscore))
131
+ elsif relation.options[:through].present? && File.exist?("app/models/#{relation.options[:through].to_s.underscore.singularize}.rb")
132
+ replace_in_file("app/models/#{relation.options[:through].to_s.singularize}.rb", relation.options[:through].to_s, relation.options[:through].to_s.gsub(@from.to_s.underscore, @to.to_s.underscore))
133
+ end
134
+
135
+ # replace followed_users -> followed_posters in user.rb
136
+ replace_in_file("app/models/#{@from.to_s.underscore}.rb", relation.name.to_s, relation.name.to_s.gsub(@from.to_s.underscore, @to.to_s.underscore))
137
+ # replace followed_users -> followed_posters in the rest of the app
138
+ rename_in_app_lib_rake_spec(relation.name.to_s, relation.name.to_s.gsub(@from.to_s.underscore.pluralize, @to.to_s.underscore.pluralize).gsub(@from.to_s.underscore, @to.to_s.underscore))
139
+ # move user_comments_spec.rb to poster_comments_spec.rb
140
+ if File.exist?("spec/models/#{relation.name.to_s.underscore}_spec.rb")
141
+ `mv "spec/models/#{relation.name.to_s.underscore}_spec.rb" spec/models/#{relation.name.to_s.gsub(@from.to_s.underscore.pluralize, @to.to_s.underscore.pluralize).gsub(@from.to_s.underscore, @to.to_s.underscore)}_spec.rb`
142
+ end
143
+ end
144
+ else
145
+ puts "Why in here? #{relation.macro}"
146
+ puts "#{relation.macro} type relationships are not supported to be renamed right now."
147
+ # could be a has_one relationship?
148
+ end
149
+ end
150
+ generate_rename_table_migration(@from.table_name, @to.to_s.underscore.pluralize)
151
+ end
152
+
153
+ def generate_rename_table_migration_from_relation(relation)
154
+ class_name = "Rename#{relation.class_name}"
155
+ file_contents = "class #{class_name} < ActiveRecord::Migration
156
+ def change
157
+ rename_table :#{relation.plural_name}, :#{relation.plural_name.to_s.gsub(@from.to_s.underscore, @to.to_s.underscore)}
158
+ end
159
+ end
160
+ "
161
+ File.open("db/migrate/#{@@timestamp}_#{class_name.underscore}.rb", 'w') {|f| f.write(file_contents) }
162
+ @@timestamp = @@timestamp + 1
163
+ end
164
+
165
+ def generate_rename_column_migration(relation, column_name)
166
+ class_name = "Rename#{relation.class_name}#{column_name.camelize}"
167
+ file_contents = "class #{class_name} < ActiveRecord::Migration
168
+ def change
169
+ rename_column :#{relation.plural_name}, :#{column_name}, :#{column_name.gsub(@from.to_s.underscore, @to.to_s.underscore)}
170
+ end
171
+ end
172
+ "
173
+ File.open("db/migrate/#{@@timestamp}_#{class_name.underscore}.rb", 'w') {|f| f.write(file_contents) }
174
+ @@timestamp = @@timestamp + 1
175
+ end
176
+
177
+ def generate_rename_table_migration(from, to)
178
+ class_name = "Rename#{from.capitalize}To#{to.capitalize}"
179
+ file_contents = "class #{class_name} < ActiveRecord::Migration
180
+ def change
181
+ rename_table :#{from}, :#{to}
182
+ end
183
+ end
184
+ "
185
+ File.open("db/migrate/#{@@timestamp}_#{class_name.underscore}.rb", 'w') {|f| f.write(file_contents) }
186
+ @@timestamp = @@timestamp + 1
187
+ end
188
+
189
+ def rename_controllers
190
+ to_controller_path = "app/controllers/#{@to.to_s.underscore.pluralize}_controller.rb"
191
+ `mv app/controllers/#{@from.to_s.underscore.pluralize}_controller.rb #{to_controller_path}`
192
+ replace(to_controller_path)
193
+ replace_in_file(to_controller_path, "#{@from.to_s.pluralize}Controller", "#{@to.to_s.pluralize}Controller")
194
+ end
195
+
196
+ def rename_views
197
+ `mv app/views/#{@from.to_s.underscore.pluralize} app/views/#{@to.to_s.underscore.pluralize}` # here test for success?
198
+ if !Dir.glob("app/views/#{@to.to_s.underscore.pluralize}/_#{@from.to_s.pluralize.underscore}.*").empty?
199
+ Dir.glob("app/views/#{@to.to_s.underscore.pluralize}/_#{@from.to_s.pluralize.underscore}.*") do |partial|
200
+ subbed_partial = partial.gsub(@from.to_s.underscore.pluralize, @to.to_s.underscore.pluralize).gsub(@from.to_s.underscore, @to.to_s.underscore)
201
+ `mv #{partial} #{subbed_partial}`
202
+ end
203
+ end
204
+
205
+ if !Dir.glob("app/views/#{@to.to_s.underscore.pluralize}/_#{@from.to_s.underscore}.*").empty?
206
+ Dir.glob("app/views/#{@to.to_s.underscore.pluralize}/_#{@from.to_s.underscore}.*") do |partial|
207
+ subbed_partial = partial.gsub(@from.to_s.underscore.pluralize, @to.to_s.underscore.pluralize).gsub(@from.to_s.underscore, @to.to_s.underscore)
208
+ `mv #{partial} #{subbed_partial}`
209
+ end
210
+ end
211
+ end
212
+
213
+ def rename_helpers
214
+ to_helper_path = "app/helpers/#{@to.to_s.underscore.pluralize}_helper.rb"
215
+ if File.exist?("app/helpers/#{@from.to_s.underscore.pluralize}_helper.rb")
216
+ `mv app/helpers/#{@from.to_s.underscore.pluralize}_helper.rb #{to_helper_path}`
217
+ replace(to_helper_path)
218
+ replace_in_file(to_helper_path, "#{@from.to_s.pluralize}Helper", "#{@to.to_s.pluralize}Helper")
219
+ end
220
+ end
221
+
222
+ def rename_routes
223
+ rake_routes_output = `rake routes | grep #{@from.to_s.underscore}`
224
+ split_output = rake_routes_output.split(/GET|POST|PATCH|PUT|DELETE|\n/).delete_if{|w| w.match("/")}.map(&:strip!)
225
+ split_output.each do |path|
226
+ rename_path(path + "_path")
227
+ rename_path(path + "_url")
228
+ end
229
+ replace('config/routes.rb')
230
+ end
231
+
232
+ def rename_specs
233
+ # controller
234
+ if File.exist?("spec/controllers/#{@from.to_s.underscore.pluralize}_controller_spec.rb")
235
+ to_spec = "spec/controllers/#{@to.to_s.underscore.pluralize}_controller_spec.rb"
236
+ `mv spec/controllers/#{@from.to_s.underscore.pluralize}_controller_spec.rb #{to_spec}`
237
+ replace(to_spec)
238
+ end
239
+ # features
240
+ if File.exist?("spec/features/#{@from.to_s.underscore}_pages_spec.rb")
241
+ to_spec = "spec/features/#{@to.to_s.underscore}_pages_spec.rb"
242
+ `mv spec/features/#{@from.to_s.underscore}_pages_spec.rb #{to_spec}`
243
+ replace(to_spec)
244
+ end
245
+ # helpers
246
+ if File.exist?("spec/helpers/#{@from.to_s.underscore.pluralize}_helper_spec.rb")
247
+ to_spec = "spec/helpers/#{@to.to_s.underscore.pluralize}_helper_spec.rb"
248
+ `mv spec/helpers/#{@from.to_s.underscore.pluralize}_helper_spec.rb #{to_spec}`
249
+ replace(to_spec)
250
+ end
251
+ # models
252
+ if File.exist?("spec/models/#{@from.to_s.underscore}_spec.rb")
253
+ to_spec = "spec/models/#{@to.to_s.underscore}_spec.rb"
254
+ `mv spec/models/#{@from.to_s.underscore}_spec.rb #{to_spec}`
255
+ replace(to_spec)
256
+ end
257
+ end
258
+
259
+ def rename_path(path_to_rename)
260
+ return if path_to_rename == "_url" || path_to_rename == "_path"
261
+ renamed_path = path_to_rename.gsub(@from.to_s.underscore, @to.to_s.underscore).gsub(@from.to_s.underscore.pluralize, @to.to_s.underscore.pluralize)
262
+ Dir.glob("app/**/*") do |app_file|
263
+ next if File.directory?(app_file)
264
+ replace_in_file(app_file, path_to_rename, renamed_path)
265
+ end
266
+
267
+ Dir.glob("spec/**/*") do |spec_file|
268
+ next if File.directory?(spec_file)
269
+ replace_in_file(spec_file, path_to_rename, renamed_path)
270
+ end
271
+ end
272
+
273
+ def rename_assets
274
+ Dir.glob("app/assets/**/*#{@from.to_s.underscore.pluralize}*") do |asset_file|
275
+ puts "Asset file: #{asset_file}"
276
+ puts "Asset file: #{asset_file.to_s.gsub(@from.to_s.underscore.pluralize, @to.to_s.underscore.pluralize)}"
277
+ `mv #{asset_file} #{asset_file.to_s.gsub(@from.to_s.underscore.pluralize, @to.to_s.underscore.pluralize)}`
278
+ end
279
+ Dir.glob("app/assets/**/*#{@from.to_s.underscore}*") do |asset_file|
280
+ puts "Asset file: #{asset_file}"
281
+ puts "Asset file: #{asset_file.to_s.gsub(@from.to_s.underscore, @to.to_s.underscore)}"
282
+ `mv #{asset_file} #{asset_file.to_s.gsub(@from.to_s.underscore, @to.to_s.underscore)}`
283
+ end
284
+ end
285
+
286
+ # here pass every file in the app folder, lib folder, spec folder through the renamer
287
+ def rename_everything_else
288
+ Dir.glob("app/**/*") do |app_file|
289
+ next if File.directory?(app_file)
290
+ replace(app_file)
291
+ end
292
+
293
+ Dir.glob("lib/**/*.rb") do |lib_file|
294
+ replace(lib_file)
295
+ end
296
+
297
+ Dir.glob("**/*.rake") do |rake_file|
298
+ replace(rake_file)
299
+ end
300
+
301
+ Dir.glob("spec/**/*.rb") do |spec_file|
302
+ replace(spec_file)
303
+ end
304
+ end
305
+
306
+ def rename_in_app_lib_rake_spec(find, replace)
307
+ Dir.glob("app/**/*") do |app_file|
308
+ next if File.directory?(app_file)
309
+ replace_in_file(app_file, find, replace)
310
+ end
311
+
312
+ Dir.glob("lib/**/*.rb") do |lib_file|
313
+ replace_in_file(lib_file, find, replace)
314
+ end
315
+
316
+ Dir.glob("**/*.rake") do |rake_file|
317
+ replace_in_file(rake_file, find, replace)
318
+ end
319
+
320
+ Dir.glob("spec/**/*.rb") do |spec_file|
321
+ replace_in_file(spec_file, find, replace)
322
+ end
323
+ end
324
+
325
+ def replace(file_name)
326
+ replace_in_file(file_name, @from.to_s, @to.to_s)
327
+ replace_in_file(file_name, @from.to_s.underscore, @to.to_s.underscore)
328
+ end
329
+
330
+ def replace_in_file(path, find, replace)
331
+ return false if !File.exist?(path)
332
+ contents = File.read(path)
333
+ replaced_contents = contents.encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '').gsub(/\b#{Regexp.escape(find)}\b/, replace).gsub(/\b#{Regexp.escape("#{find}s")}\b/, "#{replace}s").gsub(/\b#{Regexp.escape("#{find}_id")}\b/, "#{replace}_id")
334
+ File.open(path, "w+") { |f| f.write(replaced_contents) }
335
+ end
336
+
337
+ def in_test_mode?
338
+ return @in_test_mode if @in_test_mode.present?
339
+ @in_test_mode = File.exist?('./rails_magic_renamer.gemspec') || File.exist?('../../../rails_magic_renamer.gemspec')
340
+ return @in_test_mode
341
+ end
342
+ end
343
+ end