wit_bot 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/bin/wit +24 -6
- data/lib/wit_bot/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c493abbbb038f58cbea34d66f5922f11841580e4
|
4
|
+
data.tar.gz: 2a09ae8130ade22b6c5f95c03a017ed6a9987556
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9fb38619aec37a9c3cca4f65ae046a8753cb7c9bc5a8d1716cfa4bc6f14fe314ec0927f0ca255f031218cb4cae3d06d801d9ceb89c1333753ba69fe7fe92db2
|
7
|
+
data.tar.gz: 8fe3523ab7b36bfe08cbefd181401c24ff8f6ddce7cccef214eb675a642a5ee13025cf85be5e7fcda676b31f7d4644d9cc9a26717a4c398e08c57bd8934cdb3c
|
data/bin/wit
CHANGED
@@ -37,29 +37,47 @@ end
|
|
37
37
|
|
38
38
|
thread = WitBot.thread
|
39
39
|
|
40
|
-
def output_outcome(outcome)
|
40
|
+
def output_outcome(outcome, gen_pretty=false)
|
41
41
|
if $output == :json
|
42
|
-
puts JSON.dump
|
42
|
+
puts gen_pretty ? JSON.pretty_generate(outcome.raw) : JSON.dump(outcome.raw)
|
43
43
|
else
|
44
44
|
ap outcome, {raw: true}
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
+
message = nil
|
49
|
+
|
48
50
|
if repl
|
49
51
|
begin
|
50
52
|
puts 'Starting Wit REPL:'
|
51
|
-
loop
|
52
|
-
print
|
53
|
+
loop do
|
54
|
+
print 'wit > '
|
53
55
|
|
54
56
|
input = gets.chomp
|
55
57
|
|
58
|
+
if input.sub! /^!/, 'message'
|
59
|
+
if input.sub! /(^message)(.)/, '\1.\2'
|
60
|
+
if input.sub! /(^message\.)!/, '\1outcome'
|
61
|
+
input.sub! /(^message\.outcome)(.)/, '\1.\2'
|
62
|
+
end
|
63
|
+
end
|
64
|
+
begin
|
65
|
+
puts " > #{input}:"
|
66
|
+
output_outcome eval(input)
|
67
|
+
rescue StandardError => e
|
68
|
+
puts "Caught: #{e.message}"
|
69
|
+
ensure
|
70
|
+
next
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
56
74
|
message = thread.create_message input
|
57
75
|
message.send
|
58
76
|
|
59
|
-
output_outcome message.outcome
|
77
|
+
output_outcome message.outcome, true
|
60
78
|
end
|
61
79
|
rescue Interrupt
|
62
|
-
puts
|
80
|
+
puts "\nExiting..."
|
63
81
|
exit 0
|
64
82
|
end
|
65
83
|
else
|
data/lib/wit_bot/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wit_bot
|
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
|
- Ben (@penne12_)
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|