Class: ReactOnRails::VersionSyntaxConverter
- Inherits:
-
Object
- Object
- ReactOnRails::VersionSyntaxConverter
- Defined in:
- lib/react_on_rails/version_syntax_converter.rb
Instance Method Summary collapse
- #npm_to_rubygem(npm_version) ⇒ Object
- #rubygem_to_npm(rubygem_version = ReactOnRails::VERSION) ⇒ Object
Instance Method Details
#npm_to_rubygem(npm_version) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/react_on_rails/version_syntax_converter.rb', line 14 def npm_to_rubygem(npm_version) match = npm_version .tr("-", ".") .strip .match(/(\d.*)/) match.present? ? match[0] : nil end |
#rubygem_to_npm(rubygem_version = ReactOnRails::VERSION) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/react_on_rails/version_syntax_converter.rb', line 7 def rubygem_to_npm(rubygem_version = ReactOnRails::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 |