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.
25 26 27 |
# File 'lib/tapioca/helpers/source_uri.rb', line 25 def gem_version @gem_version end |
Class Method Details
.build(gem_name:, gem_version:, path:, line_number:) ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/tapioca/helpers/source_uri.rb', line 38 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
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/tapioca/helpers/source_uri.rb', line 58 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
51 52 53 54 55 |
# File 'lib/tapioca/helpers/source_uri.rb', line 51 def set_path(v) # rubocop:disable Naming/AccessorMethodName return if v.nil? @gem_version, @path = v.split("/", 2) end |
#to_s ⇒ Object
70 71 72 |
# File 'lib/tapioca/helpers/source_uri.rb', line 70 def to_s "source://#{gem_name}/#{gem_version}#{path}##{line_number}" end |