del 0.1.16 → 0.1.17
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/.gitlab-ci.yml +11 -0
- data/.rubocop.yml +41 -0
- data/.travis.yml +4 -1
- data/Gemfile +4 -2
- data/README.md +39 -5
- data/Rakefile +10 -3
- data/bin/cibuild +22 -0
- data/bin/console +6 -5
- data/bin/lint +6 -0
- data/bin/publish +6 -0
- data/bin/test +17 -0
- data/del.gemspec +23 -16
- data/exe/del +2 -1
- data/lib/del.rb +29 -20
- data/lib/del/cli.rb +91 -47
- data/lib/del/configuration.rb +60 -31
- data/lib/del/default_router.rb +8 -1
- data/lib/del/examples/routes.rb +7 -5
- data/lib/del/message.rb +9 -13
- data/lib/del/repository.rb +14 -7
- data/lib/del/robot.rb +22 -12
- data/lib/del/send_message.rb +21 -0
- data/lib/del/shell_command.rb +19 -0
- data/lib/del/socket_connection.rb +4 -2
- data/lib/del/socket_message.rb +37 -0
- data/lib/del/socket_server.rb +4 -0
- data/lib/del/source.rb +3 -0
- data/lib/del/tron.rb +58 -0
- data/lib/del/user.rb +8 -0
- data/lib/del/version.rb +3 -1
- data/lib/del/xmpp_connection.rb +126 -0
- metadata +73 -7
- data/lib/del/connection.rb +0 -98
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00ed0cb25e7f6f172d5eec3b782825e2c94c1c0923027e34283cd12dfd092d74
|
4
|
+
data.tar.gz: e11839f4721601d972425ba8dae2a7cacd6ec896c7c804505ff37f1c99703afd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: faa133b35a808632dd1b122765ea40d1e416446fdf2ac69bb344ca8143a17c14e8f3bf9814390aea1017aae8a02bfc6a7c6fe88f62e0884f086418b1d0d7121b
|
7
|
+
data.tar.gz: 3dce21f46839881060e79546e75c91837160b4e1b9f8c63440357b397db57aeb07fc532b0ed6bbb1892859171f5133bc7cfba859623a21006542065360528d7b
|
data/.gitlab-ci.yml
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
AllCops:
|
2
|
+
Exclude:
|
3
|
+
- 'coverage/**/*'
|
4
|
+
- 'pkg/**/*'
|
5
|
+
- 'spec/**/*'
|
6
|
+
- 'tmp/**/*'
|
7
|
+
- 'vendor/**/*'
|
8
|
+
TargetRubyVersion: 2.5
|
9
|
+
|
10
|
+
Layout/ClassStructure:
|
11
|
+
Enabled: true
|
12
|
+
Categories:
|
13
|
+
module_inclusion:
|
14
|
+
- include
|
15
|
+
- prepend
|
16
|
+
- extend
|
17
|
+
ExpectedOrder:
|
18
|
+
- module_inclusion
|
19
|
+
- constants
|
20
|
+
- public_class_methods
|
21
|
+
- initializer
|
22
|
+
- instance_methods
|
23
|
+
- protected_methods
|
24
|
+
- private_methods
|
25
|
+
|
26
|
+
Layout/EndOfLine:
|
27
|
+
EnforcedStyle: lf
|
28
|
+
|
29
|
+
Layout/IndentArray:
|
30
|
+
EnforcedStyle: consistent
|
31
|
+
|
32
|
+
Layout/IndentHeredoc:
|
33
|
+
EnforcedStyle: active_support
|
34
|
+
|
35
|
+
Metrics/BlockLength:
|
36
|
+
Exclude:
|
37
|
+
- '*.gemspec'
|
38
|
+
- 'Rakefile'
|
39
|
+
|
40
|
+
Style/Documentation:
|
41
|
+
Enabled: false
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
|
5
|
+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
4
6
|
|
5
7
|
# Specify your gem's dependencies in del.gemspec
|
6
8
|
gemspec
|
data/README.md
CHANGED
@@ -24,6 +24,14 @@ Run the setup command.
|
|
24
24
|
|
25
25
|
$ del setup
|
26
26
|
|
27
|
+
By default all configuration is stored in a yaml file in your $HOME
|
28
|
+
directory named `.delrc`. E.g. `~/.delrc`
|
29
|
+
|
30
|
+
The setup will ask you for your XMPP password. If you are uncomfortable
|
31
|
+
storing your password in the `.delrc` you may skip that prompt. If you
|
32
|
+
choose not to store your password in `.delrc` then Del will prompt you
|
33
|
+
for your password each time you interact with Del.
|
34
|
+
|
27
35
|
Start the chat server:
|
28
36
|
|
29
37
|
$ del server
|
@@ -36,20 +44,46 @@ Start the server with a remote file:
|
|
36
44
|
|
37
45
|
$ del server https://gist.githubusercontent.com/mokhan/15882e15908273f7880eaeaa336d12d9/raw/a54db41e7824315b63b3e4e88df5c2f74ce27e30/routes.rb
|
38
46
|
|
39
|
-
Once the server is started, you may use the client to
|
40
|
-
|
47
|
+
Once the server is started, you may use the client to issue different commands:
|
48
|
+
|
49
|
+
Send a message to another user:
|
41
50
|
|
42
51
|
$ del message 1_79@chat.btf.hipchat.com "Hello, World!"
|
43
52
|
|
44
|
-
|
53
|
+
Change your status:
|
54
|
+
|
55
|
+
$ del status busy "I am on a WebEx call"
|
56
|
+
|
57
|
+
Print your profile information:
|
58
|
+
|
59
|
+
$ del whoami
|
60
|
+
|
61
|
+
Print the profile information of another user:
|
62
|
+
|
63
|
+
$ del whois <jid>
|
64
|
+
|
65
|
+
Print all users:
|
66
|
+
|
67
|
+
$ del users
|
68
|
+
|
69
|
+
Interact with Del using a REPL:
|
70
|
+
|
71
|
+
$ del console
|
72
|
+
irb(main):001:0> Del.bot.busy!("I am really, really busy!")
|
73
|
+
irb(main):002:0> Del.bot.online!
|
74
|
+
|
75
|
+
See help for additional information:
|
45
76
|
|
46
77
|
$ del help
|
47
78
|
|
48
79
|
## Development
|
49
80
|
|
50
|
-
After checking out the repo, run `bin/setup` to install dependencies.
|
81
|
+
After checking out the repo, run `bin/setup` to install dependencies.
|
82
|
+
Then, run `bin/cibuild` to run the tests and linters.
|
83
|
+
|
84
|
+
You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
51
85
|
|
52
|
-
To install this gem onto your local machine, run `bundle exec rake install`.
|
86
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
53
87
|
|
54
88
|
## Contributing
|
55
89
|
|
data/Rakefile
CHANGED
@@ -1,6 +1,13 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
require 'rubocop/rake_task'
|
6
|
+
require 'bundler/audit/task'
|
3
7
|
|
4
8
|
RSpec::Core::RakeTask.new(:spec)
|
9
|
+
RuboCop::RakeTask.new(:rubocop)
|
10
|
+
Bundler::Audit::Task.new
|
5
11
|
|
6
|
-
task :
|
12
|
+
task default: :spec
|
13
|
+
task lint: [:rubocop, 'bundle:audit']
|
data/bin/cibuild
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
|
3
|
+
# script/cibuild: Setup environment for CI to run tests. This is primarily
|
4
|
+
# designed to run on the continuous integration server.
|
5
|
+
|
6
|
+
set -e
|
7
|
+
|
8
|
+
cd "$(dirname "$0")/.."
|
9
|
+
|
10
|
+
echo [$(date "+%H:%M:%S")] "==> Started at…"
|
11
|
+
|
12
|
+
# GC customizations
|
13
|
+
export RUBY_GC_MALLOC_LIMIT=79000000
|
14
|
+
export RUBY_GC_HEAP_INIT_SLOTS=800000
|
15
|
+
export RUBY_HEAP_FREE_MIN=100000
|
16
|
+
export RUBY_HEAP_SLOTS_INCREMENT=400000
|
17
|
+
export RUBY_HEAP_SLOTS_GROWTH_FACTOR=1
|
18
|
+
|
19
|
+
ruby -v
|
20
|
+
gem install bundler --no-ri --no-rdoc --conservative
|
21
|
+
bin/test
|
22
|
+
bin/lint
|
data/bin/console
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
|
-
require
|
4
|
-
require
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'del'
|
5
6
|
|
6
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
8
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,9 +11,9 @@ require "del"
|
|
10
11
|
# require "pry"
|
11
12
|
# Pry.start
|
12
13
|
|
13
|
-
require
|
14
|
+
require 'irb'
|
14
15
|
|
15
|
-
settings = YAML.
|
16
|
-
settings
|
16
|
+
settings = YAML.safe_load(IO.read(Pathname.new(Dir.home).join('.delrc')))
|
17
|
+
settings[:start_server] = false
|
17
18
|
Del.start(settings)
|
18
19
|
IRB.start(__FILE__)
|
data/bin/lint
ADDED
data/bin/publish
ADDED
data/bin/test
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/bin/sh
|
2
|
+
|
3
|
+
# script/test: Run test suite for application. Optionally pass in a path to an
|
4
|
+
# individual test file to run a single test.
|
5
|
+
|
6
|
+
|
7
|
+
set -e
|
8
|
+
|
9
|
+
cd "$(dirname "$0")/.."
|
10
|
+
|
11
|
+
[ -z "$DEBUG" ] || set -x
|
12
|
+
|
13
|
+
echo [$(date "+%H:%M:%S")] "==> Running setup…"
|
14
|
+
bin/setup
|
15
|
+
|
16
|
+
echo [$(date "+%H:%M:%S")] "==> Running tests…"
|
17
|
+
bundle exec rake spec
|
data/del.gemspec
CHANGED
@@ -1,29 +1,36 @@
|
|
1
1
|
|
2
|
-
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
lib = File.expand_path('lib', __dir__)
|
3
5
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require
|
6
|
+
require 'del/version'
|
5
7
|
|
6
8
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
9
|
+
spec.name = 'del'
|
8
10
|
spec.version = Del::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
11
|
+
spec.authors = ['mo']
|
12
|
+
spec.email = ['mo@mokhan.ca']
|
11
13
|
|
12
|
-
spec.summary =
|
13
|
-
spec.description =
|
14
|
-
spec.homepage =
|
15
|
-
spec.license =
|
14
|
+
spec.summary = 'Del is a funky robosapien.'
|
15
|
+
spec.description = 'Del is a funky robosapien.'
|
16
|
+
spec.homepage = 'https://www.mokhan.ca'
|
17
|
+
spec.license = 'MIT'
|
16
18
|
|
17
19
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
20
|
f.match(%r{^(test|spec|features)/})
|
19
21
|
end
|
20
|
-
spec.bindir =
|
22
|
+
spec.bindir = 'exe'
|
21
23
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
-
spec.require_paths = [
|
24
|
+
spec.require_paths = ['lib']
|
25
|
+
spec.required_ruby_version = '>= 2.5.0'
|
23
26
|
|
24
|
-
spec.add_dependency
|
25
|
-
spec.add_dependency
|
26
|
-
spec.
|
27
|
-
spec.
|
28
|
-
spec.
|
27
|
+
spec.add_dependency 'bundler-audit', '~> 0.6'
|
28
|
+
spec.add_dependency 'net-hippie', '~> 0.1'
|
29
|
+
spec.add_dependency 'rubocop', '~> 0.55'
|
30
|
+
spec.add_dependency 'thor', '~> 0.20'
|
31
|
+
spec.add_dependency 'xmpp4r', '~> 0.5'
|
32
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
33
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
34
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
35
|
+
spec.add_development_dependency 'simplecov', '~> 0.16'
|
29
36
|
end
|
data/exe/del
CHANGED
data/lib/del.rb
CHANGED
@@ -1,25 +1,34 @@
|
|
1
|
-
|
2
|
-
require "logger"
|
3
|
-
require "open3"
|
4
|
-
require "socket"
|
5
|
-
require "xmpp4r"
|
6
|
-
require "xmpp4r/muc/helper/mucbrowser"
|
7
|
-
require "xmpp4r/muc/helper/simplemucclient"
|
8
|
-
require "xmpp4r/roster/helper/roster"
|
9
|
-
require "yaml"
|
1
|
+
# frozen_string_literal: true
|
10
2
|
|
11
|
-
require
|
12
|
-
require
|
13
|
-
require
|
14
|
-
require
|
15
|
-
require
|
16
|
-
require
|
17
|
-
require
|
18
|
-
require
|
19
|
-
require
|
20
|
-
require
|
21
|
-
require
|
3
|
+
require 'json'
|
4
|
+
require 'logger'
|
5
|
+
require 'net/hippie'
|
6
|
+
require 'open3'
|
7
|
+
require 'socket'
|
8
|
+
require 'tempfile'
|
9
|
+
require 'xmpp4r'
|
10
|
+
require 'xmpp4r/muc/helper/mucbrowser'
|
11
|
+
require 'xmpp4r/muc/helper/simplemucclient'
|
12
|
+
require 'xmpp4r/roster/helper/roster'
|
13
|
+
require 'yaml'
|
22
14
|
|
15
|
+
require 'del/configuration'
|
16
|
+
require 'del/default_router'
|
17
|
+
require 'del/message'
|
18
|
+
require 'del/repository'
|
19
|
+
require 'del/robot'
|
20
|
+
require 'del/send_message'
|
21
|
+
require 'del/shell_command'
|
22
|
+
require 'del/socket_connection'
|
23
|
+
require 'del/socket_message'
|
24
|
+
require 'del/socket_server'
|
25
|
+
require 'del/source'
|
26
|
+
require 'del/tron'
|
27
|
+
require 'del/user'
|
28
|
+
require 'del/version'
|
29
|
+
require 'del/xmpp_connection'
|
30
|
+
|
31
|
+
# Del the funky robosapien.
|
23
32
|
module Del
|
24
33
|
def self.start(settings)
|
25
34
|
@configuration = Configuration.new(settings)
|
data/lib/del/cli.rb
CHANGED
@@ -1,77 +1,121 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'del'
|
4
|
+
require 'pathname'
|
5
|
+
require 'thor'
|
4
6
|
|
5
7
|
module Del
|
6
8
|
class CLI < Thor
|
7
|
-
DEFAULT_RC=Pathname.new(Dir.home).join(
|
8
|
-
class_option :configuration_file, default: ENV.fetch(
|
9
|
+
DEFAULT_RC = Pathname.new(Dir.home).join('.delrc')
|
10
|
+
class_option :configuration_file, default: ENV.fetch('DELRC', DEFAULT_RC)
|
9
11
|
class_option :socket_file, default: Del::Configuration::SOCKET_FILE
|
10
|
-
class_option :log_level, default: ENV.fetch(
|
12
|
+
class_option :log_level, default: ENV.fetch('LOG_LEVEL', Logger::INFO).to_i
|
11
13
|
|
12
|
-
desc
|
14
|
+
desc 'server <routes.rb>', 'start server'
|
13
15
|
def server(startup_file = nil)
|
14
|
-
|
15
|
-
settings.merge!(log_level: options[:log_level])
|
16
|
-
settings.merge!(socket_file: options[:socket_file])
|
17
|
-
settings.merge!(start_server: true)
|
18
|
-
settings.merge!(startup_file: startup_file)
|
19
|
-
|
20
|
-
Del.start(settings)
|
16
|
+
Del.start(load_settings(start_server: true, startup_file: startup_file))
|
21
17
|
rescue Errno::ENOENT => error
|
22
18
|
say error.message, :red
|
23
19
|
say "run 'del setup'", :yellow
|
24
20
|
end
|
25
21
|
|
26
|
-
desc
|
22
|
+
desc 'console <config.rb>', 'start read-eval-print-loop'
|
27
23
|
def console(startup_file = nil)
|
28
|
-
require
|
24
|
+
require 'irb'
|
29
25
|
|
30
|
-
|
31
|
-
settings.merge!(log_level: options[:log_level])
|
32
|
-
settings.merge!(socket_file: options[:socket_file])
|
33
|
-
settings.merge!(start_server: false)
|
34
|
-
settings.merge!(startup_file: startup_file)
|
35
|
-
|
36
|
-
Del.start(settings)
|
26
|
+
Del.start(load_settings(start_server: false, startup_file: startup_file))
|
37
27
|
ARGV.clear
|
38
28
|
IRB.start
|
29
|
+
rescue Errno::ENOENT => error
|
30
|
+
say error.message, :red
|
31
|
+
say "run 'del setup'", :yellow
|
39
32
|
end
|
40
33
|
|
41
|
-
desc
|
34
|
+
desc 'message <jid> <message>', 'send a message to the Jabber ID'
|
42
35
|
def message(jid, message)
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
36
|
+
SendMessage.new(
|
37
|
+
self,
|
38
|
+
socket_file: options[:socket_file]
|
39
|
+
).run(jid, message)
|
40
|
+
end
|
41
|
+
|
42
|
+
desc 'status <status> <message>', 'status to online, away, or busy'
|
43
|
+
def status(status, message = nil)
|
44
|
+
socket = SocketMessage.new(self, socket_file: options[:socket_file])
|
45
|
+
socket.deliver(command: :change_status, status: status, message: message)
|
46
|
+
say(socket.listen, :green)
|
51
47
|
ensure
|
52
|
-
socket
|
48
|
+
socket.close
|
53
49
|
end
|
54
50
|
|
55
|
-
desc
|
56
|
-
def
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
}
|
51
|
+
desc 'whoami', 'send a whoami message to the local del server'
|
52
|
+
def whoami
|
53
|
+
socket = SocketMessage.new(self, socket_file: options[:socket_file])
|
54
|
+
socket.deliver(command: :whoami)
|
55
|
+
say(socket.listen, :green)
|
56
|
+
ensure
|
57
|
+
socket.close
|
58
|
+
end
|
64
59
|
|
65
|
-
|
66
|
-
|
67
|
-
|
60
|
+
desc 'whois <jid>', 'whois a specific user'
|
61
|
+
def whois(jid)
|
62
|
+
socket = SocketMessage.new(self, socket_file: options[:socket_file])
|
63
|
+
socket.deliver(command: :whois, q: jid)
|
64
|
+
say(socket.listen, :green)
|
65
|
+
ensure
|
66
|
+
socket.close
|
67
|
+
end
|
68
|
+
|
69
|
+
desc 'users', 'list all users'
|
70
|
+
def users
|
71
|
+
socket = SocketMessage.new(self, socket_file: options[:socket_file])
|
72
|
+
socket.deliver(command: :users)
|
73
|
+
say(socket.listen, :green)
|
74
|
+
ensure
|
75
|
+
socket.close
|
76
|
+
end
|
77
|
+
|
78
|
+
desc 'setup', 'setup your $HOME/.delrc'
|
79
|
+
def setup
|
80
|
+
yaml = YAML.dump(new_settings)
|
68
81
|
IO.write(options[:configuration_file], yaml)
|
69
|
-
File.chmod(
|
82
|
+
File.chmod(0o600, options[:configuration_file])
|
83
|
+
say ''
|
84
|
+
say "Configuration saved to: #{options[:configuration_file]}", :green
|
70
85
|
end
|
71
86
|
|
72
|
-
desc
|
87
|
+
desc 'version', 'Print the version of this gem'
|
73
88
|
def version
|
74
89
|
say Del::VERSION, :green
|
75
90
|
end
|
91
|
+
|
92
|
+
private
|
93
|
+
|
94
|
+
def new_settings
|
95
|
+
{
|
96
|
+
'host' => ask("XMPP server: (E.g. 'chat.hipchat.com')"),
|
97
|
+
'jid' => ask('Jabber Id:'),
|
98
|
+
'muc_domain' => ask("MUC domain: (E.g. 'conf.hipchat.com')"),
|
99
|
+
'full_name' => ask('Name:'),
|
100
|
+
'password' => ask('Password:', echo: false)
|
101
|
+
}
|
102
|
+
end
|
103
|
+
|
104
|
+
def load_settings(additional_settings)
|
105
|
+
settings = YAML.safe_load(
|
106
|
+
IO.read(options[:configuration_file]),
|
107
|
+
symbolize_names: true
|
108
|
+
)
|
109
|
+
if blank?(settings[:password])
|
110
|
+
settings[:password] = ask('Password:', echo: false)
|
111
|
+
end
|
112
|
+
settings[:log_level] = options[:log_level]
|
113
|
+
settings[:socket_file] = options[:socket_file]
|
114
|
+
settings.merge(additional_settings)
|
115
|
+
end
|
116
|
+
|
117
|
+
def blank?(string)
|
118
|
+
string.nil? || string.length.zero?
|
119
|
+
end
|
76
120
|
end
|
77
121
|
end
|