uv_refactor 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.markdown +20 -8
- data/lib/uv_refactor.rb +2 -3
- data/lib/uv_refactor/deprecation.rb +2 -6
- metadata +2 -2
data/README.markdown
CHANGED
@@ -32,17 +32,29 @@ Imagine you'd like to rename
|
|
32
32
|
|
33
33
|
Creates an attribute accessor for `:new_method` and redirects `:old_method` to it.
|
34
34
|
|
35
|
-
refactor_method
|
35
|
+
refactor_method :user, :buyer
|
36
|
+
refactor_method :user, :seller
|
37
|
+
refactor_method :amount, :credits
|
36
38
|
|
37
|
-
|
39
|
+
This will have these effects:
|
38
40
|
|
39
|
-
|
41
|
+
Remove **user** in UnitTransaction.
|
42
|
+
Missing migration for UnitTransaction **buyer**.
|
43
|
+
Remove **user** in UnitTransaction.
|
44
|
+
Missing migration for UnitTransaction **seller**.
|
45
|
+
Remove **amount** in UnitTransaction.
|
46
|
+
Missing migration for UnitTransaction **credits**.
|
40
47
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
48
|
+
After deleting `user` and `amount` you have these warnings left:
|
49
|
+
|
50
|
+
Missing migration for UnitTransaction **buyer**.
|
51
|
+
Remove **user** in UnitTransaction.
|
52
|
+
Missing migration for UnitTransaction **seller**.
|
53
|
+
Missing migration for UnitTransaction **credits**.
|
54
|
+
|
55
|
+
Additionally you have warnings, whenever you execute code.
|
56
|
+
|
57
|
+
I like it because when running the test suite, I can see beforehand where methods are which I'd like to refactor. Otherwise you have failing tests where dependencies overshadow the actual source of your planned refactoring.
|
46
58
|
|
47
59
|
## Changelog
|
48
60
|
|
data/lib/uv_refactor.rb
CHANGED
@@ -7,7 +7,7 @@ module Refactor
|
|
7
7
|
if klass.instance_methods.include?(old_method)
|
8
8
|
Deprecation.remove_old_method(old_method,
|
9
9
|
klass,
|
10
|
-
|
10
|
+
caller(0)[1])
|
11
11
|
end
|
12
12
|
|
13
13
|
unless klass.instance_methods.include?(new_method)
|
@@ -21,8 +21,7 @@ module Refactor
|
|
21
21
|
Deprecation.
|
22
22
|
renaming_warning(old_method,
|
23
23
|
new_method,
|
24
|
-
|
25
|
-
eval("caller(0)", &lambda {}))
|
24
|
+
caller(0)[1])
|
26
25
|
send(new_method, *args, &block)
|
27
26
|
end
|
28
27
|
}
|
@@ -38,17 +38,13 @@ module Refactor
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def refactor_warning(warning)
|
41
|
-
# if defined?(logger)
|
42
|
-
# logger.warn warning
|
43
|
-
# else
|
44
41
|
Warnings << warning
|
45
42
|
warn warning
|
46
|
-
# end
|
47
43
|
end
|
48
44
|
|
49
45
|
def prettify(origin)
|
50
|
-
stack_trace_line = origin
|
51
|
-
only_file_and_filenumber = stack_trace_line.gsub(/:in.*$/,"")
|
46
|
+
stack_trace_line = origin.to_s.split(':in `block').first
|
47
|
+
# only_file_and_filenumber = stack_trace_line.gsub(/:in.*$/,"")
|
52
48
|
end
|
53
49
|
end
|
54
50
|
end
|