jarvis-cli 0.1.0 → 0.1.1
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 +4 -4
- data/README.md +16 -5
- data/lib/jarvis/application.rb +14 -0
- data/lib/jarvis/cli.rb +14 -2
- data/lib/jarvis/configuration.rb +17 -0
- data/lib/jarvis/http_utilities.rb +40 -0
- data/lib/jarvis/server.rb +3 -3
- data/lib/jarvis/services/null_service.rb +3 -0
- data/lib/jarvis/utilities/array_responder.rb +16 -0
- data/lib/jarvis/version.rb +1 -1
- data/lib/jarvis.rb +11 -36
- data/templates/project/Gemfile +5 -1
- data/templates/project/config/environment.rb +12 -0
- data/templates/project/config/initializers/.gitkeep +0 -0
- data/templates/project/config.ru +1 -3
- data/templates/services/%name%.rb.tt +5 -0
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c00b9ecae0eade20f5d304fb6f9503d88f25896
|
4
|
+
data.tar.gz: 6fe81131c111fc54d8271e4fdd730b7d2cf2fcf7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 19ee2062a4a7eb861fffd094d1d9fa0ce7ccb867d0156ffeb92e86931080664fd0a63a4311fc5a3b737fae3f690caea7c23a451e1dda8636a61a89359d777718
|
7
|
+
data.tar.gz: fa355662c6eef79d9547069e9e75430d7d7bb06cb54ea0e380ddf033bc1eef315fabe533da7381b87d0b6aa8c9d50668de17f8c935dd62a6084514639a75edd3
|
data/README.md
CHANGED
@@ -116,12 +116,23 @@ class Joke < Jarvis::Service
|
|
116
116
|
end
|
117
117
|
end
|
118
118
|
```
|
119
|
-
##
|
119
|
+
## Ship List
|
120
120
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
121
|
+
When these things are done, we'll be ready for 1.0
|
122
|
+
|
123
|
+
✓ Finish Porting The Services from the original bot to the framework
|
124
|
+
|
125
|
+
☐ Ability for Jarvis to Post Back into the Slack Chatroom
|
126
|
+
|
127
|
+
☐ Jarvis::Schedule
|
128
|
+
|
129
|
+
☐ Add Test Framework to the Project Generator
|
130
|
+
|
131
|
+
✓ Service Generator
|
132
|
+
|
133
|
+
✓ Configure All The Things
|
134
|
+
|
135
|
+
✓ Boot Process for the Generated App
|
125
136
|
|
126
137
|
## Contributing
|
127
138
|
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Jarvis
|
2
|
+
class Application
|
3
|
+
def self.initialize!
|
4
|
+
require File.join Jarvis.root, "bot/server"
|
5
|
+
require_initializers
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.require_initializers
|
9
|
+
Dir[Jarvis.root + '/config/initializers/*.rb'].each do |file|
|
10
|
+
require file
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/jarvis/cli.rb
CHANGED
@@ -3,23 +3,35 @@ module Jarvis
|
|
3
3
|
class CLI < Thor
|
4
4
|
include Thor::Actions
|
5
5
|
|
6
|
+
attr_reader :name
|
7
|
+
|
6
8
|
desc "new BOT_NAME", "Sets up a new Jarvis project"
|
7
9
|
def new(name)
|
8
10
|
@name = Thor::Util.snake_case(name)
|
9
11
|
directory(:project, @name)
|
10
12
|
end
|
11
13
|
|
12
|
-
desc "
|
13
|
-
def
|
14
|
+
desc "start", "Bootup the Jarvis Application"
|
15
|
+
def start(*args)
|
14
16
|
port_option = args.include?('-p') ? '' : ' -p 3030'
|
15
17
|
command = "rackup #{port_option}"
|
16
18
|
run_command(command)
|
17
19
|
end
|
18
20
|
|
21
|
+
desc "generate", "Generate service NAME"
|
22
|
+
def generate(type, name)
|
23
|
+
@name = Thor::Util.snake_case(name)
|
24
|
+
generate_service(@name)
|
25
|
+
end
|
26
|
+
|
19
27
|
private
|
20
28
|
|
21
29
|
def run_command(command)
|
22
30
|
system(command)
|
23
31
|
end
|
32
|
+
|
33
|
+
def generate_service(name)
|
34
|
+
template("services/%name%.rb.tt", "bot/services/#{name}.rb")
|
35
|
+
end
|
24
36
|
end
|
25
37
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Jarvis
|
2
|
+
module Configuration
|
3
|
+
require 'active_support'
|
4
|
+
require 'active_support/configurable'
|
5
|
+
require 'active_support/dependencies'
|
6
|
+
def self.included(base)
|
7
|
+
base.include ActiveSupport::Configurable
|
8
|
+
base.configure do |config|
|
9
|
+
config.default_response = "What is this, I don't even"
|
10
|
+
config.unfit_environment_response = "I'm really sorry, but that service needs to be configured"
|
11
|
+
config.third_party_api_failure_respone = "Most unfortunately, that service is not working right now."
|
12
|
+
config.standard_error_response = "I'm sorry, Something went wrong."
|
13
|
+
config.autoload_paths = ["#{Jarvis.root}/app/services"]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Jarvis
|
2
|
+
module HTTPUtilities
|
3
|
+
require 'httparty'
|
4
|
+
require 'uri'
|
5
|
+
module ClassMethods
|
6
|
+
# HTTP Requests
|
7
|
+
def get(path, options={}, &block)
|
8
|
+
Jarvis::API::Response.new HTTParty.get(path, options, &block)
|
9
|
+
end
|
10
|
+
|
11
|
+
def post(path, options={}, &block)
|
12
|
+
Jarvis::API::Response.new HTTParty.post(path, options, &block)
|
13
|
+
end
|
14
|
+
|
15
|
+
def patch(path, options={}, &block)
|
16
|
+
Jarvis::API::Response.new HTTParty.patch(path, options, &block)
|
17
|
+
end
|
18
|
+
|
19
|
+
def put(path, options={}, &block)
|
20
|
+
Jarvis::API::Response.new HTTParty.put(path, options, &block)
|
21
|
+
end
|
22
|
+
|
23
|
+
def delete(path, options={}, &block)
|
24
|
+
Jarvis::API::Response.new HTTParty.delete(path, options, &block)
|
25
|
+
end
|
26
|
+
|
27
|
+
def encode_uri(str)
|
28
|
+
URI.encode(str)
|
29
|
+
end
|
30
|
+
|
31
|
+
def decode_uri(str)
|
32
|
+
URI.decode(str)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
def self.included(base)
|
36
|
+
base.send(:include, HTTParty)
|
37
|
+
base.send(:extend, ClassMethods)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/jarvis/server.rb
CHANGED
@@ -17,11 +17,11 @@ module Jarvis
|
|
17
17
|
begin
|
18
18
|
json text: run_service(service)
|
19
19
|
rescue Jarvis::UnfitEnvironmentException => e
|
20
|
-
json text:
|
20
|
+
json text: Jarvis::ArrayResponder.new(Jarvis.config.unfit_environment_response).respond
|
21
21
|
rescue Jarvis::ThirdPartyAPIFailure
|
22
|
-
json text:
|
22
|
+
json text: Jarvis::ArrayResponder.new(Jarvis.config.third_party_api_failure_respone).respond
|
23
23
|
rescue => e
|
24
|
-
json text:
|
24
|
+
json text: Jarvis::ArrayResponder.new(Jarvis.config.standard_error_response).respond
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
data/lib/jarvis/version.rb
CHANGED
data/lib/jarvis.rb
CHANGED
@@ -9,19 +9,12 @@ require 'jarvis/refinements'
|
|
9
9
|
require 'jarvis/services'
|
10
10
|
require 'jarvis/slack'
|
11
11
|
require 'jarvis/api/response'
|
12
|
-
require '
|
13
|
-
require '
|
14
|
-
require '
|
15
|
-
|
12
|
+
require 'jarvis/configuration'
|
13
|
+
require 'jarvis/http_utilities'
|
14
|
+
require 'jarvis/application'
|
15
|
+
require 'jarvis/utilities/array_responder'
|
16
16
|
module Jarvis
|
17
|
-
include HTTParty
|
18
|
-
include ActiveSupport::Configurable
|
19
|
-
|
20
|
-
self.configure do |config|
|
21
|
-
end
|
22
|
-
|
23
17
|
class << self
|
24
|
-
|
25
18
|
attr_accessor :services
|
26
19
|
def services
|
27
20
|
@services ||= []
|
@@ -36,33 +29,15 @@ module Jarvis
|
|
36
29
|
@services = []
|
37
30
|
end
|
38
31
|
|
39
|
-
|
40
|
-
|
41
|
-
Jarvis::
|
42
|
-
end
|
43
|
-
|
44
|
-
def post(path, options={}, &block)
|
45
|
-
Jarvis::API::Response.new HTTParty.post(path, options, &block)
|
46
|
-
end
|
47
|
-
|
48
|
-
def patch(path, options={}, &block)
|
49
|
-
Jarvis::API::Response.new HTTParty.patch(path, options, &block)
|
50
|
-
end
|
51
|
-
|
52
|
-
def put(path, options={}, &block)
|
53
|
-
Jarvis::API::Response.new HTTParty.put(path, options, &block)
|
54
|
-
end
|
55
|
-
|
56
|
-
def delete(path, options={}, &block)
|
57
|
-
Jarvis::API::Response.new HTTParty.delete(path, options, &block)
|
58
|
-
end
|
59
|
-
|
60
|
-
def encode_uri(str)
|
61
|
-
URI.encode(str)
|
32
|
+
def bootstrap
|
33
|
+
require File.join Jarvis.root, "config", "environment"
|
34
|
+
Jarvis::Application.initialize!
|
62
35
|
end
|
63
36
|
|
64
|
-
def
|
65
|
-
|
37
|
+
def root
|
38
|
+
self.config.root
|
66
39
|
end
|
67
40
|
end
|
41
|
+
include Jarvis::HTTPUtilities
|
42
|
+
include Jarvis::Configuration
|
68
43
|
end
|
data/templates/project/Gemfile
CHANGED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
Bundler.require(:default, ENV["RACK_ENV"].to_sym)
|
3
|
+
Jarvis.configure do |config|
|
4
|
+
config.root = File.expand_path "./"
|
5
|
+
# Default response is what Jarvis will say in response to a message that doesn't have a registered service.
|
6
|
+
# If you configure this to be an array of strings, a random one will be selected.
|
7
|
+
# config.default_response = "What is this, I don't even"
|
8
|
+
|
9
|
+
# Add additional autoload directories to autoload_paths
|
10
|
+
# config.autoload_paths << "#{Jarvis.root}/bot/models"
|
11
|
+
end
|
12
|
+
Jarvis.bootstrap
|
File without changes
|
data/templates/project/config.ru
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jarvis-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- DVG
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-02-
|
11
|
+
date: 2015-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -323,10 +323,13 @@ files:
|
|
323
323
|
- jarvis-cli.gemspec
|
324
324
|
- lib/jarvis.rb
|
325
325
|
- lib/jarvis/api/response.rb
|
326
|
+
- lib/jarvis/application.rb
|
326
327
|
- lib/jarvis/cli.rb
|
328
|
+
- lib/jarvis/configuration.rb
|
327
329
|
- lib/jarvis/core_ext.rb
|
328
330
|
- lib/jarvis/core_ext/symbol.rb
|
329
331
|
- lib/jarvis/exceptions.rb
|
332
|
+
- lib/jarvis/http_utilities.rb
|
330
333
|
- lib/jarvis/interpreter.rb
|
331
334
|
- lib/jarvis/refinements.rb
|
332
335
|
- lib/jarvis/refinements/zip_refinement.rb
|
@@ -361,6 +364,7 @@ files:
|
|
361
364
|
- lib/jarvis/slack/message.rb
|
362
365
|
- lib/jarvis/test_support/cucumber.rb
|
363
366
|
- lib/jarvis/test_support/test_support.rb
|
367
|
+
- lib/jarvis/utilities/array_responder.rb
|
364
368
|
- lib/jarvis/version.rb
|
365
369
|
- spec/jarvis/interpreter_spec.rb
|
366
370
|
- spec/jarvis/jarvis_spec.rb
|
@@ -402,6 +406,9 @@ files:
|
|
402
406
|
- templates/project/bot/services/.gitkeep
|
403
407
|
- templates/project/config.ru
|
404
408
|
- templates/project/config/.gitkeep
|
409
|
+
- templates/project/config/environment.rb
|
410
|
+
- templates/project/config/initializers/.gitkeep
|
411
|
+
- templates/services/%name%.rb.tt
|
405
412
|
homepage: https://github.com/DVG/jarvis-cli.git
|
406
413
|
licenses:
|
407
414
|
- MIT
|