background preloader

Bundler: The best way to manage a Ruby application's gems

Bundler: The best way to manage a Ruby application's gems

Berkshelf A Different View... Bundler rocks, but you need to think differently about how to start and run your Rails app. The Bundler Way You should realise that Bundler is a library management tool. This has to be in your mind when you are getting a Rails application running on version 3.0. For example, I had a new Rails application that I want to run with PostgreSQL, so I go in and change database.yml to look at my PostgreSQL database instead of the Sqlite3 database, fairly standard, straight forward opperation. Then starting the application console however, I got a bit of a shock: This confused me for a second, I was sure that the pg gem was installed on my system, and the following confirmed it for me: mikel@baci.lindsaar.net ~ $ gem list pg *** LOCAL GEMS *** pg (0.8.0) OK, but the rails app was complaining that it couldn’t find it. This is an important datum, Bundler is a library management tool, and it allows you to totally bypass the rubygems on your system. So, first things first, bundler gives you some tools:

untitled A guide to setting up a Ruby on Rails development environment This will take about 30 minutes. We will be setting up a Ruby on Rails development environment on Mac OS X 10.11 El Capitan. Older versions of OS X are mostly compatible so follow along as far as you can and then Google search for any problems you run into. There are plenty of people who have documented solutions for them. First, we need to install Homebrew. Homebrew comes with a very simple install script. Open Terminal and run the following command: ruby -e "$(curl -fsSL Choose the version of Ruby you want to install: Now that we have Homebrew installed, we can use it to install Ruby. We're going to use rbenv to install and manage our Ruby versions. To do this, run the following commands in your Terminal: We'll be using Git for our version control system so we're going to set it up to match our Github account. cat ~/.ssh/id_rsa.pub ssh -T git@github.com Hi excid3!

How to start writing a ruby gem If you are a Ruby developer, by now, you have probably used tons of gems in your apps. That's one of the best things of using Ruby, a lot of people writes repeatable code that you can easily integrate into your own apps. In this brief tutorial, I will try to explain the basic things you need to know in order to start writing your own gems, you know, just in case you have something to share with the world. Setting up the folders We'll start by creating the gem folder structure using Bundler. First thing you have to do is, install bundler itself. $ gem install bundler Now, bundler comes with a handy command to generate the basic files to start writing a gem. $ bundle gem awesome_gem create awesome_gem/Gemfile create awesome_gem/Rakefile create awesome_gem/.gitignore create awesome_gem/awesome_gem.gemspec create awesome_gem/lib/awesome_gem.rb create awesome_gem/lib/awesome_gem/version.rb The Gemspec All gems have a .gemspec file. Let's say your gem heavily depends on rails. The code And so on.

awslabs/aws-flow-ruby-samples technicalpickles/jeweler - GitHub aws/aws-flow-ruby mikeaddison93/aws-sdk-ruby Amazon Web Services - Labs Pry - an IRB alternative and runtime developer console File: README — AWS SDK for Ruby This is version 1 of the AWS SDK for Ruby. Version 2 can be found in the master branch. Installation Version 1 of the AWS SDK for Ruby is available on rubygems.org as two gems: aws-sdk-v1aws-sdk This project uses semantic versioning. gem 'aws-sdk', '< 2' gem 'aws-sdk-v1' If you use the aws-sdk-v1 gem, you may also load the v2 Ruby SDK in the same process; The v2 Ruby SDK uses a different namespace, making this possible. gem 'aws-sdk', '~> 2.0'gem 'aws-sdk-v1' If you are currently using v1 of aws-sdk and you update to aws-sdk-v1, you may need to change how you require the Ruby SDK: require 'aws-sdk-v1' If you are using a version of Ruby older than 1.9, you may encounter problems with Nokogiri. gem 'nokogiri', '~> 1.5.0' Basic Configuration You need to provide your AWS security credentials and choose a default region. AWS.config(access_key_id: ' You can also specify these values via ENV: export AWS_ACCESS_KEY_ID='...' Basic Usage Each service provides a service interface and a client. Testing AWS.stub!

Bundler: The best way to manage a Ruby application's gems If you run bundle update with no parameters, bundler will ignore any previously installed gems and resolve all dependencies again based on the latest versions of all gems available in the sources. Consider the following Gemfile: source ' 'rails', '3.0.0.rc'gem 'nokogiri' When you run bundle install the first time, bundler will resolve all of the dependencies, all the way down, and install what you need: As you can see, even though you have just two gems in the Gemfile, your application actually needs 25 different gems in order to run. After checking in the Gemfile.lock into version control and cloning it on another machine, running bundle install will _still_ install the gems that you installed last time. However, from time to time, you might want to update the gems you are using to the newest versions that still match the gems in your Gemfile. To do this, run bundle update, which will ignore the Gemfile.lock, and resolve all the dependencies again.

Related: