dummy_log_generator 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4b77ee9d48bae1cb615e7b45a3c3cc2b58388c48
4
- data.tar.gz: fbd14739b3aaf235d0e9e095c6d1777a4d6ae14c
3
+ metadata.gz: 87393b7e11cfd15b9095bd7017a3cc9114862326
4
+ data.tar.gz: bebf7667d4944db0f8f780108f766a387e963b0e
5
5
  SHA512:
6
- metadata.gz: ae54272e33cec7b6871acf5f6b63402ae4f83bc264fe48abddd63fe6741fd2ad71dae41a380e827f23a8ce91a65189f84ddccb3d5edd0a5b2b512974aad8e9f0
7
- data.tar.gz: 26ff83fa64e28e9c16b8163d3a2117f414da3add07f6082adb2f54af8706e497753a3a727b5ffedf704179d09d3b11a1343ba70cd6d3d4ce4be5bccc49aeba5e
6
+ metadata.gz: d90ec26f92a62473ccc1dd36429ef5f725e5f62448bb80fca062ea981a691fc97a4c72eab4f747632108cd3776e591f922d87240713edc1c719b3ff2047df270
7
+ data.tar.gz: 76d4e265b8c44a7cea642c5aa0f469be9aa841a1369c6454fb2059491903b1ba75712b5031ced0939834fe9dc7e674f9c4df1d422f72b39cb3e7b0d92ecf4d6c
@@ -1,3 +1,9 @@
1
+ ### 0.0.3
2
+
3
+ Enhancement:
4
+
5
+ * Add `value` option to specify fixed value
6
+
1
7
  ### 0.0.2
2
8
 
3
9
  Enhancement:
data/README.md CHANGED
@@ -29,7 +29,7 @@ Sample configuration is as follows:
29
29
  configure 'sample' do
30
30
  rate 500
31
31
  delimiter "\t"
32
- labeled false
32
+ labeled true
33
33
  field :id, type: :integer, countup: true
34
34
  field :time, type: :datetime, format: "[%Y-%m-%d %H:%M:%S]", random: true
35
35
  field :level, type: :string, any: %w[DEBUG INFO WARN ERROR]
@@ -43,9 +43,9 @@ end
43
43
  Running dummy_log_generator outputs like
44
44
 
45
45
  ```
46
- 360 [2031-02-09 15:01:07] DEBUG GET /api/v1/people 1.105236938958904 PcGw8kEi
47
- 361 [1991-08-26 13:03:05] WARN GET /api/v1/people 1.8938518088450287 RGOuoydG
48
- 362 [2037-11-04 15:32:38] DEBUG POST /api/v1/people 2.7431863060457538 rVij0nWP
46
+ id:422 time:[2013-11-19 02:34:58] level:INFO method:POST uri:/api/v1/textdata reqtime:3.9726677258569842 foobar:LFK6XV1N
47
+ id:423 time:[2013-11-19 02:34:58] level:DEBUG method:GET uri:/api/v1/people reqtime:0.49912949125272277 foobar:DcOYrONH
48
+ id:424 time:[2013-11-19 02:34:58] level:WARN method:POST uri:/api/v1/textdata reqtime:2.930590441869852 foobar:XEZ5bQsh
49
49
  ```
50
50
 
51
51
  ## Configuration Parameters
@@ -58,17 +58,17 @@ Following parameters for configuration is available
58
58
 
59
59
  * delimiter
60
60
 
61
- Specify the delimiter between each columns. Default: tab
61
+ Specify the delimiter between each field. Default: "\t" (Tab)
62
62
 
63
63
  * labeled
64
64
 
65
- Add label or not. Default: true
65
+ Whether add field name as a label or not. Default: true
66
66
 
67
67
  * field
68
68
 
69
69
  Define data fields to generate
70
70
 
71
- ## Data Types
71
+ ## Field Data Types
72
72
 
73
73
  You can specify following data types to your `field` parameters:
74
74
 
@@ -80,7 +80,11 @@ You can specify following data types to your `field` parameters:
80
80
 
81
81
  * :random
