brakeman 7.1.2 → 8.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.
Files changed (130) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +11 -0
  3. data/README.md +1 -1
  4. data/bundle/load.rb +2 -2
  5. data/bundle/ruby/3.2.0/gems/erubi-1.13.1/CHANGELOG +111 -0
  6. data/bundle/ruby/3.2.0/gems/{erubis-2.7.0 → erubi-1.13.1}/MIT-LICENSE +1 -0
  7. data/bundle/ruby/3.2.0/gems/erubi-1.13.1/README.rdoc +151 -0
  8. data/bundle/ruby/3.2.0/gems/erubi-1.13.1/lib/erubi/capture_block.rb +91 -0
  9. data/bundle/ruby/3.2.0/gems/erubi-1.13.1/lib/erubi/capture_end.rb +58 -0
  10. data/bundle/ruby/3.2.0/gems/erubi-1.13.1/lib/erubi.rb +299 -0
  11. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/asciidoc.rb +12 -5
  12. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/babel.rb +5 -0
  13. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/builder.rb +4 -0
  14. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/coffee.rb +14 -4
  15. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/commonmarker.rb +41 -0
  16. data/bundle/ruby/3.2.0/gems/tilt-2.7.0/lib/tilt/csv.rb +63 -0
  17. data/bundle/ruby/3.2.0/gems/tilt-2.7.0/lib/tilt/erb.rb +130 -0
  18. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/erubi.rb +41 -8
  19. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/etanni.rb +7 -0
  20. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/haml.rb +67 -1
  21. data/bundle/ruby/3.2.0/gems/tilt-2.7.0/lib/tilt/kramdown.rb +59 -0
  22. data/bundle/ruby/3.2.0/gems/tilt-2.7.0/lib/tilt/liquid.rb +93 -0
  23. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/livescript.rb +11 -4
  24. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/mapping.rb +8 -8
  25. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/markaby.rb +11 -2
  26. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/nokogiri.rb +13 -2
  27. data/bundle/ruby/3.2.0/gems/tilt-2.7.0/lib/tilt/pandoc.rb +81 -0
  28. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/pipeline.rb +6 -1
  29. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/plain.rb +5 -1
  30. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/prawn.rb +17 -6
  31. data/bundle/ruby/3.2.0/gems/tilt-2.7.0/lib/tilt/radius.rb +96 -0
  32. data/bundle/ruby/3.2.0/gems/tilt-2.7.0/lib/tilt/rdiscount.rb +82 -0
  33. data/bundle/ruby/3.2.0/gems/tilt-2.7.0/lib/tilt/rdoc.rb +33 -0
  34. data/bundle/ruby/3.2.0/gems/tilt-2.7.0/lib/tilt/redcarpet.rb +73 -0
  35. data/bundle/ruby/3.2.0/gems/tilt-2.7.0/lib/tilt/redcloth.rb +40 -0
  36. data/bundle/ruby/3.2.0/gems/tilt-2.7.0/lib/tilt/rst-pandoc.rb +33 -0
  37. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/sass.rb +16 -3
  38. data/bundle/ruby/3.2.0/gems/tilt-2.7.0/lib/tilt/slim.rb +18 -0
  39. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/string.rb +10 -2
  40. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/template.rb +5 -5
  41. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/typescript.rb +5 -0
  42. data/bundle/ruby/3.2.0/gems/tilt-2.7.0/lib/tilt/yajl.rb +91 -0
  43. data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt.rb +1 -2
  44. data/lib/brakeman/app_tree.rb +7 -2
  45. data/lib/brakeman/checks/check_model_attributes.rb +1 -1
  46. data/lib/brakeman/checks/check_render.rb +1 -27
  47. data/lib/brakeman/checks/check_render_rce.rb +43 -0
  48. data/lib/brakeman/checks/check_session_settings.rb +1 -1
  49. data/lib/brakeman/checks.rb +31 -25
  50. data/lib/brakeman/commandline.rb +6 -1
  51. data/lib/brakeman/file_parser.rb +3 -2
  52. data/lib/brakeman/logger.rb +264 -0
  53. data/lib/brakeman/options.rb +0 -9
  54. data/lib/brakeman/parsers/rails_erubi.rb +82 -0
  55. data/lib/brakeman/parsers/template_parser.rb +7 -15
  56. data/lib/brakeman/processor.rb +2 -2
  57. data/lib/brakeman/processors/controller_alias_processor.rb +1 -1
  58. data/lib/brakeman/processors/controller_processor.rb +3 -3
  59. data/lib/brakeman/processors/{erubis_template_processor.rb → erubi_template_procesor.rb} +3 -3
  60. data/lib/brakeman/processors/lib/rails2_config_processor.rb +4 -3
  61. data/lib/brakeman/processors/lib/rails2_route_processor.rb +1 -1
  62. data/lib/brakeman/processors/lib/render_helper.rb +1 -1
  63. data/lib/brakeman/processors/lib/render_path.rb +1 -1
  64. data/lib/brakeman/processors/model_processor.rb +1 -1
  65. data/lib/brakeman/report/ignore/config.rb +1 -1
  66. data/lib/brakeman/scanner.rb +25 -49
  67. data/lib/brakeman/tracker/collection.rb +12 -2
  68. data/lib/brakeman/tracker/config.rb +17 -13
  69. data/lib/brakeman/tracker/constants.rb +17 -2
  70. data/lib/brakeman/tracker/controller.rb +1 -1
  71. data/lib/brakeman/tracker.rb +7 -15
  72. data/lib/brakeman/version.rb +1 -1
  73. data/lib/brakeman.rb +89 -49
  74. metadata +51 -80
  75. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/CHANGES.txt +0 -828
  76. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/README.txt +0 -102
  77. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/contrib/erubis +0 -3468
  78. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/contrib/erubis-run.rb +0 -132
  79. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/contrib/inline-require +0 -179
  80. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/context.rb +0 -83
  81. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/converter.rb +0 -357
  82. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/ec.rb +0 -117
  83. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/ecpp.rb +0 -113
  84. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/ejava.rb +0 -110
  85. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/ejavascript.rb +0 -119
  86. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/enhanced.rb +0 -126
  87. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/eperl.rb +0 -95
  88. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/ephp.rb +0 -99
  89. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/eruby.rb +0 -125
  90. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/escheme.rb +0 -114
  91. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine/optimized.rb +0 -127
  92. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/engine.rb +0 -120
  93. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/enhancer.rb +0 -723
  94. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/error.rb +0 -23
  95. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/evaluator.rb +0 -88
  96. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/generator.rb +0 -85
  97. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/helper.rb +0 -47
  98. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/helpers/rails_form_helper.rb +0 -197
  99. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/helpers/rails_helper.rb +0 -353
  100. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/local-setting.rb +0 -9
  101. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/main.rb +0 -516
  102. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/preprocessing.rb +0 -58
  103. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/tiny.rb +0 -144
  104. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis/util.rb +0 -22
  105. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/lib/erubis.rb +0 -73
  106. data/bundle/ruby/3.2.0/gems/erubis-2.7.0/setup.rb +0 -1331
  107. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/creole.rb +0 -16
  108. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/csv.rb +0 -53
  109. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/erb.rb +0 -65
  110. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/kramdown.rb +0 -13
  111. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/liquid.rb +0 -37
  112. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/pandoc.rb +0 -39
  113. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/radius.rb +0 -41
  114. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/rdiscount.rb +0 -23
  115. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/rdoc.rb +0 -11
  116. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/redcarpet.rb +0 -31
  117. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/redcloth.rb +0 -13
  118. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/rst-pandoc.rb +0 -10
  119. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/slim.rb +0 -5
  120. data/bundle/ruby/3.2.0/gems/tilt-2.6.1/lib/tilt/yajl.rb +0 -81
  121. data/lib/brakeman/parsers/erubis_patch.rb +0 -11
  122. data/lib/brakeman/parsers/rails2_erubis.rb +0 -9
  123. data/lib/brakeman/parsers/rails2_xss_plugin_erubis.rb +0 -52
  124. data/lib/brakeman/parsers/rails3_erubis.rb +0 -85
  125. /data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/COPYING +0 -0
  126. /data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/_emacs_org.rb +0 -0
  127. /data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/_handlebars.rb +0 -0
  128. /data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/_jbuilder.rb +0 -0
  129. /data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/_org.rb +0 -0
  130. /data/bundle/ruby/3.2.0/gems/{tilt-2.6.1 → tilt-2.7.0}/lib/tilt/cli.rb +0 -0
