File: app.rb

package info (click to toggle)
ruby-faker 3.6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,360 kB
  • sloc: ruby: 20,654; makefile: 6; sh: 6
file content (68 lines) | stat: -rw-r--r-- 1,718 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# frozen_string_literal: true

module Faker
  class App < Base
    class << self
      ##
      # Produces an app name.
      #
      # @return [String]
      #
      # @example
      #   Faker::App.name #=> "Treeflex"
      #
      # @faker.version 1.4.3
      def name
        fetch('app.name')
      end

      ##
      # Produces a version string.
      #
      # @return [String]
      #
      # @example
      #   Faker::App.version #=> "1.85"
      #
      # @faker.version 1.4.3
      def version
        parse('app.version')
      end

      ##
      # Produces the name of an app's author.
      #
      # @return [String]
      #
      # @example
      #   Faker::App.author #=> "Daphne Swift"
      #
      # @faker.version 1.4.3
      def author
        parse('app.author')
      end

      ##
      # Produces a String representing a semantic version identifier.
      #
      # @param major [Integer, Range] An integer to use or a range to pick the integer from.
      # @param minor [Integer, Range] An integer to use or a range to pick the integer from.
      # @param patch [Integer, Range] An integer to use or a range to pick the integer from.
      # @return [String]
      #
      # @example
      #   Faker::App.semantic_version #=> "3.2.5"
      # @example
      #   Faker::App.semantic_version(major: 42) #=> "42.5.2"
      # @example
      #   Faker::App.semantic_version(minor: 100..101) #=> "42.100.4"
      # @example
      #   Faker::App.semantic_version(patch: 5..6) #=> "7.2.6"
      #
      # @faker.version 1.4.3
      def semantic_version(major: 0..9, minor: 0..9, patch: 1..9)
        [major, minor, patch].map { |chunk| sample(Array(chunk)) }.join('.')
      end
    end
  end
end