Class: CoffeeTrace::CLI
- Inherits:
-
Object
- Object
- CoffeeTrace::CLI
- Defined in:
- lib/coffee_trace/cli.rb
Instance Method Summary collapse
-
#initialize(insert_logging = CoffeeTrace::InsertLogging.new) ⇒ CLI
constructor
A new instance of CLI.
- #insert_logging ⇒ Object
- #remove_logging ⇒ Object
Constructor Details
#initialize(insert_logging = CoffeeTrace::InsertLogging.new) ⇒ CLI
Returns a new instance of CLI.
3 4 5 6 |
# File 'lib/coffee_trace/cli.rb', line 3 def initialize insert_logging=CoffeeTrace::InsertLogging.new @insert_logging = insert_logging @files = Dir.glob "**/*.coffee" end |
Instance Method Details
#insert_logging ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/coffee_trace/cli.rb', line 8 def insert_logging @files.each do |file| prefix =File.basename file, ".coffee" result = @insert_logging.into File.readlines(file), prefix write_lines file, result end end |
#remove_logging ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/coffee_trace/cli.rb', line 16 def remove_logging @files.each do |file| lines = @insert_logging.into File.readlines(file) result = lines.select do |line| /console\.log.*#coffee_trace.*/.match(line).nil? end write_lines file, result end end |