wit_bot 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/console +3 -0
- data/lib/wit_bot/models/state.rb +5 -2
- data/lib/wit_bot/models/wit/base.rb +5 -1
- data/lib/wit_bot/models/wit/entity.rb +4 -0
- data/lib/wit_bot/models/wit/intent.rb +4 -0
- data/lib/wit_bot/requests/models/wit_model_request.rb +1 -1
- data/lib/wit_bot/requests/wit_request.rb +12 -1
- data/lib/wit_bot/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 931f58cf60b1216e89ca8cbc037a8d7d1f9bacc6
|
4
|
+
data.tar.gz: 50f63f7128bb94520d7482ebebe0115641af1712
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 000a54affd75c669637c93f5e75b00c3729ddeda2162108003ac7893877e64556964cdfde0432ee2dada908436fa0559aa454afdcbd5131a34fbbb217b6c781d
|
7
|
+
data.tar.gz: 5f95529a175d8f27c0c2281c703ece179a21f0231da6efe1033a7700e92e13da38b3e548e488752a0d7ddd9f9f03fccf1207ad8b413966729bfc1aa13e40a2f4
|
data/bin/console
CHANGED
data/lib/wit_bot/models/state.rb
CHANGED
@@ -7,11 +7,14 @@ module WitBot
|
|
7
7
|
|
8
8
|
def initialize(state)
|
9
9
|
@state = state
|
10
|
-
@@states[state] = self
|
11
10
|
end
|
12
11
|
|
13
12
|
def self.find(state)
|
14
|
-
@@states[state]
|
13
|
+
@@states[state] ||= State.new(state)
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.all
|
17
|
+
@@states.values
|
15
18
|
end
|
16
19
|
|
17
20
|
alias :to_s :state
|
@@ -18,7 +18,11 @@ module WitBot
|
|
18
18
|
|
19
19
|
class << self
|
20
20
|
def all
|
21
|
-
@all ||=
|
21
|
+
@all ||= request.get(all: true).map do |data|
|
22
|
+
model = self.new data[:id]
|
23
|
+
model.from_response_data data
|
24
|
+
model
|
25
|
+
end
|
22
26
|
end
|
23
27
|
|
24
28
|
def get(model: nil)
|
@@ -6,11 +6,22 @@ module WitBot
|
|
6
6
|
|
7
7
|
def request(request=http)
|
8
8
|
if request.code.between? 200, 299
|
9
|
-
request.parse
|
9
|
+
process_response request.parse
|
10
10
|
else
|
11
11
|
response = request.parse.with_indifferent_access
|
12
12
|
raise WitError.new(response[:status]), (response[:error] || response[:body])
|
13
13
|
end
|
14
14
|
end
|
15
|
+
|
16
|
+
private
|
17
|
+
def process_response(response)
|
18
|
+
if response.respond_to? :with_indifferent_access
|
19
|
+
response.with_indifferent_access
|
20
|
+
elsif response.respond_to? :map
|
21
|
+
response.map {|r| process_response r}
|
22
|
+
else
|
23
|
+
response
|
24
|
+
end
|
25
|
+
end
|
15
26
|
end
|
16
27
|
end
|
data/lib/wit_bot/version.rb
CHANGED