Has somebody built a navigation/menu helper for Sinatra? - ruby

I see there is one for staticmatic,
and plenty in the Ruby toolbox for rails menu builders,
but I can't seem to track one down specifically for Sinatra.

As far as I know, no, there is no menu helper for sinatra.
You can look at all the libraries and extensions for sinatra at Sinatra in the Wild (scroll about halfway down the page). There is also the Padrino Framework, which builds on Sinatra by adding more functionality. That is probably where something you are looking for is most likely to appear.

The popular simple-menu gem works with Sinatra as well as Rails.

Related

Problems creating a railtie for a rails ORM gem I'm developing

I am developing a Ruby gem, Ampere, that acts as an ORM for the Redis database. I am trying to shore up its Rails integration, and was able to tie in an initializer and console hook, but my generators do not work yet. I have a generator, ampere:config that installs a default configuration YAML file, and a replacement for the model generator as well.
When I install my gem into a testing Rails app, the ampere:config generator shows up in the list when I run rails generate on the command line, but when I type rails g ampere:config, I get:
Could not find generator ampere:config.
and nothing else. My generator lives in "lib/rails/generators/config/" within the gem, and clearly Rails knows about it since it showed up in the rails g list, but something's not right. If anyone can help or knows of some better documentation for this than the Rails Guides, which are sparse to say the least, it'd be much appreciated.
Ok so I finally got this. For the generators to work, they have to call source_root with the relative path of their templates, and they have to live in lib/rails/generators/your_gem_name/, then the directory structure in your_gem_name/ is what you'd expect from reading the documentation (or running rails g generator in a Rails project).
The documentation is not very clear about this, so it was a bit confusing, but after looking at a few examples I tried this and it worked.

Ruby: Lightweight web server

I'm developing at Ruby on Rails. It's good framework and etc., but now I need to make one little promo-site. It can be done at simple HTML, but should have content at two languages.
It will be very pretty if I can use some super-fast and lightweight framework. Something like Ruby on Rails, with ERB-templates, partials and YAML-files for internationalisation, but without ActiveRecord and blah-blah-blah. Any ideas?
If the website can be done using static HTML, but you want the comfort of templates and YAML internationalization, you might want to take a look at Middleman, which does exactly that. :)
Sinatra? Renee? These are the small frameworks that are great for this kind of job.
Mini-rails can also be a good solution to your problem, especially if your website might grow one day or another

How do I change the default gemfile created with 'rails new' command?

I have recently experienced an issue where I must add the following to my gemfile:
gem 'execjs'
gem 'therubyracer'
I must do this to avoid a javascript runtime error that occurs when starting the rails server. I would like to have this modification added to all new gemfiles created with the rails new command.
You're looking for application templates.
Rails documentation on Application Templates
If you want the option to customize each app individually instead of having a rigid template, a really good option is Rails Composer. It prompts you about common gems during setup, and it nails a lot of the more common gems.
Finally, if you like Rails Composer, but want to be able to re-use application templates, check out Rails Apps Composer. I haven't looked into this too much, but it seems to give you a lot of flexibility while doing most of the heavy lifting for you.

How can I help TextMate recognize which bundle to load?

I have a problem with four bundles I'm using, specifically Ruby, Ruby on Rails, RSpec and Sinatra.
Most of the time TextMate manages to get the bundle type right, but for these, I find myself constantly switching form Sinatra to Ruby on Rails, as some model files get recognized as Sinatra.
It also happens a lot with RSpec, where the Sinatra bundle sometimes takes precedence.
Is there any way to manage the way in which bundles are recognized? It would be great if I could somehow hint TextMate what bundles to completely ignore in a specific project, or based on a directory structure.
I think you can modify your Sinatra bundle to trigger as soon as it detects require 'sinatra'

Package rails app as gem or something else reusable?

I'm looking for a guide on how to package a rails app as a gem or something reusable like that..
At work we build a lot of client rails apps where wordpress is too bloggy(and php) and radient and the other ruby cms's seem a little clunky to fit them perfectly..
So im building (you guessed it) yet another CMS for simple sites using the common factors ive seen across multiple sites..
What would be perfect would be, being able to say
$: MyCMSName new sitename
To setup the common defaults, and then:
$: rails g MyCMSName:downloads
Or
$: rails g MyCMSName:galleries
Also it would also be nice to say:
$: MyCMSName new sitename --with-galleries --with-downloads
This is the way RefineryCMS works.
Rather than wasting your time creating yet another CMS, I suggest you download the source and help in development.
There are a few rails engine extensions available too, including a gallery. The main developer is open to pull requests and can often be found on irc.

Resources