pyre 0.2.0 → 0.3.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 +9 -0
- data/Manifest.txt +1 -0
- data/README.txt +5 -0
- data/contrib/svn/post-commit +76 -0
- data/lib/pyre.rb +8 -1
- data/lib/pyre/campfire.rb +1 -1
- data/lib/pyre/room.rb +17 -6
- metadata +3 -2
data/History.txt
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
== 0.3.0 / 2008-02-20
|
2
|
+
|
3
|
+
* Huge enhancement!
|
4
|
+
* contrib/ directory with Subversion post-commit hook ready to be tried out!
|
5
|
+
* New methods
|
6
|
+
* Room#upload('path/to/file') - UPLOAD!
|
7
|
+
* Improved methods
|
8
|
+
* A bunch of them now raise errors on failure
|
9
|
+
|
1
10
|
== 0.2.0 / 2008-02-17
|
2
11
|
|
3
12
|
* New methods
|
data/Manifest.txt
CHANGED
data/README.txt
CHANGED
@@ -44,6 +44,11 @@ Patches awfully welcome.
|
|
44
44
|
|
45
45
|
You can also grab the current trunk from http://pyre.rubyforge.org/svn/pyre/trunk
|
46
46
|
|
47
|
+
== MORE:
|
48
|
+
|
49
|
+
Check out the contrib directory for example scripts you can use, like a stylish
|
50
|
+
Subversion post-commit hook that shoots a nice-looking message to a Campfire room.
|
51
|
+
|
47
52
|
== LICENSE:
|
48
53
|
|
49
54
|
(The MIT License)
|
@@ -0,0 +1,76 @@
|
|
1
|
+
#!/usr/bin/ruby
|
2
|
+
|
3
|
+
# Subversion Post-Commit Hook using Pyre
|
4
|
+
#
|
5
|
+
# Throw this in your subversion repositories hooks/ directory
|
6
|
+
# (after making the appropriate changes) and it will paste
|
7
|
+
# nice commit messages for you in a Campfire chat room.
|
8
|
+
#
|
9
|
+
# The messages look like this:
|
10
|
+
|
11
|
+
# cms commited revision 104
|
12
|
+
# *************************
|
13
|
+
# Fixed all spelling mistaeks in the README
|
14
|
+
# *************************
|
15
|
+
# U pyre/trunk/README
|
16
|
+
|
17
|
+
# Get creative. For Rails projects, you might want to add
|
18
|
+
# a warning if a revision added or changed a mirgration.
|
19
|
+
# You could try adding something like this near the beginning
|
20
|
+
# of the messsage-building section:
|
21
|
+
#
|
22
|
+
# message << "MIGRATION!!!\n" if files.include?('db/migrate')
|
23
|
+
|
24
|
+
# CHANGE THESE VALUES!
|
25
|
+
# AND make sure the path in the first line is correct!
|
26
|
+
# AND make sure this file is executable!
|
27
|
+
|
28
|
+
SVNLOOK = '/path/to/svnlook' # svn hooks need full paths!
|
29
|
+
CAMPFIRE_SUBDOMAIN = 'your_subdomain'
|
30
|
+
CAMPFIRE_USERNAME = 'svn_bot_username'
|
31
|
+
CAMPFIRE_PASSWORD = 'svn_bot_password'
|
32
|
+
CAMPFIRE_ROOM = 'campfire_room'
|
33
|
+
CAMPFIRE_SSL = false # set to true if needed
|
34
|
+
|
35
|
+
# Okay, you're done changing values.
|
36
|
+
|
37
|
+
require 'rubygems'
|
38
|
+
require 'pyre'
|
39
|
+
|
40
|
+
# Subversion passes along the path of the repo and the revision number
|
41
|
+
# to the post-commit hook (and in that order).
|
42
|
+
path = ARGV[0]
|
43
|
+
revision = ARGV[1]
|
44
|
+
|
45
|
+
# See `svnlook help` for more.
|
46
|
+
author = `#{SVNLOOK} author -r #{revision} #{path}`.strip
|
47
|
+
files = `#{SVNLOOK} changed -r #{revision} #{path}`
|
48
|
+
log = `#{SVNLOOK} log -r #{revision} #{path}`.strip
|
49
|
+
|
50
|
+
# Here's where the message that gets pasted to the room gets built.
|
51
|
+
# Change this as you see fit.
|
52
|
+
message = "#{author} commited revision #{revision}\n"
|
53
|
+
separator = '*' * (message.length - 1) << "\n"
|
54
|
+
message << separator
|
55
|
+
message << log << "\n"
|
56
|
+
message << separator
|
57
|
+
message << files
|
58
|
+
|
59
|
+
# And here's where Pyre kicks in and pastes it.
|
60
|
+
Pyre::Campfire.new(CAMPFIRE_SUBDOMAIN, :ssl => CAMPFIRE_SSL) do |campfire|
|
61
|
+
campfire.login(CAMPFIRE_USERNAME, CAMPFIRE_PASSWORD)
|
62
|
+
campfire.room(CAMPFIRE_ROOM) do |room|
|
63
|
+
room.paste(message)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
# For more information on Subversion repository hooks, see:
|
68
|
+
# http://svnbook.red-bean.com/en/1.4/svn.reposadmin.create.html#svn.reposadmin.create.hooks
|
69
|
+
|
70
|
+
# THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
71
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
72
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
73
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
74
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
75
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
76
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/lib/pyre.rb
CHANGED
@@ -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.
|
4
|
+
VERSION = '0.3.0'
|
5
5
|
LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
|
6
6
|
PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
|
7
7
|
# :startdoc:
|
@@ -11,6 +11,13 @@ module Pyre
|
|
11
11
|
def self.version
|
12
12
|
VERSION
|
13
13
|
end
|
14
|
+
|
15
|
+
# :stopdoc:
|
16
|
+
class LoginError < StandardError; end
|
17
|
+
class CommunicationError < StandardError; end
|
18
|
+
class UploadError < StandardError; end
|
19
|
+
class NavigationError < StandardError; end
|
20
|
+
# :startdoc:
|
14
21
|
end
|
15
22
|
|
16
23
|
require 'uri'
|
data/lib/pyre/campfire.rb
CHANGED
data/lib/pyre/room.rb
CHANGED
@@ -13,7 +13,7 @@ module Pyre
|
|
13
13
|
# Enter the room. Returns true on success.
|
14
14
|
def join
|
15
15
|
@campfire.agent.get(@url)
|
16
|
-
joined?
|
16
|
+
joined? or begin raise NavigationError end
|
17
17
|
end
|
18
18
|
|
19
19
|
# Leave the room. Returns true on success.
|
@@ -21,7 +21,7 @@ module Pyre
|
|
21
21
|
if joined?
|
22
22
|
leave = @campfire.agent.current_page.links.detect {|link| link.text == 'Leave'}
|
23
23
|
@campfire.agent.post(leave.uri)
|
24
|
-
not joined?
|
24
|
+
not joined? or begin raise NavigationError end
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -30,20 +30,31 @@ module Pyre
|
|
30
30
|
@campfire.agent.current_page.at('h1[@id="room_name"]').inner_text == @name rescue false
|
31
31
|
end
|
32
32
|
|
33
|
-
# Send +message+ to the room. Joins the room if necessary.
|
33
|
+
# Send +message+ to the room. Joins the room if necessary. Returns true on success.
|
34
34
|
def speak(message)
|
35
35
|
result = submit_chat_form(message)
|
36
36
|
success = (result.uri.to_s == "#{@url}/speak")
|
37
37
|
join
|
38
|
-
success
|
38
|
+
success or begin raise CommunicationError end
|
39
39
|
end
|
40
40
|
|
41
|
-
# Paste +message+ to the room. Joins the room if necessary.
|
41
|
+
# Paste +message+ to the room. Joins the room if necessary. Returns true on success.
|
42
42
|
def paste(message)
|
43
43
|
result = submit_chat_form(message, 'paste' => 'true')
|
44
44
|
success = (result.links.detect {|link| link.text == 'View paste'} and result.uri.to_s == "#{@url}/speak")
|
45
45
|
join
|
46
|
-
success
|
46
|
+
success or begin raise CommunicationError end
|
47
|
+
end
|
48
|
+
|
49
|
+
# Upload a file (named +filename+) to the room. Joins the room if necessary. Returns true on success.
|
50
|
+
def upload(filename)
|
51
|
+
join unless joined?
|
52
|
+
upload_form = @campfire.agent.current_page.forms.detect {|form| form.form_node[:id] == 'upload_form_tag'}
|
53
|
+
upload_form.file_uploads.first.file_name = filename
|
54
|
+
result = @campfire.agent.submit(upload_form)
|
55
|
+
join
|
56
|
+
success = @campfire.agent.current_page.search(%Q{ul[@id="file_list"]//a[@href$="/#{File.basename(filename)}"]}).size > 0
|
57
|
+
success or begin raise UploadError end
|
47
58
|
end
|
48
59
|
|
49
60
|
def inspect #:nodoc:
|
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.3.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-20 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -50,6 +50,7 @@ files:
|
|
50
50
|
- tasks/spec.rake
|
51
51
|
- tasks/svn.rake
|
52
52
|
- tasks/test.rake
|
53
|
+
- contrib/svn/post-commit
|
53
54
|
has_rdoc: true
|
54
55
|
homepage: http://pyre.rubyforge.org
|
55
56
|
post_install_message:
|