Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
This is a ruby library for interacting with v2 of the Crocodoc API.
Ruby
branch: master

This branch is 3 commits ahead of instructure:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
spec
.gitignore
Gemfile
LICENSE
README.md
crocodoc-ruby-0.0.2.gem
crocodoc-ruby.gemspec

README.md

Crocodoc Ruby

This is a ruby library for interacting with v2 of the Crocodoc API.

Rails Installation

Add this line to your application's Gemfile:

gem 'crocodoc-ruby', :require => 'crocodoc'

And then execute:

$ bundle

Or install it yourself as:

$ gem install crocodoc-ruby

Configuration

$ rails g crocodoc:install --api-token your_token_here

The generator adds two files for your rails project:

  • config/crocodoc.yml
  • config/initializers/crocodoc.rb

Customise the config/crocodoc.yml config file if you wish to use different API tokens per environment (by default it uses the same token in development, test and production).

Rails application

The Crocodoc API is configured during rails initialization, and no further configuration is nessecary before use.

Non-rails application

When using the Crocodoc gem in a non-rails application, you must configure it to use your Crocodoc Token manually:

Crocodoc.configure do |config|
    config.token = 'MY_CROCODOC_TOKEN'
end

Usage

Once configured, you can start using the API:

Upload a document

crocodoc = Crocodoc::API.new
doc = crocodoc.upload("http://www.example.com/test.doc")

# => {"uuid"=>"732b17dd-1fd6-49b1-8a2f-58ec9f6dc381"}

Get the status of a document

crocodoc.status('732b17dd-1fd6-49b1-8a2f-58ec9f6dc381')

# => {"status"=>"DONE", "viewable"=>true, "uuid"=>"732b17dd-1fd6-49b1-8a2f-58ec9f6dc381"}

Delete a document

crocodoc.delete('732b17dd-1fd6-49b1-8a2f-58ec9f6dc381')

# => true

Create a session

crocodoc_session = crocodoc.session('732b17dd-1fd6-49b1-8a2f-58ec9f6dc381')

# => { "session": "CFAmd3Qjm_2ehBI7HyndnXKsDrQXJ7jHCuzcRv_V4FAgbSmaBkFrDRS8KX8m-Ur9MdZFbH3ykKdZ7cZswFqrDKX965nba9-MW0DiiA" }

View a document

url = crocodoc.view('CFAmd3Qjm_2ehBI7HyndnXKsDrQXJ7jHCuzcRv_V4FAgbSmaBkFrDRS8KX8m-Ur9MdZFbH3ykKdZ7cZswFqrDKX965nba9-MW0DiiA')

Download a document

download_url = crocodoc.download('732b17dd-1fd6-49b1-8a2f-58ec9f6dc381')

Download a document thumbnail

download_url = crocodoc.thumbnail('732b17dd-1fd6-49b1-8a2f-58ec9f6dc381')

Download extracted text

document_text = crocodoc.text('732b17dd-1fd6-49b1-8a2f-58ec9f6dc381')

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request
Something went wrong with that request. Please try again.