<commit_before># Importr

Rails Engine which extends active-admin to import excel files, based on top of [Active-Importer](https://github.com/continuum/active_importer) dsl import.

[![Build Status](https://secure.travis-ci.org/continuum/importr.png)](http://travis-ci.org/continuum/importr) [![Coverage Status](https://coveralls.io/repos/continuum/importr/badge.png)](https://coveralls.io/r/continuum/importr)
=======

## Installation

Add this line to your application's Gemfile:

    gem 'importr'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install importr

## Usage

Install migrations

    $ rake importr:install:migrations

Add an your importers in app/importers

    class PricingImporter < Importr::Importer
      imports Pricing

      column 'Fecha', :date
      column 'Precio/tasa', :value
      column 'Vector precio', :vector_id
    end

Go to active-importer documentation for more information about importers

### Active Admin support

    ActiveAdmin.register Pricing do
      menu parent: "Money"
      data_import_interface
    end


### WebSocket integration, Faye example

If you need to emit the progress of importation in realtime, like errors validations, you can configure the Importer in an initializer for websocket notification:


    Importr::Config.setup do |config|
      config.web_socket_class         = 'FayeWrapper'
      config.web_socket_method        = "publish"
      config.websocket_url_service    = "http://localhost:8000/faye"
      config.websocket_client_script  = "http://localhost:8000/faye/client.js"
    end

Importr will manage the event publication for errors send notifications with FayeWrapper.publish

### Faye Wrapper example

in config/initializers/faye.rb write something like

    WS_CLIENT = Faye::Client.new('http://localhost:8000/faye')

    class FayeWrapper
      def self.publish(channel, message)
        run_event_machine
        puts "#{channel} #{message}"
        WS_CLIENT.publish(channel, message)
      end

      def self.run_event_machine
        Thread.new { EM.run } unless EM.reactor_running?
        Thread.pass until EM.reactor_running?
      end
    end

Finnaly you must to run a Faye server

## Dependences

[SideKiq](https://github.com/mperham/sidekiq)

[CarrierWave](https://github.com/carrierwaveuploader/carrierwave)
<commit_msg>Minor improvements to README.md (without any significat content change)<commit_after># Importr

Extends active-admin to import excel files. Based on [Active-Importer](https://github.com/continuum/active_importer) dsl import.

[![Build Status](https://secure.travis-ci.org/continuum/importr.png)](http://travis-ci.org/continuum/importr) [![Coverage Status](https://coveralls.io/repos/continuum/importr/badge.png)](https://coveralls.io/r/continuum/importr)
=======

## Installation

Add this line to your application's Gemfile:

    gem 'importr'

Then execute:

    $ bundle

Or just install it as gem if you don't use bundler:

    $ gem install importr

## Usage

Install migrations:

    $ rake importr:install:migrations

Add your importers in app/importers. Here is a importer example:

    class PricingImporter < Importr::Importer
      imports Pricing

      column 'Fecha', :date
      column 'Precio/tasa', :value
      column 'Vector precio', :vector_id
    end

Go to active-importer documentation for more information about importers

### Active Admin support

    ActiveAdmin.register Pricing do
      menu parent: "Money"
      data_import_interface
    end


### WebSocket integration, Faye example

If you need to notify the progress of a import in real time (and
errors or validation issues), you can configure websocket notification
in an initializer:


    Importr::Config.setup do |config|
      config.web_socket_class         = 'FayeWrapper'
      config.web_socket_method        = "publish"
      config.websocket_url_service    = "http://localhost:8000/faye"
      config.websocket_client_script  = "http://localhost:8000/faye/client.js"
    end

Importr will manage the event publication for errors and send notifications with FayeWrapper.publish.

### Faye Wrapper example

In config/initializers/faye.rb write something like

    WS_CLIENT = Faye::Client.new('http://localhost:8000/faye')

    class FayeWrapper
      def self.publish(channel, message)
        run_event_machine
        puts "#{channel} #{message}"
        WS_CLIENT.publish(channel, message)
      end

      def self.run_event_machine
        Thread.new { EM.run } unless EM.reactor_running?
        Thread.pass until EM.reactor_running?
      end
    end

Finnaly you must to run a Faye server

## Dependencies

[SideKiq](https://github.com/mperham/sidekiq)

[CarrierWave](https://github.com/carrierwaveuploader/carrierwave)
{'fraction_non_alphanumeric': 0.09548793284365163, 'fraction_numerical': 0.005036726128016789, 'mean_word_length': 3.5651340996168583, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 12, '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': '6729234', 'n_tokens_mistral': 1485, 'n_tokens_neox': 1410, 'n_words': 390}