Class: Vernier::Output::FilenameFilter
- Inherits:
-
Object
- Object
- Vernier::Output::FilenameFilter
- Defined in:
- lib/vernier/output/filename_filter.rb
Instance Attribute Summary collapse
-
#gem_match_regex ⇒ Object
readonly
Returns the value of attribute gem_match_regex.
-
#gem_regex ⇒ Object
readonly
Returns the value of attribute gem_regex.
-
#pwd ⇒ Object
readonly
Returns the value of attribute pwd.
-
#rubylibdir ⇒ Object
readonly
Returns the value of attribute rubylibdir.
Instance Method Summary collapse
- #call(filename) ⇒ Object
-
#initialize ⇒ FilenameFilter
constructor
A new instance of FilenameFilter.
Constructor Details
#initialize ⇒ FilenameFilter
6 7 8 9 10 11 |
# File 'lib/vernier/output/filename_filter.rb', line 6 def initialize @pwd = "#{Dir.pwd}/" @gem_regex = %r{\A#{Regexp.union(Gem.path)}/gems/} @gem_match_regex = %r{\A#{Regexp.union(Gem.path)}/gems/([a-zA-Z](?:[a-zA-Z0-9\.\_]|-[a-zA-Z])*)-([0-9][0-9A-Za-z\-_\.]*)/(.*)\z} @rubylibdir = "#{RbConfig::CONFIG["rubylibdir"]}/" end |
Instance Attribute Details
#gem_match_regex ⇒ Object (readonly)
Returns the value of attribute gem_match_regex.
13 14 15 |
# File 'lib/vernier/output/filename_filter.rb', line 13 def gem_match_regex @gem_match_regex end |
#gem_regex ⇒ Object (readonly)
Returns the value of attribute gem_regex.
13 14 15 |
# File 'lib/vernier/output/filename_filter.rb', line 13 def gem_regex @gem_regex end |
#pwd ⇒ Object (readonly)
Returns the value of attribute pwd.
13 14 15 |
# File 'lib/vernier/output/filename_filter.rb', line 13 def pwd @pwd end |
#rubylibdir ⇒ Object (readonly)
Returns the value of attribute rubylibdir.
13 14 15 |
# File 'lib/vernier/output/filename_filter.rb', line 13 def rubylibdir @rubylibdir end |
Instance Method Details
#call(filename) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/vernier/output/filename_filter.rb', line 15 def call(filename) if filename.match?(gem_regex) gem_match_regex =~ filename "gem:#$1-#$2:#$3" elsif filename.start_with?(pwd) filename.delete_prefix(pwd) elsif filename.start_with?(rubylibdir) path = filename.delete_prefix(rubylibdir) "rubylib:#{RUBY_VERSION}:#{path}" else filename end end |