Coder Social home page Coder Social logo

google_forms_ruby's Introduction

Google Forms Ruby Gem

When you need to post something to a Google Form from your ruby script.

How it works

I got tired of copypasting field names from Google Forms to my code and created a gem that gets the whole Google Form page using curb and grabs input names from it using Nokogiri.

Installation

Add to your Gemfile:

gem 'google_forms'

and run bundle, or just:

gem install google_forms

Usage

Assuming you have a form to fill with your script:

Example Google Form

Make sure your fields don't have any validations

Add the gem to your project:

require 'google_forms'

Pass a Google Form id or an url (yes, short url will work too):

form = GoogleForm.new('https://forms.gle/QvQbSm5Gxg7GNwBq9')

 => #<GoogleForm:12134640 @id=\"1FAIpQLScgwPtuN0aMJ6NLztq2kTZ4pdebxcrE_99Ax6I0fQtBwaT7fA\">

Get the list of input fields:

form.inputs

 => [#<GoogleFormInput:... @input_type="text", @label="id", @name="entry.462465405">, ...]

form.inputs.map(&:label)

 => ["id", "username", "first_name", "last_name"]

Fill in the inputs (using labels):

form.id = 12345
form.username = 'installero'
form.first_name = 'Vadim'
form.last_name = 'V'

And post the response:

form.post

Or do it all in one line:

form.post(id: 12345, username: 'installero', first_name: 'Vadim', last_name: 'V')

Yes, you can combine:

form.id = 12345
form.post(username: 'installero', first_name: 'Vadim', last_name: 'V')

google_forms_ruby's People

Contributors

installero avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.