sequential_file

Sequential File makes determination of which file to process (read or write) easy!

Project Sequential File
gem name sequential_file
license MIT
moldiness Maintainer Status
version Gem Version
dependencies Dependency Status
code quality Code Climate
continuous integration Build Status (Apparently Travis doesn't let me create files? Build passes locally)
test coverage Coverage Status
homepage https://github.com/pboling/sequential_file
documentation http://rdoc.info/github/pboling/sequential_file/frames
author Peter Boling
Spread ~♡ⓛⓞⓥⓔ♡~ Endorse Me

Summary

It allows you to create files that are named sequentially and intelligently.

Files will have four primary parts in their filenames:

  1. First part, which will be useful for list files in the shell.
  2. Second part is a date stamp, which will be useful in not having unwanted junk in our globs.
  3. Third part makes it easy to find the counter
  4. Fourth part is the counter

Compatibility

Tested with Ruby 2.0.0+. Due to the use of Ruby's 'prepend' initialization feature, will not work with anything older.

There are no dependencies, gem or otherwise, this is a pure Ruby library, and will work with any sort of File-type class.

Installation

Add this line to your application's Gemfile:

gem 'sequential_file'

And then execute:

$ bundle

Or install it yourself as:

$ gem install sequential_file

Usage

If you have your own File-like class then you may just need to use the SequentialFile::Namer by including it.

class MyFileLikeThing
    include SequentialFile::Namer
end

This gem ships with a reference implementation of a File-wrapper class that uses the Namer to determine which file to process.

Have a look at lib/sequential_file/base.rb or require it and play with it:

require 'sequential_file/base'

file = SequentialFile::Base.new({
                           directory_path: '/tmp',
                           name: 'access_log.FileBase.csv',
                           process_date: Date.today
                         })

file.write('this is new text')          # => write ensures that the file is open for writing, but you have to remember to close!
file.close
file.write('this is after close text')
file.read =~ /this is after close text/ # => integer representation of the position in the file where the text match starts
file.close

Also, see the specs.

Contributors

See the Network View and the CHANGELOG

How you can help!

Take a look at the reek and roodi lists. These are the files names REEK and ROODI in the root of the gem.

Currently they are clean, and we like to keep them that way! Once you complete a change, run the tests:

bundle exec rake spec

If the tests pass refresh the reek and roodi lists and make sure things have not gotten worse:

bundle exec rake reek > REEK
bundle exec rake reek > ROODI

Follow the instructions for "Contributing" below.

Contributing

  1. Fork it
  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 new Pull Request

Versioning

This library aims to adhere to Semantic Versioning 2.0.0. Violations of this scheme should be reported as bugs. Specifically, if a minor or patch version is released that breaks backward compatibility, a new version should be immediately released that restores compatibility. Breaking changes to the public API will only be introduced with new major versions.

As a result of this policy, you can (and should) specify a dependency on this gem using the Pessimistic Version Constraint with two digits of precision.

For example:

spec.add_dependency 'sequential_file', '~> 1.0.8'

Legal

Bitdeli Badge