Module: Solargraph::Rspec::PinFactory
- Defined in:
- lib/solargraph/rspec/pin_factory.rb
Overview
Factory class for building pins and references.
Class Method Summary collapse
- .build_location(location_range, path) ⇒ Solargraph::Location
- .build_location_range(ast) ⇒ Solargraph::Range
- .build_module_extend(namespace, module_name, location) ⇒ Solargraph::Pin::Reference::Extend
- .build_module_include(namespace, module_name, location) ⇒ Solargraph::Pin::Reference::Include
- .build_public_method(namespace, name, types: nil, location: nil, comments: [], attribute: false, scope: :instance, node: nil) ⇒ Solargraph::Pin::Method
- .dummy_location(path) ⇒ Solargraph::Location
Class Method Details
.build_location(location_range, path) ⇒ Solargraph::Location
92 93 94 95 96 97 |
# File 'lib/solargraph/rspec/pin_factory.rb', line 92 def self.build_location(location_range, path) Solargraph::Location.new( File.(path), location_range ) end |
.build_location_range(ast) ⇒ Solargraph::Range
80 81 82 83 84 85 86 87 |
# File 'lib/solargraph/rspec/pin_factory.rb', line 80 def self.build_location_range(ast) Solargraph::Range.from_to( ast.first_lineno - 1, ast.first_column, ast.last_lineno - 1, ast.last_column ) end |
.build_module_extend(namespace, module_name, location) ⇒ Solargraph::Pin::Reference::Extend
60 61 62 63 64 65 66 |
# File 'lib/solargraph/rspec/pin_factory.rb', line 60 def self.build_module_extend(namespace, module_name, location) Solargraph::Pin::Reference::Extend.new( closure: namespace, name: module_name, location: location ) end |
.build_module_include(namespace, module_name, location) ⇒ Solargraph::Pin::Reference::Include
48 49 50 51 52 53 54 |
# File 'lib/solargraph/rspec/pin_factory.rb', line 48 def self.build_module_include(namespace, module_name, location) Solargraph::Pin::Reference::Include.new( closure: namespace, name: module_name, location: location ) end |
.build_public_method(namespace, name, types: nil, location: nil, comments: [], attribute: false, scope: :instance, node: nil) ⇒ Solargraph::Pin::Method
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/solargraph/rspec/pin_factory.rb', line 17 def self.build_public_method( namespace, name, types: nil, location: nil, comments: [], attribute: false, scope: :instance, node: nil ) opts = { name: name, location: location, closure: namespace, scope: scope, attribute: attribute, comments: [], node: node } comments << "@return [#{types.join(",")}]" if types opts[:comments] = comments.join("\n") Solargraph::Pin::Method.new(**opts) end |
.dummy_location(path) ⇒ Solargraph::Location
70 71 72 73 74 75 |
# File 'lib/solargraph/rspec/pin_factory.rb', line 70 def self.dummy_location(path) Solargraph::Location.new( File.(path), Solargraph::Range.from_to(0, 0, 0, 0) ) end |