Sha256: eb2090dbcb1ccf912e2f413239fc322396dd3b4918588b426cbecadb061976e6

Contents?: true

Size: 837 Bytes

Versions: 102

Compression:

Stored size: 837 Bytes

Contents

require 'httparty'

module Caboose
  class GoogleSpreadsheetsController < Caboose::ApplicationController
    
    # GET /google-spreadsheets/:spreadsheet_id/csv
    def csv_data           
      spreadsheet_id = params[:spreadsheet_id]                                                                                                              
      #url = "https://docs.google.com/spreadsheets/d/#{spreadsheet_id}/export?format=csv&id=#{spreadsheet_id}&gid=0"
      url = "https://docs.google.com/spreadsheets/d/#{spreadsheet_id}/pub?output=csv&single=true&gid=0"            
      resp = HTTParty.get(url)
      arr = nil
      begin 
        arr = CSV.parse(resp.body)
      rescue
        Caboose.log("Error parsing CSV in spreadsheet #{spreadsheet_id}:\n\n#{resp.body}")    
      end
      render :json => arr
    end

  end
end

Version data entries

102 entries across 102 versions & 1 rubygems

Version Path
caboose-cms-0.7.85 app/controllers/caboose/google_spreadsheets_controller.rb
caboose-cms-0.7.84 app/controllers/caboose/google_spreadsheets_controller.rb
caboose-cms-0.7.83 app/controllers/caboose/google_spreadsheets_controller.rb
caboose-cms-0.7.82 app/controllers/caboose/google_spreadsheets_controller.rb
caboose-cms-0.7.81 app/controllers/caboose/google_spreadsheets_controller.rb
caboose-cms-0.7.80 app/controllers/caboose/google_spreadsheets_controller.rb
caboose-cms-0.7.79 app/controllers/caboose/google_spreadsheets_controller.rb
caboose-cms-0.7.78 app/controllers/caboose/google_spreadsheets_controller.rb
caboose-cms-0.7.77 app/controllers/caboose/google_spreadsheets_controller.rb
caboose-cms-0.7.76 app/controllers/caboose/google_spreadsheets_controller.rb
caboose-cms-0.7.75 app/controllers/caboose/google_spreadsheets_controller.rb
caboose-cms-0.7.74 app/controllers/caboose/google_spreadsheets_controller.rb
caboose-cms-0.7.73 app/controllers/caboose/google_spreadsheets_controller.rb
caboose-cms-0.7.72 app/controllers/caboose/google_spreadsheets_controller.rb
caboose-cms-0.7.71 app/controllers/caboose/google_spreadsheets_controller.rb
caboose-cms-0.7.70 app/controllers/caboose/google_spreadsheets_controller.rb
caboose-cms-0.7.69 app/controllers/caboose/google_spreadsheets_controller.rb
caboose-cms-0.7.68 app/controllers/caboose/google_spreadsheets_controller.rb
caboose-cms-0.7.67 app/controllers/caboose/google_spreadsheets_controller.rb
caboose-cms-0.7.66 app/controllers/caboose/google_spreadsheets_controller.rb