Sha256: 3f1219eb2ae9402514a62b959efa72252edcc1f8cead39d0b193f61608e01a5a

Contents?: true

Size: 497 Bytes

Versions: 1

Compression:

Stored size: 497 Bytes

Contents

require_relative "version"

class VersionSyntaxConverter
  def rubygem_to_npm(rubygem_version = ReactOnRails::VERSION)
    regex_match = rubygem_version.match(/(\d+\.\d+\.\d+)[.\-]?(.+)?/)
    if regex_match[2]
      return "#{regex_match[1]}-#{regex_match[2]}"
    else
      return "#{regex_match[1]}"
    end
  end

  def npm_to_rubygem(npm_version)
    match = npm_version
            .tr("-", ".")
            .strip
            .match(/(\d.*)/)
    match.present? ? match[0] : nil
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
react_on_rails-2.0.2 lib/react_on_rails/version_syntax_converter.rb