Skip to content
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.

Commit

Permalink
Eliminate all duplicate occurrences of the RDoc version that Hanna us…
Browse files Browse the repository at this point in the history
…es, which

will make it very easy to change this version in the future.  Now, Hanna's RDoc
version can be changed simply by altering RDOC_VERSION in
lib/hanna/rdoc_version.rb.
  • Loading branch information
DesigningPatterns committed Aug 20, 2008
1 parent d6ae5d0 commit 017a4d7
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 16 deletions.
12 changes: 4 additions & 8 deletions bin/hanna
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,14 @@ HELP
end

require 'rubygems'
begin
gem 'rdoc', '~> 2.1.0'
rescue Gem::LoadError
$stderr.puts "Hanna requires the RDoc 2.1 gem."
exit 1
else
require 'rdoc/rdoc'
end

hanna_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
$:.unshift(hanna_dir) unless $:.include?(hanna_dir)

require 'hanna/rdoc_version'
Hanna::require_rdoc
require 'rdoc/rdoc'

require 'hanna/rdoc_patch'

options = []
Expand Down
9 changes: 7 additions & 2 deletions hanna.gemspec
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
#
# This can be made cleaner by using the relative gem.
#
require File.join(File.dirname(__FILE__), "lib/hanna/rdoc_version")

This comment has been minimized.

Copy link
@mislav

mislav Aug 21, 2008

Owner

GitHub doesn’t allow this in gemspecs, you’ll just have to hardcode it.


Gem::Specification.new do |s|
s.name = 'hanna'
s.version = '0.1.3'
Expand All @@ -12,8 +17,8 @@ Gem::Specification.new do |s|

s.executables = ['hanna']
s.has_rdoc = false
s.add_dependency 'rdoc', ['~> 2.1.0']
s.add_dependency 'rdoc', [Hanna::RDOC_VERSION_REQUIREMENT]
s.add_dependency 'haml', ['~> 2.0']

s.files = %w(README.markdown Rakefile bin bin/hanna lib lib/hanna lib/hanna.rb lib/hanna/hanna.rb lib/hanna/rdoc_patch.rb lib/hanna/rdoctask.rb lib/hanna/template_files lib/hanna/template_files/class_index.haml lib/hanna/template_files/file_index.haml lib/hanna/template_files/index.haml lib/hanna/template_files/layout.haml lib/hanna/template_files/method_list.haml lib/hanna/template_files/page.haml lib/hanna/template_files/sections.haml lib/hanna/template_files/styles.sass lib/hanna/template_helpers.rb lib/hanna/template_page_patch.rb)
s.files = %w(README.markdown Rakefile bin bin/hanna lib lib/hanna lib/hanna.rb lib/hanna/hanna.rb lib/hanna/rdoc_patch.rb lib/hanna/rdoc_version.rb lib/hanna/rdoctask.rb lib/hanna/template_files lib/hanna/template_files/class_index.haml lib/hanna/template_files/file_index.haml lib/hanna/template_files/index.haml lib/hanna/template_files/layout.haml lib/hanna/template_files/method_list.haml lib/hanna/template_files/page.haml lib/hanna/template_files/sections.haml lib/hanna/template_files/styles.sass lib/hanna/template_helpers.rb lib/hanna/template_page_patch.rb)
end
21 changes: 21 additions & 0 deletions lib/hanna/rdoc_version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module Hanna
#
# The version of RDoc that Hanna should use.
#
RDOC_VERSION = '2.1.0'
RDOC_VERSION_REQUIREMENT = "~> #{RDOC_VERSION}"

#
# This method loads the correct version of RDoc. If the correct
# version of RDoc is not present, this method will terminate the
# program with a helpful error message.
#
def self.require_rdoc
begin
gem 'rdoc', RDOC_VERSION_REQUIREMENT
rescue Gem::LoadError
$stderr.puts "Error: hanna requires the RDoc #{RDOC_VERSION} gem!"
exit 1
end
end
end
9 changes: 3 additions & 6 deletions lib/hanna/rdoctask.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'hanna/rdoc_version'

require 'rake'
require 'rake/rdoctask'

Expand Down Expand Up @@ -31,12 +33,7 @@ def define
task name => [rdoc_target]
file rdoc_target => @rdoc_files + [$rakefile] do
rm_r @rdoc_dir rescue nil

begin
gem 'rdoc', '~> 2.1.0'
rescue Gem::LoadError
$stderr.puts "Couldn't load RDoc 2.1 gem"
end
Hanna::require_rdoc
require 'rdoc/rdoc'
require 'hanna/rdoc_patch'

Expand Down

3 comments on commit 017a4d7

@ELLIOTTCABLE
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest using echoe, and a task to generate a github-safe gemspec. That’s what I do.

@DesigningPatterns
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That’s a really annoying github restriction, although understandable. Thanks for the echoe suggestion; that seems very reasonable to me.

@DesigningPatterns
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I committed the changes. Hanna now uses the echoe gem to generate a gemspec.

Please sign in to comment.