interscript 3.2.1 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,6 @@
1
+ class Interscript::Node::Ruleset < Interscript::Node::Stage
2
+ # ISC-WF-1 W1: a named, reusable block of stage items. Lives on
3
+ # Node::Document#rulesets, never in #stages — a ruleset never executes
4
+ # on its own; it only reaches the runtime through `use` expansion
5
+ # (a macro expansion performed at adapter time).
6
+ end
@@ -8,6 +8,8 @@ class Interscript::Node
8
8
  autoload :Dependency, "interscript/node/dependency"
9
9
  autoload :Tests, "interscript/node/tests"
10
10
  autoload :Stage, "interscript/node/stage"
11
+ autoload :Ruleset, "interscript/node/ruleset"
12
+ autoload :LanguagesDecl, "interscript/node/languages_decl"
11
13
  autoload :Rule, "interscript/node/rule"
12
14
  autoload :Item, "interscript/node/item"
13
15
 
@@ -1,3 +1,3 @@
1
1
  module Interscript
2
- VERSION = "3.2.1"
2
+ VERSION = "3.4.0"
3
3
  end
data/lib/interscript.rb CHANGED
@@ -50,9 +50,22 @@ module Interscript
50
50
  end
51
51
 
52
52
  # Transliterates the string.
53
- def transliterate(system_code, string, maps = {}, compiler: Interscript::Interpreter)
53
+ #
54
+ # ISC-WF-1 W3: `language:` selects one of the map's declared
55
+ # `languages`, activating the matching `when`-guarded rules. A
56
+ # selection outside the declaration (or no selection) leaves every
57
+ # guard inert (spec §5.1).
58
+ def transliterate(system_code, string, maps = {}, compiler: Interscript::Interpreter, language: nil)
54
59
  # The current best implementation is Interpreter
55
- load(system_code, maps, compiler: compiler).call(string)
60
+ compiled = load(system_code, maps, compiler: compiler)
61
+ if language.nil?
62
+ compiled.call(string)
63
+ elsif compiler.equal?(Interscript::Interpreter)
64
+ compiled.call(string, language: language)
65
+ else
66
+ raise ArgumentError,
67
+ "language selection is only supported by Interscript::Interpreter, not #{compiler}"
68
+ end
56
69
  end
57
70
 
58
71
  # Gives each possible value of the transliteration.
@@ -82,8 +95,28 @@ module Interscript
82
95
  detector.call(source, destination)
83
96
  end
84
97
 
98
+ # Locate the interscript-maps registry yaml(s) across installed gems.
99
+ #
100
+ # rubygems 4 removed StubSpecification#files, which
101
+ # Gem.find_latest_files relies on, so the fast path can raise there;
102
+ # the fallback globs the interscript-maps gems directly (there are
103
+ # only ever one or two of them, so this stays cheap).
104
+ def locate_map_gems_yaml
105
+ found = begin
106
+ Gem.find_latest_files("interscript-maps.yaml")
107
+ rescue
108
+ nil
109
+ end
110
+ return found if found.is_a?(Array) && found.any?
111
+
112
+ Gem::Specification.latest_specs
113
+ .select { |spec| spec.name == "interscript-maps" }
114
+ .flat_map { |spec| Dir.glob(File.join(spec.full_gem_path, "**", "interscript-maps.yaml")) }
115
+ .uniq
116
+ end
117
+
85
118
  def map_gems
86
- @map_gems ||= Gem.find_latest_files("interscript-maps.yaml").map do |i|
119
+ @map_gems ||= locate_map_gems_yaml.map do |i|
87
120
  [i, YAML.load_file(i)]
88
121
  end.to_h
89
122
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: interscript
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.1
4
+ version: 3.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-10-25 00:00:00.000000000 Z
11
+ date: 2026-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '2.5'
33
+ version: '3.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '2.5'
40
+ version: '3.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: text
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -150,6 +150,7 @@ files:
150
150
  - lib/interscript/isc/model/document.rb
151
151
  - lib/interscript/isc/model/item.rb
152
152
  - lib/interscript/isc/model/rule.rb
153
+ - lib/interscript/isc/model/ruleset.rb
153
154
  - lib/interscript/isc/model/stage.rb
154
155
  - lib/interscript/isc/model/stage_item.rb
155
156
  - lib/interscript/isc/model/test.rb
@@ -182,11 +183,14 @@ files:
182
183
  - lib/interscript/node/item/repeat.rb
183
184
  - lib/interscript/node/item/stage.rb
184
185
  - lib/interscript/node/item/string.rb
186
+ - lib/interscript/node/languages_decl.rb
185
187
  - lib/interscript/node/metadata.rb
186
188
  - lib/interscript/node/rule.rb
187
189
  - lib/interscript/node/rule/funcall.rb
188
190
  - lib/interscript/node/rule/run.rb
189
191
  - lib/interscript/node/rule/sub.rb
192
+ - lib/interscript/node/rule/use.rb
193
+ - lib/interscript/node/ruleset.rb
190
194
  - lib/interscript/node/stage.rb
191
195
  - lib/interscript/node/tests.rb
192
196
  - lib/interscript/stdlib.rb