Ruby gem for Solve Media's API
Ruby
Latest commit dc14afd Nov 29, 2012 SolveMedia Merge pull request #7 from tylercunnion/master
Rails 3
Permalink
Failed to load latest commit information.
generators/solvemedia_config Generator fix Sep 3, 2010
lib Rails 3 compatibility May 4, 2012
LICENSE initial commit Sep 3, 2010
README.rdoc Documentation change Sep 3, 2010
Rakefile initial commit Sep 3, 2010
VERSION initial commit Sep 3, 2010
init.rb initial commit Sep 3, 2010
install.rb initial commit Sep 3, 2010
solvemedia.gemspec Gemspec fix Sep 3, 2010
uninstall.rb initial commit Sep 3, 2010

README.rdoc

SolveMedia

Author:: Eddie Siegel Info:: www.solvemedia.com Documentation:: portal.solvemedia.com/portal/help/pub

Installation

SolveMedia can be installed as a gem by adding the following line to your environment.rb file:

config.gem "solvemedia"

And then running the following to install the gem:

sudo rake gems:install

Alternatively you can install SolveMedia as a plugin

script/plugin install git://github.com/SolveMedia/SolveMedia.git

API Keys

Your Solve Media API keys should be stored in config/solvemedia_config.yml, which can be generated by running

script/generate solvemedia_config

Don't forget to edit the generated file to contain your API keys.

Adding A Solve Media Puzzle To A View

Displaying a Solve Media Puzzle is as simple as calling solvemedia_puzzle inside a form within your view. For example:

<% form_for(@user) do |f| %>
  # ...
  <p>
    <%= solvemedia_puzzle %>
  </p>
  # ...
<% end %>

The appearance of the puzzle can be adjusted by passing options to solvemedia_puzzle. For a full list of options, see the documentation.

Verifying The Input To A Solve Media Puzzle In A Controller

The verify_solvemedia_puzzle method verifies the user's input and returns true if the user provided the correct input. In the simplest case, verification could be performed as follows:

respond_to do |format|
  if verify_solvemedia_puzzle && @user.save
    # ...
  else
    # ...
  end
end

verify_solvemedia_puzzle can also be used to add an error to a model object if the verification fails:

respond_to do |format|
  if verify_solvemedia_puzzle(:model => @user, :error_message => 'Solve Media puzzle input is invalid') && @user.save
    # ...
  else
    # ...
  end
end

See the documentation for a full list of options accepted by verify_solvemedia_puzzle.