35d6615
= rubygem-asciidoctor: Asciidoctor RPM package spec
35d6615
35d6615
This repository hosts the RPM package spec file for the https://github.com/erebor/asciidoctor[Asciidoctor] library. The package is named `rubygem-asciidoctor`.
35d6615
35d6615
== Prerequisites
35d6615
320bd91
This RPM spec was developed for Fedora 17 and above, but may be useful for other RPM-based systems.
35d6615
35d6615
== Preparing your environment
35d6615
dc8be8c
You first need to install the packages necessary to build the RPM. Begin by installing the `@fedora-packager` group (as root or using sudo):
35d6615
dc8be8c
 yum install @fedora-packager wget
35d6615
35d6615
Next, clone this repository and switch to it:
35d6615
320bd91
 git clone git://github.com/asciidoctor/rubygem-asciidoctor-rpm.git 
320bd91
 cd rubygem-asciidoctor-rpm
35d6615
dc8be8c
Finally, install the packages that this build requires (as root or using sudo):
35d6615
35d6615
 yum-builddep rubygem-asciidoctor.spec
35d6615
35d6615
Next, we need to put the package source and patches in place.
35d6615
35d6615
== Preparing the sources
35d6615
35d6615
You can build RPMs as a non-privileged user, though you need to prepare the directories first. Let's use the directory rpmbuild in our `$HOME` directory:
35d6615
35d6615
 echo "%_topdir %(echo $HOME)/rpmbuild" > $HOME/.rpmmacros
35d6615
35d6615
You'll also need to create all the required folders:
35d6615
35d6615
 mkdir -p $HOME/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
35d6615
35d6615
Next, grab the Asciidoctor gem (the sources) and put it into the `$HOME/rpmbuild/SOURCES` directory:
35d6615
dc8be8c
 wget -O $HOME/rpmbuild/SOURCES/asciidoctor-0.1.1.gem http://rubygems.org/gems/asciidoctor-0.1.1.gem
35d6615
35d6615
Finally, copy the `.patch` files from this repository to the same directory:
35d6615
dc8be8c
 cp patches/* $HOME/rpmbuild/SOURCES/
35d6615
35d6615
You're now ready to build the RPM.
35d6615
35d6615
== Building the RPM
35d6615
35d6615
With everything in place, building the RPM is easy!
35d6615
35d6615
 rpmbuild -ba rubygem-asciidoctor.spec
35d6615
35d6615
If all goes well, both the binary and source RPMs will emerge in the `$HOME/rpmbuild/RPMS/noarch` and `$HOME/rpmbuild/SRPMS` directories, respectively.
35d6615
35d6615
== Installing the RPM
35d6615
35d6615
There's nothing special about installing this RPM. I recommend using `yum` because it will install any dependencies that the package requires (though you should already have them if you built the RPM).
35d6615
dc8be8c
 yum localinstall $HOME/rpmbuild/RPMS/noarch/rubygem-asciidoctor-0.1.1.rpm
35d6615
35d6615
Now, it's time to start using Asciidoctor!
35d6615
35d6615
== Basic Asciidoctor usage
35d6615
35d6615
Create a file named asciidoctor-test.rb and populate it with the following code:
35d6615
06ca8ed
  require 'asciidoctor'
06ca8ed
  content = "= My First Document\n\nRender me some **HTML**!"
dc8be8c
  puts Asciidoctor.render(content, :header_footer => true, :compact => true)
35d6615
35d6615
Now execute the file with Ruby:
35d6615
35d6615
 ruby asciidoctor-test.rb
35d6615
35d6615
You should see the HTML output to your terminal. You can update your script to write it to a file, or just redirect the output:
35d6615
35d6615
 ruby asciidoctor-test.rb > test.html
35d6615
35d6615
Open up your browser to see the result!