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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e16364d1ebe1f3488a79c52b5c6b02a56d67280c76b75c4f22edf17b84b007cd
4
- data.tar.gz: 814184969ee5e5eb6506da65922354a840fc377f71cd02b132a160b7d308e83e
3
+ metadata.gz: 00ed0cb25e7f6f172d5eec3b782825e2c94c1c0923027e34283cd12dfd092d74
4
+ data.tar.gz: e11839f4721601d972425ba8dae2a7cacd6ec896c7c804505ff37f1c99703afd
5
5
  SHA512:
6
- metadata.gz: 9f83cd17cabc1de409cf471b4158a58a661fc06216e51ff5263cc4606fb0db3a314adc998576d1bcc2731c88535f1aec03a87c0dbf156908bdca5c2cce11dc07
7
- data.tar.gz: 03a42d1386bafd92c9e945ed547c5fd41115c1ffee2c7180447ca4f5c43ca6462fce4f96cd3d52df95a175bbdc95c081902326b4519b3ef531db92f4f1578893
6
+ metadata.gz: faa133b35a808632dd1b122765ea40d1e416446fdf2ac69bb344ca8143a17c14e8f3bf9814390aea1017aae8a02bfc6a7c6fe88f62e0884f086418b1d0d7121b
7
+ data.tar.gz: 3dce21f46839881060e79546e75c91837160b4e1b9f8c63440357b397db57aeb07fc532b0ed6bbb1892859171f5133bc7cfba859623a21006542065360528d7b
data/.gitlab-ci.yml ADDED
@@ -0,0 +1,11 @@
1
+ image: ruby:2.5
2
+
3
+ before_script:
4
+ - apt-get update && apt-get install -y locales
5
+ - echo "en_US.UTF-8 UTF-8" > /etc/locale.gen
6
+ - locale-gen
7
+ - export LC_ALL=en_US.UTF-8
8
+
9
+ ci:
10
+ script:
11
+ - bin/cibuild
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
@@ -1,5 +1,8 @@
1
1
  sudo: false
2
2
  language: ruby
3
+ cache: bundler
3
4
  rvm:
4
5
  - 2.5.1
5
- before_install: gem install bundler -v 1.16.1
6
+ before_install: gem install bundler
7
+ script:
8
+ - bin/cibuild
data/Gemfile CHANGED
@@ -1,6 +1,8 @@
1
- source "https://rubygems.org"
1
+ # frozen_string_literal: true
2
2
 
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
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 send messages
40
- through it.
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
- See the help for additional information:
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. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
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`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
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
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
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 :default => :spec
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 "bundler/setup"
4
- require "del"
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 "irb"
14
+ require 'irb'
14
15
 
15
- settings = YAML.load(IO.read(Pathname.new(Dir.home).join(".delrc")))
16
- settings.merge!(start_server: false)
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
@@ -0,0 +1,6 @@
1
+ #!/bin/sh
2
+
3
+ set -e
4
+
5
+ echo [$(date "+%H:%M:%S")] "==> Running linters…"
6
+ bundle exec rake lint
data/bin/publish ADDED
@@ -0,0 +1,6 @@
1
+ #!/bin/sh
2
+
3
+ set -e
4
+
5
+ bin/cibuild
6
+ bundle exec rake release
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
- lib = File.expand_path("../lib", __FILE__)
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 "del/version"
6
+ require 'del/version'
5
7
 
6
8
  Gem::Specification.new do |spec|
7
- spec.name = "del"
9
+ spec.name = 'del'
8
10
  spec.version = Del::VERSION
9
- spec.authors = ["mo"]
10
- spec.email = ["mo@mokhan.ca"]
11
+ spec.authors = ['mo']
12
+ spec.email = ['mo@mokhan.ca']
11
13
 
12
- spec.summary = %q{Del is a funky robosapien.}
13
- spec.description = %q{Del is a funky robosapien.}
14
- spec.homepage = "https://www.mokhan.ca"
15
- spec.license = "MIT"
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 = "exe"
22
+ spec.bindir = 'exe'
21
23
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
- spec.require_paths = ["lib"]
24
+ spec.require_paths = ['lib']
25
+ spec.required_ruby_version = '>= 2.5.0'
23
26
 
24
- spec.add_dependency "xmpp4r", "~> 0.5"
25
- spec.add_dependency "thor", "~> 0.20"
26
- spec.add_development_dependency "bundler", "~> 1.16"
27
- spec.add_development_dependency "rake", "~> 10.0"
28
- spec.add_development_dependency "rspec", "~> 3.0"
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
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require "del/cli"
4
+ require 'del/cli'
4
5
 
5
6
  Del::CLI.start(ARGV)
data/lib/del.rb CHANGED
@@ -1,25 +1,34 @@
1
- require "json"
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 "del/configuration"
12
- require "del/connection"
13
- require "del/default_router"
14
- require "del/message"
15
- require "del/repository"
16
- require "del/robot"
17
- require "del/socket_connection"
18
- require "del/socket_server"
19
- require "del/source"
20
- require "del/user"
21
- require "del/version"
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
- require "del"
2
- require "pathname"
3
- require "thor"
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(".delrc")
8
- class_option :configuration_file, default: ENV.fetch("DELRC", DEFAULT_RC)
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("LOG_LEVEL", Logger::INFO).to_i
12
+ class_option :log_level, default: ENV.fetch('LOG_LEVEL', Logger::INFO).to_i
11
13
 
12
- desc "server <routes.rb>", "start server"
14
+ desc 'server <routes.rb>', 'start server'
13
15
  def server(startup_file = nil)
14
- settings = YAML.load(IO.read(options[:configuration_file]))
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 "console <config.rb>", "start read-eval-print-loop"
22
+ desc 'console <config.rb>', 'start read-eval-print-loop'
27
23
  def console(startup_file = nil)
28
- require "irb"
24
+ require 'irb'
29
25
 
30
- settings = YAML.load(IO.read(options[:configuration_file]))
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 "message <jid> <message>", "send a message to the Jabber ID"
34
+ desc 'message <jid> <message>', 'send a message to the Jabber ID'
42
35
  def message(jid, message)
43
- socket = UNIXSocket.new(options[:socket_file])
44
- socket.puts(JSON.generate(command: :send_message, jid: jid, message: message))
45
- say socket.readline, :green
46
- rescue EOFError => error
47
- say error.message, :red
48
- rescue Errno::ECONNREFUSED => error
49
- say error.message, :red
50
- say "You must start the del server first.", :yellow
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&.close
48
+ socket.close
53
49
  end
54
50
 
55
- desc "setup", "setup your $HOME/.delrc"
56
- def setup
57
- settings = {
58
- host: ask("Where is your xmpp server? (E.g. 'chat.hipchat.com')"),
59
- jid: ask("What is your jabber Id?"),
60
- muc_domain: ask("What is your MUC domain? (E.g. 'conf.hipchat.com')"),
61
- full_name: ask("What is your name?"),
62
- password: ask("What is your password?", echo: false),
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
- say ""
66
- say "Writing your configuration to: #{options[:configuration_file]}", :green
67
- yaml = YAML.dump(settings)
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(0600, options[:configuration_file])
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 "version", "Print the version of this gem"
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