Class: GamesAndRpgParadise::Lpc::Checker
- Includes:
- GamesAndRpgParadise::Lpc
- Defined in:
- lib/games_and_rpg_paradise/lpc/utility_scripts/checker.rb
Constant Summary collapse
- BE_VERBOSE =
false
- LPC_START_COMMENT =
#
LPC_START_COMMENT
#
'/*'
- LPC_CLOSE_COMMENT =
#
LPC_CLOSE_COMMENT
#
'*/'
Constants included from GamesAndRpgParadise::Lpc
CHARACTERS_IN_GUILDS, CHARACTER_EXCLUSION_DATA, CHARS_PER_LINE, DEFAULT_NAME, FILE_CHARACTER_DATASET, FILE_GEAS_CHARACTER_EXCLUSION_DATA, GEAS_CHARACTER_EXCLUSION_DATA, GEAS_YAML, HASH_EXITS_EXPANDED, HASH_LPC_TO_RUBY, HASH_OPPOSITE_EXITS, N, PROJECT_BASE_DIRECTORY, RPG, SAVE_FILE
Constants included from Base::Extensions::Colours
Base::Extensions::Colours::ARRAY_AVAILABLE_KONSOLE_COLOURS
Constants included from CommonExtensions
CommonExtensions::CONTROL_C_CODE, CommonExtensions::N
Instance Method Summary collapse
-
#colourize_this(i, use_this_colour = 'slateblue') ⇒ Object
# === colourize_this ========================================================================= #.
-
#correct_or_not(brackets) ⇒ Object
# === correct_or_not.
-
#count_brackets ⇒ Object
# === count_brackets ========================================================================= #.
-
#initialize(this_file) ⇒ Checker
constructor
# === initialize ========================================================================= #.
-
#read_file(f) ⇒ Object
# === read_file ========================================================================= #.
-
#remove_comments_from_file ⇒ Object
# === remove_comments_from_file.
-
#reset ⇒ Object
# === reset ========================================================================= #.
-
#set_file(i) ⇒ Object
# === set_file ========================================================================= #.
Methods included from GamesAndRpgParadise::Lpc
add_lpc_comment, find_opposite_exit, parse_forum_dataset, project_base_dir?, #rev, #warn
Methods included from Base::Extensions::Colours
ecomment, #efancy, #eparse, #forestgreen, #gold, #grey, #lightblue, #mediumseagreen, #mediumslateblue, #peru, #rev, sdir, sfancy, #sfile, simp, #teal, #yellow
Methods included from Base::Extensions::CommandlineArguments
#commandline_arguments?, #filter_away_commandline_arguments, #first_argument?, #first_non_hyphened_argument?, #set_commandline_arguments
Methods included from CommonExtensions
#cat, #cd, #cliner, #copy_file, #delete, #dirname_but_retains_the_trailing_slash, #disable_colours, #ensure_that_the_log_directory_exists, #esystem, #get_user_input, #infer_the_namespace, #is_on_roebe?, #log_dir?, #mkdir, #mkdir_then_cd_into_it, #mv, #namespace?, #opne, #opnn, #project_base_directory?, #project_image_directory?, #project_yaml_directory?, #rds, #register_sigint, #remove_this_directory, #rename_file, #reset_the_internal_hash, #return_pwd, #return_today, #touch_file, #wrap, #write_what_into
Constructor Details
#initialize(this_file) ⇒ Checker
#
initialize
#
41 42 43 44 45 46 47 48 |
# File 'lib/games_and_rpg_paradise/lpc/utility_scripts/checker.rb', line 41 def initialize(this_file) reset set_file(this_file) e 'Reading from file '+@file+' now.' if BE_VERBOSE read_file(@file) remove_comments_from_file count_brackets end |
Instance Method Details
#colourize_this(i, use_this_colour = 'slateblue') ⇒ Object
#
colourize_this
#
121 122 123 124 125 126 |
# File 'lib/games_and_rpg_paradise/lpc/utility_scripts/checker.rb', line 121 def colourize_this(i, use_this_colour = 'slateblue') if Object.const_defined? :Colours i = Colours.send(use_this_colour.to_sym, (i)) end i end |
#correct_or_not(brackets) ⇒ Object
#
correct_or_not
We must be careful here. Everything within a comment must be ignored.
#
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/games_and_rpg_paradise/lpc/utility_scripts/checker.rb', line 95 def correct_or_not(brackets) first = brackets[0,1] second = brackets[-1,1] count_first = @array.join.count(first) count_second = @array.join.count(second) value = (count_first == count_second) case value when true e 'Correct, we found '+colourize_this( @joined.count(first).to_s+ ' '+brackets)+' brackets.' e 'At least in regard of '+first+second+' brackets '+ 'the LPC file ' e colourize_this(@file, :darkorange)+' is correct.'+N when false ewarn 'Incorrect!' ewarn ' We found '+count_first.to_s+' "'+first.to_s+'" and '+ count_second.to_s+' "'+second.to_s+'"' end end |
#count_brackets ⇒ Object
#
count_brackets
#
85 86 87 88 |
# File 'lib/games_and_rpg_paradise/lpc/utility_scripts/checker.rb', line 85 def count_brackets correct_or_not('()') correct_or_not('{}') end |
#read_file(f) ⇒ Object
#
read_file
#
77 78 79 80 |
# File 'lib/games_and_rpg_paradise/lpc/utility_scripts/checker.rb', line 77 def read_file(f) @array = File.readlines(f) @joined = @array.join end |
#remove_comments_from_file ⇒ Object
#
remove_comments_from_file
We remove all LPC comments from the file.
#
68 69 70 71 72 |
# File 'lib/games_and_rpg_paradise/lpc/utility_scripts/checker.rb', line 68 def remove_comments_from_file e 'Removing LPC comments from the file '+@file if BE_VERBOSE # copy_string = '' # pp @joined.scan(/#{LPC_START_COMMENT}/) end |
#reset ⇒ Object
#
reset
#
53 54 |
# File 'lib/games_and_rpg_paradise/lpc/utility_scripts/checker.rb', line 53 def reset end |
#set_file(i) ⇒ Object
#
set_file
#
59 60 61 |
# File 'lib/games_and_rpg_paradise/lpc/utility_scripts/checker.rb', line 59 def set_file(i) @file = i end |