New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

welder

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

welder

  • 0.1.1
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Welder

Gem Version Build Status Code Climate Test Coverage Dependency Status Inline docs

Welder allows you to define pipelines in a true Unix style.

It provides a simple and powerful DSL to define you own pipelines and compose them together. You can define a pipeline out of one or more ruby callables:

read_file = ->(filename) { File.read(filename) }
count_words = ->(text) { text.split.size }

count_words_from_file = Welder::Pipeline.new | read_file | count_words  # Define a pipeline
puts "My book has #{'my_book.txt' | count_words_from_file} words"       # Execute it with a specific value

Note that, for the pipe operator to work, the first argument has to be a Welder::Pipeline

Why pipelines?

In some use cases, pipelines have several advantages over the natural, imperative style of languages like ruby. Take, for instance, the following example:

puts "My book has #{'my_book.txt' | read_file | count_words} words"

Here, the alternative way to write the word count would be count_words(read_file('my_book.txt')). Pipelines, in contrast:

  • Provide a cleaner syntax that is better at expressing the statement's order and intent
  • Ease the instrumentation of the whole process (e.g. for debugging and benchmarking purposes)
  • Allow for ways to abstract the way the different stages in the pipeline are called. For instance, creating pipelines of remote methods using RPC

Valves

Valves are callables that get called at every step of a pipeline with the input to the step, the function processing it, and the generated output. Valves are useful for logging, debugging and code instrumentation. You set valves like this:

logged_steps = []
log = ->(i, l, o) { logged_steps << "Executed step #{l.inspect} with input=#{i.inspect} and got #{o.inspect}" }
count_words_and_log_steps = (Welder::Pipeline.new | read_file | count_words) -log

'my_book.txt' | count_words_and_log_steps
puts logged_steps.size  # => 2
puts logged_steps[0]    # Executed step "..." with input="my_book.txt" and output="this is my book"
puts logged_steps[1]    # Executed step "..." with input="this is my book" and output=4

Present and Future

The next step for Welder will be getting a nice toolbelt to start his work (extra gems with useful pipelines our of the box)

Contributing to Welder

Welder is open for help in any way.

License

See LICENSE file

FAQs

Package last updated on 28 Feb 2016

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc