underlog-campfire-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.
- data/CHANGELOG +3 -0
- data/Manifest +4 -0
- data/README +30 -0
- data/bin/campfire +98 -0
- data/campfire-cli.gemspec +60 -0
- metadata +70 -0
data/CHANGELOG
ADDED
data/Manifest
ADDED
data/README
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
campfire-cli is a simple command line interface to 37signals campfire product.
|
2
|
+
|
3
|
+
== Requirements ==
|
4
|
+
|
5
|
+
|
6
|
+
== Usage ==
|
7
|
+
|
8
|
+
Define the campfire accounts and chat rooms you want to use in ~/.campfire.yml file. It is a simple yml file, mine looks like this:
|
9
|
+
|
10
|
+
|
11
|
+
underlog:
|
12
|
+
domain: underlg
|
13
|
+
username: underlog(at)gmail
|
14
|
+
password: passs
|
15
|
+
default-room: Room 1
|
16
|
+
|
17
|
+
underlog-room2:
|
18
|
+
domain: underlg
|
19
|
+
username: underlog(at)gmail
|
20
|
+
password: passs
|
21
|
+
default-room: Room 2
|
22
|
+
# ssl: true #uncomment this if you use paid accounts
|
23
|
+
|
24
|
+
#vim: filetype=yaml
|
25
|
+
|
26
|
+
|
27
|
+
The default-room is optional, and if missed, you will be presented by a list of options.
|
28
|
+
|
29
|
+
== TODO ==
|
30
|
+
Many stuff ;)
|
data/bin/campfire
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
#!/usr/local/bin/ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'tinder'
|
5
|
+
require 'yaml'
|
6
|
+
|
7
|
+
include Tinder
|
8
|
+
|
9
|
+
rooms = File.join()
|
10
|
+
@chats = YAML.load_file(ENV['HOME'] + '/.campfire.yml')
|
11
|
+
puts "Available chats:"
|
12
|
+
@chats.keys.each_with_index do |key, index|
|
13
|
+
puts "(#{index}) #{key}"
|
14
|
+
end
|
15
|
+
|
16
|
+
puts "Which one do you want to join?"
|
17
|
+
|
18
|
+
chat_index = gets.strip.to_i || 0
|
19
|
+
|
20
|
+
conf = @chats.values[chat_index]
|
21
|
+
|
22
|
+
chat_name = @chats.keys[chat_index]
|
23
|
+
|
24
|
+
|
25
|
+
puts "Joining #{chat_name} ..."
|
26
|
+
|
27
|
+
|
28
|
+
campfire = Campfire.new conf['domain'], :ssl => conf['ssl']
|
29
|
+
puts "Logging in..."
|
30
|
+
campfire.login conf['username'], conf['password']
|
31
|
+
puts "Logged in!"
|
32
|
+
|
33
|
+
unless conf['default-room']
|
34
|
+
puts "Available rooms:"
|
35
|
+
|
36
|
+
campfire.rooms.each_with_index do |room, index|
|
37
|
+
puts "(#{index}) #{room.name}"
|
38
|
+
end
|
39
|
+
|
40
|
+
puts "Join which one?"
|
41
|
+
room_index = gets.strip.to_i
|
42
|
+
room = campfire.rooms[room_index]
|
43
|
+
else
|
44
|
+
room = campfire.find_room_by_name conf["default-room"]
|
45
|
+
end
|
46
|
+
|
47
|
+
puts "Joining #{room.name} ..."
|
48
|
+
room.join(true)
|
49
|
+
puts "Entered room #{room.name}"
|
50
|
+
|
51
|
+
|
52
|
+
puts "Listening for messages..."
|
53
|
+
|
54
|
+
def print_message(msg)
|
55
|
+
puts "\n\e[32m#{msg[:person]}: \e[0m#{msg[:message]}"
|
56
|
+
$stdout.print "Say what?: "
|
57
|
+
$stdout.flush
|
58
|
+
end
|
59
|
+
|
60
|
+
def users(room)
|
61
|
+
puts "Users:"
|
62
|
+
u = Hpricot.parse(room.users.to_s)
|
63
|
+
u.search('//span').each do |span|
|
64
|
+
puts "# #{span.children.first}"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
Thread.new(room) do |listener|
|
69
|
+
listener.listen do |msg|
|
70
|
+
print_message msg
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
commands = {
|
75
|
+
'/users' => lambda { |room| users(room) },
|
76
|
+
'/exit' => lambda { |room| room.leave; exit },
|
77
|
+
'/history' => lambda do |room|
|
78
|
+
transcript = room.transcript room.available_transcripts.last
|
79
|
+
transcript.each do |message|
|
80
|
+
p message
|
81
|
+
# print_message message
|
82
|
+
end
|
83
|
+
end,
|
84
|
+
}
|
85
|
+
|
86
|
+
while true
|
87
|
+
$stdout.print "\e[31mSay what?: \e[0m"
|
88
|
+
$stdout.flush
|
89
|
+
msg = gets.strip
|
90
|
+
if commands[msg]
|
91
|
+
commands[msg].call(room)
|
92
|
+
next
|
93
|
+
end
|
94
|
+
puts "Me: #{msg}"
|
95
|
+
room.speak msg
|
96
|
+
end
|
97
|
+
|
98
|
+
#vim: filetype=ruby
|
@@ -0,0 +1,60 @@
|
|
1
|
+
|
2
|
+
# Gem::Specification for Campfire-cli-0.0.1
|
3
|
+
# Originally generated by Echoe
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = %q{campfire-cli}
|
7
|
+
s.version = "0.0.1"
|
8
|
+
|
9
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
10
|
+
s.authors = ["Petyo Ivanov"]
|
11
|
+
s.date = %q{2008-08-27}
|
12
|
+
s.default_executable = %q{campfire}
|
13
|
+
s.description = %q{Campfire-cli is a simple command line interface to 37signals campfire product.}
|
14
|
+
s.email = %q{underlog@gmail.com}
|
15
|
+
s.executables = ["campfire"]
|
16
|
+
s.files = ["CHANGELOG", "README", "bin/campfire", "Manifest", "campfire-cli.gemspec"]
|
17
|
+
s.has_rdoc = true
|
18
|
+
s.homepage = %q{http://reborn.underlog.org}
|
19
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Campfire-cli", "--main", "README"]
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
s.rubyforge_project = %q{campfire-cli}
|
22
|
+
s.rubygems_version = %q{1.2.0}
|
23
|
+
s.summary = %q{Campfire-cli is a simple command line interface to 37signals campfire product.}
|
24
|
+
|
25
|
+
if s.respond_to? :specification_version then
|
26
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
27
|
+
s.specification_version = 2
|
28
|
+
|
29
|
+
if current_version >= 3 then
|
30
|
+
s.add_runtime_dependency(%q<tinder>, [">= 0"])
|
31
|
+
else
|
32
|
+
s.add_dependency(%q<tinder>, [">= 0"])
|
33
|
+
end
|
34
|
+
else
|
35
|
+
s.add_dependency(%q<tinder>, [">= 0"])
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
# # Original Rakefile source (requires the Echoe gem):
|
41
|
+
#
|
42
|
+
# require 'echoe'
|
43
|
+
#
|
44
|
+
# Echoe.new('campfire-cli', '0.0.1') do |p|
|
45
|
+
#
|
46
|
+
# p.changelog = "CHANGELOG.rdoc"
|
47
|
+
#
|
48
|
+
# p.author = "Petyo Ivanov"
|
49
|
+
# p.email = "underlog@gmail.com"
|
50
|
+
#
|
51
|
+
# p.summary = <<-DESC.strip.gsub(/\n\s+/, " ")
|
52
|
+
# Campfire-cli is a simple command line interface to 37signals campfire product.
|
53
|
+
# DESC
|
54
|
+
#
|
55
|
+
# p.url = "http://reborn.underlog.org"
|
56
|
+
# p.rdoc_pattern = /^(lib|README.rdoc|CHANGELOG.rdoc)/
|
57
|
+
#
|
58
|
+
# p.dependencies = ["tinder"]
|
59
|
+
#
|
60
|
+
# end
|
metadata
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: underlog-campfire-cli
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Petyo Ivanov
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-08-27 00:00:00 -07:00
|
13
|
+
default_executable: campfire
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: tinder
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: "0"
|
23
|
+
version:
|
24
|
+
description: Campfire-cli is a simple command line interface to 37signals campfire product.
|
25
|
+
email: underlog@gmail.com
|
26
|
+
executables:
|
27
|
+
- campfire
|
28
|
+
extensions: []
|
29
|
+
|
30
|
+
extra_rdoc_files: []
|
31
|
+
|
32
|
+
files:
|
33
|
+
- CHANGELOG
|
34
|
+
- README
|
35
|
+
- bin/campfire
|
36
|
+
- Manifest
|
37
|
+
- campfire-cli.gemspec
|
38
|
+
has_rdoc: true
|
39
|
+
homepage: http://reborn.underlog.org
|
40
|
+
post_install_message:
|
41
|
+
rdoc_options:
|
42
|
+
- --line-numbers
|
43
|
+
- --inline-source
|
44
|
+
- --title
|
45
|
+
- Campfire-cli
|
46
|
+
- --main
|
47
|
+
- README
|
48
|
+
require_paths:
|
49
|
+
- lib
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: "0"
|
55
|
+
version:
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: "0"
|
61
|
+
version:
|
62
|
+
requirements: []
|
63
|
+
|
64
|
+
rubyforge_project: campfire-cli
|
65
|
+
rubygems_version: 1.2.0
|
66
|
+
signing_key:
|
67
|
+
specification_version: 2
|
68
|
+
summary: Campfire-cli is a simple command line interface to 37signals campfire product.
|
69
|
+
test_files: []
|
70
|
+
|