Rakefile in unicode-display_width-0.3.1 vs Rakefile in unicode-display_width-1.0.0
- old
+ new
@@ -43,42 +43,21 @@
# Update index table
namespace :update do
desc "#{gemspec.name} | Update index"
task :index do
- require File.dirname(__FILE__) + '/lib/unicode/display_width'
- data = File.open Unicode::DisplayWidth::DATA_FILE
- data.rewind
- table = {}
- dir = File.dirname Unicode::DisplayWidth::TABLE_FILE
- Dir.mkdir(dir) unless Dir.exists?(dir)
- data.each_line{ |line|
- line =~ /^(\S+?);(\S+)\s+#.*$/
- if $1 && $2
- cps, width = $1, $2
- if cps['..']
- range = Range.new(*cps.split('..').map{ |cp| cp.to_i(16) })
- range.each{ |cp| table[ cp ] = width.to_sym }
- else
- table[ cps.to_i(16) ] = width.to_sym
- end
- end
-
- }
- File.open(Unicode::DisplayWidth::TABLE_FILE, 'wb') { |f| Marshal.dump(table, f) }
+ require File.dirname(__FILE__) + '/lib/unicode/display_width/index_builder'
+ Unicode::DisplayWidth::IndexBuilder.build!
end
end
# # #
# Update data file
namespace :update do
desc "#{gemspec.name} | Update unicode data"
task :data do
- require File.dirname(__FILE__) + '/lib/unicode/display_width'
- require 'open-uri'
- open("http://www.unicode.org/Public/UNIDATA/EastAsianWidth.txt") { |f|
- File.write(Unicode::DisplayWidth::DATA_FILE, f.read)
- }
+ require File.dirname(__FILE__) + '/lib/unicode/display_width/index_builder'
+ Unicode::DisplayWidth::IndexBuilder.fetch!
end
end