build_watcher 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +3 -0
- data/Manifest.txt +15 -0
- data/README.txt +51 -0
- data/Rakefile +30 -0
- data/bin/update_listeners +10 -0
- data/lib/build_watcher.rb +12 -0
- data/lib/update_listeners/cli.rb +54 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/spec/build_watcher_spec.rb +11 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +13 -0
- data/spec/update_listeners_cli_spec.rb +45 -0
- data/tasks/rspec.rake +21 -0
- metadata +124 -0
data/History.txt
ADDED
data/Manifest.txt
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
History.txt
|
2
|
+
Manifest.txt
|
3
|
+
README.txt
|
4
|
+
Rakefile
|
5
|
+
bin/update_listeners
|
6
|
+
lib/build_watcher.rb
|
7
|
+
lib/update_listeners/cli.rb
|
8
|
+
script/console
|
9
|
+
script/destroy
|
10
|
+
script/generate
|
11
|
+
spec/build_watcher_spec.rb
|
12
|
+
spec/spec.opts
|
13
|
+
spec/spec_helper.rb
|
14
|
+
spec/update_listeners_cli_spec.rb
|
15
|
+
tasks/rspec.rake
|
data/README.txt
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
= build_watcher
|
2
|
+
|
3
|
+
* http://github.com/gn-research/build_watcher
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
Monitors the build status of projects on http://codefumes.com and
|
8
|
+
sends out notifications via a USB-connected Arduino board which has
|
9
|
+
a ZigBee wireless chip.
|
10
|
+
|
11
|
+
|
12
|
+
== FEATURES/PROBLEMS:
|
13
|
+
|
14
|
+
* coming soon...
|
15
|
+
|
16
|
+
== SYNOPSIS:
|
17
|
+
|
18
|
+
* coming soon...
|
19
|
+
|
20
|
+
== REQUIREMENTS:
|
21
|
+
|
22
|
+
* coming soon...
|
23
|
+
|
24
|
+
== INSTALL:
|
25
|
+
|
26
|
+
* gem install build_watcher
|
27
|
+
|
28
|
+
== LICENSE:
|
29
|
+
|
30
|
+
(The MIT License)
|
31
|
+
|
32
|
+
Copyright (c) 2010 GN ReSound
|
33
|
+
|
34
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
35
|
+
a copy of this software and associated documentation files (the
|
36
|
+
'Software'), to deal in the Software without restriction, including
|
37
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
38
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
39
|
+
permit persons to whom the Software is furnished to do so, subject to
|
40
|
+
the following conditions:
|
41
|
+
|
42
|
+
The above copyright notice and this permission notice shall be
|
43
|
+
included in all copies or substantial portions of the Software.
|
44
|
+
|
45
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
46
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
47
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
48
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
49
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
50
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
51
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
begin
|
2
|
+
require 'hoe'
|
3
|
+
rescue LoadError
|
4
|
+
require 'rubygems'
|
5
|
+
gem 'hoe', '>= 2.1.0'
|
6
|
+
require 'hoe'
|
7
|
+
end
|
8
|
+
|
9
|
+
begin
|
10
|
+
require "hanna/rdoctask"
|
11
|
+
rescue LoadError
|
12
|
+
require 'rake/rdoctask'
|
13
|
+
end
|
14
|
+
|
15
|
+
require 'fileutils'
|
16
|
+
require './lib/build_watcher'
|
17
|
+
|
18
|
+
|
19
|
+
Hoe.plugin :git
|
20
|
+
|
21
|
+
$hoe = Hoe.spec 'build_watcher' do
|
22
|
+
self.developer 'Tom Kersten', 'tom@whitespur.com'
|
23
|
+
extra_deps = [['codefumes','>= 0.1.8'], ['serialport', '= 1.0.2']]
|
24
|
+
extra_dev_deps = [['hoe-git', '>= 1.3.0']]
|
25
|
+
end
|
26
|
+
|
27
|
+
Dir['tasks/**/*.rake'].each { |t| load t }
|
28
|
+
|
29
|
+
# remove_task :default
|
30
|
+
# task :default => [:spec, :features]
|
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Created on 2010-4-15.
|
4
|
+
# Copyright (c) 2010. All rights reserved.
|
5
|
+
|
6
|
+
require 'rubygems'
|
7
|
+
require File.expand_path(File.dirname(__FILE__) + "/../lib/build_watcher")
|
8
|
+
require "update_listeners/cli"
|
9
|
+
|
10
|
+
UpdateListeners::CLI.execute(STDOUT, ARGV)
|
@@ -0,0 +1,12 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__)) unless
|
2
|
+
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
|
+
|
4
|
+
require 'build_watcher/zigbee_device'
|
5
|
+
require 'build_watcher/message'
|
6
|
+
require 'serialport'
|
7
|
+
|
8
|
+
module BuildWatcher
|
9
|
+
VERSION = '0.1.0'
|
10
|
+
|
11
|
+
class AppropriateMessageTypeNotFound < StandardError; end
|
12
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'optparse'
|
3
|
+
require 'serialport'
|
4
|
+
require 'codefumes'
|
5
|
+
|
6
|
+
module UpdateListeners
|
7
|
+
class CLI
|
8
|
+
DEFAULT_SERIAL_DEVICE = '/dev/tty.usbserial-A800ejOJ'
|
9
|
+
DEVICE_BAUD_RATE = 9600
|
10
|
+
ASCII_STX = 0x02
|
11
|
+
ASCII_ETX = 0x03
|
12
|
+
ASCII_US = 0x1F
|
13
|
+
|
14
|
+
def self.execute(stdout, arguments=[])
|
15
|
+
@stdout = stdout
|
16
|
+
parse_options!(arguments)
|
17
|
+
|
18
|
+
device = BuildWatcher::ZigbeeDevice.new(@raw_device_string)
|
19
|
+
device.project_quantity.times do |project_index|
|
20
|
+
project_info = device.project_info(project_index)
|
21
|
+
project = CodeFumes::Project.find(project_info.public_key)
|
22
|
+
device.broadcast_status(project.public_key, project.build_status)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.parse_options!(arguments)
|
27
|
+
OptionParser.new do |opts|
|
28
|
+
opts.banner = <<-BANNER.gsub(/^ /,'')
|
29
|
+
|
30
|
+
Usage: #{File.basename($0)} -d /dev/<some_device_string>
|
31
|
+
|
32
|
+
Options are:
|
33
|
+
BANNER
|
34
|
+
opts.separator ""
|
35
|
+
opts.on("-h", "--help",
|
36
|
+
"Show this help message.") { @stdout.puts opts; exit }
|
37
|
+
opts.on("-d", "--device [RAW_DEVICE]",
|
38
|
+
"Override the default serial device used") {|device| @raw_device_string = device}
|
39
|
+
|
40
|
+
opts.parse!(arguments)
|
41
|
+
|
42
|
+
if @raw_device_string.nil? || @raw_device_string.empty?
|
43
|
+
@stdout.puts opts
|
44
|
+
exit
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.log(message, level = 'INFO')
|
51
|
+
@stdout.puts "#{level}: #{message}"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
data/script/console
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# File: script/console
|
3
|
+
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
|
4
|
+
|
5
|
+
libs = " -r irb/completion"
|
6
|
+
# Perhaps use a console_lib to store any extra methods I may want available in the cosole
|
7
|
+
# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
|
8
|
+
libs << " -r #{File.dirname(__FILE__) + '/../lib/build_watcher.rb'}"
|
9
|
+
puts "Loading build_watcher gem"
|
10
|
+
exec "#{irb} #{libs} --simple-prompt"
|
data/script/destroy
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/destroy'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Destroy.new.run(ARGV)
|
data/script/generate
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/generate'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Generate.new.run(ARGV)
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
begin
|
2
|
+
require 'spec'
|
3
|
+
require 'ruby-debug'
|
4
|
+
rescue LoadError
|
5
|
+
require 'rubygems' unless ENV['NO_RUBYGEMS']
|
6
|
+
gem 'rspec'
|
7
|
+
require 'spec'
|
8
|
+
end
|
9
|
+
|
10
|
+
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
11
|
+
require 'build_watcher'
|
12
|
+
require 'build_watcher/fake_serial_port'
|
13
|
+
include BuildWatcher
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
require 'update_listeners/cli'
|
3
|
+
|
4
|
+
describe UpdateListeners::CLI, "execute" do
|
5
|
+
before(:each) do
|
6
|
+
@serial_port = FakeSerialPort.new
|
7
|
+
@zgb_device = BuildWatcher::ZigbeeDevice.new('/dev/something')
|
8
|
+
@project = CodeFumes::Project.new(:public_key => 'pub', :private_key => 'priv')
|
9
|
+
@project.stub!(:build_status).and_return("running")
|
10
|
+
|
11
|
+
SerialPort.stub!(:new).and_return(@serial_port)
|
12
|
+
BuildWatcher::ZigbeeDevice.stub!(:new).and_return(@zgb_device)
|
13
|
+
CodeFumes::Project.stub!(:find).and_return(@project)
|
14
|
+
end
|
15
|
+
|
16
|
+
context "3 projects have been registered on the 'server' device and CodeFumes.com" do
|
17
|
+
before(:each) do
|
18
|
+
@project_quantity = 3
|
19
|
+
Message.stub!(:project_qty_request).and_return(Message.project_qty_request!(@project_quantity))
|
20
|
+
Message.stub!(:project_info_request).and_return(Message.project_info_request!(0,'pub','priv'))
|
21
|
+
end
|
22
|
+
|
23
|
+
it "requests the quantity of projects from the serial device" do
|
24
|
+
@zgb_device.should_receive(:project_quantity).and_return(@project_quantity)
|
25
|
+
UpdateListeners::CLI.execute(STDOUT, [])
|
26
|
+
end
|
27
|
+
|
28
|
+
it "requests the project information from the serial device for each project" do
|
29
|
+
project_info = OpenStruct.new({:private_key => 'priv', :public_key => 'pub'})
|
30
|
+
@zgb_device.should_receive(:project_info).exactly(3).times.and_return(project_info)
|
31
|
+
UpdateListeners::CLI.execute(STDOUT, [])
|
32
|
+
end
|
33
|
+
|
34
|
+
it "it requests the project build status from CodeFumes for each project" do
|
35
|
+
CodeFumes::Project.should_receive(:find).exactly(@project_quantity).times.and_return(@project)
|
36
|
+
@project.should_receive(:build_status).exactly(@project_quantity).times.and_return('running')
|
37
|
+
UpdateListeners::CLI.execute(STDOUT, [])
|
38
|
+
end
|
39
|
+
|
40
|
+
it "it broadcasts the status of each project via the serial device" do
|
41
|
+
@zgb_device.should_receive(:broadcast_status).exactly(@project_quantity).times
|
42
|
+
UpdateListeners::CLI.execute(STDOUT, [])
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/tasks/rspec.rake
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
begin
|
2
|
+
require 'spec'
|
3
|
+
rescue LoadError
|
4
|
+
require 'rubygems' unless ENV['NO_RUBYGEMS']
|
5
|
+
require 'spec'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'spec/rake/spectask'
|
9
|
+
rescue LoadError
|
10
|
+
puts <<-EOS
|
11
|
+
To use rspec for testing you must install rspec gem:
|
12
|
+
gem install rspec
|
13
|
+
EOS
|
14
|
+
exit(0)
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Run the specs under spec/models"
|
18
|
+
Spec::Rake::SpecTask.new do |t|
|
19
|
+
t.spec_opts = ['--options', "spec/spec.opts"]
|
20
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: build_watcher
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: 0.1.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Tom Kersten
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-04-21 00:00:00 -05:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rubyforge
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 2
|
29
|
+
- 0
|
30
|
+
- 3
|
31
|
+
version: 2.0.3
|
32
|
+
type: :development
|
33
|
+
version_requirements: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: gemcutter
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 0
|
43
|
+
- 3
|
44
|
+
- 0
|
45
|
+
version: 0.3.0
|
46
|
+
type: :development
|
47
|
+
version_requirements: *id002
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: hoe
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
segments:
|
56
|
+
- 2
|
57
|
+
- 5
|
58
|
+
- 0
|
59
|
+
version: 2.5.0
|
60
|
+
type: :development
|
61
|
+
version_requirements: *id003
|
62
|
+
description: |-
|
63
|
+
Monitors the build status of projects on http://codefumes.com and
|
64
|
+
sends out notifications via a USB-connected Arduino board which has
|
65
|
+
a ZigBee wireless chip.
|
66
|
+
email:
|
67
|
+
- tom@whitespur.com
|
68
|
+
executables:
|
69
|
+
- update_listeners
|
70
|
+
extensions: []
|
71
|
+
|
72
|
+
extra_rdoc_files:
|
73
|
+
- History.txt
|
74
|
+
- Manifest.txt
|
75
|
+
- README.txt
|
76
|
+
files:
|
77
|
+
- History.txt
|
78
|
+
- Manifest.txt
|
79
|
+
- README.txt
|
80
|
+
- Rakefile
|
81
|
+
- bin/update_listeners
|
82
|
+
- lib/build_watcher.rb
|
83
|
+
- lib/update_listeners/cli.rb
|
84
|
+
- script/console
|
85
|
+
- script/destroy
|
86
|
+
- script/generate
|
87
|
+
- spec/build_watcher_spec.rb
|
88
|
+
- spec/spec.opts
|
89
|
+
- spec/spec_helper.rb
|
90
|
+
- spec/update_listeners_cli_spec.rb
|
91
|
+
- tasks/rspec.rake
|
92
|
+
has_rdoc: true
|
93
|
+
homepage: http://github.com/gn-research/build_watcher
|
94
|
+
licenses: []
|
95
|
+
|
96
|
+
post_install_message:
|
97
|
+
rdoc_options:
|
98
|
+
- --main
|
99
|
+
- README.txt
|
100
|
+
require_paths:
|
101
|
+
- lib
|
102
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
segments:
|
107
|
+
- 0
|
108
|
+
version: "0"
|
109
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
segments:
|
114
|
+
- 0
|
115
|
+
version: "0"
|
116
|
+
requirements: []
|
117
|
+
|
118
|
+
rubyforge_project: build_watcher
|
119
|
+
rubygems_version: 1.3.6
|
120
|
+
signing_key:
|
121
|
+
specification_version: 3
|
122
|
+
summary: Monitors the build status of projects on http://codefumes.com and sends out notifications via a USB-connected Arduino board which has a ZigBee wireless chip.
|
123
|
+
test_files: []
|
124
|
+
|