hachi 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/lib/hachi/clients/artifact.rb +4 -2
- data/lib/hachi/clients/base.rb +10 -0
- data/lib/hachi/clients/case.rb +5 -2
- data/lib/hachi/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 789e04c496071bb676e874312b47929b538a1d6a028ca5042ac18b85364d2ac7
|
4
|
+
data.tar.gz: 439eccca76345fb3b74aacc2a9749ef4875652b5ba1ab15f171b7b47a9f0d45b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba111b9284560325d00bcbe3f09240130c75428072a85fe596db524e35f9437c603a0788ca008ae309b179f475aac0ab11c0872455b6233f178da687b1c01996
|
7
|
+
data.tar.gz: c9c720cf508b16cc10170d52732b6a2cdb0d0b39899810a5f3b559d1a561574cea3298b5a64911cc2addb574f117e5afd8870f32445ef0ca5f90f3dc42ac0ab4
|
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# Hachi
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/hachi.svg)](https://badge.fury.io/rb/hachi)
|
3
4
|
[![Build Status](https://travis-ci.org/ninoseki/hachi.svg?branch=master)](https://travis-ci.org/ninoseki/hachi)
|
4
5
|
[![Coverage Status](https://coveralls.io/repos/github/ninoseki/hachi/badge.svg?branch=master)](https://coveralls.io/github/ninoseki/hachi?branch=master)
|
5
6
|
|
@@ -23,7 +23,9 @@ module Hachi
|
|
23
23
|
delete("/api/case/artifact/#{id}") { |json| json }
|
24
24
|
end
|
25
25
|
|
26
|
-
def search(data:, data_type:)
|
26
|
+
def search(data:, data_type:, range: "all")
|
27
|
+
validate_range range
|
28
|
+
|
27
29
|
artifact = Models::Artifact.new(data: data, data_type: data_type)
|
28
30
|
payload = {
|
29
31
|
query: {
|
@@ -41,7 +43,7 @@ module Hachi
|
|
41
43
|
}
|
42
44
|
}
|
43
45
|
|
44
|
-
post("/api/case/artifact/_search?range
|
46
|
+
post("/api/case/artifact/_search?range=#{range}", payload) { |json| json }
|
45
47
|
end
|
46
48
|
end
|
47
49
|
end
|
data/lib/hachi/clients/base.rb
CHANGED
@@ -99,6 +99,16 @@ module Hachi
|
|
99
99
|
delete.add_field "Authorization", "Bearer #{api_key}"
|
100
100
|
request(delete, &block)
|
101
101
|
end
|
102
|
+
|
103
|
+
def validate_range(range)
|
104
|
+
return true if range == "all"
|
105
|
+
raise ArgumentError, "range should be 'all' or `from-to`" unless range.match?(/(\d+)-(\d+)/)
|
106
|
+
|
107
|
+
from, to = range.split("-").map(&:to_i)
|
108
|
+
return true if from < to
|
109
|
+
|
110
|
+
raise ArgumentError, "from should be smaller than to"
|
111
|
+
end
|
102
112
|
end
|
103
113
|
end
|
104
114
|
end
|
data/lib/hachi/clients/case.rb
CHANGED
@@ -30,7 +30,9 @@ module Hachi
|
|
30
30
|
post("/api/case", kase.payload) { |json| json }
|
31
31
|
end
|
32
32
|
|
33
|
-
def search(query)
|
33
|
+
def search(query, range: "all")
|
34
|
+
validate_range range
|
35
|
+
|
34
36
|
payload = {
|
35
37
|
query: {
|
36
38
|
_and:
|
@@ -45,7 +47,8 @@ module Hachi
|
|
45
47
|
]
|
46
48
|
}
|
47
49
|
}
|
48
|
-
|
50
|
+
|
51
|
+
post("/api/case/_search?range=#{range}", payload) { |json| json }
|
49
52
|
end
|
50
53
|
end
|
51
54
|
end
|
data/lib/hachi/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hachi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Manabu Niseki
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-04-
|
11
|
+
date: 2019-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|