interscript 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/interscript +3 -5
- data/bin/rspec +29 -0
- data/lib/interscript.rb +27 -41
- data/lib/interscript/version.rb +1 -1
- metadata +36 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: def03b1856a5b9d98e397f378e9958627dfe19077b90293797cc6fc6b81bce3e
|
4
|
+
data.tar.gz: d105d03d4c918bfb5a478a4928a8d15cd59dd0be4a04c990bae0b38e52df7a23
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c8e1535bc0d688b54da2ebcf29e8c846e07f315c5fe3cc456f918f15b9d46e3ff87ebfb3dc0b40efcc6769f236002b3784fc9e1febfe133b2e81f7a7c5a09a0
|
7
|
+
data.tar.gz: 6c11004204682f6b476d4764ac68cb5bbba8a1b53ac6afc268edd2204d3746e953ffbef51ab4bb8c5661ff959bb51c05447622a1e79fa7e012c40a2e77830d0e
|
data/bin/interscript
CHANGED
@@ -5,7 +5,7 @@ require_relative '../lib/interscript'
|
|
5
5
|
if ARGV.empty?
|
6
6
|
puts "write source file, source format, and output file"
|
7
7
|
else
|
8
|
-
args = Hash[
|
8
|
+
args = Hash[ARGV.flat_map { |s| s.scan(/--?([^=\s]+)(?:=(\S+))?/) }]
|
9
9
|
input = ARGV[0]
|
10
10
|
system_code = args["system"]
|
11
11
|
output_file = args["output"]
|
@@ -13,10 +13,8 @@ else
|
|
13
13
|
raise "Please enter the system code with --system={system_code}" unless system_code
|
14
14
|
|
15
15
|
if output_file
|
16
|
-
Interscript.
|
16
|
+
Interscript.transliterate_file(system_code, input, output_file)
|
17
17
|
else
|
18
|
-
puts Interscript.
|
18
|
+
puts Interscript.transliterate(system_code, IO.read(input))
|
19
19
|
end
|
20
20
|
end
|
21
|
-
|
22
|
-
|
data/bin/rspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rspec' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("rspec-core", "rspec")
|
data/lib/interscript.rb
CHANGED
@@ -1,53 +1,39 @@
|
|
1
|
-
|
2
|
-
require 'singleton'
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
4
|
-
|
5
|
-
include Singleton
|
6
|
-
|
7
|
-
SYSTEM_DEFINITIONS_PATH = File.expand_path('../../maps', __FILE__)
|
3
|
+
require 'yaml'
|
8
4
|
|
9
|
-
|
10
|
-
|
11
|
-
|
5
|
+
# Transliteration
|
6
|
+
module Interscript
|
7
|
+
SYSTEM_DEFINITIONS_PATH = File.expand_path('../maps', __dir__)
|
12
8
|
|
13
|
-
|
14
|
-
|
15
|
-
|
9
|
+
class << self
|
10
|
+
def transliterate_file(system_code, input_file, output_file)
|
11
|
+
input = File.read(input_file)
|
12
|
+
output = transliterate(system_code, input)
|
16
13
|
|
17
|
-
|
18
|
-
|
14
|
+
File.open(output_file, "w") do |f|
|
15
|
+
f.puts(output)
|
16
|
+
end
|
17
|
+
puts "Output written to: #{output_file}"
|
19
18
|
end
|
20
|
-
puts "Output written to: #{output_file}"
|
21
|
-
end
|
22
|
-
|
23
|
-
def load_system_definition(system_code)
|
24
|
-
@systems[system_code] ||= YAML.load_file(File.join(SYSTEM_DEFINITIONS_PATH, "#{system_code}.yaml"))
|
25
|
-
end
|
26
|
-
|
27
|
-
def get_system(system_code)
|
28
|
-
@systems[system_code]
|
29
|
-
end
|
30
19
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
def system_rules(system_code)
|
36
|
-
get_system(system_code)["map"]["rules"]
|
37
|
-
end
|
20
|
+
def load_system_definition(system_code)
|
21
|
+
YAML.load_file(File.join(SYSTEM_DEFINITIONS_PATH, "#{system_code}.yaml"))
|
22
|
+
end
|
38
23
|
|
39
|
-
|
40
|
-
|
24
|
+
def transliterate(system_code, string)
|
25
|
+
system = load_system_definition(system_code)
|
41
26
|
|
42
|
-
|
27
|
+
rules = system["map"]["rules"] || []
|
28
|
+
charmap = system["map"]["characters"] || {}
|
43
29
|
|
44
|
-
|
30
|
+
rules.each do |r|
|
31
|
+
string.gsub! %r{#{r["pattern"]}}, r["result"]
|
32
|
+
end
|
45
33
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
end
|
34
|
+
string.split('').map do |char|
|
35
|
+
charmap[char] || char
|
36
|
+
end.join('')
|
37
|
+
end
|
50
38
|
end
|
51
|
-
|
52
39
|
end
|
53
|
-
|
data/lib/interscript/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: interscript
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- project_contibutors
|
@@ -16,28 +16,42 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: debase
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rake
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
45
|
- - "~>"
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
47
|
+
version: '12.0'
|
34
48
|
type: :development
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
52
|
- - "~>"
|
39
53
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
54
|
+
version: '12.0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rspec
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,15 +66,31 @@ dependencies:
|
|
52
66
|
- - ">="
|
53
67
|
- !ruby/object:Gem::Version
|
54
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: ruby-debug-ide
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
55
83
|
description: Interoperable script conversion systems
|
56
84
|
email:
|
57
85
|
executables:
|
58
86
|
- interscript
|
87
|
+
- rspec
|
59
88
|
extensions: []
|
60
89
|
extra_rdoc_files: []
|
61
90
|
files:
|
62
91
|
- README.adoc
|
63
92
|
- bin/interscript
|
93
|
+
- bin/rspec
|
64
94
|
- lib/interscript.rb
|
65
95
|
- lib/interscript/version.rb
|
66
96
|
homepage: ''
|
@@ -82,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
82
112
|
- !ruby/object:Gem::Version
|
83
113
|
version: '0'
|
84
114
|
requirements: []
|
85
|
-
rubygems_version: 3.0.
|
115
|
+
rubygems_version: 3.0.6
|
86
116
|
signing_key:
|
87
117
|
specification_version: 4
|
88
118
|
summary: Interoperable script conversion systems
|