Package rails app as gem or something else reusable? - ruby

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.

Related

Releasing Ruby Application for Specific users

I am new to Ruby and I have written a small app, that consists of around 50 .rb files and 6 folders. The purpose of app is to be an SDK for Ruby users, to interact with my API. It also uses few gems. Now I want to release this app for specific users, but looking at the internet for the solution really confused me (may be just because I'm new to it) and MOST of the posts found were for Rails
Being through several posts, what I find to be reasonable is to make a gem out of it and publish this gem at rubygems.org. (but this also makes it fully public)
Question:
Is this the correct approach in my specific scenario?
How can I manage the dependencies? (This part is very confusing, I will need more guidelines on this)
How to limit audience? (I have personal git server, would this be of any help)
Other Info:
App is developed in Ruby version 2.1.8, It makes http Get/Post requests using TLS, and is NOT a Rails or web app
I have been through several SO posts like THIS, THIS etc. But I couldn't understand it for my case.
I created a project in Jetbrains' IDE, called RubyMine. My project doesn't have bin folder, etc. but only my own folders and .rb files. And most of the solutions also talk about bin.
Any help will be appreciated.
Gemfury is probably what you're looking for. You'll package your library as a gem the same way as if you were going to publish it publicly on RubyGems, but Gemfury lets you restrict access to it to only the people you want to allow.

How do I integrate nanoc and Twitter Bootstrap/Zurb Foundation?

I am making a fairly big website. Mostly on culture of a particular place.
Are static sites a good idea?
How do I integrate nanoc and some framework? There are a couple of github repos on this, but I wanted to this from scratch in order to learn. Otherwise, I am afraid I might not be able to fix something that goes wrong later.
PLease help~
I've recently decided to make a reasonably sized site using nanoc and Zurb Foundation myself, so I can tell you my thoughts on this:
A static site is a good idea in many situations, but they do have obvious limitations (with everything being static!). The typical use of a static generator like nanoc is for a blog, for which most of the limitations aren't a problem (especially with services like Disqus for comments). I personally decided to use nanoc to save hosting/maintenance costs initially (using Amazon S3 to host a static site is cheap and scalable compared to a VPS), because I don't need any of the dynamic stuff yet, and to learn something new!
I've written a few posts on my blog (link in my profile) about how I've integrated foundation from scratch with nanoc. I can't comment for bootstrap, but my steps were:
Use the nanoc tutorial to create a site
Use compass to integrate foundation into your site, by creating a compass.rb that has a require "zurb-foundation" line as well as config for your asset paths (mine is here)
Run a compass install foundation -c compass.rb to populate the foundation stylesheets, images and javascripts into your asset directories
Update your Rules file to include compass, and process the stylesheets accordingly
That is a high-level overview - there's step-by-step detail on my blog if you're interested in going the foundation route.

Customize Gems or merge into main rails project

Currently I am writing a Ruby on Rails application, and I am using Gems, however sometimes I feel that Gems are not as flexible as I want them to be. To make them more flexible. Should I
Fork them on github, and customize it, but this still present the challenging of managing everything.
or
Strip and merge the code of the gem to the main application? This will allow further customization of the gem. This would be for situations where a Gem require another Gem's functionality.
or is there a better way of doing this?
Thanks
B
Choice A is the better answer for a number of reasons.
You get to merge in security updates, enhancements, and bug fixes easily.
Your changes may get merged into the core--in fact, consider if you could implement them in such a way as they live alongside the core functionality as options. If this happens, you have the ultimate win--nothing to maintain, and you can retire your fork.
Others can benefit from your changes.
Your project's footprint is kept smaller and focused by keeping the gem code isolated.
You'll have something to add to your Github "resume."
If its some kind if not so popular gem or "bicycle" from some previous studio or developer who started project(in my case).
I prefer deprecate this gem's and move code into project,
for example they have c***la-deploy - it's just wrapper to Capistrano 2 with own methods))) - I just delete it and rewrite on last Capistrano 3
Than that have own "CMS" c***la-cms where they wrap standard form_for or simple_form with name "twitter_form_for" ? - fist of all I start try to find gem who use this name, and than find in dependency gem's ...
Its take a lot of time for new developer involve in project - better move to standard rails methods/heplers
But anyway i understand for a what this studio do that - its just vendor lock and for client more hard to move out from them to another developers.
For example for startup its bad to use a lot of dependencies and if it's just simple website - dose not matter.

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.

i18n assets management / translation UI

i'm building a multi-lingual webapp with i18n from the ground up, and while i myself can deal with an army of yml files, the languages i speak are ( very ) limited, and would eventually like to ask for outside help.
I'd like to know if anyone here is using a UI plugin/gem ( not unlike django-rosetta on django ) to deal with multiple translators, some of them unwilling or unable to mess with 100+ files in a repository, working on language data.
thanks &regards,
Andras
( apologies if you bumped into this on rubyonrails-talk already )
There is a rails3 branch of the tolk gem on github. You can install it by inserting the following line in your Gemfile
gem "tolk", :git => "http://github.com/dhh/tolk.git", :branch => "rails3"
We used the translate gem for one of our projects before and it worked nicely. It's not perfect as your YAML files are no longer in your SCM but it lets the client translate his own application. We only used one YAML file per language so I don't know if it scales to a few 100 files...
DHH created another one, tolk, but I didn't have a chance to look at it yet.
Both solutions are for Rails 2.x, haven't tried this in Rails 3 yet.
Although this might be a bit late, the phrase service looks like something that suits your need. They provide i18n management through in-place edit.
For Rails 3, the URL for tolk is just http://github.com/tolk/tolk and installation is as simple as adding
gem "tolk"
to your Gemfile and running bundle install.

Resources