Coach4rb

Coach4rb is a quick and dirty client solution for the Cyber Coach Webservice @unifr.ch.

For more details see.

Principles:

Some examples

Example: Retrieving a user: ruby @coach_user = @coach.user_by_uri '/CyberCoachServer/resources/users/arueedlinger' # get a user by its uri @coach_user = @coach.user 'arueedlinger' # get a user

Example: Encapsulating a coach client behind a proxy

@proxy = Coach4rb::Proxy::Access.new 'arueedlinger', 'muha', @coach #@coach is our coach client

Example: Updating a user: “`ruby @uri = '/CyberCoachServer/resources/users/arueedlinger' @proxy.update_user(@uri) do |user| user.real_name = 'Alex Rueedlinger' end

@user = @coach.user 'arueedlinger' # get a user @proxy.update_user(@user) do |user| user.real_name = 'Alex Rueedlinger' end



## Installation

Add this line to your application's Gemfile:

ruby gem 'coach4rb' “`

And then execute:

$ bundle

Or install it yourself as:

$ gem install coach4rb

Usage

For testing the examples on this page open a terminal and run the ruby shell: irb

Now, require the gem 'coach4rb'

require 'coach4rb'

Documentation

For a better understanding how the client works see the code examples in the file: lib/coach4rb/coach.rb and have a look at the tests with prefix test_coach_X.

Configuration

Coach4rb can be easily configured as the following example shows:

@coach = Coach4rb.configure(
        scheme: 'http',
        host: 'diufvm31.unifr.ch',
        port: 8090,
        path: '/CyberCoachServer/resources'
    )

Without the debug options all coach4rb exceptions are catched. By adding the option debug: true all exceptions are 'ducked' to the caller.

@coach = Coach4rb.configure(
        scheme: 'http',
        host: 'diufvm31.unifr.ch',
        port: 8090,
        path: '/CyberCoachServer/resources',
        debug: true
    )

To be sure that Coach4rb is correctly configured the method valid? can be executed for testing purposes.

@coach.available? # => true | false

Contributing

  1. Fork it ( github.com/[my-github-username]/coach4rb/fork )

  2. Create your feature branch (git checkout -b my-new-feature)

  3. Commit your changes (git commit -am 'Add some feature')

  4. Push to the branch (git push origin my-new-feature)

  5. Create a new Pull Request