StringInFile
This gem allows you to store a string value in a file. It's the ultimate global variable. This gem can also be used to replace a string in a file with another string, determine if a string is present in a file, or add a string to the beginning or end of a file.
Installation
Add this line to your application's Gemfile:
gem 'string_in_file'
And then execute:
$ bundle
Or install it yourself as:
$ gem install string_in_file
Usage
Store the string "Doppler Value Investing" at /home/wbuffett/test.txt:
StringInFile.write('Doppler Value Investing', '/home/wbuffett/test.txt')
Read the string stored at /home/wbuffett/test.txt:
StringInFile.read('/home/wbuffett/test.txt')
Replace "Doppler" with "Next Generation" in the string stored at /home/wbuffett/test.txt:
StringInFile.replace('Doppler', 'Next Generation', '/home/wbuffett/test.txt')
Check to see if the string "Doppler" is present at /home/wbuffett/test.txt:
StringInFile.present('Doppler', '/home/wbuffett/test.txt')
Add a string to the beginning of a file:
StringInFile.add_beginning("one two three\n", 'numbers.txt')
Add a string to the end of a file
StringInFile.add_end("four five six\n", 'numbers.txt')
Development
- To test this gem, enter the command "sh gem_test.sh".
- To install this gem, enter the command "sh gem_install.sh".
- To test the source code for various metrics, enter the command "sh code_test.sh".
- To do all of the above, enter the command "sh all.sh".
- To run an interactive prompt, enter the command "sh console.sh".
- To release a new version, update the version number in the lib/(name of gem)/version.rb file, and then run "bundle exec rake release". This creates a git tag for the version, push git commits and tags, and pushes the
.gem
file to rubygems.org.
Contributing
Bug reports and pull requests are welcome on BitBucket at https://bitbucket.org/jhsu802701/string_in_file. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
License
The gem is available as open source under the terms of the MIT License.
Code of Conduct
Everyone interacting in the StringInFile project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.