jarvis-cli 0.0.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 ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ OWI3NjY2OTRkOWIyZmYwZTA2ZGM5ZTc5MTZkNzc0OGNmM2MxOWVlZA==
5
+ data.tar.gz: !binary |-
6
+ ODc1MGM3OWRkYmM3ZDJlMWU3NzA4N2VhZDJhNDM5NTczY2Q1MWNhMA==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ NDMzMjI2YzQ4YmMzM2I4YzAwYjU1Nzk3MWM2YTJlY2YxNTgxMGNhYmI0Yzdk
10
+ NTE5ZDgyNmI1OTM3NTAxY2FlNDgzMzlmMDg2M2RmMDViYzAxMjc2NmUyY2E3
11
+ YmZmNTM1YzM4Y2U3NjhmNTY3M2I2OTlmMWU5ODZmNjM5NjJlMTI=
12
+ data.tar.gz: !binary |-
13
+ ZTEwZWY2ZDM4NzE5MDVmOTNhMGNlOTYxZTBhODZkZDRhNzI5NGY4MjlkYjUy
14
+ YTU4NTk1Y2MzMDI4ZTM5ZTgyMTg1YTJkNWRmNGIwMThkZmUzODg2MDM0YTBj
15
+ YjIyN2YxNzBiMzcyM2M3ZDMzNjQwYTk0MTI5MDY4NTBkN2Y4YzE=
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in jarvis_server.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 DVG
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,61 @@
1
+ # Jarvis CLI
2
+
3
+ ## Warning, these instructions are not true yet, but they will be!
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'jarvis-cli', require: 'jarvis'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install jarvis-cli
18
+
19
+ ## Usage
20
+
21
+ Jarvis is an application framework for building Chat bots to integrate with your Slack chatroom. It ships with a number of useful and funny built-in services, but it also provides and easy DSL for creating your own services.
22
+
23
+ ### Generating a new chat bot
24
+
25
+ Creating a chatbot is as easy as:
26
+
27
+ ```bash
28
+ $ jarvis new my-bot
29
+ ```
30
+
31
+ ### Registering Services
32
+
33
+ `/app/server.rb` is the main brain of your Jarvis bot. Here you can register which services you want to be available on your chatbot.
34
+
35
+ ```ruby
36
+ class MyBot < Jarvis::Server
37
+ register_services Twitter, ImgFlip, UrbanDictionary, Weather
38
+ end
39
+ ```
40
+
41
+ These are the services that will be enabled when Jarvis interprets a message from Slack.
42
+
43
+ ### Required Environment Variables
44
+
45
+ If a Service integrates with an authenticated, third party API, you may need to set up environment variables for API Tokens, Secrets, Usernames and Passwords, etc. To ensure that services are not run in environments that aren't set up to support them, services can require certain variables be set up.
46
+
47
+ ```ruby
48
+ class MyService < Jarvis::Service
49
+ required_environment "SERVICE_TOKEN", "SERVICE_SECRET"
50
+ end
51
+ ```
52
+
53
+ If a service is Registered in `app/server.rb` but does not have it's expected environment, Jarvis will throw an exception and respond with a polite refusal to execute the service. This message can be set in your Jarvis configuration.
54
+
55
+ ## Contributing
56
+
57
+ 1. Fork it ( https://github.com/[my-github-username]/jarvis_server/fork )
58
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
59
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
60
+ 4. Push to the branch (`git push origin my-new-feature`)
61
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/bin/jarvis ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'jarvis'
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'jarvis/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "jarvis-cli"
8
+ spec.version = Jarvis::VERSION
9
+ spec.authors = ["DVG"]
10
+ spec.email = ["bradley.temple@gmail.com"]
11
+ spec.summary = %q{Modular Slackbot Framework}
12
+ spec.homepage = ""
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.6"
21
+ spec.add_development_dependency "rake"
22
+ spec.add_development_dependency "rspec"
23
+ spec.add_dependency "sinatra"
24
+ spec.add_dependency "sinatra-contrib"
25
+ spec.add_dependency "httparty"
26
+ end
@@ -0,0 +1,9 @@
1
+ module Jarvis
2
+ class Exception < StandardError
3
+ end
4
+ end
5
+
6
+ module Jarvis
7
+ class UnfitEnvironmentException < Exception
8
+ end
9
+ end
@@ -0,0 +1,14 @@
1
+ require 'sinatra'
2
+ require "sinatra/json"
3
+ require 'json'
4
+
5
+ module Jarvis
6
+ class Server < Sinatra::Base
7
+
8
+ get "/" do
9
+ json text: "Hello, I'm Jarvis"
10
+ end
11
+
12
+ run! if app_file == $0
13
+ end
14
+ end
@@ -0,0 +1,16 @@
1
+ module Jarvis
2
+ class Service
3
+ class << self
4
+ attr_accessor :required_environment_variables
5
+ def required_environment(*args)
6
+ @required_environment_variables = args
7
+ end
8
+ end
9
+
10
+ def validate_environment
11
+ self.class.required_environment_variables.each do |v|
12
+ raise UnfitEnvironmentException unless ENV[v]
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,3 @@
1
+ module Jarvis
2
+ VERSION = "0.0.1"
3
+ end
data/lib/jarvis.rb ADDED
@@ -0,0 +1,19 @@
1
+ require "jarvis/version"
2
+ require 'jarvis/server'
3
+ require 'jarvis/service'
4
+ require 'jarvis/exceptions'
5
+
6
+ module Jarvis
7
+ class << self
8
+
9
+ attr_accessor :services
10
+ def services
11
+ @services ||= []
12
+ end
13
+
14
+ def register(klass)
15
+ services << klass
16
+ end
17
+
18
+ end
19
+ end
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Jarvis do
4
+
5
+ describe "Service Registry" do
6
+ it "Allows you to register a Jarvis::Service subclass" do
7
+ class MyRegisteredService < Jarvis::Service
8
+ end
9
+ Jarvis.register(MyRegisteredService)
10
+ expect(Jarvis.services).to eq [MyRegisteredService]
11
+ end
12
+ end
13
+
14
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Jarvis::Server do
4
+ let(:parsed_response) { JSON.parse(last_response.body) }
5
+
6
+ describe "get /" do
7
+ before { get "/" }
8
+ it { expect(last_response).to be_ok }
9
+ it { expect(parsed_response["text"]).to eq "Hello, I'm Jarvis" }
10
+ end
11
+ end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Jarvis::Service do
4
+
5
+ describe "Validate Environment Variables are Present" do
6
+
7
+ class MyService < Jarvis::Service
8
+ required_environment "SERVICE_TOKEN"
9
+ end
10
+
11
+ subject { MyService.new }
12
+
13
+ context "Required Environment not set up" do
14
+ it { expect { subject.validate_environment }.to raise_exception(Jarvis::UnfitEnvironmentException) }
15
+ end
16
+
17
+ context "Environment Correctly Set Up" do
18
+ before { ENV["SERVICE_TOKEN"] = "token" }
19
+ it { expect { subject.validate_environment }.to_not raise_exception }
20
+ end
21
+
22
+ context "Multiple Required Variables, Some not present" do
23
+ class MyOtherService < Jarvis::Service
24
+ required_environment "SERVICE_TOKEN", "SERVICE_SECRET"
25
+ end
26
+ subject { MyOtherService.new }
27
+ before { ENV["SERVICE_TOKEN"] = "token" }
28
+ it { expect { subject.validate_environment }.to raise_exception(Jarvis::UnfitEnvironmentException) }
29
+ end
30
+
31
+ end
32
+
33
+ end
@@ -0,0 +1,15 @@
1
+ ENV['RACK_ENV'] = 'test'
2
+ require 'rspec'
3
+ require 'rack/test'
4
+ require 'json'
5
+ require 'jarvis'
6
+
7
+ include Rack::Test::Methods
8
+
9
+ def app
10
+ Jarvis::Server
11
+ end
12
+
13
+ RSpec.configure do |config|
14
+ config.expose_dsl_globally = false
15
+ end
metadata ADDED
@@ -0,0 +1,151 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jarvis-cli
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - DVG
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: sinatra
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: sinatra-contrib
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: httparty
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description:
98
+ email:
99
+ - bradley.temple@gmail.com
100
+ executables:
101
+ - jarvis
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - .gitignore
106
+ - .rspec
107
+ - Gemfile
108
+ - LICENSE.txt
109
+ - README.md
110
+ - Rakefile
111
+ - bin/jarvis
112
+ - jarvis-cli.gemspec
113
+ - lib/jarvis.rb
114
+ - lib/jarvis/exceptions.rb
115
+ - lib/jarvis/server.rb
116
+ - lib/jarvis/service.rb
117
+ - lib/jarvis/version.rb
118
+ - spec/jarvis/jarvis_spec.rb
119
+ - spec/jarvis/server_spec.rb
120
+ - spec/jarvis/service_spec.rb
121
+ - spec/spec_helper.rb
122
+ homepage: ''
123
+ licenses:
124
+ - MIT
125
+ metadata: {}
126
+ post_install_message:
127
+ rdoc_options: []
128
+ require_paths:
129
+ - lib
130
+ required_ruby_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ! '>='
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ required_rubygems_version: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ! '>='
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
140
+ requirements: []
141
+ rubyforge_project:
142
+ rubygems_version: 2.2.2
143
+ signing_key:
144
+ specification_version: 4
145
+ summary: Modular Slackbot Framework
146
+ test_files:
147
+ - spec/jarvis/jarvis_spec.rb
148
+ - spec/jarvis/server_spec.rb
149
+ - spec/jarvis/service_spec.rb
150
+ - spec/spec_helper.rb
151
+ has_rdoc: