model_renamer 1.0.0 → 1.1.0

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: f5e42b0a3bfd2fe82b23f951f1a15062ac0c8f29
4
- data.tar.gz: c1f5b417f6a45de0a8eff12be12c6e49aa315c7f
3
+ metadata.gz: e3a829ecbbb9250b2dab972232984d45f61e4243
4
+ data.tar.gz: 96329fca0b7a2d690b2707090aef81b0337eb161
5
5
  SHA512:
6
- metadata.gz: 8f24bcc31fbec3936c37fc40e36c1f17fa2c836ca2ff5136a032236c041a359ade986f328f2ca551be1785e729fb90f0b814f08907d154c99436cddca35710d4
7
- data.tar.gz: 88486ac6e04529429322a417f7b0222c5453224e1f2a7545b33837d83c6b46e0790ac5fca924d4f7e46fc657a55f066e03c1a8c1295a267f59be22073e215ec0
6
+ metadata.gz: f006580e6973f02dbf688df36d5aa4862b60e5b962e3bff167dc7cb3ef5f8666f7f341dc2ae14d12abd7113de5b5f45946707c30eda5e09533dc144162041688
7
+ data.tar.gz: 8b339a61d5bca5acb16cd9e2f328192055509ec46038ac8d22e890eb5ac52badfe42bcc13d31bba0067b80df0115b2e2dcd1c8909b4be58ff2845f0ad37df278
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # ModelRenamer
2
2
 
3
+ [![CircleCI](https://circleci.com/gh/viewthespace/model_renamer/tree/master.svg?style=svg)](https://circleci.com/gh/viewthespace/model_renamer/tree/master)
4
+
3
5
  The model renamer gem allows you to rename any a model in your rails application. The gem looks for occurrences of any variation or pluralization of the old model name and changes it to the corresponding variation of the new name. It also generates database migrations that rename tables and foreign keys referencing the old name.
4
6
 
5
7
  ## Installation
@@ -24,15 +24,15 @@ class Rename
24
24
  generate_migrations
25
25
  end
26
26
 
27
- def rename_files_and_directories path = @path
28
- Dir["#{path}/*"].reject { |path| ignore_file? path }.each do |path|
29
- if File.directory?(path)
30
- rename_files_and_directories path
27
+ def rename_files_and_directories outer_path = @path
28
+ Dir["#{outer_path}/*"].reject { |path| ignore_file? path }.each do |inner_path|
29
+ if File.directory?(inner_path)
30
+ rename_files_and_directories inner_path
31
31
  else
32
- rename_path path
32
+ rename_path inner_path
33
33
  end
34
34
  end
35
- rename_path path
35
+ rename_path outer_path
36
36
  end
37
37
 
38
38
  def rename_in_files
@@ -47,10 +47,13 @@ class Rename
47
47
 
48
48
  private
49
49
 
50
- def rename_path filepath
51
- variation_pairs.each do |old_name, new_name|
52
- next unless File.basename(filepath).include? old_name
53
- FileUtils.mv filepath, File.dirname(filepath) + "/#{File.basename(filepath).gsub(old_name, new_name)}"
50
+ def rename_path initial_filepath
51
+ current_filepath = initial_filepath
52
+ variation_pairs.uniq.each do |old_name, new_name|
53
+ next unless File.basename(current_filepath).include? old_name
54
+ new_filepath = File.dirname(current_filepath) + "/#{File.basename(current_filepath).gsub(old_name, new_name)}"
55
+ FileUtils.mv current_filepath, new_filepath
56
+ current_filepath = new_filepath
54
57
  end
55
58
  end
56
59
 
@@ -59,7 +62,7 @@ class Rename
59
62
  end
60
63
 
61
64
  def all_filepaths
62
- Find.find('.').to_a.reject do |path|
65
+ Find.find(@path.presence || ".").to_a.reject do |path|
63
66
  FileTest.directory?(path) || !acceptable_filetype?(path) || ignore_file?(path)
64
67
  end
65
68
  end
@@ -1,3 +1,3 @@
1
1
  module ModelRenamer
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: model_renamer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Gut
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-12 00:00:00.000000000 Z
11
+ date: 2018-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler