35d6615
= rubygem-asciidoctor: Asciidoctor RPM package spec
5501ef6
Dan Allen
5501ef6
:idprefix:
ceeaf60
:idseparator: -
9cac499
:compat-mode!:
Dan Allen 27b5874
:gem_title: Asciidoctor
Dan Allen 27b5874
:gem_name: asciidoctor
9cac499
:gem_version: 1.5.2
Dan Allen 27b5874
:gem_gem: {gem_name}-{gem_version}.gem
Dan Allen 27b5874
:gem_url: https://github.com/asciidoctor/asciidoctor
Dan Allen 27b5874
:rpm_name: rubygem-{gem_name}
Dan Allen 27b5874
:rpm_rpm: {rpm_name}-{gem_version}.rpm
Dan Allen 27b5874
:rpm_repo: git://github.com/asciidoctor/rubygem-asciidoctor-rpm.git
35d6615
9cac499
This repository is the official host of the build materials to create the Fedora RPM package for the https://github.com/asciidoctor/asciidoctor[Asciidoctor] Ruby Gem.
9cac499
The RPM package is named `rubygem-asciidoctor`.
35d6615
ceeaf60
While this RPM spec was developed specifically for Fedora 18 and above, it may be useful for other RPM-based systems.
35d6615
5501ef6
== Build the Asciidoctor RPM
35d6615
5501ef6
If you want to build the RPM on your own machine, follow the instructions in this section.
5501ef6
If you want to test a pre-built package, skip to the next section on <<test-the-asciidoctor-rpm-and-report-feedback,testing the RPM>>.
5501ef6
5501ef6
=== Preparing your environment
35d6615
Dan Allen 27b5874
You first need to install the packages necessary to build the RPM.
9cac499
Begin by installing the `@fedora-packager` group (as root or using sudo):
35d6615
9cac499
 yum install -y @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
5501ef6
=== Preparing the sources
35d6615
5501ef6
You can build RPMs as a non-privileged user, though you need to prepare the directories first.
9cac499
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
9cac499
Next, grab the Asciidoctor gem (the sources) and put it into the `$HOME/rpmbuild/SOURCES` directory:
35d6615
9cac499
 wget -O $HOME/rpmbuild/SOURCES/asciidoctor-1.5.2.gem http://rubygems.org/gems/asciidoctor-1.5.2.gem
35d6615
9cac499
Finally, copy the `.patch` files from this repository to the same directory:
35d6615
Dan Allen 25c3495
 cp *.patch $HOME/rpmbuild/SOURCES/
35d6615
35d6615
You're now ready to build the RPM.
35d6615
5501ef6
=== Building the RPM
35d6615
35d6615
With everything in place, building the RPM is easy!
35d6615
35d6615
 rpmbuild -ba rubygem-asciidoctor.spec
35d6615
9cac499
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
b042612
Alternatively, you can build directly from the SRPM.
b042612
9cac499
 wget -P srpms http://kojipkgs.fedoraproject.org/packages/rubygem-asciidoctor/1.5.2/1.fc21/src/rubygem-asciidoctor-1.5.2-1.fc21.src.rpm
9cac499
 rpmbuild --rebuild srpms/rubygem-asciidoctor-1.5.2-1.fc21.src.rpm
b042612
b042612
The SPRMs are stored with the builds in the http://koji.fedoraproject.org/koji/packageinfo?packageID=15660[koji build system].
b042612
5501ef6
=== Installing the RPM
35d6615
5501ef6
There's nothing special about installing this RPM.
9cac499
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
9cac499
 yum install -y $HOME/rpmbuild/RPMS/noarch/rubygem-asciidoctor-1.5.2.rpm
35d6615
35d6615
Now, it's time to start using Asciidoctor!
35d6615
5501ef6
== Test the Asciidoctor RPM and report feedback
35d6615
9cac499
Before the Asciidoctor package (`rubygem-asciidoctor`) can be included in the Fedora distribution, it must be tested by users and receive karma via the http://admin.fedoraproject.org/updates[Bohdi system].
5501ef6
One way to provide this feedback is to use the http://admin.fedoraproject.org/pkgdb/acls/name/fedora-easy-karma[fedora-easy-karma] tool.
Sarah White 433091b
Sarah White 433091b
=== Enable the updates-testing repository temporarily
Sarah White 433091b
Sarah White 433091b
In a terminal, type:
Sarah White 433091b
9cac499
 yum install -y rubygem-asciidoctor --enablerepo=updates-testing
Sarah White 433091b
Sarah White 433091b
This command will download and install the asciidoctor package.
Sarah White 433091b
9cac499
=== Test the Asciidoctor API
Sarah White 433091b
Dan Allen a8c3364
First, let's test using Asciidoctor as a Ruby library.
Dan Allen a8c3364
9cac499
. On your computer, create a new file and name it `asciidoctor-test.rb`
Dan Allen a8c3364
. Copy and paste the following code into the file:
9cac499
+
9cac499
[source,ruby]
9cac499
----
9cac499
require 'asciidoctor'
9cac499
content = "= My First Document\n\nRender me some **HTML**!"
9cac499
puts Asciidoctor.render content, :header_footer => true
9cac499
----
35d6615
Sarah White 433091b
. Save the file.
9cac499
. In a terminal, navigate to the directory where you saved `asciidoctor-test.rb` and type the following command to execute the file with Ruby:
35d6615
35d6615
 ruby asciidoctor-test.rb
Sarah White 433091b
+
Sarah White 433091b
You should see this output in your terminal.
9cac499
+
9cac499
[source,html]
9cac499
----
9cac499
9cac499
<html lang="en">
9cac499
<head>
9cac499
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
9cac499
<meta name="generator" content="Asciidoctor 1.5.2">
9cac499
<meta name="viewport" content="width=device-width, initial-scale=1.0">
9cac499
<title>My First Document</title>
9cac499
<link rel="stylesheet" href="./asciidoctor.css">
9cac499
</head>
9cac499
<body class="article">
9cac499
9cac499

My First Document

9cac499
9cac499
9cac499
9cac499
9cac499
9cac499

Render me some HTML!

9cac499
9cac499
9cac499
9cac499
9cac499
9cac499
9cac499
Last updated 2013-09-22 17:35:41 MDT
9cac499
9cac499
9cac499
</body>
9cac499
</html>
9cac499
----
Sarah White 433091b
Sarah White 433091b
. You can render the output as HTML using:
35d6615
Dan Allen a8c3364
 ruby asciidoctor-test.rb > asciidoctor-test.html
Dan Allen a8c3364
Dan Allen a8c3364
. Open your browser to see the result.
Dan Allen a8c3364
. Alternatively, if you're using Gnome, type:
Dan Allen a8c3364
Dan Allen a8c3364
 gnome-open asciidoctor-test.html
Dan Allen a8c3364
+
Dan Allen a8c3364
A new tab should open in your current browser session.
Dan Allen a8c3364
9cac499
=== Test the Asciidoctor CLI
Dan Allen a8c3364
9cac499
Now let's test using the Asciidoctor executable (i.e., CLI).
Dan Allen a8c3364
9cac499
. On your computer, create a new file and name it [path]_test.adoc_
9cac499
. Copy and paste the following markup into the file:
9cac499
+
9cac499
----
9cac499
= My Second Document
9cac499
Your Name
Dan Allen a8c3364
9cac499
AsciiDoc is _rockin'_ docs.
9cac499
----
Dan Allen a8c3364
Dan Allen a8c3364
. Save the file
9cac499
. In a terminal, navigate to the directory where you saved [path]_test.adoc_ and type the following command to run it through the Asciidoctor processor:
Dan Allen a8c3364
9cac499
 asciidoctor test.adoc
Dan Allen a8c3364
+
Dan Allen a8c3364
You shouldn't see any output in your terminal.
9cac499
That's because it writes the output to the file `test.html`.
35d6615
Dan Allen 27b5874
. Open your browser to see the result.
Dan Allen a8c3364
. Alternatively, if you're using Gnome, type:
Sarah White 433091b
Sarah White 433091b
 gnome-open test.html
Sarah White 433091b
+
Sarah White 433091b
A new tab should open in your current browser session.
Sarah White 433091b
Sarah White 433091b
=== Provide feedback with fedora-easy-karma
Sarah White 433091b
Sarah White 433091b
. If you don't have fedora-easy-karma installed on your computer, type the following command in a terminal.
Sarah White 433091b
9cac499
 yum install -y fedora-easy-karma
Sarah White 433091b
Sarah White 433091b
. Once fedora-easy-karma is installed, run it in the terminal.
Sarah White 433091b
Dan Allen a8c3364
 fedora-easy-karma --fas-username <yourFASaccount> *asciidoctor
Sarah White 433091b
+
9cac499
--
5501ef6
To be on the safe side, include the flag for your FAS account when you start fedora-easy-karma.
5501ef6
Once fedora-easy-karma runs, you will not be able to switch accounts.
9cac499
Sarah White 433091b
NOTE: It may take fedora-easy-karma several minutes to fetch the list of packages in updates-testing.
9cac499
9cac499
When fedora-easy-karma finds `rubygem-asciidoctor`, it will display a summary of the package and prompt you to give -1 (negative), 0 (neutral), or 1 (postive) karma to the package.
Dan Allen 27b5874
For more information about providing karma for packages and how to comment on packages, review the http://fedoraproject.org/wiki/QA:Update_feedback_guidelines[Fedora feedback guidelines].
9cac499
--
Sarah White 433091b
Sarah White 433091b
. Enter your karma rating.
5501ef6
. Next, you will be asked to provide additional, detailed feedback.
5501ef6
  Please comment whether the package worked as expected and you successfully used it, if you think you may have encountered an error, but aren't sure, or if you definitely encountered a bug.
Sarah White 433091b
. When prompted, enter your FAS password.
Sarah White 433091b
. W00t! The feedback process is complete.
Dan Allen 27b5874
. You can verify your feedback was recorded by visiting the https://admin.fedoraproject.org/updates[Bodhi updates page].