@@ -1,132 +0,0 @@
1
- =begin
2
-
3
- = apache/erubis-run.rb
4
-
5
- Copyright (C) 2007 Andrew R Jackson <arjackson at acm dot org>
6
-
7
- Built from original by Shugo Maeda:
8
- Copyright (C) 2001 Shugo Maeda <shugo@modruby.net>
9
-
10
- All rights reserved.
11
-
12
- Redistribution and use in source and binary forms, with or without
13
- modification, are permitted provided that the following conditions
14
- are met:
15
- 1. Redistributions of source code must retain the above copyright
16
- notice, this list of conditions and the following disclaimer.
17
- 2. Redistributions in binary form must reproduce the above copyright
18
- notice, this list of conditions and the following disclaimer in the
19
- documentation and/or other materials provided with the distribution.
20
-
21
- THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22
- ANY EXPRESS OR IMPLIED WAreqANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23
- IMPLIED WAreqANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24
- ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27
- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTEreqUPTION)
28
- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29
- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30
- OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31
- SUCH DAMAGE.
32
-
33
- == Overview
34
-
35
- Apache::ErubisRun handles eRuby files with erubis
36
-
37
- == Example of httpd.conf
38
-
39
- RubyRequire apache/erubis-run
40
- <Location /eruby>
41
- SetHandler ruby-object
42
- RubyHandler Apache::ErubisRun.instance
43
- </Location>
44
-
45
- =end
46
-
47
- require "singleton"
48
- require "tempfile"
49
- require "eruby" # Still needed to bring in a couple useful helper methods
50
- require "erubis"
51
-
52
- module Erubis
53
- @@cgi = nil
54
-
55
- def self.cgi
56
- return @@cgi
57
- end
58
-
59
- def self.cgi=(cgi)
60
- @@cgi = cgi
61
- end
62
- end
63
-
64
- module Apache
65
- class ErubisRun
66
- include Singleton
67
-
68
- def handler(req)
69
- status = check_request(req)
70
- return status if(status != OK)
71
-
72
- filename = req.filename.dup
73
- filename.untaint
74
- erubis = compile(filename)
75
- prerun(req)
76
- begin
77
- run(erubis, filename)
78
- ensure
79
- postrun(req)
80
- end
81
-
82
- return OK
83
- end
84
-
85
- private
86
-
87
- def initialize
88
- @compiler = nil
89
- end
90
-
91
- def check_request(req)
92
- if(req.method_number == M_OPTIONS)
93
- req.allowed |= (1 << M_GET)
94
- req.allowed |= (1 << M_POST)
95
- return DECLINED
96
- end
97
- if(req.finfo.mode == 0)
98
- return NOT_FOUND
99
- end
100
- return OK
101
- end
102
-
103
- def compile(filename)
104
- @compiler = Erubis::Eruby.load_file(filename) # use caching version as much as possible
105
- return @compiler
106
- end
107
-
108
- def prerun(req)
109
- Erubis.cgi = nil
110
- req.setup_cgi_env
111
- Apache.chdir_file(req.filename)
112
- end
113
-
114
- def run(erubis, filename)
115
- binding = eval_string_wrap("binding")
116
- puts erubis.result(binding) # eval the code in the context of the same binding ERuby uses
117
- end
118
-
119
- def postrun(req)
120
- if(cgi = Erubis.cgi)
121
- # TODO: pull the content type header from the cgi object, if set there?
122
- elsif(req.sync_output or req.sync_header)
123
- # Do nothing: header has already been sent
124
- else
125
- unless(req.content_type)
126
- req.content_type = format("text/html;")
127
- end
128
- req.send_http_header
129
- end
130
- end
131
- end
132
- end
@@ -1,179 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- ###
4
- ### inline-require - expand 'require "foo"' into inline code
5
- ###
6
- ### usage: inline-require [-h] [-I path[,path2,..]] script
7
- ###
8
- ### copyright(c) 2006-2011 kuwata-lab.com all rights reserved.
9
- ### 2.7.0
10
- ### $Rev: 10 $
11
- ###
12
-
13
-
14
- class InlineRequire
15
-
16
- def initialize(opts={})
17
- @opts = opts.dup
18
- end
19
- attr_accessor :opts
20
-
21
- def expand(filename)
22
- sbuf = ''
23
- inlined = []
24
- level = 0
25
- expand_require(filename, sbuf, inlined, level)
26
- return sbuf
27
- end
28
-
29
- private
30
-
31
- def expand_require(filename, sbuf, inlined, level)
32
- raise "*** assertion error" if inlined.include?(filename)
33
- remove_comment = @opts[:remove_comment]
34
- expand_indented = @opts[:expand_indented]
35
- keep_filename = @opts[:keep_filename]
36
- loaded_features = @opts[:loaded_features]
37
- inlined << filename
38
- prog = File.read(filename)
39
- n = 0
40
- flag_if_file = false
41
- prog.each_line do |line|
42
- n += 1
43
-
44
- ## comment out from 'if __FILE__ == $0' to 'end'
45
- if level > 0
46
- if flag_if_file
47
- sbuf << "#" << line
48
- flag_if_file = false if line =~ /^end$/
49
- next
50
- end
51
- if line =~ /^if\s+__FILE__\s*==\s*\$0(\s+then)?$/ || line =~ /^if\s+\$0\s*==\s*__FILE__(\s+then)?$/
52
- flag_if_file = true
53
- sbuf << "#" << line
54
- next
55
- end
56
- end
57
-
58
- ## find 'require "foo"' and expand it to inline code
59
- flag_inline = false
60
- pattern = expand_indented ? /^[ \t]*require ['"](.*)["']\s*$/ \
61
- : /^require ['"](.*)["']\s*$/
62
- if line =~ pattern
63
- libname = $1
64
- libpath = find_library(libname)
65
- $stderr.puts "*** debug: libpath=#{libpath.inspect}" if $debug_mode
66
- unless libpath
67
- #raise "file '#{filename}'(line #{n}): library '#{libname}' not found."
68
- warn "file '#{filename}'(line #{n}): library '#{libname}' not found."
69
- else
70
- flag_inline = true if libpath =~ /\.rb$/ && local_library?(libpath)
71
- end
72
- end
73
- if !flag_inline
74
- sbuf << line unless remove_comment && line =~ /^[ \t]*\#/
75
- elsif inlined.include?(libpath)
76
- sbuf << "#--already included #{line}" unless remove_comment
77
- else
78
- if keep_filename
79
- @n ||= 0; @n += 1; n = @n
80
- end
81
- sbuf << "#--begin of #{line}" unless remove_comment
82
- sbuf << "$LOADED_FEATURES << '#{libname}.rb'\n" if loaded_features
83
- sbuf << "eval <<'END_OF_SCRIPT__#{n}', TOPLEVEL_BINDING, '#{libpath}', 1\n" if keep_filename
84
- expand_require(libpath, sbuf, inlined, level+1)
85
- sbuf << "END_OF_SCRIPT__#{n}\n" if keep_filename
86
- sbuf << "#--end of #{line}" unless remove_comment
87
- end
88
- end
89
- #sbuf << "\n" if sbuf[-1] != ?\n
90
- end
91
-
92
- def local_library?(libpath)
93
- return libpath !~ /^\//
94
- end
95
-
96
- def find_library(libname)
97
- if libname =~ /^\.rb$/
98
- libname_rb = libname
99
- libname_so = nil
100
- elsif libname =~ /^\.so$/
101
- libname_rb = nil
102
- libname_so = libname
103
- else
104
- libname_rb = libname + ".rb"
105
- libname_so = libname + ".so"
106
- end
107
- $LOAD_PATH.each do |path|
108
- if libname_rb
109
- libpath = path + "/" + libname_rb
110
- return libpath if test(?f, libpath)
111
- end
112
- if libname_so
113
- libpath = path + "/" + libname_so
114
- return libpath if test(?f, libpath)
115
- end
116
- end
117
- return nil
118
- end
119
-
120
- end
121
-
122
- if __FILE__ == $0
123
-
124
- begin
125
- require "optparse"
126
- op = OptionParser.new
127
- options = {}
128
- op.on("-h", "--help") {|v| options[:help] = v }
129
- op.on("-I libpath") {|v| options[:libpath] = v }
130
- op.on("-i") {|v| options[:expand_indented] = v }
131
- op.on("-c") {|v| options[:remove_comment] = v }
132
- op.on("-k") {|v| options[:keep_filename] = v }
133
- op.on("-l") {|v| options[:loaded_features] = v }
134
- op.on("-D") {|v| options[:debug] = v }
135
- op.parse!()
136
-
137
- $debug_mode = options[:debug]
138
-
139
- if options[:help]
140
- command = File.basename($0)
141
- puts "Usage: #{command} [-h] [-I path[,path2,..]] script"
142
- puts " -h : help"
143
- puts " -i : expand indented require(), too"
144
- puts " -c : remove comment lines start with '#'"
145
- puts " -k : keep filename (for debugging)"
146
- puts " -l : append libs to $LOADED_FEATURES"
147
- puts " -I path[,path2,...] : ruby library path"
148
- exit(0)
149
- end
150
-
151
- if options[:libpath]
152
- rubylib_paths = options[:libpath].split(/,/)
153
- else
154
- rubylib_paths = []
155
- end
156
- $stderr.puts "*** debug: rubylib_paths=#{rubylib_paths.inspect}" if $debug_mode
157
- $LOAD_PATH.concat(rubylib_paths)
158
-
159
- filenames = ARGV
160
-
161
- opts = { :expand_indented => options[:expand_indented],
162
- :remove_comment => options[:remove_comment],
163
- :keep_filename => options[:keep_filename],
164
- :loaded_features => options[:loaded_features] }
165
- inline_require = InlineRequire.new(opts)
166
- filenames.each do |filename|
167
- print inline_require.expand(filename)
168
- end
169
-
170
- rescue => ex
171
- if $debug_mode
172
- raise ex
173
- else
174
- $stderr.puts ex.message
175
- end
176
-
177
- end
178
-
179
- end
@@ -1,83 +0,0 @@
1
- ##
2
- ## $Release: 2.7.0 $
3
- ## copyright(c) 2006-2011 kuwata-lab.com all rights reserved.
4
- ##
5
-
6
-
7
- module Erubis
8
-
9
-
10
- ##
11
- ## context object for Engine#evaluate
12
- ##
13
- ## ex.
14
- ## template = <<'END'
15
- ## Hello <%= @user %>!
16
- ## <% for item in @list %>
17
- ## - <%= item %>
18
- ## <% end %>
19
- ## END
20
- ##
21
- ## context = Erubis::Context.new(:user=>'World', :list=>['a','b','c'])
22
- ## # or
23
- ## # context = Erubis::Context.new
24
- ## # context[:user] = 'World'
25
- ## # context[:list] = ['a', 'b', 'c']
26
- ##
27
- ## eruby = Erubis::Eruby.new(template)
28
- ## print eruby.evaluate(context)
29
- ##
30
- class Context
31
- include Enumerable
32
-
33
- def initialize(hash=nil)
34
- hash.each do |name, value|
35
- self[name] = value
36
- end if hash
37
- end
38
-
39
- def [](key)
40
- return instance_variable_get("@#{key}")
41
- end
42
-
43
- def []=(key, value)
44
- return instance_variable_set("@#{key}", value)
45
- end
46
-
47
- def keys
48
- return instance_variables.collect { |name| name[1..-1] }
49
- end
50
-
51
- def each
52
- instance_variables.each do |name|
53
- key = name[1..-1]
54
- value = instance_variable_get(name)
55
- yield(key, value)
56
- end
57
- end
58
-
59
- def to_hash
60
- hash = {}
61
- self.keys.each { |key| hash[key] = self[key] }
62
- return hash
63
- end
64
-
65
- def update(context_or_hash)
66
- arg = context_or_hash
67
- if arg.is_a?(Hash)
68
- arg.each do |key, val|
69
- self[key] = val
70
- end
71
- else
72
- arg.instance_variables.each do |varname|
73
- key = varname[1..-1]
74
- val = arg.instance_variable_get(varname)
75
- self[key] = val
76
- end
77
- end
78
- end
79
-
80
- end
81
-
82
-
83
- end