Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
= Processr
== Overview
Processr is a simple text processing and concatenation library. It takes a number of input strings (or files) and outputs a single string (or file) containing the result. Text can be passed through filters to modify the output.
== Installation
The project is hosted on rubygems.org. Getting it is simple:
gem install processr
== Usage
=== Configuration
Use the configuration block to setup Processr
Processr.configure do |config| config.root = File.expand_path(File.dirname(FILE)) config.out = File.join(config.root, 'output.txt') end
If an output file is specified the result will be written to that file, otherwise the result will be returned directly from the #process! method.
=== Basic
processor = Processr.new processor << "Some\n" processor << "Text" processor.process! # => "Some\nText"
This will result in a concatenated string being returned.
=== Basic (from file)
processor = Processr.new processor.files << 'input_one.txt' processor.files << 'input_two.txt' processor.process! # => contents of input_one.txt and input_two.txt
This will result in the contents of input_one.txt and input_two.txt returned.
=== Filters
Filters can be used to modify the output of a processing session. A filter is any object that responds to #call. Filters take a single argument (the input buffer) and must return the modified buffer for further processing. For example:
lambda do |buffer| # ...do something with buffer here...
buffer
end
Or
class MyFilter
def self.call(buffer)
# ...do something with buffer here...
buffer
end
end
You can register a filter by calling #add_filter on an instance of Processr. A further example would be a really simple textile parser:
TextileFilter = lambda do |buffer|
lookup = {
/_(.*)_/ => '<em>\1</em>',
/\*(.*)\*/ => '<strong>\1</strong>',
/\"(.*)\":(\S*)/ => '<a href="\2">\1</a>'
}
lookup.each_pair do |regex, replacement|
buffer.gsub!(regex, replacement)
end
buffer
end
processor = Processr.new processor.add_filter(TextileFilter) processor << 'A simple example of a "textile":http://www.textism.com/tools/textile/ parser using a filter.' processor.process! # => "A simple example of a textile parser using a filter."
Run the examples for more information.
== Bugs
If you have any problems with processr, please file an issue at http://github.com/joshnesbitt/processr/issues.
== Note on Patches/Pull Requests
== Copyright
Copyright (c) 2010 Josh Nesbitt josh@josh-nesbitt.net. See LICENSE for details.
FAQs
Unknown package
We found that processr demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.