Class: Rubomop::RandomMop::DeleteOption
- Inherits:
-
Struct
- Object
- Struct
- Rubomop::RandomMop::DeleteOption
- Defined in:
- lib/rubomop/random_mop.rb
Instance Attribute Summary collapse
-
#cop ⇒ Object
Returns the value of attribute cop.
-
#file ⇒ Object
Returns the value of attribute file.
-
#run_rubocop ⇒ Object
Returns the value of attribute run_rubocop.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
Instance Method Summary collapse
- #delete! ⇒ Object
- #parse_io(string) ⇒ Object
- #print_message ⇒ Object
- #rubocop_runner ⇒ Object
- #subtract!(offense_count) ⇒ Object
Instance Attribute Details
#cop ⇒ Object
Returns the value of attribute cop
65 66 67 |
# File 'lib/rubomop/random_mop.rb', line 65 def cop @cop end |
#file ⇒ Object
Returns the value of attribute file
65 66 67 |
# File 'lib/rubomop/random_mop.rb', line 65 def file @file end |
#run_rubocop ⇒ Object
Returns the value of attribute run_rubocop
65 66 67 |
# File 'lib/rubomop/random_mop.rb', line 65 def run_rubocop @run_rubocop end |
#verbose ⇒ Object
Returns the value of attribute verbose
65 66 67 |
# File 'lib/rubomop/random_mop.rb', line 65 def verbose @verbose end |
Instance Method Details
#delete! ⇒ Object
71 72 73 |
# File 'lib/rubomop/random_mop.rb', line 71 def delete! cop.delete!(file) end |
#parse_io(string) ⇒ Object
90 91 92 93 94 |
# File 'lib/rubomop/random_mop.rb', line 90 def parse_io(string) match_data = string.match(/(\d*) offense(s?) corrected/) return 0 if match_data.nil? match_data[1].to_i end |
#print_message ⇒ Object
66 67 68 69 |
# File 'lib/rubomop/random_mop.rb', line 66 def return unless verbose print "Deleting #{file} from #{cop.name}" if verbose end |
#rubocop_runner ⇒ Object
79 80 81 82 83 84 85 86 87 88 |
# File 'lib/rubomop/random_mop.rb', line 79 def rubocop_runner return unless run_rubocop print "\nbundle exec rubocop #{file} -aD\n" IO.popen("bundle exec rubocop #{file} -aD") do |io| result_string = io.read puts result_string.split("\n").last puts "\n" parse_io(result_string) end end |
#subtract!(offense_count) ⇒ Object
75 76 77 |
# File 'lib/rubomop/random_mop.rb', line 75 def subtract!(offense_count) cop.subtract!(offense_count) end |