This gem provides a simple way to download report data from salesforce.com. It works well with any ruby applications, include such as Ruby on Rails.

You can access salesfore.com using only your salesforce login id (=email) and password. A security token is no need.

Data will be saved in CSV format.

source:https://github.com/apuruni/salesforce_http_client

Installation

Add this line to your application's Gemfile:

gem 'salesforce_http_client'

And then execute:

$ bundle

Or install it yourself as:

$ gem install salesforce_http_client

Configuring SalesforceHttpClient

Add configurations to set your salesforce.com login_id/password. You must check your salesforce.com instance to get the right domain for your account. For example: https://na12.salesforce.com/000000000000ABC, where 'http://na12.salesforce.com/' is the salesforce.com instance domain.

require 'fileutils'
require 'httpclient'

SalesforceHttpClient.configure do |config|
  config.salesforce_login_id = 'my_login_id_or_email'
  config.salesforce_password = 'my_password'
  # this parameter must be set if you are not using the default (ap.salesforce.com) instance domain of this gem.
  config.salesforce_instance_domain = 'https://na12.salesforce.com'
end

If you're using Rails, create an initializer for this:

config/initializers/salesforce_http_client.rb

Downloading report from salesforce.com

First, you need find the salesforce ID for your report. For example: http://na1.salesforce.com/000000000000ABC, where '000000000000ABC' is the salesforce ID.

Then, pass the salesforce ID and a file path to SalesforceHttpClient::Client#download_report(salesforce_id, report_save_path) method.

salesforce_id = '000000000000ABC'
report_save_path = "tmp/#{salesforce_id}.csv"

sf_client = SalesforceHttpClient::Client.new
sf_client.download_report(salesforce_id, report_save_path)

After a few seconds, you will find your report data(csv format) at report_save_path.