neurogami

Mind-bending application development 

Pivotal Slacker @ Ruby::AZ

Very good meeting at tonight's Ruby::AZ gathering.  I gave a not-too-lengthy demo of Pivotal Slacker, a tool for command-line interaction with the Pivotal Tracker Web API.

Chad Wooley of Pivotal Labs was there, up from Tuscon.  Mighty nice to have him.  He answered a number of questions about the PT API, and took note of a some observations, too.

The Slacker code was very recently updated for the PT v3 API. Turns out some things in Slacker are broken, too.  An update is planned, and now would be a good time to start putting in those tests.

The app/lib started as a one-file hack on top of swiped PT Ruby code.  Things pretty much Just Worked; testing consisted of simply running the damn thing and tweaking as I went.  Now, though, with it being a Real Gem, it would be a big help to have automated verification of correct behavior.

There will be an announcement when the gem up on gems.neurogami.com is updated.

Loading mentions Retweet
Posted by neurogami 

Comments [0]

Rhesus 0.3.4 released

rhesus

by James Britt / Neurogami 
http://www.neurogami.com
james@neurogami.com

DESCRIPTION

Rhesus is a tool for copying over pre-built templates with optional embedded string interpolation.

It started as a way to make jump-starting Jimpanzee apps easier, but the user-defined templates need not have anything to do with any special library or programming language.

Basically, you create a skeleton of the files you want as templates in some suitably-named subdirectory of ~/.rhesus.

If any of those files contain Erb variables, they will be used to prompt the user for real values when that template is used to generate files and directories.

The same value gets applied in all cases where that variable is used. Some magic is used to handle proper casing for class and file names.

The results are copied out to a directory relative to where you invoked the 'rhesus' script.

FEATURES/PROBLEMS

Generates files for you to jump-start projects that have common code.

Makes assorted assumptions and needs more testing with a variety of template sources

Driven by the Works for James criteria. Feedback is welcome.

SYNOPSIS

Installation

Make sure you have http://gems.neurogami.com added as a gem server source.

$ sudo gem sources -a http://gems.neurogami.com

Then install the gem:

$ sudo gem install rhesus

Or, pass the gem source as part of the command:

$ sudo gem i rhesus ––source http://gems.neurogami.com

Then run the rhesus setup option:

$ rhesus --setup

This should create a .rhesus folder in your home directory. This is where you store you templates, each in its own containing folder.

Basic usage

To use templates, cd to an existing project, or wherever you want to splat out the generated code. For example, start a new jimpanzee application:

$ jimpanzee cool-app $ cd cool-app

Run rhesus list to see the available templates

$ rhesus list

NOTE: This behavior might vanish, since in actual use it is pretty useless. See below.

Run rhesus gen to generate code from a template. You may optionally pass the name of a template, but if you leave that out you'll get a list to pick from.

$ rhesus gen
1: jimpanzee.about
2: jimpanzee.basic
3: jimpanzee.midi

Enter the number of the template to use:

If you pass a complete template name then that is automatically used:

$ rhesus gen  jimpanzee.midi

Run rhesus stuff to have rhesus show a list of templates that match on stuff.

$ rhesus midi
1: jimpanzee.midi

Enter the number of the template to use:

Template structure

The code assumes you have a directory .rhesus in your home directory (+~/.rhesus+)

That directory holds the template sets.

Each set is just a top-level directory containing the skeleton files and directories to use:

