housefire 0.0.3 → 0.1.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.
Files changed (4) hide show
  1. data/README.markdown +8 -0
  2. data/VERSION +1 -1
  3. data/lib/housefire.rb +58 -20
  4. metadata +3 -3
data/README.markdown CHANGED
@@ -24,3 +24,11 @@ Then, start up housefire and just leave it running. It currently checks LH
24
24
  every 60 seconds and keeps a local cache of what it has previously seen to
25
25
  keep the spam down on campfire.
26
26
 
27
+ TODO:
28
+ - don't let the cache grow ad infinitum, only cache the last few dozen events
29
+ - better formatting for specific events
30
+ - cowsay?
31
+ - better control over verbosity
32
+ - xmpp support
33
+
34
+
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.1.0
data/lib/housefire.rb CHANGED
@@ -3,6 +3,7 @@
3
3
  #
4
4
  # dbgrandi.in.2010
5
5
  #
6
+ #
6
7
  require 'rubygems'
7
8
  require 'nokogiri'
8
9
  require 'sanitize'
@@ -11,18 +12,6 @@ require 'broach'
11
12
  class Housefire
12
13
 
13
14
  def initialize(*args)
14
- #
15
- # required config:
16
- # lhuser: <your lh login>
17
- # lhpass: <your lh password>
18
- # account: <your campfire domain>
19
- # token: <your campfire auth token>
20
- # room: <the campfire room to talk to>
21
- #
22
- # optional config:
23
- # ssl: <use ssl for campfire?>
24
- # lhcache: <where to put the lighthouse event cache>
25
- #
26
15
  @conf = YAML.load(File.read(File.expand_path("~/.housefire")))
27
16
  @conf['ssl'] ||= false
28
17
  @conf['lhcache'] ||= File.expand_path("~/.housefire.tmp")
@@ -59,21 +48,70 @@ class Housefire
59
48
  e = {}
60
49
  e[:id] = id
61
50
 
62
- # DON'T notify changesets, github already does that
63
51
  title = entry.css("title")[0].content
64
- if !title.include?("[Changeset] ")
52
+ puts "title = #{title}"
53
+ case
54
+ when title.include?("[Changeset] ")
55
+ # changeset = [Changeset] <projectname>: Changeset [<sha>] by <user>
56
+ # we don't care about these, github already posts it for us
57
+ puts "Discarding Changeset message..."
58
+ when title.include?("[Page] ")
59
+ # page = [Page] <projectname>: <title>
60
+ # content needs html un-escaping
61
+ e[:title] = title
62
+ e[:author] = entry.css("author name")[0].content
63
+ e[:link] = entry.css("link")[0].attributes["href"].content
64
+ message = "#{e[:title]} - #{e[:author]} #{e[:link]}"
65
+ puts message + "\n\n\n"
66
+ @room.speak(message)
67
+ when title.include?("New ")
68
+ # member = New <projectname> Project Member
69
+ # like "New axislivewebsite Project Member"
70
+ message = entry.css("content")[0].content
71
+ puts message + "\n\n\n"
72
+ @room.speak(message)
73
+ when title.include?(" Bulk Edit: ")
74
+ # bulk edit = <projectname> Bulk Edit: <ticketlist no commas>
75
+ # also, href link is like http://wgrids.lighthouseapp.com/projects/45964/bulk_edits/19926
65
76
  e[:title] = title
66
77
  e[:content] = Sanitize.clean(entry.css("content")[0].content)
67
78
  e[:author] = entry.css("author name")[0].content
68
79
  e[:link] = entry.css("link")[0].attributes["href"].content
69
- e[:date] = entry.css("published")[0].content
70
-
71
- message = "#{e[:author]}: #{e[:title]} -- #{e[:content]}".gsub(/[^[:print:]]/, '').gsub(/&amp;/,'&')
72
- puts message
73
- puts "\n\n\n"
80
+ message = "#{e[:title]} - #{e[:content].gsub(/[^[:print:]]/, '').gsub(/&amp;/,'&')} #{e[:author]} #{e[:link]}"
81
+ puts message + "\n\n\n"
74
82
  @room.speak(message)
83
+ when title.include?("[Milestone] ")
84
+ # milestone = [Milestone] <projectname>: <title>
85
+ e[:title] = title
86
+ e[:content] = Sanitize.clean(entry.css("content")[0].content)
87
+ e[:author] = entry.css("author name")[0].content
88
+ e[:link] = entry.css("link")[0].attributes["href"].content
89
+ message = "#{e[:title]} -- #{e[:content].gsub(/[^[:print:]]/, '').gsub(/&amp;/,'&')} - #{e[:author]} #{e[:link]}"
90
+ puts message + "\n\n\n"
91
+ @room.speak(message)
92
+ when title[/\s\[#\d+\]$/] != nil
93
+ # ticket takes the form <projectname>: comment...blah [#<num>]
94
+ # e.g. <title type="html">weheartradio: It's possible to have multiple xmppclients trying to reconnect [#418]</title>
95
+ e[:title] = title
96
+ #
97
+ # tickets that were just created may not have any content
98
+ #
99
+ if entry.css("content").empty?
100
+ e[:content] = "NEW"
101
+ else
102
+ content = Sanitize.clean(entry.css("content")[0].content)
103
+ e[:content] = (content.length > 200) ? content[0..200] + "..." : content
104
+ end
105
+ e[:author] = entry.css("author name")[0].content
106
+ e[:link] = entry.css("link")[0].attributes["href"].content
107
+ message = "#{e[:title]} -- #{e[:content]} - #{e[:author]} #{e[:link]}"
108
+ puts message + "\n\n\n"
109
+ @room.speak(message)
110
+ else
111
+ puts "Not a valid message...or perhaps a new format."
75
112
  end
76
- # recent_items = recent_items.sort.last 10
113
+
114
+ # recent_items = recent_items.sort.last 10
77
115
  recent_items[id] = e
78
116
  save_db(@conf['lhcache'], recent_items)
79
117
  end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
+ - 1
7
8
  - 0
8
- - 3
9
- version: 0.0.3
9
+ version: 0.1.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - David Grandinetti
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-05-04 00:00:00 +01:00
17
+ date: 2010-05-30 00:00:00 +01:00
18
18
  default_executable: housefire
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency