Acts as gem for Citero
Ruby HTML CSS JavaScript
Latest commit 5538f6f Mar 7, 2017 @ericgriffis ericgriffis committed on GitHub Merge pull request #17 from NYULibraries/feature/improve_tests
Improve tests
Permalink
Failed to load latest commit information.
lib Update version Jan 30, 2015
spec
.gitignore Install rspec rails; add first test Mar 1, 2017
.rspec
.ruby-version
.travis.yml Cache bundle install Mar 7, 2017
Gemfile Add some development dependencies Jan 30, 2015
MIT-LICENSE Fixes #9 Jun 14, 2013
README.md
README.rdoc Things can now act as citable Feb 25, 2013
Rakefile Remove test-unit Mar 7, 2017
acts_as_citable.gemspec Remove test-unit Mar 7, 2017

README.md

acts_as_citable

Build Status Build Status Coverage Status Dependency Status Gem Version Code Climate

Acts as gem for Citero. This gem allows an object to utilize Citero's translating properties.

Config

Simply put acts_as_citable in your model. If you have attributes named data and format, you are set. If you must configure, do the following.

    acts_as_citable do |c|
    	c.format_field = 'your_format_field_name'
    	c.fata_field = 'your_data_field_name'
	  end

How to use

Using acts_as_citable is easy! Once you have your model configured, simply use the to_format method on your model where format is one of the desired formats.

  • BibTeX
  • RIS
  • OpenURL
  • EasyBib
  • CSF (Citero Standard Format)

The results are returned as string. Additionally, you can have it render the format with a responds with action. You must have something like this in your controller.

class TestController < ApplicationController
	respond_to :ris, :bibtex, :json
	def test
		rec = Record.create(:data => "itemType: book", :format => "csf")
		arr = Array.new
		arr << rec
		respond_with(arr)
	end
end

Finally, to interact with the CSF object, you can call the csf method.

rec = Record.create(:data => "itemType: book", :format => "csf")
csf = rec.csf
p csf.itemType # => Prints ['book']
p csf.keys # => Prints ['itemType']