Jun 1, 2015 - First week progress

Introduction

Hi, first week of GSOC 2015 is over and in this post I want to explain what progress I had and provide you some thoughts about my objectives for the next week.

Working features

GnuplotRB gem already may be used to plot some 2D graphs. It can plot math functions, data given in file or in Ruby Array. You may plot in cartesian or polar coordinates and set functions with parametric formulas.

I think examples from repository are more informative. Most of them are used to test gnuplot gem in specs so you may be sure they work since Travis CI builds are successful.

Plotting data from existing file

When you need to plot data from file you should not read it and them pass to gem as data. All you need is to pass file name. In this case file is not read by Ruby and piped out to Gnuplot. Only its name piped out to Gnuplot. And Gnuplot takes care of reading and plotting itself. Plotting from datafiles with gnuplot gem works as fast as with Gnuplot itself.

More information and samples of that case may be found in mailing list.

Installation (variant used during development)

Dependencies:

  • Ruby 2.0.0+
  • Gnuplot 5.0+

How to install with Gemfile

  • create Gemfile with following contents
source 'https://rubygems.org'
gem 'gnuplotrb', :git => 'https://github.com/dilcom/gnuplotrb.git'
  • run 'bundle install' in directory with Gemfile

How to install without creating Gemfile

Run following commands:

git clone https://github.com/dilcom/gnuplotrb.git
cd gnuplotrb
bundle install
rake install

Usage

require 'gnuplotrb'
include GnuplotRB
  
# see examples

Examples: https://github.com/dilcom/gnuplotrb/tree/master/examples

Objectives for this week

This week I'm going to focus on trying to use Daru for storage data in memory. I will also need to write specs for Datablock and Plot. And finally I'm going to share the gem and samples with community to recieve feedbacks and make gem better.

May 23, 2015 - Project state before coding starts

About my project

Hi, this summer I will develop new Ruby gem for Gnuplot. I aim to build a new user-friendly interface for such an amazing plotting tool which will support modern Gnuplot features such as multiplot and data inside here-doc.

Much more detailed information about the new gem and development process may be found in my proposal.

I wrote that proposal about two months ago and spent this time to think more about my project and make some preparation to coding phase. And in this post I want to share with you my thoughts and show what is already done.

Functional approach

My proposal does not contain any thoughts about programming style I'm going to use. After discussion with my mentor we decided to choose functional style.

I often use functional style in my Ruby code since it improves readability and safety. It also decreases amount of code I need to write because in functional style one should explain *what* to do, not *how*.

All above is pretty nice but developing a gem in functional style it's not only about using each\map\inject in every fitting place. Functional style also comes with some requirements to functions such as absence of side-effects. Since all the functions I'm going to develop are class methods, in order to avoid side-effects I'm going to make objects immutable.

Immutability is a good thing but in this case it may be very inefficient because Gnuplot often works with huge datasets and one of the new gem features is using temporary files for storage to append to them as data updates. Making everything immutable will make the gem to copy this files before update and only then appending them. Because of this I prefer the Ruby way of implementation immutability: every method that changes object's state should have two versions, the first one (default, named like #set_options(...)) creates new object with updated data, and the second one (it's name ends with !) changes the existing object. I also want to not allow methods like #option= to avoid modifying objects.

I expect it will both make code safe and allow users to avoid unnecessary copying when they really need high performance.

Preparations

As I already mentioned in my proposal, I was going to setup continuos integration tools for my repository. During my preparations to coding phase I worked on installing gnuplot 5.0 at Travis CI virtual machine and successed.

I also wrote some tests with RSpec. This tests are based on examples I already have. All of them use both command line and gem to plot some graphs and them compare them using ChunkyPNG's #eql? method. Test considered as passed if images are equal.

So anytime the project may be checked for such characteristics as:

  • Current build status Build status
  • Current code quality (via CodeClimate) Code quality
  • Test coverage (via CodeClimate) Test coverage

Future work

In nearest feature I'm going to start moving along my timeline and next week I will end implementation of Terminal, Dataset and Datablock classes. I also want to spend some time to make my existing code safe in terms of functional style.

Hope you'll like it when the gem will come to its working state.