james@james06:~/.rhesus$ tree
.
|-- jimpanzee.about
| `-- src
| `-- about
| |-- about_controller.rb
| |-- about_model.rb
| |-- about_ui.rb
| `-- about_view.rb
|-- jimpanzee.basic
| `-- src
| `-- klassname
| |-- klassname_controller.rb
| |-- klassname_model.rb
| |-- klassname_ui.rb
| `-- klassname_view.rb
`-- jimpanzee.midi
|-- com
| `-- neurogami
| `-- ResourceLoader.java
|-- lib
| |-- java
| | |-- libWiiuseJ.so
| | |-- libwiiuse.so
| | |-- miglayout-3.6.jar
| | `-- wiiusej.jar
| `-- ruby
| |-- README.txt
| |-- wii_api_manager.rb
| |-- wiimotable.rb
| `-- wiimote_event_listener.rb
`-- src
|-- mainclass
| |-- mainclass_controller.rb
| |-- mainclass_model.rb
| |-- mainclass_ui.rb
| `-- mainclass_view.rb
|-- midi.rb
|-- resolver.rb
|-- resource_loader.rb
`-- spinner_dialog.rb

What you call these directories is up to you; there is no code in place to do anything clever with the names (such as grouping projects and templates). But something like that may be added if managing growing numbers of templates becomes an issue. So, the suggested format is project_type.template_name

Rhesus starts with some assumptions about what files might be using Erb. You can add your own file patterns (sort of) by placing a haz_vars.txt file in your .rhesus folder.

By default, the file-end patterns are: rb txt rhtml ini yml yaml Rakefile gemspec.

Note

A recent addition, and still evolving, is the use of a .options.yaml file in the root of a template folder.

This is because you may have a large set files that do not need any template processing.

Worse, some files may be themselves Erb templates (or contain Erb markup) that should be copied over as-is, but would otherwise get preprocessed by rhesus.

a .options.yaml file can contain a hash of file patterns, like this

    noparse: 
- /gems/gems/rack
- .git/

ignore:
- .git/

This tells rhesus that any file whose template path matches on any of the items listed in noparse should not be parsed for template variables, and simply copied over as-is.

The array under ignore means to ignore any files or directories that match on that substring. No parsing, no copying.

Template variables

When you select a template set, Rhesus scans these files for Erb (or some alternate) variables. It then prompts you to provide values. If you use any of these variable names in file or path names then Rhesus will apply those values to the names and paths when applying the template.

You need to be sure, then, to only use the same variable name across files when you want them to all have the same value.

That is, if foo.rb and baz.ini both use <%= my_var %>, then the resulting text will have the same value used in both.

If a file in a template set is not among the file types that may have Erb (e.g., jar, dll, gif) then it will be copied over as-is.

For example:

jimpanze.basic has this structure:

jimpanzee.basic
| `-- src
| `-- klassname
| |-- klassname_controller.rb
| |-- klassname_model.rb
| |-- klassname_ui.rb
| `-- klassname_view.rb

The file klassname_controller.rb has Erb to define the name of the class:

class <%= klassname  %>Controller < ApplicationController
set_model '<%= klassname %>Model'
set_view '<%= klassname %>View'

When jimpanze.basic is selected for code generation, Rhesus scans the template files and picks out variable names used inside Erb brackets (i.e., <%= this_is_the_variable %> )

When the list of all such variables in all the files is assembled, rhesus prompts for a value for each one.

Using template jimpanzee.basic
Value for klassname:

The value entered will than be used for all instances of klassname in Erb. It will also be used to alter any file or folder names that contain that as well.

Assume you gave the value of Goober

Since the template directory has src/klassname, and several files with that string, the generated code will look like this

