gem
Gem is a packaged #ruby library (extension).
Gem is a packaged #ruby library (extension).
You can run any gem executable at a desired version by adding a _version_ after the gem executable name (gemexec) and before the usual arguments (*args).
gemexec _version_ *args
Example:
bundle _1.0.22_ update
Will run version 1.0.22 of bundler to update the Gemfile.lock file. More under the cut
There are a few authorization gems at the ruby toolbox, but they are very complicated to use in complex cases.. And you have two ways: hack that gems for your needs or use a simple gem and write your own solution to use and implement it. What maymay do
The Levenshtein distance is a string metric for measuring the difference between two sequences.
http://en.wikipedia.org/wiki/Levenshtein_distance
For #ruby you can use #gem levenshtein-ffi and do something like this: More under the cut
So imagine that we have #rails application with User model and we don't want to delete users - we want to ban them and don't let to login again. So we need to logout user after banning and add checking if banned on login. In my app (it is quite old) I use #warden #gem so I will show a tip how to implement it with #warden. More under the cut
Hi guys!
Check out new #gistflow feature – page views counts for each post page. For example recent post about strong parameters by @homakov:
Here is a #gem cocaine by #thoughtbot.
It helps to run and handle commands (like you enter to terminal).
options = {
title: "Run commands with Cocaine gem",
content: "..."
}
line = Cocaine::CommandLine.new("gistflow", "-title :title -content :content", options)
line.command
# => "gistflow -title 'Run commands with Cocaine gem' -content '...'"
I had a task to add a #wiki to #rails.
After google I found most popular #gem - gollum by github.
It is a simple git-powered wiki and I thought how to use it with rails. More under the cut
Here is the gem terminal-notifier.
TerminalNotifier.notify "Message...", title: "Title"

You can add, remove and list notifications. All what you need :)
Thanks, @alloy
@bmuller creates a #gem detecting user's gender by name.
d = SexMachine::Detector.new
d.get_gender("Hank")
# => :male
d.get_gender('Jane')
# => :female
d.get_gender('Hulk')
# => :andy
So, it's very useful for projects caring about content targeting (mailing robot toys for boys and ponies for girls).
Specs output groups by top describe and shows failure specs immediately.
Authentication ..
User ........................F.
1) User#all_requests
Failure/Error: it { should == [request] }
expected: [#<Request id: 1>]
got: [] (using ==)
Diff:
@@ -1,2 +1,2 @@
-[#<Request id: 1">]
+[]
# ./spec/models/user_spec.rb:45:in `block (3 levels) in <top (required)>'
Dashboard ....
#shoulda - is a #gem by #thoughtbot. It provides helpers for your #rspec or unit-tests like this:
# account_spec.rb
it { should belong_to(:user) }
it { should belong_to(:project) }
it { should validate_presence_of(:user) }
it { should validate_presence_of(:project) }
it { should validate_uniqueness_of(:project_id).scoped_to(:user_id) }
If you wanna find some #gem the best way is not google it but find it on ruby toolbox. This site group and sort all popular gems.
#high_voltage is a #gem for #rails created by #thoughtbot.
It helps you create static pages like about, contacts, etc.
Use it If you won't create extra controllers and care about routes.
This #gem for #rails provides simple DSL for controllers. You can implement your CRUD actions by minimum code. For example:
class ProjectsController < InheritedResources::Base
actions :all, :except => [ :edit, :update, :destroy ]
end
Also #inherited_resources provides other methods for customization default behavior easy.
Check out it on github: https://github.com/josevalim/inherited_resources
#rackspace have a cloud files service. So you can store your backups there. They also creates a libs for their API.
For example cloudfiles #gem for #ruby. Very simple! Usage
If your db is not very big or if you have enough time to migrate your database you can use #yaml_db #gem.
It copies your db columns data to the simple #yaml file and load it to new db. how it works
A great technique to improve your code is using benchmarking – comparison between different solutions leads to faster and better code.
Examples under the cut. More under the cut
I wrote a #microgem for a simple validation a state of the object with #statemachine More under the cut