komagata-saimaa 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.
- data/LICENSE +20 -0
- data/README.rdoc +42 -0
- data/bin/saimaa +4 -0
- data/lib/saimaa.rb +71 -0
- data/saimaa.gemspec +47 -0
- data/test/saimaa_test.rb +15 -0
- data/test/test_helper.rb +10 -0
- metadata +71 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Masaki Komagata
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
= saimaa
|
2
|
+
|
3
|
+
An easy Continuous Integration Toolkit.
|
4
|
+
|
5
|
+
== DESCRIPTION
|
6
|
+
|
7
|
+
saimaa command use -c COMMAND and -n NOTIFY_COMMAND parameters.
|
8
|
+
saimaa do nothing when COMMAND return status zero.
|
9
|
+
but, It print that merged stdout and stderr when COMMAND return status not zero.
|
10
|
+
and execute NOTIFY_COMMAND with merged string.
|
11
|
+
COMMAND results saved YAML file at ~/.saimaa/saimaa.yml
|
12
|
+
|
13
|
+
== INSTALLATION
|
14
|
+
|
15
|
+
$ gem install komagata-saimaa -s http://gems.github.com
|
16
|
+
|
17
|
+
== USAGE
|
18
|
+
|
19
|
+
$ saimaa -c "ls /tmp" example
|
20
|
+
$ saimaa -c "ls /tmpp" example
|
21
|
+
--project--
|
22
|
+
example
|
23
|
+
--stdout--
|
24
|
+
|
25
|
+
--stderr--
|
26
|
+
ls: /tmpp: No such file or directory
|
27
|
+
|
28
|
+
for testing.
|
29
|
+
|
30
|
+
$ saimaa -c "rake spec" -n "mail -s '[example] rspec testing' foo@example.com" example
|
31
|
+
$ saimaa -c "script/cucumber features -s -l ja" -n "growlnotify -t 'cucumber testing'" example
|
32
|
+
|
33
|
+
using cron
|
34
|
+
|
35
|
+
$ crontab -e
|
36
|
+
PATH=/bin:/usr/bin:/opt/local/bin
|
37
|
+
HOME=/Users/komagata
|
38
|
+
0 5 * * * saimaa -c "rake spec" -n "mail -s '[example] rspec testing' foo@example.com" example
|
39
|
+
|
40
|
+
== Copyright
|
41
|
+
|
42
|
+
Copyright (c) 2009 Masaki Komagata. See LICENSE for details.
|
data/bin/saimaa
ADDED
data/lib/saimaa.rb
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "systemu"
|
3
|
+
require "optparse"
|
4
|
+
require "fileutils"
|
5
|
+
require "yaml/store"
|
6
|
+
|
7
|
+
class Saimaa
|
8
|
+
class Command
|
9
|
+
class << self
|
10
|
+
def run(argv)
|
11
|
+
options = {}
|
12
|
+
stats, result = []
|
13
|
+
OptionParser.new do |opt|
|
14
|
+
opt.on('-c COMMAND', 'execute command') do |cmd|
|
15
|
+
options[:execute] = cmd
|
16
|
+
end
|
17
|
+
opt.on('-n COMMAND', 'notifier command') do |cmd|
|
18
|
+
options[:notify] = cmd
|
19
|
+
end
|
20
|
+
opt.parse!(argv)
|
21
|
+
end
|
22
|
+
|
23
|
+
project = argv.first
|
24
|
+
|
25
|
+
if options.key?(:execute)
|
26
|
+
stats, result = execute(options[:execute], project)
|
27
|
+
end
|
28
|
+
|
29
|
+
unless stats.to_i == 0
|
30
|
+
if options.key?(:notify)
|
31
|
+
notify(options[:notify], result)
|
32
|
+
else
|
33
|
+
puts result
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
save(project,
|
38
|
+
:stats => stats.to_i,
|
39
|
+
:result => result,
|
40
|
+
:time => Time.now)
|
41
|
+
end
|
42
|
+
|
43
|
+
def execute(cmd, project)
|
44
|
+
stats, stdout, stderr = systemu(cmd)
|
45
|
+
result = %W(
|
46
|
+
--project--
|
47
|
+
#{project}
|
48
|
+
--stdout--
|
49
|
+
#{stdout}
|
50
|
+
--stderr--
|
51
|
+
#{stderr}
|
52
|
+
).join("\n")
|
53
|
+
[stats, result]
|
54
|
+
end
|
55
|
+
|
56
|
+
def notify(cmd, stdin)
|
57
|
+
systemu(cmd, :stdin => stdin)
|
58
|
+
end
|
59
|
+
|
60
|
+
def save(project, record)
|
61
|
+
path = "#{ENV["HOME"]}/.saimaa"
|
62
|
+
FileUtils.mkdir(path) unless File.exists?(path)
|
63
|
+
db = YAML::Store.new("#{path}/saimaa.yml")
|
64
|
+
db.transaction do
|
65
|
+
db[project] ||= []
|
66
|
+
db[project] << record
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
data/saimaa.gemspec
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{saimaa}
|
5
|
+
s.version = "0.1.0"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Masaki Komagata"]
|
9
|
+
s.date = %q{2009-08-17}
|
10
|
+
s.default_executable = %q{saimaa}
|
11
|
+
s.description = %q{An easy Continuous Integration Toolkit.}
|
12
|
+
s.email = %q{komagata@gmail.com}
|
13
|
+
s.executables = ["saimaa"]
|
14
|
+
s.extra_rdoc_files = [
|
15
|
+
"LICENSE",
|
16
|
+
"README.rdoc"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
"bin/saimaa",
|
20
|
+
"lib/saimaa.rb",
|
21
|
+
"saimaa.gemspec",
|
22
|
+
"test/saimaa_test.rb",
|
23
|
+
"test/test_helper.rb"
|
24
|
+
]
|
25
|
+
s.homepage = %q{http://github.com/komagata/saimaa}
|
26
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
27
|
+
s.require_paths = ["lib"]
|
28
|
+
s.rubygems_version = %q{1.3.4}
|
29
|
+
s.summary = %q{An easy Continuous Integration Toolkit.}
|
30
|
+
s.test_files = [
|
31
|
+
"test/saimaa_test.rb",
|
32
|
+
"test/test_helper.rb"
|
33
|
+
]
|
34
|
+
|
35
|
+
if s.respond_to? :specification_version then
|
36
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
37
|
+
s.specification_version = 3
|
38
|
+
|
39
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
40
|
+
s.add_runtime_dependency(%q<systemu>, [">= 1.2.0"])
|
41
|
+
else
|
42
|
+
s.add_dependency(%q<systemu>, [">= 1.2.0"])
|
43
|
+
end
|
44
|
+
else
|
45
|
+
s.add_dependency(%q<systemu>, [">= 1.2.0"])
|
46
|
+
end
|
47
|
+
end
|
data/test/saimaa_test.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class SaimaaTest < Test::Unit::TestCase
|
4
|
+
context "execute method" do
|
5
|
+
should "return status 0 when good command" do
|
6
|
+
stat, result = Saimaa::Command.execute("ls /tmp", "test")
|
7
|
+
assert_equal 0, stat.to_i
|
8
|
+
end
|
9
|
+
|
10
|
+
should "reutnr status not 0 when bad comand" do
|
11
|
+
stat, result = Saimaa::Command.execute("ls /tmpppp", "test")
|
12
|
+
assert_not_equal 0, stat.to_i
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: komagata-saimaa
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Masaki Komagata
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-08-17 00:00:00 -07:00
|
13
|
+
default_executable: saimaa
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: systemu
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.2.0
|
24
|
+
version:
|
25
|
+
description: An easy Continuous Integration Toolkit.
|
26
|
+
email: komagata@gmail.com
|
27
|
+
executables:
|
28
|
+
- saimaa
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files:
|
32
|
+
- LICENSE
|
33
|
+
- README.rdoc
|
34
|
+
files:
|
35
|
+
- bin/saimaa
|
36
|
+
- lib/saimaa.rb
|
37
|
+
- saimaa.gemspec
|
38
|
+
- test/saimaa_test.rb
|
39
|
+
- test/test_helper.rb
|
40
|
+
- LICENSE
|
41
|
+
- README.rdoc
|
42
|
+
has_rdoc: false
|
43
|
+
homepage: http://github.com/komagata/saimaa
|
44
|
+
licenses:
|
45
|
+
post_install_message:
|
46
|
+
rdoc_options:
|
47
|
+
- --charset=UTF-8
|
48
|
+
require_paths:
|
49
|
+
- lib
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: "0"
|
55
|
+
version:
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: "0"
|
61
|
+
version:
|
62
|
+
requirements: []
|
63
|
+
|
64
|
+
rubyforge_project:
|
65
|
+
rubygems_version: 1.3.5
|
66
|
+
signing_key:
|
67
|
+
specification_version: 3
|
68
|
+
summary: An easy Continuous Integration Toolkit.
|
69
|
+
test_files:
|
70
|
+
- test/saimaa_test.rb
|
71
|
+
- test/test_helper.rb
|