Commit 689cd4d
Changed files (5)
exe/del
@@ -3,6 +3,8 @@
require "del"
require "pathname"
+startup_file = Pathname.new(ARGV[0]) if ARGV[0]
Del.start(
- dotenv_file: ENV.fetch("DELRC", Pathname.new(Dir.home).join(".delrc"))
+ dotenv_file: ENV.fetch("DELRC", Pathname.new(Dir.home).join(".delrc")),
+ startup_file: startup_file,
)
lib/del/examples/routes.rb
@@ -0,0 +1,7 @@
+Del.configure do |config|
+ puts "Registering custom routes."
+
+ config.router.register(/.*/) do |message|
+ message.reply(message.text.reverse)
+ end
+end
lib/del/configuration.rb
@@ -17,6 +17,7 @@ module Del
@host = ENV.fetch("DEL_HOST", 'chat.hipchat.com')
@jid = ENV.fetch("DEL_JID")
@logger = Logger.new(STDOUT)
+ @logger.level = Logger::INFO
@muc_domain = ENV.fetch("DEL_MUC_DOMAIN", "conf.hipchat.com")
@name = ENV.fetch("DEL_FULL_NAME")
@password = ENV.fetch("DEL_PASSWORD")
lib/del.rb
@@ -16,17 +16,17 @@ require "del/user"
require "del/version"
module Del
- def self.start(dotenv_file:)
+ def self.start(dotenv_file:, startup_file:)
puts "Loading... #{dotenv_file}"
Dotenv.load(dotenv_file.to_s)
- Del.logger.level = Logger::INFO
- del = Robot.new(configuration: configuration)
Del.configure do |config|
config.router.register(/.*/) do |message|
- logger.info(message.to_s)
- message.reply(message.text.reverse)
+ logger.debug(message.to_s)
end
end
+ load startup_file if startup_file && File.exist?(startup_file)
+
+ del = Robot.new(configuration: configuration)
del.get_funky!
end
README.md
@@ -1,8 +1,6 @@
# Del
-Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/del`. To experiment with that code, run `bin/console` for an interactive prompt.
-
-TODO: Delete this and the text above, and describe your gem
+Del is a funky robosapien.
## Installation
@@ -22,7 +20,7 @@ Or install it yourself as:
## Usage
-TODO: Write usage instructions here
+ $ del routes.rb # see lib/del/examples/routes.rb for an example
## Development
@@ -32,7 +30,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
## Contributing
-Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/del.
+Bug reports and pull requests are welcome on GitHub at https://github.com/mokhan/del.
## License