|   `-- src
| `-- goober
| |-- goober_controller.rb
| |-- goober_model.rb
| |-- goober_ui.rb
| `-- goober_view.rb

Inside the files, the code will also have this value:

class GooberController < ApplicationController
set_model 'GooberModel'
set_view 'GooberView'

Some assumptions are made in writing out the code. Variables inside files are replaces as-is.

That is, if you want Goober in your text, use Goober. If instead you want goober, use that.

However, for file and folder names, variable values are snake-cased. That's why you end up with src/goober/goober_controller.rb.

A value of FooBar, for example, would create src/foo_bar/foo_bar.rb. But the string FooBar would be used inside the generated files.

Note: poly-lingual templates

Some of the code for auto-mangling file and path names is changing. Initially the code was specific to Ruby apps, but it's really very handy for all sorts of things, such as Haskell projects.

But these other things have different conventions; code to apply appropriate conventions is being added.

Note: "rhamaze" templating

Another recent evolving features is the use of "rhamaze" templating.

Suppose you have a Ramaze project template set, with some .xhtml files that contain Erb markup. You do not want Rhesus to pre-process this as Erb, but you *do* want to have some interpolated variables.

So, you need to add a leading line that contains the string RHEMAZAR and do your rhesus variables using this syntax:

 <|= my_variable |>

That leading line will be skipped when processing the file.

Adding templates

You can add templates by just tossing them into the appropriate directory structure under ~/.rhesus.

You can also install templates from a git repository:

$ rhesus --install git@gitlandia.org:Neurogami/super.bad.template.git

or

$ rhesus --install git://gitistan.org/Neurogami/super.bader.template.git

Rhesus will do a straight-up git clone to fetch the files. If the repo name begins with rhesus. (e.g. git://gitistan.org/Neurogami/rhesus.ramaze.basic) then that leading string gets stripped from the destination folder (ramaze.basic).

This is so that repos names can have an identifiable name prefix without having the resulting template folder cluttered with that prefix.

REQUIREMENTS

Ruby, and a sense of adventure.

INSTALL

$ sudo gem i rhesus ––source http://gems.neurogami.com

LICENSE

(The MIT License)

Copyright (c) 2009 James Britt / Neurogami

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Feed your head.

Loading mentions Retweet
Posted by neurogami 

Comments [2]

Ruby::AZ Ruby business directory beta ready

After adding a few tweaks to the code, a link has been added to the Ruby::AZ site for the Arizona Ruby Business Directory.

It's still beta level, but better to release it (so to speak) now and get feedback.

If you're a Ruby business (product development, consulting, whatever) in Arizona, get in touch to get added to the directory.

Loading mentions Retweet
Posted by neurogami 

Comments [0]

Android development helper tool Andi, version 0.2.0, released

Version 0.2.0 of Andi has been released as a gem, hosted on gems.neurogami.com.

Source code is available from http://github.com/Neurogami/andi

To install a gem from Neurogami, you need to either add gems.neurogami.com to your gem source list:

sudo gem sources -a http://gems.neurogami.com

... or pass the gem source when installing a particular gem:

sudo gem i andi  -source http://gems.neurogami.com

Andi wraps calls to the Android SDK command line tools to make life a bit easier.  It allows you to configure assorted default values (such as the package name and  the target Google platform) so you don't have to pass those on every call.

It also creates a Rakefile you can use with your Android project to help with common actions, such as compiling, installing, and signing your code.

It's still evolving; features are aded or altered based on what seems to work well or not.

Other code from Neurogami can be found at http://gems.neurogami.com/code/

 

Loading mentions Retweet
Posted by neurogami 

Comments [0]

Further Adventures with Glassfish and Ramaze

The JotBot Web site has been hosted on eApps for quite a few months now (8, I reckon).  It's a mix of static pages created using Webby and some Ramaze backend code to handle transactions for license keys.   Since Neurogami already had a server when taking over JotBot the plan was to move the code over and get off of eApps.

eApps was picked because they offered the Glassfish server out of the box, and that's how the server has been run.  The ideas was to setup Glassfish on the Neurogami machine and just move the code over.  Sadly, few things are so simple.

Some of the complications came from wanting to use current versions of the libraries involved.  That meant new Ramaze, new Rack, new Warbler, and possibly new Glassfish.  As it turns out, these things do not all play nice together.

I managed to get a proper war file generated from Warbler after creating a new version using updated jruby and rack jars. But I never got the results to run reliably with any version of Glassfish.

The current Glassfish gem does not correctly handle Rack applications.  It appears to work OK for very specific config.ru files, but falls apart, for example, if asked to use middleware.  My guess is that testing has been following the "works OK for Rails" methodology.  The issues have been pointed out to the developers, and I expect that proper Rack compatibility will eventually happen, but for the time being it is unusable for the JotBot server.

So, the current move means dropping Glassfish  and running jruby-rack with jruby-mongrel, proxied via Apache (which will serve the static files straight away).

Interestingly enough, while the eApps instance has been super solid for the last many months, just now I've been seeing errors in processing transactions.  I know from past experience that sorting these things out with Glassfish can be a black art.  It's a trade -off: when Glassfish is doing well it can offer a number of useful services.  But to get it running well can be quite tricky.  This time, I decided to just skip fixing it and made the move to the new set up on the other box.

My testing tells me all is order, and I really don't want to have to fight with an app server, so updated the DNS records and let it fly.   I'm sure at some point I'll reevaluate Glassfish (and Tomcat, et al) for serving JRuby apps, but lean deployment is working for me.


Loading mentions Retweet
Posted by neurogami 

Comments [0]

Ramaze and Rack with JRuby: Some examples

 

I have a production app running Ramaze on top of JRuby, deployed to a Glassfish v2 server.  It's been happily spinning along for about 8 months now.

I've been looking to move it off its current server to another machine, so I tried to get it running with current versions of Ramaze, JRuby, etc.

I had some initial bad luck, with assorted cryptic errors and the need to change configuration files.  The libs in question (jruby-rack, warbler, glassfish) have assorted docs and examples that talk quite a bit about Rails, but nothing about Ramaze, and relatively little about plain old Rack. (Sun, the people behind Glassfish, seems to think Ruby and Rails are the same thing.)

I wanted to have some simple example apps so that I could pinpoint what works and what doesn't.

There is code and some notes up on Github:

http://github.com/Neurogami/gf-rack-ramaze-experiments/tree/master

I have dead-simple Ramaze and Rack apps set to run either as Warbler-generated war files, or  run via the glassfish gem command-line call.

I've successfully war'ed up Rack and Ramaze apps and deployed to a glassfish v2 server. 

However, at the moment it looks as though the glassfish gem does not properly fill in for rackup; whereas a config.ru file can typically have assorted Rack middleware, the glassfish gem just breaks when encountering "use Rack::Foo" or "run SomeThing".  Basically, it has no idea what the 'use' or 'run' methods are.

You can use it for really simple Rack apps (no middleware, just a proc), but Ramaze fails with assorted errors over the lack of values for various rack env keys (such as rack.run_once, which are otherwise fine when using rackup, with or without JRuby).

Loading mentions Retweet
Posted by neurogami 

Comments [2]

Ignite Phoenix - Cross-platform desktop Wii applications

My talk from Ignite Phoenix IV is now up on Blip TV: "Building cross-platform desktop Wii applications":

You can also download it as an mp4 file here.

BTW, I am granting release of the video under a Creative Commons license:

Creative Commons License
Cross-platform desktop Wii applications by James Britt / Neurogami is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 License.

Loading mentions Retweet
Posted by neurogami 

Comments [0]

Ignite Phoenix 4 Lineup

The line-up for Ignite Phoenix IV has been announced.

 

I'm quite excited to be one of the presenters, so I'm now busy hacking what I hope to demo during during my talk.

Loading mentions Retweet
Posted by neurogami 

Comments [0]

Kempten Webcam, but bigger

There's a nice app for Android phones, La Tour Eiffel, that repalces your background image with (surprise!)  an auto-updating shot from the Eiffel Tower Web camera.  That alone would be quite nice, but the app also provides config options for about a dozen or so other Web cameras from around the world.

But the best feature is being able to type in a custom Web cam URL.  My favorite is the Kempten camera that points at the town hall square. However, the image is too small for the G1 app; left as it is, it makes for a dinky background image.

ImageMagick + cron FTW.  I have a small script that fetches the current camera image, resizes it, and saves it.  Now I point the Web cam app to the new URL.

If you have an Android phone, check out La Tour Eiffel. And if you're a Kempten fan (and who isn't?), have it grab the resized image.

Loading mentions Retweet
Posted by neurogami 

Comments [0]

Neurogami JRuby gems available from GitHub

I was skeptical at first of GitHub being an alternative gem server, along with rubyforge.org (the canonical gem source).
 
However, it happens to be *extremely* handy.
 
It is especially useful for projects that are forks of other code.
 
Neurogami is busy working on assorted Web and desktop applications, and often needs this or that feature that is not in some key library.
 
In particular, much use has been made of rawr and Monkeybars. There are times when certain behavior is needed, and the most expedient way to keep rolling has been to work with a fork of those libraries.
 
Using GitHub, it's stupid easy to make those forks available as Ruby gems for folks who want to try out these alterations.
 
To avoid installation collisions (and because making up names is fun), the forks have project names different from the originals:
 
All are available as gems from Github (see http://gems.github.com for general instructions).
 
 
Jimpanzee is the fork of Monkeybars.
 
  sudo gem install Neurogami-jimpanzee
 
  jruby -S install Neurogami-jimpanzee
 
 
Roir is the fork of rawr.
 
  sudo gem install Neurogami-roir
 
  jruby -S gem install Neurogami-roir
 
 
There is also SwingSet, code puled out of an earlier fork of Monkeybars that allows for easier inline Ruby/Swing code
 
  jruby -S gem install Neurogami-swingset
 
 
Finally, there is Restafarian, Rack middleware for managing RESTful routing.
 
  sudo gem install Neurogami-restafarian
 
 
 
See also http://www.neurogami.com/code

Loading mentions Retweet
Posted by neurogami 

Comments [0]