Class: Shakapacker::Utils::VersionSyntaxConverter
- Inherits:
-
Object
- Object
- Shakapacker::Utils::VersionSyntaxConverter
- Defined in:
- lib/shakapacker/utils/version_syntax_converter.rb
Instance Method Summary collapse
- #npm_to_rubygem(npm_version) ⇒ Object
- #rubygem_to_npm(rubygem_version = Shakapacker::VERSION) ⇒ Object
Instance Method Details
#npm_to_rubygem(npm_version) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/shakapacker/utils/version_syntax_converter.rb', line 15 def npm_to_rubygem(npm_version) match = npm_version .tr("-", ".") .strip .match(/(\d.*)/) match.present? ? match[0] : nil end |
#rubygem_to_npm(rubygem_version = Shakapacker::VERSION) ⇒ Object
8 9 10 11 12 13 |
# File 'lib/shakapacker/utils/version_syntax_converter.rb', line 8 def rubygem_to_npm(rubygem_version = Shakapacker::VERSION) regex_match = rubygem_version.match(/(\d+\.\d+\.\d+)[.\-]?(.+)?/) return "#{regex_match[1]}-#{regex_match[2]}" if regex_match[2] regex_match[1].to_s end |