pyre 0.1.1 → 0.2.0
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/History.txt +8 -0
- data/README.txt +7 -6
- data/lib/pyre.rb +1 -1
- data/lib/pyre/campfire.rb +33 -1
- data/lib/pyre/room.rb +3 -2
- data/tasks/setup.rb +1 -1
- metadata +2 -2
data/History.txt
CHANGED
data/README.txt
CHANGED
@@ -26,12 +26,13 @@ Patches awfully welcome.
|
|
26
26
|
require 'rubygems'
|
27
27
|
require 'pyre'
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
29
|
+
Pyre::Campfire.new('pyre') do |campfire|
|
30
|
+
campfire.login('mycoolemail@example.com', 'anactualpassword')
|
31
|
+
campfire.room('Pyre Test') do |room|
|
32
|
+
room.speak("Nested blocks. Is there nothing you CAN'T do?")
|
33
|
+
room.paste('svn commit message!') # For example.
|
34
|
+
end
|
35
|
+
end
|
35
36
|
|
36
37
|
== REQUIREMENTS:
|
37
38
|
|
data/lib/pyre.rb
CHANGED
data/lib/pyre/campfire.rb
CHANGED
@@ -7,12 +7,21 @@ module Pyre
|
|
7
7
|
# Pass in your subdomain and maybe some options.
|
8
8
|
# Of course, the only option is whether or not to use ssl.
|
9
9
|
# Pass along <tt>:ssl => true</tt> if you need it.
|
10
|
+
# Give it a block for self-contained wonderfulness
|
11
|
+
# (logs out for you).
|
10
12
|
def initialize(subdomain, options={})
|
11
13
|
@subdomain = subdomain
|
12
14
|
protocol = 'http'
|
13
15
|
protocol << 's' if options[:ssl]
|
14
16
|
@uri = "#{protocol}://#{subdomain}.campfirenow.com"
|
15
17
|
@agent = WWW::Mechanize.new
|
18
|
+
|
19
|
+
if block_given?
|
20
|
+
yield self
|
21
|
+
self.logout
|
22
|
+
end
|
23
|
+
|
24
|
+
self
|
16
25
|
end
|
17
26
|
|
18
27
|
# Login with the supplied credentials. Returns true on success.
|
@@ -42,7 +51,8 @@ module Pyre
|
|
42
51
|
@rooms = @agent.current_page.parser.search('div[@id="rooms"]//h2').map do |h2|
|
43
52
|
name = h2.inner_text.strip
|
44
53
|
url = h2.at('a')[:href]
|
45
|
-
|
54
|
+
id = h2.at('a')[:href].match(/room\/(\d+)/)[1].to_i
|
55
|
+
Pyre::Room.new(name, url, id, self)
|
46
56
|
end
|
47
57
|
end
|
48
58
|
end
|
@@ -53,6 +63,28 @@ module Pyre
|
|
53
63
|
@rooms.detect {|room| room.name == name}
|
54
64
|
end
|
55
65
|
|
66
|
+
# Know the id of the room you're looking for? Try it here.
|
67
|
+
def find_room_by_id(id)
|
68
|
+
@rooms ||= rooms
|
69
|
+
@rooms.detect {|room| room.id == id}
|
70
|
+
end
|
71
|
+
|
72
|
+
# Pass the name or id of the room and get it back. Pass a block too!
|
73
|
+
# If you pass a block, the room will be left when the block completes.
|
74
|
+
def room(identifier)
|
75
|
+
room = case identifier
|
76
|
+
when String
|
77
|
+
find_room_by_name(identifier)
|
78
|
+
when Integer
|
79
|
+
find_room_by_id(identifier)
|
80
|
+
end
|
81
|
+
if block_given?
|
82
|
+
yield room
|
83
|
+
room.leave
|
84
|
+
end
|
85
|
+
room
|
86
|
+
end
|
87
|
+
|
56
88
|
def inspect #:nodoc:
|
57
89
|
"#<#{self.class} \"#{@subdomain}\" \"#{uri}\">"
|
58
90
|
end
|
data/lib/pyre/room.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
module Pyre
|
2
2
|
# Pyre::Room is for interacting with a room!
|
3
3
|
class Room
|
4
|
-
attr_reader :name
|
4
|
+
attr_reader :name, :id
|
5
5
|
|
6
|
-
def initialize(name, url, campfire) #:nodoc:
|
6
|
+
def initialize(name, url, id, campfire) #:nodoc:
|
7
7
|
@name = name
|
8
8
|
@url = url
|
9
|
+
@id = id
|
9
10
|
@campfire = campfire
|
10
11
|
end
|
11
12
|
|
data/tasks/setup.rb
CHANGED
@@ -23,7 +23,7 @@ PROJ.specs = FileList['spec/**/*_spec.rb']
|
|
23
23
|
PROJ.spec_opts = []
|
24
24
|
|
25
25
|
# Test::Unit
|
26
|
-
PROJ.tests = FileList['test/**/test_*.rb']
|
26
|
+
PROJ.tests = FileList['test/**/test_*.rb', 'test_private/**/test_*.rb']
|
27
27
|
PROJ.test_file = 'test/all.rb'
|
28
28
|
PROJ.test_opts = []
|
29
29
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pyre
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Christopher Shea
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-02-
|
12
|
+
date: 2008-02-17 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|