Skip to content

Commit

Permalink
Finalizing 1.3 release with custom hyphens.
Browse files Browse the repository at this point in the history
  • Loading branch information
halostatue committed Jun 21, 2012
1 parent 8a35678 commit 86deef6
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 15 deletions.
9 changes: 9 additions & 0 deletions History.rdoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
== 1.3 / 2012.06.20
* Feature:
* Cezary Baginsky (https://github.com/e2) added the ability to specify a
hyphen character (such as the HTML soft-hyphen entity) instead of always
using the dash-hyphen.
* Added a new option to bin/ruby-hyphen to support the new feature.
* Bug Fix:
* bin/ruby-hyphen didn't work when visualizing to a size. Fixed.

== 1.2.1 / 2012.04.05
* Bug Fix:
* Fixed some typos in the README
Expand Down
8 changes: 4 additions & 4 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ hyphenation pattern files are based on the sources available from
{CTAN}[http://www.ctan.org] as of 2004.12.19 and have been manually translated
by Austin Ziegler.

This is a minor release fixing documentation errors. This release provides both
Ruby 1.8.7 and Ruby 1.9.2 support. This is the last major release supporting
Ruby 1.8 interpreters. Future versions will only work with Ruby 1.9 or later
interpreters.
This is a small feature release adding support for custom hyphens and fixing a
bug in ruby-hyphen. This release provides both Ruby 1.8.7 and Ruby 1.9.2
support. This is the last major release supporting Ruby 1.8 interpreters.
Future versions will only work with Ruby 1.9 or later interpreters.

== Where

Expand Down
19 changes: 9 additions & 10 deletions bin/ruby-hyphen
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,12 @@

require 'optparse'
require 'ostruct'

begin
require 'text/hyphen'
rescue LoadError
require 'rubygems'
require 'text/hyphen'
end
require 'text/hyphen'

options = OpenStruct.new
options.action = :visualise
options.dash = '-'

ARGV.options do |opt|
opt.banner = "Usage: #{File.basename($0)} [options] [mode] word+"
opt.separator ""
Expand Down Expand Up @@ -48,6 +44,9 @@ ARGV.options do |opt|
opt.on('-l', '--language LANGUAGE', 'Loads the specified language resource.') { |lang|
options.language = lang
}
opt.on('-d', '--hyphen DASH', 'Sets the hyphen character. If not provided, uses the normal hyphen ("-").') { |dash|
options.dash = dash
}

opt.separator ""
opt.on_tail('-h', '--help', 'Shows this help') {
Expand All @@ -63,7 +62,7 @@ end

if ARGV.empty? and options.action != :stats
$stderr.puts ARGV.options
exit 0
exit 1
end

hyphenator = Text::Hyphen.new do |h|
Expand All @@ -76,7 +75,7 @@ case options.action
when :visualise
size = 80
ARGV.each do |word|
vis = hyphenator.visualise(word)
vis = hyphenator.visualise(word, options.dash)
if (size - vis.size - 1) < 0
puts
size = 80
Expand All @@ -95,7 +94,7 @@ when :hyphenate
when :hyphenate_to
size = 80
ARGV.each do |word|
vis = hyphenator.visualise_to(word, options.size)
vis = hyphenator.hyphenate_to(word, options.size, options.dash)
if (size - vis.size - 1) < 0
puts
size = 80
Expand Down
5 changes: 4 additions & 1 deletion lib/text/hyphen.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- ruby encoding: utf-8 -*-

module Text # :nodoc:
end

Expand All @@ -7,7 +8,7 @@ module Text # :nodoc:
# a specific language's hyphenation patterns.
class Text::Hyphen
DEBUG = false
VERSION = '1.2.1'
VERSION = '1.3'

DEFAULT_MIN_LEFT = 2
DEFAULT_MIN_RIGHT = 2
Expand Down Expand Up @@ -259,3 +260,5 @@ def self.require_real_hyphenation_file(loader) # :nodoc:
require File.join(p, v, f)
end
end

# vim: syntax=ruby

0 comments on commit 86deef6

Please sign in to comment.