uv_refactor 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
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 old_method, new_method
35
+ refactor_method :user, :buyer
36
+ refactor_method :user, :seller
37
+ refactor_method :amount, :credits
36
38
 
37
- ## Configure the Refactorer
39
+ This will have these effects:
38
40
 
39
- You are able to override the deprecation_method to fit your needs.
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
- # config/initializers/currency_updater.rb
42
-
43
- Refactor.setup do |config|
44
- config.deprecation_method = lambda {|old_method, new_method| 1.2345 }
45
- end
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
- eval("caller(0)", &lambda{}))
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
- # 3rd stacktrace element from caller
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[3]
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
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 1
9
- version: 0.0.1
8
+ - 2
9
+ version: 0.0.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jan Riethmayer