math_ml 0.13 → 1.0.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.
data/lib/math_ml.rb CHANGED
@@ -3,23 +3,23 @@
3
3
  # Copyright (C) 2005, KURODA Hiraku <hiraku@hinet.mydns.jp>
4
4
  # You can redistribute it and/or modify it under GPL2.
5
5
 
6
- require "strscan"
6
+ require 'strscan'
7
7
  module MathML
8
- require "eim_xml"
8
+ require 'eim_xml'
9
9
 
10
- class XMLElement < EimXML::Element
11
- def pop
12
- @contents.pop
13
- end
14
- end
10
+ class XMLElement < EimXML::Element
11
+ def pop
12
+ @contents.pop
13
+ end
14
+ end
15
15
 
16
- def self.pcstring(s, encoded=false)
17
- s.is_a?(EimXML::PCString) ? s : EimXML::PCString.new(s, encoded)
18
- end
16
+ def self.pcstring(s, encoded = false)
17
+ s.is_a?(EimXML::PCString) ? s : EimXML::PCString.new(s, encoded)
18
+ end
19
19
 
20
- class Error < StandardError; end
20
+ class Error < StandardError; end
21
21
  end
22
22
 
23
- require "math_ml/element"
24
- require "math_ml/symbol/entity_reference"
25
- require "math_ml/latex"
23
+ require 'math_ml/element'
24
+ require 'math_ml/symbol/entity_reference'
25
+ require 'math_ml/latex'
metadata CHANGED
@@ -1,98 +1,68 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: math_ml
3
- version: !ruby/object:Gem::Version
4
- hash: 17
5
- prerelease:
6
- segments:
7
- - 0
8
- - 13
9
- version: "0.13"
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
10
5
  platform: ruby
11
- authors:
6
+ authors:
12
7
  - KURODA Hiraku
13
8
  autorequire:
14
9
  bindir: bin
15
10
  cert_chain: []
16
-
17
- date: 2012-08-01 00:00:00 Z
18
- dependencies:
19
- - !ruby/object:Gem::Dependency
11
+ date: 2024-08-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
20
14
  name: eim_xml
21
- prerelease: false
22
- requirement: &id001 !ruby/object:Gem::Requirement
23
- none: false
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- hash: 3
28
- segments:
29
- - 0
30
- version: "0"
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.0
31
20
  type: :runtime
32
- version_requirements: *id001
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.0.0
33
27
  description:
34
- email: hiraku@hinet.mydns.jp
28
+ email: hirakuro@gmail.com
35
29
  executables: []
36
-
37
30
  extensions: []
38
-
39
31
  extra_rdoc_files: []
40
-
41
- files:
42
- - Rakefile
43
- - Rakefile.utirake
44
- - lib/math_ml/string.rb
32
+ files:
33
+ - LICENSE
34
+ - lib/math_ml.rb
45
35
  - lib/math_ml/element.rb
36
+ - lib/math_ml/latex.rb
46
37
  - lib/math_ml/latex/builtin.rb
47
38
  - lib/math_ml/latex/builtin/symbol.rb
48
- - lib/math_ml/util.rb
49
- - lib/math_ml/symbol/utf8.rb
39
+ - lib/math_ml/string.rb
50
40
  - lib/math_ml/symbol/character_reference.rb
51
41
  - lib/math_ml/symbol/entity_reference.rb
52
- - lib/math_ml/latex.rb
53
- - lib/math_ml.rb
54
- - spec/math_ml_spec.rb
55
- - spec/util.rb
56
- - spec/math_ml/latex/parser_spec.rb
57
- - spec/math_ml/latex/scanner_spec.rb
58
- - spec/math_ml/latex/macro_spec.rb
59
- - spec/math_ml/string_spec.rb
60
- - spec/math_ml/util_spec.rb
61
- - spec/math_ml/element_spec.rb
62
- homepage: http://mathml.rubyforge.org/
63
- licenses: []
64
-
42
+ - lib/math_ml/symbol/utf8.rb
43
+ - lib/math_ml/util.rb
44
+ homepage: https://github.com/hirakuro/math_ml
45
+ licenses:
46
+ - GPL-2.0-only
47
+ metadata:
48
+ rubygems_mfa_required: 'true'
65
49
  post_install_message:
66
50
  rdoc_options: []
