priehlazx 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +4 -0
- data/.gitignore +4 -0
- data/.rspec +2 -0
- data/CHANGES.md +11 -0
- data/Gemfile +4 -0
- data/HELP +7 -0
- data/LICENSE +20 -0
- data/README.md +20 -0
- data/Rakefile +3 -0
- data/TODO +10 -0
- data/bin/priehlahq +93 -0
- data/bin//320/277/321/200/321/243/321/205/320/273/320/260/320/263/321/212 +93 -0
- data/lib/priehlazx.rb +510 -0
- data/lib//320/277/321/200/321/243/321/205/320/273/320/260/320/266/321/214/version.rb +3 -0
- data/lib//320/277/321/200/321/243/321/205/320/273/320/260/320/266/321/214.rb +510 -0
- data/priehlazx.gemspec +29 -0
- data/share/HIP./321/201/320/272/321/201 +316 -0
- data/share/TR-CYR-S./321/201/320/272/321/201 +106 -0
- data/share/UCS8./321/201/320/272/321/201 +342 -0
- data/share/UTF8./321/201/320/272/321/201 +360 -0
- data/spec/spec_helper.rb +18 -0
- data/spec//320/277/321/200/321/243/321/205/320/273/320/260/320/266/321/214_spec.rb +29 -0
- metadata +107 -0
data/.document
ADDED
data/.gitignore
ADDED
data/.rspec
ADDED
data/CHANGES.md
ADDED
data/Gemfile
ADDED
data/HELP
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
* http://rails-bestpractices.com/blog/posts/8-using-bundler-and-rvm-to-build-a-rubygem
|
2
|
+
* http://rails-bestpractices.com/blog/posts/9-autotest-your-rubygem
|
3
|
+
* http://blog.grayproductions.net/articles/bytes_and_characters_in_ruby_18
|
4
|
+
* http://blog.grayproductions.net/articles/ruby_18_character_encoding_flaws
|
5
|
+
* ruby code:
|
6
|
+
p [Encoding.default_external, Encoding.default_internal, __ENCODING__]
|
7
|
+
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Malo Skrylevo
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# Прехлагъ (Priehlazx)
|
2
|
+
|
3
|
+
Текстопреобразующая программка и библіотека. Сейчасъ поддерживаетъ слѣдующія кодировки:
|
4
|
+
* UTF8
|
5
|
+
* UTF8/HIP
|
6
|
+
* UCS8
|
7
|
+
|
8
|
+
Text converting utility. Now supports the following codepages:
|
9
|
+
* UTF8
|
10
|
+
* UTF8/HIP
|
11
|
+
* UCS8
|
12
|
+
|
13
|
+
## Права (Copyright)
|
14
|
+
|
15
|
+
Авторскія и исключительныя права (а) 2011 Малъ Скрылевъ
|
16
|
+
Зри LICENSE за подробностями.
|
17
|
+
|
18
|
+
Copyright (c) 2011 Malo Skrylevo
|
19
|
+
See LICENSE for details.
|
20
|
+
|
data/Rakefile
ADDED
data/TODO
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
# add advanced and comlex HIP-format parsing
|
2
|
+
# добавить приоритет кс
|
3
|
+
# добавить правила для перевода из гражданки (совр. и царск.) в hip-слав
|
4
|
+
# добавить области имён (слав, ру, ...)
|
5
|
+
# дополнить таблицу сѣтка, заменив значения nil на значения сложных символов, и убрать обратную таблицу
|
6
|
+
# проверить все диапазоны букв
|
7
|
+
# добавить получения регеца только для букв типо \w, и возможно др. \s \d и т.п.
|
8
|
+
# ! надстрочники в кодировках
|
9
|
+
# добавить alias(тождество) для кс
|
10
|
+
# поместить кс зависимые от родительских в их подпапки
|
data/bin/priehlahq
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
#!/usr/bin/ruby -KU
|
2
|
+
#<Encoding:UTF-8>
|
3
|
+
|
4
|
+
require 'optparse'
|
5
|
+
# check if priehlazx is available as not-a-gem
|
6
|
+
begin
|
7
|
+
$: << '../lib'
|
8
|
+
require 'priehlazx'
|
9
|
+
rescue LoadError
|
10
|
+
begin require 'rubygems'; rescue LoadError; end
|
11
|
+
require 'priehlazx'
|
12
|
+
end
|
13
|
+
|
14
|
+
begin
|
15
|
+
dest = File.expand_path(File.dirname($0))
|
16
|
+
ifile = nil
|
17
|
+
ofile = nil
|
18
|
+
istring = nil
|
19
|
+
ostring = nil
|
20
|
+
debug = nil
|
21
|
+
re_cp = re_cp_w = nil
|
22
|
+
цѣль = nil
|
23
|
+
истокъ = nil
|
24
|
+
debug = nil
|
25
|
+
|
26
|
+
ARGV.options do |o|
|
27
|
+
script_name = File.basename($0)
|
28
|
+
|
29
|
+
o.set_summary_indent(' ')
|
30
|
+
o.banner = "Usage: #{script_name} [OPTIONS]"
|
31
|
+
o.separator ""
|
32
|
+
o.separator "Mandatory arguments to long options are mandatory for " +
|
33
|
+
"short options too."
|
34
|
+
|
35
|
+
o.on("-i", "--input-file=val", String,
|
36
|
+
"Input file to convert") { |i| ifile = IO.read(i) }
|
37
|
+
o.on("--", "--stdin-input", String,
|
38
|
+
"Read standard input to convert") { |i| ifile = $stdin.read }
|
39
|
+
o.on("-o", "--output-file=val", String,
|
40
|
+
"Output file to convert") { |i| ofile = i }
|
41
|
+
o.on("-I", "--input-string=val", String,
|
42
|
+
"Input string to convert") { |i| istring = i }
|
43
|
+
o.on("-c", "--codepage=val", String,
|
44
|
+
"Target (and source) code page(s) " +
|
45
|
+
"separated with signs '<' or '>'") { |i| i =~ /(.+)(<|>)(.+)/; $1 and
|
46
|
+
($2 == '<' and (цѣль = $1; истокъ = $3) or
|
47
|
+
(цѣль = $3; истокъ = $1)) or
|
48
|
+
(цѣль = i) }
|
49
|
+
o.on("-w", "--acquire-word-regexp=val", String,
|
50
|
+
"Acquire RegExp for the code page") { |i| re_cp_w = i }
|
51
|
+
o.on("-r", "--acquire-regexp=val", String,
|
52
|
+
"Acquire RegExp for the code page") { |i| re_cp = i }
|
53
|
+
o.on("-d", "--set-debug-info-level=val", String,
|
54
|
+
"Set debug information log level") { |i| $debug_Priehlazx = i.to_i(16) }
|
55
|
+
|
56
|
+
o.separator ""
|
57
|
+
|
58
|
+
o.on_tail("-h", "--help", "Show this help message.") { $stderr.puts o; exit }
|
59
|
+
|
60
|
+
o.parse!
|
61
|
+
|
62
|
+
unless re_cp or re_cp_w or istring or ifile
|
63
|
+
$stderr.puts o; exit 1
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
pl = Priehlazx.new
|
68
|
+
|
69
|
+
if re_cp
|
70
|
+
puts pl.пръ(re_cp)
|
71
|
+
elsif re_cp_w
|
72
|
+
puts pl.пръ_сл(re_cp_w)
|
73
|
+
else
|
74
|
+
if цѣль
|
75
|
+
pl.цѣль = цѣль if цѣль
|
76
|
+
pl.истокъ = истокъ if истокъ
|
77
|
+
end
|
78
|
+
|
79
|
+
istring = ifile if ifile
|
80
|
+
ostring = pl.ими( istring, цѣль, истокъ )
|
81
|
+
|
82
|
+
if ofile
|
83
|
+
File.open(ofile,'w') do |f| f.puts ostring; end
|
84
|
+
elsif istring
|
85
|
+
puts ostring
|
86
|
+
end
|
87
|
+
end
|
88
|
+
rescue
|
89
|
+
err = $!.to_s
|
90
|
+
err += "\t#{$@.join("\n\t")}" if $debug_Priehlazx.to_i > 0
|
91
|
+
puts err
|
92
|
+
exit 1
|
93
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
#!/usr/bin/ruby -KU
|
2
|
+
#<Encoding:UTF-8>
|
3
|
+
|
4
|
+
require 'optparse'
|
5
|
+
# check if priehlazx is available as not-a-gem
|
6
|
+
begin
|
7
|
+
$: << '../lib'
|
8
|
+
require 'priehlazx'
|
9
|
+
rescue LoadError
|
10
|
+
begin require 'rubygems'; rescue LoadError; end
|
11
|
+
require 'priehlazx'
|
12
|
+
end
|
13
|
+
|
14
|
+
begin
|
15
|
+
dest = File.expand_path(File.dirname($0))
|
16
|
+
ifile = nil
|
17
|
+
ofile = nil
|
18
|
+
istring = nil
|
19
|
+
ostring = nil
|
20
|
+
debug = nil
|
21
|
+
re_cp = re_cp_w = nil
|
22
|
+
цѣль = nil
|
23
|
+
истокъ = nil
|
24
|
+
debug = nil
|
25
|
+
|
26
|
+
ARGV.options do |o|
|
27
|
+
script_name = File.basename($0)
|
28
|
+
|
29
|
+
o.set_summary_indent(' ')
|
30
|
+
o.banner = "Usage: #{script_name} [OPTIONS]"
|
31
|
+
o.separator ""
|
32
|
+
o.separator "Mandatory arguments to long options are mandatory for " +
|
33
|
+
"short options too."
|
34
|
+
|
35
|
+
o.on("-i", "--input-file=val", String,
|
36
|
+
"Input file to convert") { |i| ifile = IO.read(i) }
|
37
|
+
o.on("--", "--stdin-input", String,
|
38
|
+
"Read standard input to convert") { |i| ifile = $stdin.read }
|
39
|
+
o.on("-o", "--output-file=val", String,
|
40
|
+
"Output file to convert") { |i| ofile = i }
|
41
|
+
o.on("-I", "--input-string=val", String,
|
42
|
+
"Input string to convert") { |i| istring = i }
|
43
|
+
o.on("-c", "--codepage=val", String,
|
44
|
+
"Target (and source) code page(s) " +
|
45
|
+
"separated with signs '<' or '>'") { |i| i =~ /(.+)(<|>)(.+)/; $1 and
|
46
|
+
($2 == '<' and (цѣль = $1; истокъ = $3) or
|
47
|
+
(цѣль = $3; истокъ = $1)) or
|
48
|
+
(цѣль = i) }
|
49
|
+
o.on("-w", "--acquire-word-regexp=val", String,
|
50
|
+
"Acquire RegExp for the code page") { |i| re_cp_w = i }
|
51
|
+
o.on("-r", "--acquire-regexp=val", String,
|
52
|
+
"Acquire RegExp for the code page") { |i| re_cp = i }
|
53
|
+
o.on("-d", "--set-debug-info-level=val", String,
|
54
|
+
"Set debug information log level") { |i| $debug_Priehlazx = i.to_i(16) }
|
55
|
+
|
56
|
+
o.separator ""
|
57
|
+
|
58
|
+
o.on_tail("-h", "--help", "Show this help message.") { $stderr.puts o; exit }
|
59
|
+
|
60
|
+
o.parse!
|
61
|
+
|
62
|
+
unless re_cp or re_cp_w or istring or ifile
|
63
|
+
$stderr.puts o; exit 1
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
pl = Priehlazx.new
|
68
|
+
|
69
|
+
if re_cp
|
70
|
+
puts pl.пръ(re_cp)
|
71
|
+
elsif re_cp_w
|
72
|
+
puts pl.пръ_сл(re_cp_w)
|
73
|
+
else
|
74
|
+
if цѣль
|
75
|
+
pl.цѣль = цѣль if цѣль
|
76
|
+
pl.истокъ = истокъ if истокъ
|
77
|
+
end
|
78
|
+
|
79
|
+
istring = ifile if ifile
|
80
|
+
ostring = pl.ими( istring, цѣль, истокъ )
|
81
|
+
|
82
|
+
if ofile
|
83
|
+
File.open(ofile,'w') do |f| f.puts ostring; end
|
84
|
+
elsif istring
|
85
|
+
puts ostring
|
86
|
+
end
|
87
|
+
end
|
88
|
+
rescue
|
89
|
+
err = $!.to_s
|
90
|
+
err += "\t#{$@.join("\n\t")}" if $debug_Priehlazx.to_i > 0
|
91
|
+
puts err
|
92
|
+
exit 1
|
93
|
+
end
|