kdaigle-roast 0.0.5 → 0.0.6
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.
- data/VERSION.yml +1 -1
- data/bin/roast +1 -1
- data/lib/roast/main.rb +46 -29
- metadata +2 -2
data/VERSION.yml
CHANGED
data/bin/roast
CHANGED
data/lib/roast/main.rb
CHANGED
@@ -1,16 +1,25 @@
|
|
1
1
|
module Roast
|
2
2
|
|
3
3
|
class Main
|
4
|
-
|
5
4
|
include Tinder
|
6
5
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
options[:room]
|
13
|
-
|
6
|
+
attr_accessor :message, :room, :config, :domain, :ssl, :username, :password, :verbose
|
7
|
+
|
8
|
+
def initialize(options)
|
9
|
+
@message = options[:message]
|
10
|
+
@config = YAML.load_file(ENV['HOME'] + '/roast.yml')
|
11
|
+
room_config = @config[(options[:room] ? options[:room].to_s : @config["default"])]
|
12
|
+
@room = room_config['room']
|
13
|
+
@domain = room_config['domain']
|
14
|
+
@ssl = room_config['ssl']
|
15
|
+
@username = room_config['username']
|
16
|
+
@password = room_config['password']
|
17
|
+
@verbose = options[:verbose]
|
18
|
+
self
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.run(options={})
|
22
|
+
|
14
23
|
opts = OptionParser.new do |opt|
|
15
24
|
opt.banner = "Usage: roast [options] message"
|
16
25
|
opt.separator ""
|
@@ -20,44 +29,52 @@ module Roast
|
|
20
29
|
"Room name from config") do |room|
|
21
30
|
options[:room] = room
|
22
31
|
end
|
32
|
+
opt.on("-v", "--verbose",
|
33
|
+
"Be verbose during the posting of the message") do |verbose|
|
34
|
+
options[:verbose] = true
|
35
|
+
end
|
23
36
|
end
|
24
37
|
|
25
38
|
opts.parse!(ARGV)
|
26
39
|
|
27
|
-
|
28
|
-
|
29
|
-
conf = config_file[options[:room]]
|
30
|
-
|
31
|
-
msg = first_msg || ARGV[0] || STDIN.read
|
40
|
+
roast = Roast::Main.new(options)
|
32
41
|
|
33
|
-
|
42
|
+
roast.vocalize "Using #{roast.room} configuration ..."
|
34
43
|
|
35
|
-
campfire = Campfire.new(
|
44
|
+
campfire = Campfire.new(roast.domain, :ssl => roast.ssl)
|
36
45
|
|
37
|
-
|
38
|
-
campfire.login
|
39
|
-
|
46
|
+
roast.vocalize "Logging in..."
|
47
|
+
campfire.login(roast.username, roast.password)
|
48
|
+
roast.vocalize "Logged in!"
|
40
49
|
|
41
|
-
room = campfire.find_room_by_name
|
50
|
+
room = campfire.find_room_by_name(roast.room)
|
42
51
|
|
43
|
-
|
44
|
-
|
45
|
-
puts "Entered room #{room.name}"
|
52
|
+
roast.vocalize "Joining #{room.name}..."
|
53
|
+
roast.vocalize "Entered room #{room.name}"
|
46
54
|
|
47
|
-
|
55
|
+
roast.vocalize "Saying message..."
|
48
56
|
|
49
|
-
if
|
50
|
-
room.paste(
|
57
|
+
if message_long?(options[:message])
|
58
|
+
room.paste(options[:message])
|
51
59
|
else
|
52
|
-
room.speak(
|
60
|
+
room.speak(options[:message])
|
53
61
|
end
|
54
62
|
|
55
|
-
|
63
|
+
roast.vocalize "Leaving room..."
|
56
64
|
|
57
|
-
|
65
|
+
roast.vocalize "Done."
|
66
|
+
end
|
67
|
+
|
68
|
+
def vocalize(message)
|
69
|
+
STDOUT.puts message if self.verbose
|
70
|
+
end
|
71
|
+
|
72
|
+
private
|
58
73
|
|
59
|
-
|
74
|
+
def self.message_long?(message)
|
75
|
+
(message.split("\n").size > 1) || (message.size >= 255)
|
60
76
|
end
|
77
|
+
|
61
78
|
end
|
62
79
|
|
63
80
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kdaigle-roast
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kyle Daigle
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-06-
|
12
|
+
date: 2009-06-15 00:00:00 -07:00
|
13
13
|
default_executable: roast
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|