Class: ViewSpec::SourceFile
- Inherits:
-
Object
- Object
- ViewSpec::SourceFile
- Defined in:
- lib/view_spec/source_file.rb
Instance Attribute Summary collapse
-
#absolute_path ⇒ Object
(also: #to_pathname)
readonly
Returns the value of attribute absolute_path.
Instance Method Summary collapse
- #app_path ⇒ Object
-
#initialize(absolute_path) ⇒ SourceFile
constructor
A new instance of SourceFile.
- #lookup_path ⇒ Object
- #normalized_name ⇒ Object
- #relative_path ⇒ Object
- #spec_file? ⇒ Boolean
Constructor Details
#initialize(absolute_path) ⇒ SourceFile
Returns a new instance of SourceFile.
8 9 10 |
# File 'lib/view_spec/source_file.rb', line 8 def initialize(absolute_path) @absolute_path = Pathname(absolute_path) end |
Instance Attribute Details
#absolute_path ⇒ Object (readonly) Also known as: to_pathname
Returns the value of attribute absolute_path.
3 4 5 |
# File 'lib/view_spec/source_file.rb', line 3 def absolute_path @absolute_path end |
Instance Method Details
#app_path ⇒ Object
25 26 27 |
# File 'lib/view_spec/source_file.rb', line 25 def app_path absolute_path.relative_path_from(Rails.root) end |
#lookup_path ⇒ Object
20 21 22 23 |
# File 'lib/view_spec/source_file.rb', line 20 def lookup_path relative_dirname = relative_path.dirname.to_s.delete_prefix(".") [relative_dirname.presence, normalized_name].compact.join("/") end |
#normalized_name ⇒ Object
12 13 14 |
# File 'lib/view_spec/source_file.rb', line 12 def normalized_name basename(".rb").to_s.delete_suffix(ViewSpec.config.spec_file_suffix) end |
#relative_path ⇒ Object
16 17 18 |
# File 'lib/view_spec/source_file.rb', line 16 def relative_path spec_file? ? absolute_path.relative_path_from(base_path) : app_path end |
#spec_file? ⇒ Boolean
29 30 31 |
# File 'lib/view_spec/source_file.rb', line 29 def spec_file? absolute_path.to_s.end_with?("#{ViewSpec.config.spec_file_suffix}.rb") end |