ppr 0.0.4 → 0.0.7
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.
- checksums.yaml +5 -5
- data/lib/ppr/ppr_core.rb +28 -5
- data/lib/ppr/test_ppr.rb +1 -1
- data/lib/ppr/version.rb +1 -1
- data/ppr.gemspec +3 -3
- metadata +18 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 48e44434cdd2a83270beb33c69d7d1141cc3333857505910f16cb2baa9fcdbae
|
4
|
+
data.tar.gz: f3a4d37780596606a2a1957c28a099dac51eef57330ad02f499ad7291821ee61
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77bc95d237a38e2979a861ab617b6a86ca31dc1008f85fc54ad82f15cc7f6dbcd1303d88993bb020aca05793eda2377a1ee1f713b19fb0412f670dfe24a83688
|
7
|
+
data.tar.gz: 04a6ba69898af70b296f1199e9106c3e984b6d8f8df9c81e4cb3d93f96ff77b8b031b14440bef6450eaae2092f8493bcbd7161cd17bce0189ef0a5f5e878da66
|
data/lib/ppr/ppr_core.rb
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
|
5
5
|
require "ppr/safer_generator.rb"
|
6
6
|
require "ppr/keyword_searcher.rb"
|
7
|
+
require 'delegate'
|
7
8
|
|
8
9
|
module Ppr
|
9
10
|
|
@@ -302,11 +303,26 @@ class LoadRequire < Macro
|
|
302
303
|
super("",num,ppr,expand: expand)
|
303
304
|
end
|
304
305
|
|
306
|
+
def set_locations(locations)
|
307
|
+
@locations = locations
|
308
|
+
end
|
309
|
+
|
310
|
+
def find_file(name)
|
311
|
+
@locations.each do |i|
|
312
|
+
filepath = i + "/" + name
|
313
|
+
if File.exist?(filepath)
|
314
|
+
return filepath
|
315
|
+
end
|
316
|
+
end
|
317
|
+
|
318
|
+
raise "File #{name} was not found in includes."
|
319
|
+
end
|
320
|
+
|
305
321
|
# Loads and preprocess file +name+.
|
306
322
|
def loadm(name)
|
307
323
|
output = StringIO.new("")
|
308
324
|
# print "name=#{name}\n"
|
309
|
-
File.open(name,"r") do |input|
|
325
|
+
File.open(find_file(name),"r") do |input|
|
310
326
|
@ppr.preprocess(input,output)
|
311
327
|
end
|
312
328
|
return output.string
|
@@ -392,7 +408,8 @@ class Preprocessor
|
|
392
408
|
endm: ".end",
|
393
409
|
expand: ":<",
|
394
410
|
separator: /^|[^\w]|$/, glue: "##",
|
395
|
-
escape: "\\"
|
411
|
+
escape: "\\",
|
412
|
+
includes: Dir.pwd)
|
396
413
|
# Check and Initialize the keywords
|
397
414
|
# NOTE: since there are a lot of checks, use a generic but
|
398
415
|
# harder to read code.
|
@@ -453,6 +470,10 @@ class Preprocessor
|
|
453
470
|
params.each do |k,v|
|
454
471
|
parameter_set(k,v)
|
455
472
|
end
|
473
|
+
|
474
|
+
#include folder locations to search for load and require
|
475
|
+
@includes = []
|
476
|
+
(@includes << includes).flatten!
|
456
477
|
end
|
457
478
|
|
458
479
|
# Methods for handling the execution context of the macros.
|
@@ -531,17 +552,17 @@ class Preprocessor
|
|
531
552
|
|
532
553
|
# Tells if a line corresponds to an end keyword.
|
533
554
|
def is_endm?(line)
|
534
|
-
@endm.match(line)
|
555
|
+
@endm.match(line.strip)
|
535
556
|
end
|
536
557
|
|
537
558
|
# Tells if a line corresponds to an else keyword.
|
538
559
|
def is_elsem?(line)
|
539
|
-
@elsem.match(line)
|
560
|
+
@elsem.match(line.strip)
|
540
561
|
end
|
541
562
|
|
542
563
|
# Tells if a line corresponds to an endif keyword.
|
543
564
|
def is_endifm?(line)
|
544
|
-
@endifm.match(line)
|
565
|
+
@endifm.match(line.strip)
|
545
566
|
end
|
546
567
|
|
547
568
|
# Extract a macro definition from a +line+ if there is one.
|
@@ -606,8 +627,10 @@ class Preprocessor
|
|
606
627
|
macro = Assign.new(name,@number,self,expand: @expand)
|
607
628
|
when @loadm then
|
608
629
|
macro = Load.new(@number,self,expand: @expand)
|
630
|
+
macro.set_locations(@includes)
|
609
631
|
when @requirem then
|
610
632
|
macro = Require.new(@number,self,expand: @expand)
|
633
|
+
macro.set_locations(@includes)
|
611
634
|
when @ifm then
|
612
635
|
macro = If.new(@number,self,expand: @expand)
|
613
636
|
else
|
data/lib/ppr/test_ppr.rb
CHANGED
@@ -149,7 +149,7 @@ $success &= test_preprocessor_exception($ppr,
|
|
149
149
|
print "... Undefined symbol in macro code... "
|
150
150
|
$success &= test_preprocessor_exception($ppr,
|
151
151
|
"\n.def HE(name)\n :< foobar \n.end\nHE(Foo)",
|
152
|
-
"HE:5):
|
152
|
+
"HE:5):3: undefined local variable or method")
|
153
153
|
|
154
154
|
|
155
155
|
# puts "\nBuilding a preprocessor with an invalid escape character."
|
data/lib/ppr/version.rb
CHANGED
data/ppr.gemspec
CHANGED
@@ -33,7 +33,7 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
34
34
|
spec.require_paths = ["lib"]
|
35
35
|
|
36
|
-
spec.add_development_dependency "bundler", "
|
37
|
-
spec.add_development_dependency "rake", "
|
38
|
-
spec.add_development_dependency "minitest", "
|
36
|
+
spec.add_development_dependency "bundler", ">= 2.2.10"
|
37
|
+
spec.add_development_dependency "rake", ">= 12.3.3"
|
38
|
+
spec.add_development_dependency "minitest", ">= 12.3.3"
|
39
39
|
end
|
metadata
CHANGED
@@ -1,57 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ppr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lovic Gauthier
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 2.2.10
|
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.2.10
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 12.3.3
|
34
34
|
type: :development
|
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:
|
40
|
+
version: 12.3.3
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: minitest
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 12.3.3
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 12.3.3
|
55
55
|
description: |-
|
56
56
|
Preprocessor in Ruby: provides a Ruby class named Rpp which implements a text preprocessor where macros are specified in Ruby language.
|
57
57
|
Usage:
|
@@ -90,7 +90,7 @@ homepage: https://github.com/civol
|
|
90
90
|
licenses:
|
91
91
|
- MIT
|
92
92
|
metadata: {}
|
93
|
-
post_install_message:
|
93
|
+
post_install_message:
|
94
94
|
rdoc_options: []
|
95
95
|
require_paths:
|
96
96
|
- lib
|
@@ -105,9 +105,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
105
|
- !ruby/object:Gem::Version
|
106
106
|
version: '0'
|
107
107
|
requirements: []
|
108
|
-
|
109
|
-
|
110
|
-
signing_key:
|
108
|
+
rubygems_version: 3.0.8
|
109
|
+
signing_key:
|
111
110
|
specification_version: 4
|
112
111
|
summary: 'Preprocessor in Ruby: text preprocessor where macros are specified in Ruby
|
113
112
|
language.'
|