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_host(clean) ⇒ 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
41 42 43 44 45 46 47 |
# File 'lib/terraspace_bundler/mod/concerns/notation_concern.rb', line 41 def clean_notation(source) clean = source .sub(/.*::/,'') # remove git:: .sub(%r{http[s?]://},'') # remove https:// .sub(%r{git@(.*?):},'') # remove git@word remove_host(clean) end |
#ref(source) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/terraspace_bundler/mod/concerns/notation_concern.rb', line 31 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_host(clean) ⇒ Object
49 50 51 52 53 54 55 56 57 |
# File 'lib/terraspace_bundler/mod/concerns/notation_concern.rb', line 49 def remove_host(clean) return clean unless clean.include?('ssh://') if clean.count(':') == 1 uri = URI(clean) uri.path else clean.split(':').last 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 21 |
# File 'lib/terraspace_bundler/mod/concerns/notation_concern.rb', line 13 def remove_subfolder_notation(source) clean = clean_notation(source) parts = clean.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
23 24 25 26 27 28 29 |
# File 'lib/terraspace_bundler/mod/concerns/notation_concern.rb', line 23 def subfolder(source) clean = clean_notation(source) parts = clean.split('//') if parts.size == 2 # has subfolder remove_ref_notation(parts.last) end end |