sprint 1.0.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 +3 -0
- data/Manifest.txt +11 -0
- data/README.rdoc +50 -0
- data/Rakefile +26 -0
- data/lib/sprint.rb +46 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/test/test_helper.rb +3 -0
- data/test/test_sprint.rb +58 -0
- metadata +87 -0
data/History.txt
ADDED
data/Manifest.txt
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
= sprint
|
2
|
+
|
3
|
+
* http://github.com/#{github_username}/#{project_name}
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
Make dealing with execution of external processes easier.
|
8
|
+
|
9
|
+
== FEATURES/PROBLEMS:
|
10
|
+
|
11
|
+
* Encapsulate the output of an external program/command and its return code in a single object.
|
12
|
+
|
13
|
+
== SYNOPSIS:
|
14
|
+
|
15
|
+
sprint adds a "sprint" method to the Kernel module. This method executes the given command (using Kernel.`). It then captures the program output and resulting Process::Status object (via $?) in a single Sprint::Status object.
|
16
|
+
|
17
|
+
== REQUIREMENTS:
|
18
|
+
|
19
|
+
* Shoulda for testing; no dependencies on the core code.
|
20
|
+
|
21
|
+
== INSTALL:
|
22
|
+
|
23
|
+
Assuming you have Gemcutter in your gem sources:
|
24
|
+
|
25
|
+
* sudo gem install sprint
|
26
|
+
|
27
|
+
== LICENSE:
|
28
|
+
|
29
|
+
(The MIT License)
|
30
|
+
|
31
|
+
Copyright (c) 2009 Craig Walker
|
32
|
+
|
33
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
34
|
+
a copy of this software and associated documentation files (the
|
35
|
+
'Software'), to deal in the Software without restriction, including
|
36
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
37
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
38
|
+
permit persons to whom the Software is furnished to do so, subject to
|
39
|
+
the following conditions:
|
40
|
+
|
41
|
+
The above copyright notice and this permission notice shall be
|
42
|
+
included in all copies or substantial portions of the Software.
|
43
|
+
|
44
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
45
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
46
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
47
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
48
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
49
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
50
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
gem 'hoe', '>= 2.1.0'
|
3
|
+
require 'hoe'
|
4
|
+
require 'fileutils'
|
5
|
+
require './lib/sprint'
|
6
|
+
|
7
|
+
Hoe.plugin :newgem
|
8
|
+
# Hoe.plugin :website
|
9
|
+
# Hoe.plugin :cucumberfeatures
|
10
|
+
|
11
|
+
# Generate all the Rake tasks
|
12
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
13
|
+
$hoe = Hoe.spec 'sprint' do
|
14
|
+
self.developer 'FIXME full name', 'FIXME email'
|
15
|
+
self.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
|
16
|
+
self.rubyforge_name = self.name # TODO this is default value
|
17
|
+
# self.extra_deps = [['activesupport','>= 2.0.2']]
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
require 'newgem/tasks'
|
22
|
+
Dir['tasks/**/*.rake'].each { |t| load t }
|
23
|
+
|
24
|
+
# TODO - want other tests/tasks run by default? Add them to the list
|
25
|
+
# remove_task :default
|
26
|
+
# task :default => [:spec, :features]
|
data/lib/sprint.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__)) unless
|
2
|
+
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
|
+
|
4
|
+
module Sprint
|
5
|
+
VERSION = '1.0.0'
|
6
|
+
class Status
|
7
|
+
def initialize( output, status )
|
8
|
+
@output = output
|
9
|
+
@status = status
|
10
|
+
end
|
11
|
+
|
12
|
+
def to_s
|
13
|
+
@output
|
14
|
+
end
|
15
|
+
alias :output :to_s
|
16
|
+
alias :to_string :to_s
|
17
|
+
|
18
|
+
def good_output
|
19
|
+
raise "Process exited with error code: #{return_code}" unless success?
|
20
|
+
@output
|
21
|
+
end
|
22
|
+
|
23
|
+
def to_i
|
24
|
+
@status.exitstatus
|
25
|
+
end
|
26
|
+
alias :return_code :to_i
|
27
|
+
alias :to_int :to_i
|
28
|
+
|
29
|
+
def success?
|
30
|
+
@status.success?
|
31
|
+
end
|
32
|
+
alias :to_b :success?
|
33
|
+
|
34
|
+
def self.run( command )
|
35
|
+
output = `#{command}`
|
36
|
+
status = $?
|
37
|
+
Status.new output, status
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
module Kernel
|
43
|
+
def sprint( command )
|
44
|
+
Sprint::Status.run command
|
45
|
+
end
|
46
|
+
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/sprint.rb'}"
|
9
|
+
puts "Loading sprint 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/test/test_helper.rb
ADDED
data/test/test_sprint.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper.rb'
|
2
|
+
require 'shoulda'
|
3
|
+
|
4
|
+
class TestSprint < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
end
|
8
|
+
|
9
|
+
context "The run command" do
|
10
|
+
context "when executing 'echo Test'" do
|
11
|
+
setup do
|
12
|
+
@results = sprint "echo Test"
|
13
|
+
end
|
14
|
+
|
15
|
+
should "return the word 'Test' as its execution results" do
|
16
|
+
assert_equal "Test", @results.output.strip
|
17
|
+
end
|
18
|
+
|
19
|
+
should "have good output" do
|
20
|
+
assert_nothing_raised do
|
21
|
+
@results.good_output
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
should "indicate success" do
|
26
|
+
assert_equal true, @results.success?
|
27
|
+
end
|
28
|
+
|
29
|
+
should "have a zero status" do
|
30
|
+
assert_equal 0, @results.return_code
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context "when executing 'false'" do
|
35
|
+
setup do
|
36
|
+
@results = sprint "/usr/bin/env false"
|
37
|
+
end
|
38
|
+
|
39
|
+
should "have blank execution results" do
|
40
|
+
assert_equal "", @results.output
|
41
|
+
end
|
42
|
+
|
43
|
+
should "not have good output" do
|
44
|
+
assert_raise RuntimeError do
|
45
|
+
@results.good_output
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
should "indicate failure" do
|
50
|
+
assert_equal false, @results.success?
|
51
|
+
end
|
52
|
+
|
53
|
+
should "have a nonzero status" do
|
54
|
+
assert_not_equal 0, @results.return_code
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sprint
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Craig Walker
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-11-11 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: hoe
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 2.3.3
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: thoughtbot-shoulda
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.10.2
|
34
|
+
version:
|
35
|
+
description: Make dealing with execution of external processes easier.
|
36
|
+
email:
|
37
|
+
- craig@softcraft.ca
|
38
|
+
executables: []
|
39
|
+
|
40
|
+
extensions: []
|
41
|
+
|
42
|
+
extra_rdoc_files:
|
43
|
+
- History.txt
|
44
|
+
- Manifest.txt
|
45
|
+
files:
|
46
|
+
- History.txt
|
47
|
+
- Manifest.txt
|
48
|
+
- README.rdoc
|
49
|
+
- Rakefile
|
50
|
+
- lib/sprint.rb
|
51
|
+
- script/console
|
52
|
+
- script/destroy
|
53
|
+
- script/generate
|
54
|
+
- test/test_helper.rb
|
55
|
+
- test/test_sprint.rb
|
56
|
+
has_rdoc: true
|
57
|
+
homepage: http://github.com/#{github_username}/#{project_name}
|
58
|
+
licenses: []
|
59
|
+
|
60
|
+
post_install_message: PostInstall.txt
|
61
|
+
rdoc_options:
|
62
|
+
- --main
|
63
|
+
- README.rdoc
|
64
|
+
require_paths:
|
65
|
+
- lib
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: "0"
|
71
|
+
version:
|
72
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: "0"
|
77
|
+
version:
|
78
|
+
requirements: []
|
79
|
+
|
80
|
+
rubyforge_project: sprint
|
81
|
+
rubygems_version: 1.3.5
|
82
|
+
signing_key:
|
83
|
+
specification_version: 3
|
84
|
+
summary: Make dealing with execution of external processes easier.
|
85
|
+
test_files:
|
86
|
+
- test/test_helper.rb
|
87
|
+
- test/test_sprint.rb
|