Skip to content

Instantly share code, notes, and snippets.

View jackdempsey's full-sized avatar

jack dempsey jackdempsey

View GitHub Profile

The Anatomy of an Onyx Program

In this tutorial, we'll take an in-depth view of what's happening when you execute a simple Onyx program. All of the code can be found in the Onyx Starter repository if you'd like to follow along. The code uses the development environment with HornetQ and ZooKeeper running in memory, so you don't need additional dependencies to run the example for yourself on your machine.

The Workflow

At the core of the program is the workflow - the flow of data that we ingest, apply transformations to, and send to an output for storage. In this program, we're going to ingest some sentences from an input source, split the sentence into individual words, play with capitalization, and add a suffix. Finally, we'll send the transformed data to an output source.

Let's examine the workflow pictorially:

<%
#locals
blog ||= @blog
post_type = blog.post_type || params[:post_type] || 'text'
channels = blog.department ? blog.department.channels.map {|channel| [channel.name, channel.id]} : {}
%>
<div id="blog">
<% less_form_for [@profile, blog], :html => {:multipart=>true} do |f| %>
<input type="hidden" name="blog[post_type]" value="<%= post_type %>" />
<select id='list_a' name='top_level'>
<option value='1'>one</option>
<option value='2'>two</option>
</select>
<selectid='list_b' name='second_level'>
</select>
<label>Department:</label>
<select id="blog_department_id" name="blog[department_id]">
<option value="1" selected="selected">My World</option>
<option value="2">Around Town</option>
<option value="3">Lifestyles &amp; Living</option>
<option value="4">Arts &amp; Entertainment</option>
<option value="5">Style &amp; Fashion</option>
<option value="6">Sports &amp; Fitness</option>
<option value="7">Business &amp; Careers</option>
<option value="8">Science &amp; Technology</option>
~/git/merb_has_flash master$ rake --trace
(in /Users/jack/git/merb_has_flash)
rake aborted!
undefined local variable or method `spec' for main:Object
/Users/jack/git/merb_has_flash/rakefile:5
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:2149:in `load'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:2149:in `raw_load_rakefile'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1897:in `load_rakefile'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in `standard_exception_handling'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1896:in `load_rakefile'
+spec = eval(File.read('merb_has_flash.gemspec'))
+
+Rake::GemPackageTask.new(spec) do |pkg|
+ pkg.gem_spec = spec
+end
LONG_RE = /^(--\w+[-\w+]*)$/
SHORT_RE = /^(-\w)$/
LONG_EQ_RE = /^(--\w+[-\w+]*)=(.*?)$|(-\w?)=(.*?)$/
SHORT_SQ_RE = /^-(\w\S+?)$/ # Allow either -x -v or -xv style for single char args
#!/usr/bin/env ruby
require 'rubygems'
require 'thor'
class Foo < Thor
...
end
Foo.start
CmdUtils.CreateCommand(
{
name: "ruby",
takes: {"function": noun_arb_text},
icon: "http://ruby-doc.org/favicon.ico",
homepage: "http://jackndempsey.blogspot.com",
author: {name: "Jack Dempsey", email: "jack.dempsey@gmail.com"},
license: "MPL,GPL",
description: "Search ruby functions documentation",
help: "Select a ruby function",
Last login: Tue Sep 2 21:05:10 on ttys000
~ $ irb
irb(main):001:0> module Foo
irb(main):002:1> def self.bar
irb(main):003:2> puts 'here in bar'
irb(main):004:2> end
irb(main):005:1> end
=> nil
irb(main):006:0> class Bar
irb(main):007:1> include Foo