norikra-listener-mock 0.0.4-java → 0.1.0-java

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: cd21374e13d48a5593f5d2279739cd5160f2f70b
4
- data.tar.gz: 70ca33d32e83833c5731ca6f8f9b8b1fe08f32ea
3
+ metadata.gz: f4b79e5a0d324765bb732838e99796eaefaeabfd
4
+ data.tar.gz: d2e5964e6ee952ea01ef50997044f45f1ba2c609
5
5
  SHA512:
6
- metadata.gz: 016f274e23edf632940cd6bff74ec5b347e5250fdd9d799039dbfeba0148ceae886bcfdc05f022cfc3c669e106b54192dacebd7b5b0d7294e08a4335bde75f0a
7
- data.tar.gz: 28aa9b61d84a74f64143457f7ab6233c75dd29651759495a1c22f8d59c943a799b505e1921d730335714282c6d6e0ceac7450d05320c81fba04ad193718dc397
6
+ metadata.gz: b0bb586aae9333d508fe016dc8c51f3391272d838bc8435dc3ccfdfae43d166087e5ae6cb12562df288e0bb536553040c5ba3259f6be96b184cd96074c47ac1d
7
+ data.tar.gz: b85c2bd862c1d392f5575253b85124aabbee9a3cf88778d9e2ba01a59f827484c5c5fa42b421930af1ba38ff2e342a4cc85ac7fb92400411d8cd0e5d69f5ac6d
@@ -4,20 +4,40 @@ require "json"
4
4
  module Norikra
5
5
  module Listener
6
6
  class Mock < Norikra::Listener::Base
7
- def self.check(query_group_name)
8
- query_group_name && query_group_name =~ /^MOCK\((\d+)\)$/ && $1
7
+ def self.label
8
+ "MOCK"
9
9
  end
10
10
 
11
- def initialize(query_name, query_group, events_statistics)
11
+ def initialize(argument, query_name, query_group)
12
12
  super
13
- @repeat = Mock.check(query_group).to_i
13
+ @stdout = STDOUT
14
+ end
15
+
16
+ def process_sync(news, olds)
17
+ news.each do |event|
18
+ @stdout.puts "#{@query_name}\t#{@argument}\t" + JSON.dump(event)
19
+ end
20
+ end
21
+ end
22
+
23
+ class MockAsync < Norikra::Listener::Base
24
+ def self.label
25
+ "MOCK_ASYNC"
26
+ end
27
+
28
+ attr_accessor :stdout
29
+
30
+ def initialize(argument, query_name, query_group)
31
+ super
32
+ @stdout = STDOUT
33
+ @repeat = @argument.to_i
14
34
  end
15
35
 
16
36
  def process_async(events) # [ [unixtime, {event} ], ...
17
37
  # write events to STDOUT specified times, in background
18
38
  events.each do |time, e|
19
39
  @repeat.times do |i|
20
- STDOUT.puts @query_name + "\t#{i + 1}\t#{Time.at(time)}\t" + JSON.dump(e)
40
+ @stdout.puts "#{@query_name}\t#{i + 1}\t#{Time.at(time)}\t" + JSON.dump(e)
21
41
  end
22
42
  end
23
43
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "norikra-listener-mock"
5
- spec.version = "0.0.4"
5
+ spec.version = "0.1.0"
6
6
  spec.authors = ["TAGOMORI Satoshi"]
7
7
  spec.email = ["tagomoris@gmail.com"]
8
8
  spec.summary = %q{Norikra listener mock}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: norikra-listener-mock
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.1.0
5
5
  platform: java
6
6
  authors:
7
7
  - TAGOMORI Satoshi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-15 00:00:00.000000000 Z
11
+ date: 2015-01-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler