norikra-client-jruby 0.0.6-java → 0.0.7-java

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: a0b8c2a12693429e07784a344c1609541c7ba392
4
- data.tar.gz: e63c466165e6e1bf1fcf6b4e504ce6efe8aea972
3
+ metadata.gz: 7be0d49cbcc1f5d04f3210e3fc6dd789d892b917
4
+ data.tar.gz: e54e6a9ab06bc661d6acb24dd0f35a406574eabf
5
5
  SHA512:
6
- metadata.gz: 353d7e11fa879d8a5f512947a858f049ea6142c8261cfbe0e16f39e729fb355f1805d84bf9fe06dcd0ade519b367259ca4a252ae90324f03e7d78bf516a40e63
7
- data.tar.gz: d7497c7d2691f3e37ccdfb1c0058a7d80c756e86b9473ec27bf01d9cc4320153a3e0993c5dac645aade6b45947a265aa6b213b51e8d8102e1237c65d2d4f734b
6
+ metadata.gz: 3ff64659bee138f37bba82eea0f29b9c7212e05d48325f45c83eb34360bca117e7f6a8ee6456d2003029263a08757d7dd5f4f623394a3ddc21c5f6c0bcbf21e9
7
+ data.tar.gz: fd75255d00fd316086bf9ba0deb59381a62dca79c81a6d4a5f183c9338b38c9275a040cdd1ccc7e199cd4884317b7a1f20829e4bbdbcf9d78ca0baee2250b627
@@ -28,27 +28,30 @@ class Norikra::Client
28
28
  option :simple, :type => :boolean, :default => false, :desc => "suppress header/footer", :aliases => "-s"
29
29
  def list
30
30
  wrap do
31
- puts "TARGET" unless options[:simple]
31
+ puts ["TARGET","AUTO_FIELD"].join("\t") unless options[:simple]
32
32
  targets = client(parent_options).targets
33
33
  targets.each do |t|
34
- puts t
34
+ puts [t[:name], t[:auto_field]].join("\t")
35
35
  end
36
36
  puts "#{targets.size} targets found." unless options[:simple]
37
37
  end
38
38
  end
39
39
 
40
40
  desc "open TARGET [fieldname1:type1 [fieldname2:type2 [fieldname3:type3] ...]]", "create new target (and define its fields)"
41
+ option :suppress_auto_field, :type => :boolean, :default => false, :desc => "suppress to define fields automatically", :aliases => "-x"
41
42
  def open(target, *field_defs)
42
- wrap do
43
- fields = nil
44
- if field_defs.size > 0
45
- fields = {}
46
- field_defs.each do |str|
47
- fname,ftype = str.split(':')
48
- fields[fname] = ftype
49
- end
43
+ fields = nil
44
+ if field_defs.size > 0
45
+ fields = {}
46
+ field_defs.each do |str|
47
+ fname,ftype = str.split(':')
48
+ fields[fname] = ftype
50
49
  end
51
- client(parent_options).open(target, fields)
50
+ end
51
+ auto_field = (not options[:suppress_auto_field])
52
+
53
+ wrap do
54
+ client(parent_options).open(target, fields, auto_field)
52
55
  end
53
56
  end
54
57
 
@@ -58,6 +61,14 @@ class Norikra::Client
58
61
  client(parent_options).close(target)
59
62
  end
60
63
  end
64
+
65
+ desc "modify TARGET BOOL_VALUE", "modify target to do define fields automatically or not"
66
+ def modify(target, val)
67
+ auto_field = ['yes','true','auto'].include?(val.downcase)
68
+ wrap do
69
+ client(parent_options).modify(target, auto_field)
70
+ end
71
+ end
61
72
  end
62
73
 
63
74
  class Query < Thor
@@ -128,17 +139,18 @@ class Norikra::Client
128
139
  option :format, :type => :string, :default => 'json', :desc => "format of input data per line of stdin [json(default), ltsv]"
129
140
  option :batch_size, :type => :numeric, :default => 10000, :desc => "records sent in once transferring (default: 10000)"
130
141
  def send(target)
131
- wrap do
132
- client = client(parent_options)
133
- parser = parser(options[:format])
134
- buffer = []
135
- $stdin.each_line do |line|
136
- buffer.push(parser.parse(line))
137
- if buffer.size >= options[:batch_size]
138
- client.send(target, buffer)
139
- buffer = []
140
- end
142
+ client = client(parent_options)
143
+ parser = parser(options[:format])
144
+ buffer = []
145
+ $stdin.each_line do |line|
146
+ buffer.push(parser.parse(line))
147
+ if buffer.size >= options[:batch_size]
148
+ client.send(target, buffer)
149
+ buffer = []
141
150
  end
151
+ end
152
+
153
+ wrap do
142
154
  client.send(target, buffer) if buffer.size > 0
143
155
  end
144
156
  end
@@ -148,10 +160,10 @@ class Norikra::Client
148
160
  option :time_key, :type => :string, :default => 'time', :desc => "output key name for event time (default: time)"
149
161
  option :time_format, :type => :string, :default => '%Y/%m/%d %H:%M:%S', :desc => "output time format (default: '2013/05/14 17:57:59')"
150
162
  def fetch(query_name)
151
- wrap do
152
- formatter = formatter(options[:format])
153
- time_formatter = lambda{|t| Time.at(t).strftime(options[:time_format])}
163
+ formatter = formatter(options[:format])
164
+ time_formatter = lambda{|t| Time.at(t).strftime(options[:time_format])}
154
165
 
166
+ wrap do
155
167
  client(parent_options).event(query_name).each do |time,event|
156
168
  event = {options[:time_key] => Time.at(time).strftime(options[:time_format])}.merge(event)
157
169
  puts formatter.format(event)
@@ -1,5 +1,5 @@
1
1
  module Norikra
2
2
  class Client
3
- VERSION = "0.0.6"
3
+ VERSION = "0.0.7"
4
4
  end
5
5
  end
@@ -21,17 +21,21 @@ module Norikra
21
21
  end
22
22
 
23
23
  def targets
24
- @client.call(:targets)
24
+ @client.call(:targets) #=> {:name => "name", :auto_field => true}
25
25
  end
26
26
 
27
- def open(target, fields=nil)
28
- @client.call(:open, target, fields)
27
+ def open(target, fields=nil, auto_field=true)
28
+ @client.call(:open, target, fields, auto_field)
29
29
  end
30
30
 
31
31
  def close(target)
32
32
  @client.call(:close, target)
33
33
  end
34
34
 
35
+ def modify(target, auto_field)
36
+ @client.call(:modify, target, auto_field)
37
+ end
38
+
35
39
  def queries
36
40
  @client.call(:queries)
37
41
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: norikra-client-jruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: java
6
6
  authors:
7
7
  - TAGOMORI Satoshi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-03 00:00:00.000000000 Z
11
+ date: 2013-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: msgpack-rpc-over-http-jruby