Module: TerraspaceBundler::Mod::Concerns::NotationConcern
- Included in:
- Props, Props::Typer
- Defined in:
- lib/terraspace_bundler/mod/concerns/notation_concern.rb
Instance Method Summary collapse
- #clean_notation(source) ⇒ Object
- #ref(source) ⇒ Object
- #remove_notations(source) ⇒ Object
- #remove_ref_notation(source) ⇒ Object
- #remove_subfolder_notation(source) ⇒ Object
- #subfolder(source) ⇒ Object
Instance Method Details
#clean_notation(source) ⇒ Object
38 39 40 |
# File 'lib/terraspace_bundler/mod/concerns/notation_concern.rb', line 38 def clean_notation(source) source.sub(/.*::/,'').sub(%r{http[s?]://},'').sub(%r{git@(.*?):},'') # also remove git@ notation end |
#ref(source) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/terraspace_bundler/mod/concerns/notation_concern.rb', line 29 def ref(source) url = clean_notation(source) uri = URI(url) if uri.query params = URI::decode_www_form(uri.query).to_h # if you are in 2.1 or later version of Ruby params['ref'] end end |
#remove_notations(source) ⇒ Object
5 6 7 |
# File 'lib/terraspace_bundler/mod/concerns/notation_concern.rb', line 5 def remove_notations(source) remove_subfolder_notation(remove_ref_notation(source)) end |
#remove_ref_notation(source) ⇒ Object
9 10 11 |
# File 'lib/terraspace_bundler/mod/concerns/notation_concern.rb', line 9 def remove_ref_notation(source) source.sub(/\?.*/,'') end |
#remove_subfolder_notation(source) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/terraspace_bundler/mod/concerns/notation_concern.rb', line 13 def remove_subfolder_notation(source) parts = clean_notation(source).split('//') if parts.size == 2 # has subfolder source.split('//')[0..-2].join('//') # remove only subfolder, keep rest of original source else source end end |
#subfolder(source) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/terraspace_bundler/mod/concerns/notation_concern.rb', line 22 def subfolder(source) parts = clean_notation(source).split('//') if parts.size == 2 # has subfolder remove_ref_notation(parts.last) end end |