Rakefile: fix typos in prompts.

This commit is contained in:
vonavi 2014-02-05 02:31:05 +02:00
parent cbfbe9876d
commit 4cb558788f

View File

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
extend Math
require 'rake' require 'rake'
# The year and title of tournament # The year and title of tournament
@ -23,7 +24,7 @@ yaml_file = File.expand_path("#{@year}/#{@tournament}/players.yml", file_dir)
@player_lichess[lichess] = player['lor'] @player_lichess[lichess] = player['lor']
end end
# Fix a player name in PGN # Fix the player's name in PGN
def fix_player color, name def fix_player color, name
str = File.open('temp.pgn', 'r') { |f| f.read } str = File.open('temp.pgn', 'r') { |f| f.read }
player_regex = Regexp.new "^\\[#{color.capitalize} \".*\"\\]$" player_regex = Regexp.new "^\\[#{color.capitalize} \".*\"\\]$"
@ -31,7 +32,7 @@ def fix_player color, name
File.open('temp.pgn', 'w+') do |f| File.open('temp.pgn', 'w+') do |f|
f.write(parts[0] + "[#{color.capitalize} \"#{name}\"]" + parts[2]) f.write(parts[0] + "[#{color.capitalize} \"#{name}\"]" + parts[2])
end end
puts "The 'lichess' name '#{name}' of #{color} player incorporated into PGN" puts "The 'lichess' name of #{color} player is changed to '#{name}'"
end end
# Fix the game date in PGN: YYYY-MM-DD -> YYYY.MM.DD # Fix the game date in PGN: YYYY-MM-DD -> YYYY.MM.DD
@ -51,14 +52,15 @@ end
# Returns the 'lichess' name of player to be corrected # Returns the 'lichess' name of player to be corrected
def choose_player def choose_player
print "Would you like to correct the player name? (Y/N) > " print "Would you like to correct the player's name? (Y/N)> "
answer = $stdin.gets.chomp answer = $stdin.gets.chomp
if ['Yes', 'yes', 'Y', 'y'].include? answer if ['Yes', 'yes', 'Y', 'y'].include? answer
indention = (log(@config.size) / log(10)).floor + 1
@config.each do |player| @config.each do |player|
puts "%2.0f. %s" % [ player['number'], player['lor'] ] puts "%#{indention}.0f. %s" % [ player['number'], player['lor'] ]
end end
print "Put the player number > " print "Put the player's number> "
num = Integer $stdin.gets.chomp num = Integer $stdin.gets.chomp
@config[num-1]['lichess'] @config[num-1]['lichess']
else else
@ -78,7 +80,7 @@ def pgn_dirs
black = @player_lichess[black_lichess] black = @player_lichess[black_lichess]
unless white unless white
puts "Could not recognize white player '#{white_lichess}'" puts "Could not find white player '#{white_lichess}'"
name = choose_player name = choose_player
fix_player 'white', name fix_player 'white', name
white = @player_lichess[name] white = @player_lichess[name]
@ -115,7 +117,7 @@ end
# Choose and make the directory to move PGN file in # Choose and make the directory to move PGN file in
def choose_and_mk_dir dirs def choose_and_mk_dir dirs
puts "Choose a directory of PGN file from the list below:" puts "Choose a directory of PGN file from the list below:"
dirs.each_with_index { |dir, index| puts "%2.0f. %s" % [index+1, dir] } dirs.each_with_index { |dir, index| puts "%1.0f. %s" % [index+1, dir] }
print "Create a directory? (Number)> " print "Create a directory? (Number)> "
num = Integer $stdin.gets.chomp num = Integer $stdin.gets.chomp