blastr 0.0.5 → 0.0.6

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 CHANGED
@@ -1,3 +1,7 @@
1
+ == 0.0.6 2009-01-17
2
+
3
+ * Code cleanup
4
+
1
5
  == 0.0.5 2009-01-17
2
6
 
3
7
  * Improved instructions in README.rdoc
data/Manifest.txt CHANGED
@@ -5,12 +5,12 @@ README.rdoc
5
5
  Rakefile
6
6
  bin/blastr
7
7
  lib/blastr.rb
8
- lib/blastr/git.rb
9
- lib/blastr/scm.rb
10
- lib/blastr/svn.rb
11
- lib/blastr/tts.rb
8
+ lib/scm/git.rb
9
+ lib/scm/scm.rb
10
+ lib/scm/svn.rb
11
+ lib/tts/tts.rb
12
12
  script/console
13
13
  script/destroy
14
14
  script/generate
15
- test/test_blastr.rb
16
15
  test/test_helper.rb
16
+ test/test_tts.rb
data/bin/blastr CHANGED
@@ -1,42 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'rubygems'
4
- require 'yaml'
5
4
  require "#{File.dirname(__FILE__)}/../lib/blastr.rb"
6
- require "#{File.dirname(__FILE__)}/../lib/blastr/tts.rb"
7
5
 
8
- scm_url = ARGV[0]
9
- scm = Blastr.scm(scm_url)
10
- since_revision = scm.as_revision(ARGV[1]) if ARGV.size > 1
11
- since_revision = scm.latest_revision unless ARGV.size > 1
12
-
13
- class Author
14
- PEOPLE_FILE = File.expand_path("~/.blastr/people")
15
- def self.people
16
- if File.file?(PEOPLE_FILE)
17
- yaml = YAML.load_file(PEOPLE_FILE)
18
- return yaml unless yaml == false
19
- end
20
- { }
21
- end
22
-
23
- def self.full_name_of(username)
24
- people[username] ||= username
25
- end
26
- end
27
-
28
- def announce(commit)
29
- puts "[#{commit.revision}] Commit by #{commit.author}: #{commit.comment}"
30
- Blastr::TTS.speak("Commit by #{Author.full_name_of(commit.author)}: #{commit.comment}")
31
- end
32
-
33
- puts "Polling for #{scm.name} commits since revision #{since_revision}..."
34
- while true
35
- scm.commits_since(since_revision.to_s).each do |commit|
36
- if since_revision.before?(commit.revision)
37
- announce(commit)
38
- since_revision = commit.revision
39
- end
40
- end
41
- sleep 30
42
- end
6
+ Blastr::Process.new(ARGV).run
data/lib/blastr.rb CHANGED
@@ -1,11 +1,55 @@
1
1
  $:.unshift(File.dirname(__FILE__)) unless
2
2
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
3
 
4
+ require 'yaml'
5
+ require 'scm/git.rb'
6
+ require 'scm/svn.rb'
7
+ require 'tts/tts.rb'
8
+
4
9
  module Blastr
5
- VERSION = '0.0.5'
10
+ VERSION = '0.0.6'
11
+
12
+ class Author
13
+ PEOPLE_FILE = File.expand_path("~/.blastr/people")
14
+ def self.people
15
+ if File.file?(PEOPLE_FILE)
16
+ yaml = YAML.load_file(PEOPLE_FILE)
17
+ return yaml unless yaml == false
18
+ end
19
+ { }
20
+ end
6
21
 
7
- require 'blastr/git.rb'
8
- require 'blastr/svn.rb'
22
+ def self.full_name_of(username)
23
+ people[username] ||= username
24
+ end
25
+ end
26
+
27
+ class Process
28
+ def initialize(args=[])
29
+ scm_url = ARGV[0]
30
+ @scm = Blastr.scm(scm_url)
31
+ @since_revision = @scm.as_revision(ARGV[1]) if ARGV.size > 1
32
+ @since_revision = @scm.latest_revision unless ARGV.size > 1
33
+ end
34
+
35
+ def announce(commit)
36
+ puts "[#{commit.revision}] Commit by #{commit.author}: #{commit.comment}"
37
+ Blastr::TTS.speak("Commit by #{Author.full_name_of(commit.author)}: #{commit.comment}")
38
+ end
39
+
40
+ def run
41
+ puts "Polling #{@scm.name} commits since revision #{@since_revision}..."
42
+ while true
43
+ @scm.commits_since(@since_revision.to_s).each do |commit|
44
+ if @since_revision.before?(commit.revision)
45
+ announce(commit)
46
+ @since_revision = commit.revision
47
+ end
48
+ end
49
+ sleep 30
50
+ end
51
+ end
52
+ end
9
53
 
