ed-precompiled_erb 5.0.3
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 +7 -0
- data/.document +6 -0
- data/.github/dependabot.yml +6 -0
- data/.github/workflows/dependabot_automerge.yml +30 -0
- data/.github/workflows/sync-ruby.yml +33 -0
- data/.github/workflows/test.yml +36 -0
- data/.gitignore +12 -0
- data/.rdoc_options +1 -0
- data/BDSL +22 -0
- data/COPYING +56 -0
- data/Gemfile +11 -0
- data/LICENSE.txt +2 -0
- data/NEWS.md +69 -0
- data/README.md +98 -0
- data/Rakefile +19 -0
- data/_doc/cgi.rb +3 -0
- data/_doc/erb_executable.md +240 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/erb.gemspec +36 -0
- data/ext/erb/escape/escape.c +102 -0
- data/ext/erb/escape/extconf.rb +9 -0
- data/lib/erb/compiler.rb +488 -0
- data/lib/erb/def_method.rb +47 -0
- data/lib/erb/util.rb +77 -0
- data/lib/erb/version.rb +5 -0
- data/lib/erb.rb +1220 -0
- data/libexec/erb +184 -0
- metadata +74 -0
data/libexec/erb
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# Tiny eRuby --- ERB2
|
|
3
|
+
# Copyright (c) 1999-2000,2002 Masatoshi SEKI
|
|
4
|
+
# You can redistribute it and/or modify it under the same terms as Ruby.
|
|
5
|
+
|
|
6
|
+
require 'erb'
|
|
7
|
+
|
|
8
|
+
class ERB
|
|
9
|
+
module Main
|
|
10
|
+
def ARGV.switch
|
|
11
|
+
return nil if self.empty?
|
|
12
|
+
arg = self.shift
|
|
13
|
+
return nil if arg == '--'
|
|
14
|
+
case arg
|
|
15
|
+
when /\A-(.)(.*)/
|
|
16
|
+
if $1 == '-'
|
|
17
|
+
arg, @maybe_arg = arg.split(/=/, 2)
|
|
18
|
+
return arg
|
|
19
|
+
end
|
|
20
|
+
raise 'unknown switch "-"' if $2[0] == ?- and $1 != 'T'
|
|
21
|
+
if $2.size > 0
|
|
22
|
+
self.unshift "-#{$2}"
|
|
23
|
+
@maybe_arg = $2
|
|
24
|
+
else
|
|
25
|
+
@maybe_arg = nil
|
|
26
|
+
end
|
|
27
|
+
"-#{$1}"
|
|
28
|
+
when /\A(\w+)=/
|
|
29
|
+
arg
|
|
30
|
+
else
|
|
31
|
+
self.unshift arg
|
|
32
|
+
nil
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def ARGV.req_arg
|
|
37
|
+
(@maybe_arg || self.shift || raise('missing argument')).tap {
|
|
38
|
+
@maybe_arg = nil
|
|
39
|
+
}
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def trim_mode_opt(trim_mode, disable_percent)
|
|
43
|
+
return trim_mode if disable_percent
|
|
44
|
+
case trim_mode
|
|
45
|
+
when 0
|
|
46
|
+
return '%'
|
|
47
|
+
when 1
|
|
48
|
+
return '%>'
|
|
49
|
+
when 2
|
|
50
|
+
return '%<>'
|
|
51
|
+
when '-'
|
|
52
|
+
return '%-'
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
module_function :trim_mode_opt
|
|
56
|
+
|
|
57
|
+
def run(factory=ERB)
|
|
58
|
+
trim_mode = 0
|
|
59
|
+
disable_percent = false
|
|
60
|
+
variables = {}
|
|
61
|
+
begin
|
|
62
|
+
while switch = ARGV.switch
|
|
63
|
+
case switch
|
|
64
|
+
when '-x' # ruby source
|
|
65
|
+
output = true
|
|
66
|
+
when '-n' # line number
|
|
67
|
+
number = true
|
|
68
|
+
when '-v' # verbose
|
|
69
|
+
$VERBOSE = true
|
|
70
|
+
when '--version' # version
|
|
71
|
+
STDERR.puts factory.version
|
|
72
|
+
exit
|
|
73
|
+
when '-d', '--debug' # debug
|
|
74
|
+
$DEBUG = true
|
|
75
|
+
when '-r' # require
|
|
76
|
+
require ARGV.req_arg
|
|
77
|
+
when '-T' # trim mode
|
|
78
|
+
arg = ARGV.req_arg
|
|
79
|
+
if arg == '-'
|
|
80
|
+
trim_mode = arg
|
|
81
|
+
next
|
|
82
|
+
end
|
|
83
|
+
raise "invalid trim mode #{arg.dump}" unless arg =~ /\A[0-2]\z/
|
|
84
|
+
trim_mode = arg.to_i
|
|
85
|
+
when '-E', '--encoding'
|
|
86
|
+
arg = ARGV.req_arg
|
|
87
|
+
set_encoding(*arg.split(/:/, 2))
|
|
88
|
+
when '-U'
|
|
89
|
+
set_encoding(Encoding::UTF_8, Encoding::UTF_8)
|
|
90
|
+
when '-P'
|
|
91
|
+
disable_percent = true
|
|
92
|
+
when '--help'
|
|
93
|
+
raise ''
|
|
94
|
+
when /\A-/
|
|
95
|
+
raise "Unknown switch: #{switch.dump}"
|
|
96
|
+
else
|
|
97
|
+
var, val = *switch.split('=', 2)
|
|
98
|
+
(variables ||= {})[var] = val
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
rescue # usage
|
|
102
|
+
message = $!.to_s
|
|
103
|
+
STDERR.puts message unless message.empty?
|
|
104
|
+
STDERR.puts 'Usage:'
|
|
105
|
+
STDERR.puts " #{File.basename($0)} [options] [filepaths]"
|
|
106
|
+
STDERR.puts <<EOU
|
|
107
|
+
|
|
108
|
+
Options:
|
|
109
|
+
-d --debug Set $DEBUG to enable debugging.
|
|
110
|
+
-E ex[:in] --encoding ex[:in]
|
|
111
|
+
Set default external and internal encodings.
|
|
112
|
+
-h --help Print this text and exit.
|
|
113
|
+
-n Print generated Ruby source code with line numbers;
|
|
114
|
+
ignored if given without option -x.
|
|
115
|
+
-P Disable execution tag shorthand (for lines beginning with '%').
|
|
116
|
+
-r library Load the named library.
|
|
117
|
+
-T trim_mode Specify trim_mode:
|
|
118
|
+
'0' means '%'; '1' means '%>'; '2' means '<>'; '-' means '%-'.
|
|
119
|
+
-U Set default encoding to UTF-8.
|
|
120
|
+
-v Set $VERBOSE to enable debugging,
|
|
121
|
+
--version Print ERB version string and exit.
|
|
122
|
+
-x Print generated Ruby source code.
|
|
123
|
+
-- Treat all following words as filepaths (not options).
|
|
124
|
+
name=value Set the variable named name to the given string value.
|
|
125
|
+
|
|
126
|
+
Filepaths:
|
|
127
|
+
The erb program reads the text from all files at the filepaths as a single ERB template:
|
|
128
|
+
plain text, possibly with embedded ERB tags;
|
|
129
|
+
filepaths may be repeated.
|
|
130
|
+
|
|
131
|
+
The pseudo-filepath '-' (hyphen character) specifies the standard input.
|
|
132
|
+
|
|
133
|
+
If no filepaths are given, the sole input is the standard input.
|
|
134
|
+
|
|
135
|
+
See details and examples at https://docs.ruby-lang.org/en/master/erb_executable_md.html
|
|
136
|
+
EOU
|
|
137
|
+
exit 1
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
$<.set_encoding(Encoding::UTF_8, nil)
|
|
141
|
+
src = $<.read
|
|
142
|
+
filename = $FILENAME
|
|
143
|
+
exit 2 unless src
|
|
144
|
+
trim = trim_mode_opt(trim_mode, disable_percent)
|
|
145
|
+
erb = factory.new(src, trim_mode: trim)
|
|
146
|
+
erb.filename = filename
|
|
147
|
+
if output
|
|
148
|
+
if number
|
|
149
|
+
erb.src.each_line.with_index do |line, l|
|
|
150
|
+
puts "%3d %s"%[l+1, line]
|
|
151
|
+
end
|
|
152
|
+
else
|
|
153
|
+
puts erb.src
|
|
154
|
+
end
|
|
155
|
+
else
|
|
156
|
+
bind = TOPLEVEL_BINDING
|
|
157
|
+
if variables
|
|
158
|
+
enc = erb.encoding
|
|
159
|
+
for var, val in variables do
|
|
160
|
+
val = val.encode(enc) if val
|
|
161
|
+
bind.local_variable_set(var, val)
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
erb.run(bind)
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
module_function :run
|
|
168
|
+
|
|
169
|
+
def set_encoding(extern, intern = nil)
|
|
170
|
+
verbose, $VERBOSE = $VERBOSE, nil
|
|
171
|
+
Encoding.default_external = extern unless extern.nil? || extern == ""
|
|
172
|
+
Encoding.default_internal = intern unless intern.nil? || intern == ""
|
|
173
|
+
[$stdin, $stdout, $stderr].each do |io|
|
|
174
|
+
io.set_encoding(extern, intern)
|
|
175
|
+
end
|
|
176
|
+
ensure
|
|
177
|
+
$VERBOSE = verbose
|
|
178
|
+
end
|
|
179
|
+
module_function :set_encoding
|
|
180
|
+
class << self; private :set_encoding; end
|
|
181
|
+
end
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
ERB::Main.run
|
metadata
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: ed-precompiled_erb
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 5.0.3
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Masatoshi SEKI
|
|
8
|
+
- Takashi Kokubun
|
|
9
|
+
bindir: libexec
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: An easy to use but powerful templating system for Ruby.
|
|
14
|
+
email:
|
|
15
|
+
- seki@ruby-lang.org
|
|
16
|
+
- k0kubun@ruby-lang.org
|
|
17
|
+
executables:
|
|
18
|
+
- erb
|
|
19
|
+
extensions:
|
|
20
|
+
- ext/erb/escape/extconf.rb
|
|
21
|
+
extra_rdoc_files: []
|
|
22
|
+
files:
|
|
23
|
+
- ".document"
|
|
24
|
+
- ".github/dependabot.yml"
|
|
25
|
+
- ".github/workflows/dependabot_automerge.yml"
|
|
26
|
+
- ".github/workflows/sync-ruby.yml"
|
|
27
|
+
- ".github/workflows/test.yml"
|
|
28
|
+
- ".gitignore"
|
|
29
|
+
- ".rdoc_options"
|
|
30
|
+
- BDSL
|
|
31
|
+
- COPYING
|
|
32
|
+
- Gemfile
|
|
33
|
+
- LICENSE.txt
|
|
34
|
+
- NEWS.md
|
|
35
|
+
- README.md
|
|
36
|
+
- Rakefile
|
|
37
|
+
- _doc/cgi.rb
|
|
38
|
+
- _doc/erb_executable.md
|
|
39
|
+
- bin/console
|
|
40
|
+
- bin/setup
|
|
41
|
+
- erb.gemspec
|
|
42
|
+
- ext/erb/escape/escape.c
|
|
43
|
+
- ext/erb/escape/extconf.rb
|
|
44
|
+
- lib/erb.rb
|
|
45
|
+
- lib/erb/compiler.rb
|
|
46
|
+
- lib/erb/def_method.rb
|
|
47
|
+
- lib/erb/util.rb
|
|
48
|
+
- lib/erb/version.rb
|
|
49
|
+
- libexec/erb
|
|
50
|
+
homepage: https://github.com/ruby/erb
|
|
51
|
+
licenses:
|
|
52
|
+
- Ruby
|
|
53
|
+
- BSD-2-Clause
|
|
54
|
+
metadata:
|
|
55
|
+
homepage_uri: https://github.com/ruby/erb
|
|
56
|
+
source_code_uri: https://github.com/ruby/erb
|
|
57
|
+
rdoc_options: []
|
|
58
|
+
require_paths:
|
|
59
|
+
- lib
|
|
60
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
61
|
+
requirements:
|
|
62
|
+
- - ">="
|
|
63
|
+
- !ruby/object:Gem::Version
|
|
64
|
+
version: 3.2.0
|
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
66
|
+
requirements:
|
|
67
|
+
- - ">="
|
|
68
|
+
- !ruby/object:Gem::Version
|
|
69
|
+
version: '0'
|
|
70
|
+
requirements: []
|
|
71
|
+
rubygems_version: 3.6.7
|
|
72
|
+
specification_version: 4
|
|
73
|
+
summary: An easy to use but powerful templating system for Ruby.
|
|
74
|
+
test_files: []
|