82
82
 
83
- Generate datetime randomly or not (Time.now). Default: false
83
+ Generate datetime randomly. Default: false (Time.now)
84
+
85
+ * :value
86
+
87
+ You can specify a fixed Time object.
84
88
 
85
89
  * :string
86
90
 
@@ -92,6 +96,10 @@ You can specify following data types to your `field` parameters:
92
96
 
93
97
  You can specify the length of string to generate randomly
94
98
 
99
+ * :value
100
+
101
+ You can specify a fixed string
102
+
95
103
  * :integer
96
104
 
97
105
  * :range
@@ -102,11 +110,19 @@ You can specify following data types to your `field` parameters:
102
110
 
103
111
  Generate countup data. Default: false
104
112
 
113
+ * :value
114
+
115
+ You can specify a fixed integer
116
+
105
117
  * :float
106
118
 
107
119
  * :range
108
120
 
109
- You can specify a range of integers, then the generator picks one in the range (uniform) randomly
121
+ You can specify a range of float numbers, then the generator picks one in the range (uniform) randomly
122
+
123
+ * :value
124
+
125
+ You can specify a fixed float number
110
126
 
111
127
  ## Relatives
112
128
 
@@ -1,7 +1,7 @@
1
1
  configure 'sample' do
2
2
  rate 500
3
3
  delimiter "\t"
4
- labeled false
4
+ labeled true
5
5
  field :id, type: :integer, countup: true
6
6
  field :time, type: :datetime, format: "[%Y-%m-%d %H:%M:%S]", random: false
7
7
  field :level, type: :string, any: %w[DEBUG INFO WARN ERROR]
@@ -1,11 +1,10 @@
1
1
  module DummyLogGenerator
2
2
  class Formatter
3
- attr_accessor :labeled, :delimiter, :fields
3
+ attr_accessor :labeled, :delimiter
4
4
 
5
5
  def initialize
6
6
  @labeled = true
7
7
  @delimiter = "\t"
8
- @fields = {}
9
8
  end
10
9
 
11
10
  def format(fields)
@@ -38,16 +38,20 @@ module DummyLogGenerator
38
38
  @chars = ('a'..'z').to_a + ('A'..'Z').to_a + ('0'..'9').to_a # no symbols and multi-bytes for now
39
39
  end
40
40
 
41
- def string(length: 8, any: nil, prev: nil)
42
- if any
41
+ def string(length: 8, any: nil, prev: nil, value: nil)
42
+ if value
43
+ value.to_s
44
+ elsif any
43
45
  self.any(any)
44
46
  else
45
47
  Array.new(length){@chars[rand(@chars.size-1)]}.join
46
48
  end
47
49
  end
48
50
 
49
- def integer(range: nil, countup: false, prev: nil)
50
- if range
51
+ def integer(range: nil, countup: false, prev: nil, value: nil)
52
+ if value
53
+ value.to_i
54
+ elsif range
51
55
  self.range(range)
52
56
  elsif countup
53
57
  prev ||= -1
@@ -57,8 +61,10 @@ module DummyLogGenerator
57
61
  end
58
62
  end
59
63
 
60
- def float(range: nil, prev: nil)
61
- if range
64
+ def float(range: nil, prev: nil, value: nil)
65
+ if value
66
+ value.to_f
67
+ elsif range
62
68
  self.range(range)
63
69
  else
64
70
  r = rand(1..358)
@@ -66,8 +72,10 @@ module DummyLogGenerator
66
72
  end
67
73
  end
68
74
 
69
- def datetime(format: "%Y-%m-%d %H:%M:%S.%3N", random: false, prev: nil)
70
- time = if random
75
+ def datetime(format: "%Y-%m-%d %H:%M:%S.%3N", random: false, prev: nil, value: nil)
76
+ time = if value
77
+ value
78
+ elsif random
71
79
  y = rand(1970..2037);
72
80
  m = rand(1..12);
73
81
  d = rand(1..27);
@@ -1,3 +1,3 @@
1
1
  module DummyLogGenerator
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dummy_log_generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - sonots