10
54
  def Blastr::temp_dir
11
55
  temp_file = Tempfile.new("tmp")
File without changes
File without changes
@@ -25,7 +25,7 @@ module Blastr
25
25
  def name; "Subversion"; end
26
26
 
27
27
  def self.understands_url?(url)
28
- not url.match(/(https?|svn):\/\/.+/).nil?
28
+ not url.match(/(https?|svn):\/\/.+/u).nil?
29
29
  end
30
30
 
31
31
  def initialize(svn_url)
@@ -44,11 +44,12 @@ module Blastr
44
44
  end
45
45
 
46
46
  def commits_since(since_revision = 1)
47
+ nonascii = /([^a-zA-Z0-9\.,:;\-_\?!"'\s]+?)/u
47
48
  entries = []
48
- svn_log(since_revision).scan(/r(\d+)\s\|\s(.*?)\s\|.*?\n\n(.*)\n-+/).each do |entry|
49
+ svn_log(since_revision).scan(/r(\d+)\s\|\s(.*?)\s\|.*?\n\n(.*)\n-+/u).each do |entry|
49
50
  revision = as_revision(entry[0])
50
51
  author = entry[1]
51
- comment = entry[2]
52
+ comment = entry[2].gsub(nonascii, 'X ')
52
53
  entries << LogEntry.new(revision, author, comment)
53
54
  end
54
55
  entries
@@ -45,7 +45,7 @@ module Blastr
45
45
  end
46
46
 
47
47
  def TTS::speak(msg)
48
- resolve_tts_system.speak(msg)
48
+ resolve_tts_system.speak(msg.gsub(/"/u, '\"').gsub(/'/u, '\''))
49
49
  end
50
50
 
51
51
  end
data/test/test_tts.rb ADDED
@@ -0,0 +1,9 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class TestTTSImplementation < Test::Unit::TestCase
4
+
5
+ def test_availability_depends_on_binary_existing_in_PATH
6
+ assert Blastr::TTS::TTSImplementation.new("nosuchbinaryexists").available? == false
7
+ assert Blastr::TTS::TTSImplementation.new("echo").available? == true
8
+ end
9
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blastr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lasse Koskela
@@ -62,15 +62,15 @@ files:
62
62
  - Rakefile
63
63
  - bin/blastr
64
64
  - lib/blastr.rb
65
- - lib/blastr/git.rb
66
- - lib/blastr/scm.rb
67
- - lib/blastr/svn.rb
68
- - lib/blastr/tts.rb
65
+ - lib/scm/git.rb
66
+ - lib/scm/scm.rb
67
+ - lib/scm/svn.rb
68
+ - lib/tts/tts.rb
69
69
  - script/console
70
70
  - script/destroy
71
71
  - script/generate
72
- - test/test_blastr.rb
73
72
  - test/test_helper.rb
73
+ - test/test_tts.rb
74
74
  has_rdoc: true
75
75
  homepage: http://blastr.rubyforge.org
76
76
  post_install_message:
@@ -99,5 +99,5 @@ signing_key:
99
99
  specification_version: 2
100
100
  summary: Blastr observes a version control repository for commits and makes audible announcements out of the commit messages
101
101
  test_files:
102
- - test/test_blastr.rb
103
102
  - test/test_helper.rb
103
+ - test/test_tts.rb
data/test/test_blastr.rb DELETED
@@ -1,11 +0,0 @@
1
- require File.dirname(__FILE__) + '/test_helper.rb'
2
-
3
- class TestBlastr < Test::Unit::TestCase
4
-
5
- def setup
6
- end
7
-
8
- def test_truth
9
- assert true
10
- end
11
- end