Module: Hanami::CLI::Generators::Version Private

Defined in:
lib/hanami/cli/generators/version.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Since:

  • 2.0.0

Class Method Summary collapse

Class Method Details

.gem_requirementObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 2.0.0



19
20
21
22
23
24
25
26
27
# File 'lib/hanami/cli/generators/version.rb', line 19

def self.gem_requirement
  result = if prerelease?
             prerelease_version
           else
             stable_version
           end

  "~> #{result}"
end

.npm_package_requirementObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 2.0.0



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/hanami/cli/generators/version.rb', line 29

def self.npm_package_requirement
  result = version
  # Change "2.1.0.beta2.1" to "2.1.0-beta.2" (the only format tolerable by `npm install`)
  if prerelease?
    result = result
      .sub(/\.(alpha|beta|rc)/, '-\1')
      .sub(/(alpha|beta|rc)(\d+)(?:\.\d+)?\Z/, '\1.\2')
  end

  "^#{result}"
end

.prerelease?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

Since:

  • 2.0.0



43
44
45
# File 'lib/hanami/cli/generators/version.rb', line 43

def self.prerelease?
  version.match?(/alpha|beta|rc/)
end

.prerelease_versionObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Examples:

Hanami::VERSION # => 2.0.0.alpha8.1
Hanami::CLI::Generators::Version.stable_version # => "2.0.0.alpha"

Since:

  • 2.0.0



63
64
65
# File 'lib/hanami/cli/generators/version.rb', line 63

def self.prerelease_version
  version.sub(/[[[:digit:]].]*\Z/, "")
end

.stable_versionObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Examples:

Hanami::VERSION # => 2.0.0
Hanami::CLI::Generators::Version.stable_version # => "2.0"

Since:

  • 2.0.0



53
54
55
# File 'lib/hanami/cli/generators/version.rb', line 53

def self.stable_version
  version.scan(/\A\d{1,2}\.\d{1,2}/).first
end

.versionObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 2.0.0



11
12
13
14
15
# File 'lib/hanami/cli/generators/version.rb', line 11

def self.version
  return Hanami::VERSION if Hanami.const_defined?(:VERSION)

  Hanami::CLI::VERSION
end