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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/wit +24 -6
  3. data/lib/wit_bot/version.rb +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 931f58cf60b1216e89ca8cbc037a8d7d1f9bacc6
4
- data.tar.gz: 50f63f7128bb94520d7482ebebe0115641af1712
3
+ metadata.gz: c493abbbb038f58cbea34d66f5922f11841580e4
4
+ data.tar.gz: 2a09ae8130ade22b6c5f95c03a017ed6a9987556
5
5
  SHA512:
6
- metadata.gz: 000a54affd75c669637c93f5e75b00c3729ddeda2162108003ac7893877e64556964cdfde0432ee2dada908436fa0559aa454afdcbd5131a34fbbb217b6c781d
7
- data.tar.gz: 5f95529a175d8f27c0c2281c703ece179a21f0231da6efe1033a7700e92e13da38b3e548e488752a0d7ddd9f9f03fccf1207ad8b413966729bfc1aa13e40a2f4
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 outcome.raw
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.each_with_index do |i|
52
- print "wit:#{i}> "
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 'Exitting...'
80
+ puts "\nExiting..."
63
81
  exit 0
64
82
  end
65
83
  else
@@ -1,3 +1,3 @@
1
1
  module WitBot
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
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.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-13 00:00:00.000000000 Z
11
+ date: 2016-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler