Class: URI::Source
- Inherits:
-
File
- Object
- File
- URI::Source
- Extended by:
- T::Sig
- Defined in:
- lib/tapioca/helpers/source_uri.rb
Constant Summary collapse
- COMPONENT =
T.let([ :scheme, :gem_name, :gem_version, :path, :line_number, ].freeze, T::Array[Symbol])
Instance Attribute Summary collapse
-
#gem_version ⇒ Object
readonly
Returns the value of attribute gem_version.
Class Method Summary collapse
Instance Method Summary collapse
- #check_host(v) ⇒ Object
-
#set_path(v) ⇒ Object
rubocop:disable Naming/AccessorMethodName.
- #to_s ⇒ Object
Instance Attribute Details
#gem_version ⇒ Object (readonly)
Returns the value of attribute gem_version.
22 23 24 |
# File 'lib/tapioca/helpers/source_uri.rb', line 22 def gem_version @gem_version end |
Class Method Details
.build(gem_name:, gem_version:, path:, line_number:) ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/tapioca/helpers/source_uri.rb', line 35 def build(gem_name:, gem_version:, path:, line_number:) super( { scheme: "source", host: gem_name, path: DEFAULT_PARSER.escape("/#{gem_version}/#{path}"), fragment: line_number, } ) end |
Instance Method Details
#check_host(v) ⇒ Object
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/tapioca/helpers/source_uri.rb', line 55 def check_host(v) return true unless v if /[A-Za-z][A-Za-z0-9\-_]*/ !~ v raise InvalidComponentError, "bad component(expected gem name): #{v}" end true end |
#set_path(v) ⇒ Object
rubocop:disable Naming/AccessorMethodName
48 49 50 51 52 |
# File 'lib/tapioca/helpers/source_uri.rb', line 48 def set_path(v) # rubocop:disable Naming/AccessorMethodName return if v.nil? @gem_version, @path = v.split("/", 2) end |
#to_s ⇒ Object
67 68 69 |
# File 'lib/tapioca/helpers/source_uri.rb', line 67 def to_s "source://#{gem_name}/#{gem_version}#{path}##{line_number}" end |