reqsample 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 718979fc831c5a30881ec449c3165419388dbcd6
4
- data.tar.gz: bb7e0303911a0f16c0204a4e9956ef6f30f18d1a
3
+ metadata.gz: 6904a9d1e327322cc54dc86b1f82a7884c4892f3
4
+ data.tar.gz: 1f8d0cf747f60b9ee1d78611c3acc438d4f21353
5
5
  SHA512:
6
- metadata.gz: 226ed636dadaa93c4234aac96a4924e470b9a94b4b7538a9b019658575bcee8effa33c7472fe9dc03e8e49bdc08b76ad521ac4b477b172d1abfe03cc77bc1d44
7
- data.tar.gz: 33f58bec22eb0283d314e5f14cd3928009446676d5261ed668175865a59a78340ab90b4116a89f4605edf377543cf63a5928bab84871f754c9baf0c3801106ab
6
+ metadata.gz: 62130bd76c70331f59b88479c7972d2b49aafc81430ba472f05ebb97124922a8416ecaacff4fcf0e2c1504f1a77865e9aaa91396449d200d535ac3181f1286ce
7
+ data.tar.gz: 3f7cdafda5e1bebac1fa72ebb5ffef7d16458689cbb577c8927ccd41d7ae18dbbbcf80f18c3818c9efe6d5ffc8d4f5449dab3e3ff15b215b573ea92bddd43c10
data/README.md CHANGED
@@ -3,6 +3,8 @@
3
3
  * [Homepage](https://rubygems.org/gems/reqsample)
4
4
  * [Documentation](http://rubydoc.info/gems/reqsample/frames)
5
5
 
6
+ ![Example Screenshot](./screenshot.png)
7
+
6
8
  ## Description
7
9
 
8
10
  `reqsample` is a utility to generate somewhat-realistic public HTTP traffic. If you've ever needed a large corpus of Apache or nginx logs to test geoip processing, a Logstash pipeline, or as the source for a demo; this utility is for you.
@@ -63,7 +65,7 @@ The `produce` method is the central way to generate log values:
63
65
  gen.produce
64
66
  ```
65
67
 
66
- Will return an array of logs with the previously mentioned parameters. If a block is given to the `produce` method, the results will instead be streamed to the block by yielding each log event, simulating live incoming traffic.
68
+ Will return an array of logs with the previously mentioned parameters. If a block is given to the `produce` method, the results will instead be streamed to the block by yielding each log event.
67
69
 
68
70
  ## Install
69
71
 
@@ -47,6 +47,8 @@ module ReqSample
47
47
  # @option opts [Integer] :count how many logs to generate
48
48
  # @option opts [String] :format form to return logs, :apache or :hash
49
49
  # @option opts [Time] :peak normal distribution peak for log timestamps
50
+ # @option opts [Boolean] :sleep whether or not to "realistically" sleep
51
+ # between emitting logs.
50
52
  # @option opts [Integer] :truncate hard limit to keep log range within
51
53
  #
52
54
  # @return [Array<String, Hash>] the collection of generated log events
@@ -54,17 +56,15 @@ module ReqSample
54
56
  opts[:count] ||= DEFAULT_COUNT
55
57
  opts[:format] ||= DEFAULT_FORMAT
56
58
  opts[:peak] ||= Time.now - (12 * 60 * 60)
59
+ opts[:sleep] ||= false
57
60
  opts[:truncate] ||= 12
58
61
 
59
- 1.upto(opts[:count]).map do |_|
60
- sample_time opts[:peak], opts[:truncate]
61
- end.sort.map do |time|
62
- if block_given?
63
- if (delay = time - Time.now) > 0 then sleep delay end
64
- yield sample time, opts[:format]
65
- else
66
- sample time, opts[:format]
67
- end
62
+ return to_enum(:produce, opts) unless block_given?
63
+
64
+ opts[:count].times do
65
+ time = sample_time opts[:peak], opts[:truncate]
66
+ if opts[:sleep] and (delay = time - Time.now) > 0 then sleep delay end
67
+ yield sample time, opts[:format]
68
68
  end
69
69
  end
70
70
 
@@ -1,3 +1,3 @@
1
1
  module ReqSample
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
data/screenshot.png ADDED
Binary file
@@ -16,6 +16,6 @@ describe ReqSample::Generator do
16
16
  end
17
17
 
18
18
  it 'samples time' do
19
- expect(subject.sample_time).to be_a(Time)
19
+ expect(subject.sample_time(Time.now, 12)).to be_a(Time)
20
20
  end
21
21
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reqsample
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
  - Tyler Langlois
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-13 00:00:00.000000000 Z
11
+ date: 2017-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chronic
@@ -220,6 +220,7 @@ files:
220
220
  - lib/reqsample/time.rb
221
221
  - lib/reqsample/version.rb
222
222
  - reqsample.gemspec
223
+ - screenshot.png
223
224
  - spec/lib/reqsample/generator_spec.rb
224
225
  - spec/lib/reqsample/version_spec.rb
225
226
  - spec/lib/reqsample_spec.rb