# LineContaining ## What This Gem Does The LineContaing gem is changing the contents of a file based on the content in a line. Some examples: * Look for a line containing specific content, and add a new line before it. ``` one two three four five six ten eleven twelve thirteen fourteen fifteen ``` Add the line "seven eight nine" before the line containing "ten". ``` one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen ``` * Look for a line containing specific content, and add a new line after it. ``` one two three four five six ten eleven twelve thirteen fourteen fifteen ``` Add the line "seven eight nine" after the line containing "six" ``` one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen ``` * Look for a line containing specific content, and add a new line in place of it. ``` one two three four five six sixteen seventeen eighteen ten eleven twelve thirteen fourteen fifteen ``` Add the line "seven eight nine" in place of the line containing "seventeen". ``` one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen ``` * Look for a line containing specific content, and delete this line. ``` one two three four five six seven eight nine sixteen seventeen eighteen ten eleven twelve thirteen fourteen fifteen ``` Delete the line containing "seventeen". ``` one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen ``` ## Installation Add this line to your application's Gemfile: ```ruby gem 'line_containing' ``` And then execute: $ bundle Or install it yourself as: $ gem install line_containing ## Usage #### Look for a line containing specific content, and add a new line before it. EXAMPLE: In the file "file1.txt", look for the line containing "ten", and add the line "seven eight nine" before it. ``` LineContaining.add_before("ten", "seven eight nine", "file1.txt") ``` #### Look for a line containing specific content, and add a new line after it. EXAMPLE: In the file "file2.txt", look for the line containing "six", and add the line "seven eight nine" after it. ``` LineContaining.add_after("six", "seven eight nine", "file2.txt") ``` #### Look for a line containing specific content, and add a new line in place of it. EXAMPLE: In the file "file3.txt", look for the line containing "seventeen", and add the line "seven eight nine" in place of it. ``` LineContaining.replace("seventeen", "seven eight nine", "file3.txt") ``` #### Look for a line containing specific content, and delete this line. EXAMPLE: In the file "file4.txt", look for the line containing "seventeen", and delete it. ``` LineContaining.delete("seventeen", "file4.txt") ``` ## Development ### Testing this gem Enter `sh gem_test.sh`. ### Running this gem in irb Enter `sh gem_console.sh`. ### Installing this gem Enter `sh gem_install.sh`. ## Contributing 1. Fork it ( https://github.com/[my-github-username]/line_containing/fork ) 2. Create your feature branch (`git checkout -b my-new-feature`) 3. Commit your changes (`git commit -am 'Add some feature'`) 4. Push to the branch (`git push origin my-new-feature`) 5. Create a new Pull Request