dmorrill10-utils 0.0.5 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,2 +1,28 @@
1
1
  #!/usr/bin/env rake
2
+
2
3
  require "bundler/gem_tasks"
4
+ require 'rake'
5
+ require 'rake/testtask'
6
+
7
+ require File.expand_path('../lib/dmorrill10-utils/version', __FILE__)
8
+
9
+ Rake::TestTask.new do |t|
10
+ t.libs << "lib" << 'spec/support'
11
+ t.test_files = FileList['spec/**/*_spec.rb']
12
+ t.verbose = true
13
+ t.warning = true
14
+ end
15
+
16
+ desc 'Build gem'
17
+ task :default => :build
18
+
19
+ task :build => :spec do
20
+ system "gem build dmorrill10-utils.gemspec"
21
+ end
22
+
23
+ task :tag => :build do
24
+ puts "Tagging #{AcpcPokerTypes::VERSION}..."
25
+ system "git tag -a #{AcpcPokerTypes::VERSION} -m 'Tagging #{AcpcPokerTypes::VERSION}'"
26
+ puts "Pushing #{AcpcPokerTypes::VERSION} to git..."
27
+ system "git push --tags"
28
+ end
@@ -4,10 +4,14 @@ require File.expand_path('../lib/dmorrill10-utils/version', __FILE__)
4
4
  Gem::Specification.new do |gem|
5
5
  gem.authors = ["Dustin Morrill"]
6
6
  gem.email = ["morrill@ualberta.ca"]
7
- gem.description = %q{Group of random Ruby mixin utility functions.}
7
+ gem.description = %q{My utilities.}
8
8
  gem.summary = %q{Group of random Ruby mixin utility functions.}
9
9
  gem.homepage = 'https://github.com/dmorrill10/dmorrill10-utils'
10
10
 
11
+ gem.add_development_dependency 'mocha'
12
+ gem.add_development_dependency 'simplecov'
13
+ gem.add_development_dependency 'turn'
14
+
11
15
  gem.files = `git ls-files`.split($\)
12
16
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
@@ -1,11 +1,9 @@
1
1
  require "dmorrill10-utils/version"
2
2
 
3
- require 'dmorrill10-utils/abstract'
4
3
  require 'dmorrill10-utils/class'
5
4
  require 'dmorrill10-utils/enumerable'
6
5
  require 'dmorrill10-utils/integer'
7
6
  require 'dmorrill10-utils/string_form_manipulation'
8
- require 'dmorrill10-utils/script'
9
7
  require 'dmorrill10-utils/process_runner'
10
8
 
11
9
  module Dmorrill10
@@ -2,8 +2,6 @@
2
2
  require File.expand_path('../string_form_manipulation', __FILE__)
3
3
 
4
4
  class Class
5
- private
6
-
7
5
  # @param [Array] names A list of exception names that the calling class would
8
6
  # like to define.
9
7
  def exceptions(*names)
@@ -4,13 +4,10 @@ class ProcessRunner
4
4
  # @param [Array] command The command to run.
5
5
  # @param [Hash] options Options with which the process should be started.
6
6
  # => (see IO#popen) for more information on available options.
7
- # @return [IO] Pipe to the started process.
8
- # @raise (see IO#popen)
7
+ # @return [Integer] The process ID of the started process.
8
+ # @raise (see Process#spawn)
9
+ # @raise (see Process#detach)
9
10
  def self.go(command, options={})
10
- pipe = IO.popen command.push(options)
11
-
12
- Process.detach pipe.pid
13
-
14
- pipe
11
+ Process.detach(Process.spawn(command.join(' '), options)).pid
15
12
  end
16
13
  end
@@ -1,5 +1,5 @@
1
1
  module Dmorrill10
2
2
  module Utils
3
- VERSION = "0.0.5"
3
+ VERSION = "1.0.0"
4
4
  end
5
5
  end
