Socket
Book a DemoInstallSign in
Socket

iraq_unrest

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

iraq_unrest

0.0.2
bundlerRubygems
Version published
Maintainers
1
Created
Source

IraqUnrest

Code Climate Build Status

Ruby library to assist in the visualization of Iraq data shared by Agence France-Presse.

Example
  • Supports serialzing into JSON, and Rickshaw.js data structures.
  • Renders formatted CSV or HTML to file or string.

Installation

$ gem install iraq_unrest

Usage

Data

Requests are made to a Google Spreadsheet provided by Agence France-Presse. If you have any questions about the data, please contact AFP's Baghdad Bureau

Data sets currently supported:

  • IraqiCasualtiesComparison
  • IraqGovernmentCasualtyFigures

Each data set has Ruby methods for serializing and formatting records.

Visualization

A visualize! method is provided to create a time-series chart using HTML/Rickshaw.js

irb(main):002:0> IraqUnrest::IraqiCasualtiesComparison.visualize!

=> #<File:iraqi_casualties_comparison.html (closed)>
Iraqi Casualties Comparison Graph
irb(main):001:0> IraqUnrest::IraqGovernmentCasualtyFigure.visualize!

=> #<File:iraq_government_casualty_figure.html (closed)>
Iraq Government Casualty Figure Graph

Serialization

JSON

Use ActiveModel::Serializers to return all records as a JSON Array

irb(main):003:0> IraqUnrest::IraqGovernmentCasualtyFigure.as_json

[
    [ 0] {
                    :date => 1383202800,
         :civilian_killed => "855",
           :police_killed => "65",
             :army_killed => "44",
        :civilian_wounded => "1445",
          :police_wounded => "88",
            :army_wounded => "67",
           :insurg_killed => "33",
         :insurg_arrested => "167"
    },
    ...
]

Rickshaw

Return all records as a JSON hash, using each attribute as a segment. This data set can then be rendered into a Rickshaw.js graph.

irb(main):004:0> IraqUnrest::IraqiCasualtiesComparison.as_rickshaw

{
                :afp => [
        [  0] {
            :x => 1075536000,
            :y => 0
        },
        [117] {
            :x => 1383202800,
            :y => 743
        }
    ],
           :iraq_gov => [...],
    :iraq_body_count => [...]
}

Formatting

CSV

CSV methods provide clean and formatted data as a string or file.

Creates a CSV file in local working directory

irb(main):005:0> IraqUnrest::IraqGovernmentCasualtyFigure.to_csv!

=> #<File:iraq_government_casualty_figure.csv (closed)>

As a string

irb(main):006:0> IraqUnrest::IraqGovernmentCasualtyFigure.to_csv

=> "date,civilian_killed,police_killed,army_killed,civilian_wounded,police_wounded..."

Contributing

  • Fork it
  • Create your feature branch (git checkout -b my-new-feature)
  • Commit your changes (git commit -am 'Add some feature')
  • Push to the branch (git push origin my-new-feature)
  • Create new Pull Request

FAQs

Package last updated on 13 Nov 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.