67
-
68
- require_paths:
51
+ require_paths:
69
52
  - lib
70
- required_ruby_version: !ruby/object:Gem::Requirement
71
- none: false
72
- requirements:
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: 3.2.0
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ requirements:
73
60
  - - ">="
74
- - !ruby/object:Gem::Version
75
- hash: 3
76
- segments:
77
- - 0
78
- version: "0"
79
- required_rubygems_version: !ruby/object:Gem::Requirement
80
- none: false
81
- requirements:
82
- - - ">"
83
- - !ruby/object:Gem::Version
84
- hash: 25
85
- segments:
86
- - 1
87
- - 3
88
- - 1
89
- version: 1.3.1
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
90
63
  requirements: []
91
-
92
- rubyforge_project: mathml
93
- rubygems_version: 1.8.18
64
+ rubygems_version: 3.5.11
94
65
  signing_key:
95
- specification_version: 3
66
+ specification_version: 4
96
67
  summary: MathML Library
97
68
  test_files: []
98
-
data/Rakefile DELETED
@@ -1,60 +0,0 @@
1
- load "Rakefile.utirake"
2
-
3
- VER = "0.13"
4
-
5
- UtiRake.setup do
6
- external("https://hg.hinet.mydns.jp", %w[eim_xml])
7
-
8
- rdoc do |t|
9
- t.title = "MathML Library"
10
- t.main = "README"
11
- t.rdoc_files.include(FileList["lib/**/*.rb", "README"])
12
- end
13
-
14
- publish("mathml", "hiraku") do
15
- cp "index.html", "html/index.html"
16
- end
17
-
18
- gemspec do |s|
19
- s.name = "math_ml"
20
- s.rubyforge_project = "mathml"
21
- s.version = VER
22
- s.summary = "MathML Library"
23
- s.author = "KURODA Hiraku"
24
- s.email = "hiraku@hinet.mydns.jp"
25
- s.homepage = "http://mathml.rubyforge.org/"
26
- s.add_dependency("eim_xml")
27
- end
28
-
29
- rcov_spec do |s|
30
- s.ruby_opts = %w[-rubygems]
31
- s.pattern ||= %w[spec/util.rb spec/**/*_spec.rb]
32
- s.pattern = [s.pattern] unless s.pattern.is_a?(Array)
33
- # s.pattern << "symbols/**/*_spec.rb"
34
- end
35
-
36
- spec do |s|
37
- # s.spec_opts << "-b"
38
- end
39
- alias_task
40
- end
41
-
42
- namespace :spec do
43
- RSpec::Core::RakeTask.new(:symbols) do |s|
44
- s.pattern = "./symbols/**/*_spec.rb"
45
- s.rspec_opts = %w[-c -I lib -I external/lib]
46
- end
47
- end
48
-
49
- task :package do
50
- name = "math_ml-#{VER}"
51
- cp "external/eim_xml/lib/eim_xml.rb", "pkg/#{name}/lib/"
52
- Dir.chdir "pkg" do
53
- rm "#{name}.tar.gz"
54
- sh "tar zcf #{name}.tar.gz #{name}/"
55
- end
56
- end
57
-
58
- task :default => :spec
59
- task "spec:no_here" => "spec:apart"
60
- task :all => [:spec, "spec:symbols"]
data/Rakefile.utirake DELETED
@@ -1,392 +0,0 @@
1
- # Utility for Rake
2
- #
3
- # Copyright (C) 2008, KURODA Hiraku <hiraku@hinet.mydns.jp>
4
- # You can redistribute it and/or modify it under GPL3.
5
-
6
- require "rake/clean"
7
- require "rake/testtask"
8
- require "rake/contrib/rubyforgepublisher"
9
- require "rubygems/package_task"
10
-
11
- if File.exist?("Gemfile")
12
- begin
13
- require "bundler"
14
- Bundler.setup
15
- rescue LoadError
16
- if $!.message =~ / bundler\z/
17
- warn "Warning: Bundler is not found."
18
- else
19
- raise
20
- end
21
- end
22
- end
23
-
24
- class UtiRake
25
- include Rake::DSL
26
-
27
- def self.setup(opt={}, &proc)
28
- ur = new
29
- ur.setup(opt, &proc)
30
- rescue
31
- puts $!.class, $!.message, $!.backtrace
32
- end
33
-
34
- attr_reader :opt, :spec_proc, :cucumber_proc, :rdoc_proc, :gemspec_proc, :package_proc, :rcov_spec_proc
35
-
36
- def setup(opt={}, &proc)
37
- @opt = opt
38
- directory "external"
39
- CLEAN << "coverage" << "coverage.spec" << "coverage.cuke" << "doc"
40
- CLOBBER << "external"
41
-
42
- instance_eval(&proc) if proc
43
-
44
- if need_spec?
45
- begin
46
- @rspec2_flg = false
47
- require "rspec/core/rake_task"
48
- @rspec2_flg = true
49
- rescue LoadError
50
- require "spec/rake/spectask"
51
- end
52
- define_spec_task
53
- end
54
-
55
- if need_cucumber?
56
- require "cucumber/rake/task"
57
- define_cucumber_task
58
- end
59
-
60
- define_rdoc_task
61
- define_rcov_task
62
- define_package_task
63
- define_here_dependency
64
- define_alias_task if @alias_task
65
- end
66
-
67
- def rspec2?; @rspec2_flg; end
68
-
69
- def spec_task
70
- rspec2? ? RSpec::Core::RakeTask : Spec::Rake::SpecTask
71
- end
72
-
73
- def need_spec?
74
- File.directory?("spec")
75
- end
76
-
77
- def need_cucumber?
78
- File.directory?("features")
79
- end
80
-
81
- def spec(&proc)
82
- @spec_proc = proc
83
- end
84
-
85
- def cucumber(&proc)
86
- @cucumber_proc = proc
87
- end
88
-
89
- def rdoc(&proc)
90
- @rdoc_proc = proc
91
- end
92
-
93
- def gemspec(&proc)
94
- @gemspec_proc = proc
95
- end
96
-
97
- def rcov_spec(&proc)
98
- @rcov_spec_proc = proc
99
- end
100
-
101
- def package(&proc)
102
- @package_proc = proc
103
- end
104
-
105
- def no_here(task)
106
- @no_here_task = task
107
- end
108
-
109
- def no_here_task
110
- @no_here_task || "spec:lump"
111
- end
112
-
113
- def alias_task
114
- @alias_task = true
115
- end
116
-
117
- def hg(cmd)
118
- sh "hg #{cmd.to_s}"
119
- end
120
-
121
- def external(base_url, *libs)
122
- libs = libs.first if libs.first.is_a?(Array)
123
- namespace :external do
124
- directory "external/lib"
125
- libs.each do |lib|
126
- libdir = "external/#{lib}"
127
- file libdir => "external/lib" do
128
- if File.exist?("../#{lib}")
129
- Dir.chdir("external") do
130
- ln_s "../../#{lib}", "./", :force=>true
131
- end
132
- end
133
- hg "clone #{File.join(base_url, lib)} #{libdir}" unless File.exist?(libdir)
134
- Dir["#{libdir}/lib/*"].each do |f|
135
- base = File.basename(f)
136
- cd "external/lib" do
137
- ln_s "../#{lib}/lib/#{base}", "./"
138
- end
139
- end
140
- end
141
-
142
- if File.exist?(libdir)
143
- Dir["#{libdir}/lib/*"].each do |f|
144
- base = File.basename(f)
145
- file "external/lib/#{base}" => "external/lib" do
146
- cd "external/lib" do
147
- ln_s "../#{lib}/lib/#{base}", "./"
148
- end
149
- end
150
- task :setup => "external/lib/#{base}"
151
- end
152
- end
153
-
154
- desc "Setup external libraries"
155
- task :setup=>libdir
156
- end
157
-
158
- task :rake => :setup do
159
- libs.each do |lib|
160
- Dir.chdir "external/#{lib}" do
161
- sh "rake"
162
- end
163
- end
164
- end
165
- end
166
- @external = true
167
- end
168
-
169
- def external?; @external; end
170
-
171
- def define_rdoc_task
172
- begin
173
- require "rdoc/task"
174
- rescue LoadError
175
- return
176
- end
177
-
178
- Rake::RDocTask.new(:rdoc) do |rdoc|
179
- rdoc.options << "-S"
180
- rdoc.options << "-w" << "3"
181
- rdoc.options << "-c" << "UTF-8"
182
- rdoc.rdoc_files.include("lib/**/*.rb")
183
- rdoc_proc.call(rdoc) if rdoc_proc
184
- end
185
- task :doc do
186
- remove_entry_secure "doc" if File.directory?("doc")
187
- sh "rdoc -S -w 3 -c UTF-8 -d -x external"
188
- end
189
- end
190
-
191
- def define_package_task
192
- spec = Gem::Specification.new do |s|
193
- s.platform = Gem::Platform::RUBY
194
- s.files = FileList["Rakefile*", "lib/**/*", "spec/**/*"]
195
- s.version = "0.0.0.noversion"
196
- gemspec_proc.call(s) if gemspec_proc
197
- end
198
-
199
- gem = Gem::PackageTask.new(spec) do |t|
200
- t.need_tar_gz = true
201
- package_proc.call(t) if package_proc
202
- end
203
-
204
- task "utirake:copy_for_package" do
205
- mv "Rakefile.utirake", "Rakefile.utirake_#{$$}"
206
- cp "external/utirake/utirake.rb", "Rakefile.utirake"
207
- end
208
-
209
- file gem.package_dir_path => "utirake:copy_for_package"
210
-
211
- task :gem do
212
- rm "Rakefile.utirake"
213
- mv "Rakefile.utirake_#{$$}", "Rakefile.utirake"
214
- end
215
- end
216
-
217
- def publish(project_name, user_id)
218
- task :publish => "rdoc" do
219
- yield if block_given?
220
- Rake::RubyForgePublisher.new(project_name, user_id).upload
221
- end
222
- end
223
-
224
- FILE_SORT = lambda{|a, b| File.mtime(a)<=>File.mtime(b)}
225
-
226
- def spec_files
227
- @spec_files ||= FileList["./spec/**/*_spec.rb"].sort(&FILE_SORT).reverse
228
- end
229
-
230
- def set_spec_opts(spec)
231
- spec.verbose = false
232
- if rspec2?
233
- spec.rspec_opts ||= []
234
- spec.rspec_opts << "-c"
235
- spec.rspec_opts << "-I" << "." << "-I" << "./lib" << "-I" << "./external/lib"
236
- else
237
- spec.spec_opts << "-c"
238
- spec.libs << "." << "./lib" << "./external/lib"
239
- end
240
- end
241
-
242
- def define_spec_task
243
- task :spec => "spec:apart"
244
- namespace :spec do
245
- spec_files.each do |f|
246
- desc ""
247
- spec_task.new(:apart) do |s|
248
- if rspec2?
249
- s.pattern = f
250
- else
251
- s.spec_files = FileList[f]
252
- end
253
- set_spec_opts(s)
254
- spec_proc.call(s) if spec_proc
255
- end
256
- end
257
- task(:apart).comment = "Run all specs separately"
258
-
259
- desc "Run all specs in a lump"
260
- spec_task.new(:lump) do |s|
261
- s.spec_files = spec_files unless rspec2?
262
- set_spec_opts(s)
263
- spec_proc.call(s) if spec_proc
264
- end
265
-
266
- desc "Run all specs to profile"
267
- spec_task.new(:profile) do |s|
268
- set_spec_opts(s)
269
- if rspec2?
270
- s.rspec_opts << "-p"
271
- else
272
- s.spec_opts << "-f" << "profile"
273
- end
274
- end
275
-
276
- `grep -sRn '#[[:space:]]*here\\([[:space:]]\\|$\\)' --include='*.rb' spec`.split(/\n/).map{|l|
277
- next nil unless l=~/\A(.*?):(\d+):/
278
- [$1, $2.to_i]
279
- }.compact.sort{|a, b| FILE_SORT.call(a[0], b[0])}.reverse.each do |file, line|
280
- desc ""
281
- spec_task.new(:here) do |s|
282
- set_spec_opts(s)
283
- if rspec2?
284
- s.pattern = file
285
- s.rspec_opts << "-l#{line}"
286
- else
287
- s.spec_files = [file]
288
- s.spec_opts << "-l#{line}"
289
- end
290
- spec_proc.call(s) if spec_proc
291
- end
292
- end
293
- task :no_here => no_here_task
294
- end
295
- end
296
-
297
- def set_cucumber_opts(task)
298
- task.libs << "."
299
- cucumber_proc.call(task) if cucumber_proc
300
- end
301
-
302
- def define_cucumber_task
303
- Cucumber::Rake::Task.new do |t|
304
- set_cucumber_opts(t)
305
- end
306
-
307
- unless `grep -sRn '^[[:space:]]*@here$' features`.empty?
308
- Cucumber::Rake::Task.new("cucumber:here") do |t|
309
- t.cucumber_opts = %w[--tags @here]
310
- set_cucumber_opts(t)
311
- end
312
- end
313
- task "cucumber:no_here" => :cucumber
314
- end
315
-
316
- def define_here_dependency
317
- unless Rake::Task.task_defined?("spec:here") || Rake::Task.task_defined?("cucumber:here")
318
- task "spec:here" => "spec:no_here" if need_spec? && !Rake::Task.task_defined?("spec:here")
319
- task "cucumber:here" => "cucumber:no_here" if need_cucumber? && !Rake::Task.task_defined?("cucumber:here")
320
- end
321
-
322
- task("spec:here").comment = "Run spec only marked '# here'"
323
- task("cucumber:here").comment = "only tagged '@here'"
324
- end
325
-
326
- def rcov_opts(t, aggregation)
327
- t.rcov_opts ||= []
328
- t.rcov_opts << "-I" << "./spec:./lib:./external/lib"
329
- t.rcov_opts << "--exclude" << "gems\/,features\/,external\/"
330
- t.rcov_opts << "--aggregate" << "coverage.data" if aggregation
331
- t.rcov = true
332
- end
333
-
334
- def define_rcov_each_task(aggregation)
335
- if need_spec?
336
- spec_task.new do |t|
337
- t.verbose = false
338
- rcov_opts(t, aggregation)
339
- if rspec2?
340
- t.rcov_opts << "-o" << "coverage.spec" unless aggregation
341
- else
342
- set_spec_opts(t)
343
- t.spec_files = spec_files
344
- t.rcov_dir = "coverage.spec" unless aggregation
345
- end
346
- rcov_spec_proc.call(t) if rcov_spec_proc
347
- end
348
- else
349
- task "spec"
350
- end
351
-
352
- if need_cucumber?
353
- Cucumber::Rake::Task.new do |t|
354
- set_cucumber_opts(t)
355
- rcov_opts(t, aggregation)
356
- t.rcov_opts << "-o" << "coverage.cuke" unless aggregation
357
- end
358
- else
359
- task "cucumber"
360
- end
361
- end
362
-
363
- def define_rcov_task
364
- namespace :rcov do
365
- define_rcov_each_task(false)
366
- end
367
-
368
- desc "Run specs and Cucumber using RCov"
369
- task "rcov:lump" do
370
- rm "coverage.data" if File.exist?("coverage.data")
371
- ns = namespace do
372
- define_rcov_each_task(true)
373
- end
374
- ns.tasks.each do |t|
375
- t.invoke
376
- end
377
- rm "coverage.data"
378
- end
379
-
380
- task "rcov:all" => %w[rcov:spec rcov:cucumber rcov:lump]
381
- end
382
-
383
- def define_alias_task
384
- if Rake::Task.task_defined?("spec:apart")
385
- task :apart => "spec:apart"
386
- task :lump => "spec:lump"
387
- task :here => "spec:here"
388
- task :profile => "spec:profile"
389
- end
390
- task :here => "cucumber:here" if Rake::Task.task_defined?("cucumber:here")
391
- end
392
- end
@@ -1,32 +0,0 @@
1
- require "math_ml"
2
-
3
- describe MathML::Element do
4
- it "#display_style and #as_display_style" do
5
- MathML::Element.new("test").display_style.should == nil
6
- e = MathML::Element.new("test")
7
- r = e.as_display_style
8
- r.should equal(e)
9
- e.display_style.should be_true
10
- end
11
-
12
- it "#pop" do
13
- e = MathML::Element.new("super")
14
- s = MathML::Element.new("sub")
15
-
16
- e.pop.should be_nil
17
-
18
- e << s
19
- e.pop.should equal(s)
20
- e.pop.should be_nil
21
-
22
- e << "text"
23
- e.pop.should == "text"
24
- e.pop.should be_nil
25
- end
26
-
27
- it "#to_s" do
28
- e = MathML::Element.new("e")
29
- e << "test<"
30
- e.to_s.should == "<e>test&lt;</e>"
31
- end
32
- end