pyre 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,11 @@
1
+ == 0.2.0 / 2008-02-17
2
+
3
+ * New methods
4
+ * Campfire#find_room_by_id
5
+ * Campfire#room - give it a name or an id, and maybe a block!
6
+ * Improved methods
7
+ * Campfire.new takes a block now too.
8
+
1
9
  == 0.1.0 / 2008-02-15
2
10
 
3
11
  * 1 major enhancement
data/README.txt CHANGED
@@ -26,12 +26,13 @@ Patches awfully welcome.
26
26
  require 'rubygems'
27
27
  require 'pyre'
28
28
 
29
- campfire = Pyre::Campfire.new('pyre')
30
- campfire.login('mycoolemail@example.com', 'anactualpassword')
31
- room = campfire.find_room_by_name('Pyre Test')
32
- room.speak('ZOMG! It works!') # automatically joins the room
33
- room.leave
34
- campfire.logout
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
 
@@ -1,7 +1,7 @@
1
1
  # Pyre: Because there isn't a real API for Campfire.
2
2
  module Pyre
3
3
  # :stopdoc:
4
- VERSION = '0.1.1'
4
+ VERSION = '0.2.0'
5
5
  LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
6
6
  PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
7
7
  # :startdoc:
@@ -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
- Pyre::Room.new(name, url, self)
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
@@ -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
 
@@ -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.1.1
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-16 00:00:00 -07:00
12
+ date: 2008-02-17 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency