Ruby development kit for prismic.io
Getting Started
Install the kit for your project
(Assuming that Ruby is installed on your computer, as well as RubyGems)
To install the gem on your computer, run in shell:
gem install prismic.io --pre
then add in your code:
require 'prismic'
To add the gem as a dependency to your project with Bundler, you can add this line in your Gemfile:
gem 'prismic.io', require: 'prismic'
Get started with prismic.io
You can find out how to get started with prismic.io on our prismic.io developer's portal.
Get started using the kit
Also on our prismic.io developer's portal, on top of our full documentation, you will:
- get a thorough introduction of how to use prismic.io kits, including this one.
- see what else is available for Ruby: starter projects, examples, ...
Kit's detailed documentation
To get a detailed documentation of the Ruby kit's variables and methods, please check out the prismic.io Ruby kit's documentation.
Thanks to Ruby's syntax, this kit contains some mild differences and syntastic sugar over the "Kits and helpers" section of our API documentation in general (which you should read first). They are listed here:
- When calling the API, a faster way to pass the
ref
: directly as a parameter of thesubmit
method (no need to use theref
method then):api.form("everything").submit(@ref)
. - Accessing type-dependent fields from a
document
is done through the[]
operator (rather than aget()
method). Printing the HTML version of a field therefore looks likedocument["title_user_friendly"].as_html(link_resolver(@ref))
. - Two of the fields in the
DocumentLink
object (the one used to write yourlink_resolver
method, for instance) were renamed to fit Ruby's best practice:doc.type
is in factdoc.link_type
, anddoc.isBroken
is in factdoc.broken?
.
Changelog
Need to see what changed, or to upgrade your kit? We keep our changelog on this repository's "Releases" tab.
Contribute to the kit
Contribution is open to all developer levels, read our "Contribute to the official kits" documentation to learn more.
Install the kit locally
Of course, you're going to need Ruby installed on your computer, as well as RubyGems and Bundler.
Clone the kit, then run bundle install
.
Test
Please write tests for any bugfix or new feature, by placing your tests in the spec/ folder, following the RSpec syntax. Launch the tests by running bundle exec rspec
If you find existing code that is not optimally tested and wish to make it better, we really appreciate it; but you should document it on its own branch and its own pull request.
Documentation
Please document any bugfix or new feature, using the Yard syntax. Don't worry about generating the doc, we'll take care of that.
If you find existing code that is not optimally documented and wish to make it better, we really appreciate it; but you should document it on its own branch and its own pull request.
Licence
This software is licensed under the Apache 2 license, quoted below.
Copyright 2013 Zengularity (http://www.zengularity.com).
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this project except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.