Class: Yoda::Store::Actions::ReadFile
- Inherits:
-
Object
- Object
- Yoda::Store::Actions::ReadFile
- Defined in:
- lib/yoda/store/actions/read_file.rb
Instance Attribute Summary collapse
- #content ⇒ String? readonly
- #file ⇒ String readonly
- #registry ⇒ Registry readonly
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(registry, file, content: nil, root_path: nil) ⇒ ReadFile
constructor
A new instance of ReadFile.
- #run ⇒ void
Constructor Details
#initialize(registry, file, content: nil, root_path: nil) ⇒ ReadFile
Returns a new instance of ReadFile.
30 31 32 33 34 35 |
# File 'lib/yoda/store/actions/read_file.rb', line 30 def initialize(registry, file, content: nil, root_path: nil) @registry = registry @file = file @content = content @root_path = root_path end |
Instance Attribute Details
#content ⇒ String? (readonly)
12 13 14 |
# File 'lib/yoda/store/actions/read_file.rb', line 12 def content @content end |
#file ⇒ String (readonly)
9 10 11 |
# File 'lib/yoda/store/actions/read_file.rb', line 9 def file @file end |
#registry ⇒ Registry (readonly)
6 7 8 |
# File 'lib/yoda/store/actions/read_file.rb', line 6 def registry @registry end |
Class Method Details
.patch_id_for_file(file) ⇒ String
23 24 25 |
# File 'lib/yoda/store/actions/read_file.rb', line 23 def self.patch_id_for_file(file) YardImporter.patch_id_for_file(file) end |
.run(registry, file, content: nil, root_path: nil) ⇒ void
This method returns an undefined value.
17 18 19 |
# File 'lib/yoda/store/actions/read_file.rb', line 17 def self.run(registry, file, content: nil, root_path: nil) self.new(registry, file, content: content, root_path: root_path).run end |
Instance Method Details
#run ⇒ void
This method returns an undefined value.
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/yoda/store/actions/read_file.rb', line 38 def run YARD::Registry.clear if content YARD.parse_string(content) if Yoda::Parsing.parse_with_comments(content) else YARD.parse([file]) end patch = YardImporter.new(file, source_path: file).import(YARD::Registry.all + [YARD::Registry.root]).patch registry.local_store.add_file_patch(patch) end |