<commit_before># FormhubRuby

A very simple Ruby Wrapper for the Formhub API

## Installation

Add this line to your application's Gemfile:

    gem 'formhub_ruby'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install formhub_ruby

## Usage

### Basic usage
This gem is a very simple API wrapper for the JSON API of [Formhub
](https://formhub.org/) application.
More details on their JSON API can be foud on their [wiki page]( https://github.com/SEL-Columbia/formhub/wiki/Formhub-Access-Points-(API)).


### Set a connection with the Formhub API

Create a connection like so:

    connection = FormhubRuby::API.new(username: 'fake_username', password: '<PASSWORD>', formnamne: 'my_form_name' )

You can also pass authentification configuration arguments in a block (e.g. in a initializer file, etc...):

    FormhubRuby.configure do |config|
      config.username =  'fake_username'
      config.password =  '<PASSWORD>'
    end

To get the actual data from the api call, call the fetch method on it:

    connection.fetch

You should then be able to retrieve an array of hashes by using the data method

    the_result = connection.data 
    the_result.first.name
    # => Loic<commit_msg>Small Correction in  Readme<commit_after># FormhubRuby

A very simple Ruby Wrapper for the Formhub API

## Installation

Add this line to your application's Gemfile:

    gem 'formhub_ruby'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install formhub_ruby

## Usage

### Basic usage
This gem is a very simple API wrapper for the JSON API of [Formhub
](https://formhub.org/) application.
More details on their JSON API can be foud on their [wiki page]( https://github.com/SEL-Columbia/formhub/wiki/Formhub-Access-Points-(API)).


### Set a connection with the Formhub API

Create a connection like so:

    connection = FormhubRuby::ApiConnector.new(username: 'fake_username', password: '<PASSWORD>', formnamne: 'my_form_name' )

You can also pass authentification configuration arguments in a block (e.g. in a initializer file, etc...):

    FormhubRuby.configure do |config|
      config.username =  'fake_username'
      config.password =  '<PASSWORD>'
    end

To get the actual data from the api call, call the fetch method on it:

    connection.fetch

You should then be able to retrieve an array of hashes by using the data method

    the_result = connection.data 
    the_result.first.name
    # => Loic
{'fraction_non_alphanumeric': 0.08391038696537678, 'fraction_numerical': 0.0, 'mean_word_length': 3.6427221172022684, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5227014', 'n_tokens_mistral': 738, 'n_tokens_neox': 703, 'n_words': 292}