@@ -0,0 +1,33 @@
1
+ # Spec helper (must include first to track code coverage with SimpleCov)
2
+ require_relative 'support/spec_helper'
3
+
4
+ require_relative '../lib/dmorrill10-utils/process_runner'
5
+
6
+ describe ProcessRunner do
7
+ before do
8
+ @pid = nil
9
+ end
10
+
11
+ describe '::go' do
12
+ it 'starts a process asynchronously that can be killed by an external signal, and return its PIDs' do
13
+ @pid = ProcessRunner.go(['sleep', '10'])
14
+
15
+ check_process_exists
16
+
17
+ cleanup
18
+ end
19
+ end
20
+
21
+ def cleanup
22
+ Process.kill 'KILL', @pid
23
+
24
+ ->() { Process.getpgid(@pid) }.must_raise Errno::ESRCH
25
+ end
26
+ def check_process_exists
27
+ begin
28
+ Process.getpgid(@pid)
29
+ rescue Errno::ESRCH => e
30
+ flunk "Process with pid #{@pid} does not exist: #{e.message}"
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,24 @@
1
+
2
+ require 'simplecov'
3
+ SimpleCov.start
4
+
5
+ require 'minitest/spec'
6
+ require 'minitest/autorun'
7
+
8
+ begin
9
+ require 'turn/autorun'
10
+
11
+ Turn.config do |c|
12
+ # use one of output formats:
13
+ # :outline - turn's original case/test outline mode [default]
14
+ # :progress - indicates progress with progress bar
15
+ # :dotted - test/unit's traditional dot-progress mode
16
+ # :pretty - new pretty reporter
17
+ # :marshal - dump output as YAML (normal run mode only)
18
+ # :cue - interactive testing
19
+ c.format = :pretty
20
+ # use humanized test names (works only with :outline format)
21
+ c.natural = true
22
+ end
23
+ rescue LoadError
24
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dmorrill10-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 1.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,9 +9,57 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-01 00:00:00.000000000 Z
13
- dependencies: []
14
- description: Group of random Ruby mixin utility functions.
12
+ date: 2012-07-14 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: mocha
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: simplecov
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: turn
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ description: My utilities.
15
63
  email:
16
64
  - morrill@ualberta.ca
17
65
  executables: []
@@ -24,14 +72,14 @@ files:
24
72
  - Rakefile
25
73
  - dmorrill10-utils.gemspec
26
74
  - lib/dmorrill10-utils.rb
27
- - lib/dmorrill10-utils/abstract.rb
28
75
  - lib/dmorrill10-utils/class.rb
29
76
  - lib/dmorrill10-utils/enumerable.rb
30
77
  - lib/dmorrill10-utils/integer.rb
31
78
  - lib/dmorrill10-utils/process_runner.rb
32
- - lib/dmorrill10-utils/script.rb
33
79
  - lib/dmorrill10-utils/string_form_manipulation.rb
34
80
  - lib/dmorrill10-utils/version.rb
81
+ - spec/process_runner_spec.rb
82
+ - spec/support/spec_helper.rb
35
83
  homepage: https://github.com/dmorrill10/dmorrill10-utils
36
84
  licenses: []
37
85
  post_install_message:
@@ -56,5 +104,7 @@ rubygems_version: 1.8.24
56
104
  signing_key:
57
105
  specification_version: 3
58
106
  summary: Group of random Ruby mixin utility functions.
59
- test_files: []
107
+ test_files:
108
+ - spec/process_runner_spec.rb
109
+ - spec/support/spec_helper.rb
60
110
  has_rdoc:
@@ -1,18 +0,0 @@
1
- module Abstract
2
- private
3
-
4
- def abstract_class_name
5
- self.class.ancestors.each_index do |i|
6
- current_module_name = Module.nesting.last
7
- if self.class.ancestors[i] == current_module_name
8
- return self.class.ancestors[i - 1]
9
- end
10
- end
11
- ''
12
- end
13
-
14
- def enforce_abstract(method)
15
- puts "Please redefine #{abstract_class_name}##{method}"
16
- exit 0
17
- end
18
- end
@@ -1,25 +0,0 @@
1
- require File.expand_path('../abstract', __FILE__)
2
-
3
- module Script
4
- include Abstract
5
-
6
- private
7
-
8
- def proper_usage?
9
- enforce_abstract __method__
10
- end
11
-
12
- def print_usage
13
- enforce_abstract __method__
14
- end
15
-
16
- def run_script_if_run_as_script(file_being_run)
17
- return unless file_being_run == $0
18
-
19
- if proper_usage?
20
- yield
21
- else
22
- print_usage
23
- end
24
- end
25
- end