wolfpack 0.0.3 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 91d7bcdedd9e608b7278e6007c23cb2cdf37fcc4
4
- data.tar.gz: e4f101fbfb56764e6f667dd56dd0b31441f85814
3
+ metadata.gz: a3b94a6f6dd6d481d9d187ab548bd5759b8b78f6
4
+ data.tar.gz: 551b2ca1dd025466d1540033a38c8d1bf8726815
5
5
  SHA512:
6
- metadata.gz: 90cea5961aed8bd69467e934c6a9c77e880444ad451bcad2ba8499b9bed4b58cbad4b9e58f53046cee1e010642b82a41cec9aa4fb18c3ddb47366092c86ef886
7
- data.tar.gz: 1a178ff4108c8695fb12bac5d5e413ea49dddc17a69eabd08d1454bbbca4f8e5c72416f1f65e6291250021162c076f2b23ecd352ef1a11b97691f716addf3a63
6
+ metadata.gz: 305c3f077623ae5874c1f59144ecfb72207fc827d63cf130330a256f0a0a7cb9b33216f0907c924a14161d17ad6b35b73359b0b1057366bfb0afe5f1c69115f9
7
+ data.tar.gz: b2f64f10ed193a827d23d59d78841f4ced2963621ad97cc6633e8090621a7c03f8f8301ffba6390cd00a87f1438cd28561f61a079d9d64529f6f45b5c5c23a61
data/README.md CHANGED
@@ -58,7 +58,9 @@ Then run wolfpack with the config file.
58
58
  ```sh
59
59
  # Running the wolfpack command on a 4 processor machine. Your machine might
60
60
  # run with a different number of workers depending on processors.
61
- $ find spec/**/**_spec.rb | wolfpack run 'echo "Using $DATABASE_URL"; rake db:create db:schema:load; rspec $SPEC_FILES;' -c config/wolfpack.rb
61
+ $ wolfpack run 'echo "Using $DATABASE_URL"; rake db:create db:schema:load; rspec $SPEC_FILES;' \
62
+ -c config/wolfpack.rb
63
+ --args `find spec/**/**_spec.rb`
62
64
  Using mysql2://localhost/app_test_0
63
65
  Using mysql2://localhost/app_test_1
64
66
  Using mysql2://localhost/app_test_2
@@ -1,3 +1,3 @@
1
1
  module Wolfpack
2
- VERSION = "0.0.3"
2
+ VERSION = "1.0.1"
3
3
  end
data/lib/wolfpack.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  require "wolfpack/version"
2
2
  require "thor"
3
3
  require "parallel"
4
- require "timeout"
5
4
 
6
5
  module Wolfpack
7
6
  # Gets the number of "processors" on the current machine. This does not map
@@ -11,9 +10,6 @@ module Wolfpack
11
10
  @processor_count ||= Parallel.processor_count
12
11
  end
13
12
 
14
- # Wait 10 seconds before blowing up if stdio isn't reading any data.
15
- STDIN_READ_TIMEOUT = 10
16
-
17
13
  # Configure a runner instance
18
14
  class Configurator
19
15
  attr_reader :runner
@@ -42,7 +38,7 @@ module Wolfpack
42
38
 
43
39
  # Create a command that will run with the give arguments. Optionally
44
40
  # a path may be given to a configuration file that sets up a runner.
45
- def initialize(command, args = [], config_path = nil)
41
+ def initialize(command, args, config_path = nil)
46
42
  @command, @args = command, args
47
43
  configure(config_path) if config_path
48
44
  end
@@ -54,8 +50,9 @@ module Wolfpack
54
50
  # make sure we have a number to work with.
55
51
  processes ||= Wolfpack.processor_count
56
52
 
57
- # Split args into groups of n processes.
58
- partions = partition(args, processes)
53
+ # If arguments exist then split args into groups of n processes.
54
+ # Otherwise run commands on every runner
55
+ partions = args ? partition(args, processes) : Array.new(processes){[]}
59
56
 
60
57
  # Now run the command with the processes.
61
58
  Parallel.each_with_index(partions, :in_processes => processes) do |args, n|
@@ -77,7 +74,9 @@ module Wolfpack
77
74
  arr.each_with_index do |el, idx|
78
75
  result[idx % n].push el
79
76
  end
80
- result
77
+
78
+ # Return only partitions with data in them
79
+ result.reject{|a| a.empty?}
81
80
  end
82
81
  end
83
82
 
@@ -91,29 +90,7 @@ module Wolfpack
91
90
  # thor doesn't return an integer for its params.
92
91
  processes = options[:processes].to_i if options[:processes]
93
92
 
94
- # If args are passed in, just use those.
95
- args = options[:args]
96
-
97
- # Otherwise read stdin from a pipe and split by lines.
98
- if args.nil?
99
- # Process stdin that's piped in.
100
- if $stdin.tty?
101
- args = [] # Screw it, lets return an empty array of args.
102
- else
103
- # Read from the pipe
104
- buffer = ""
105
-
106
- Timeout::timeout STDIN_READ_TIMEOUT do
107
- until $stdin.eof? do
108
- buffer << $stdin.read
109
- end
110
- end
111
-
112
- args = buffer.lines
113
- end
114
- end
115
-
116
- Wolfpack::Runner.new(command, args, options[:config]).run(processes)
93
+ Wolfpack::Runner.new(command, options[:args], options[:config]).run(processes)
117
94
  end
118
95
 
119
96
  desc "version", "Wolfpack version"
metadata CHANGED
@@ -1,83 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wolfpack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brad Gessler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-12 00:00:00.000000000 Z
11
+ date: 2014-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.3'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: guard-rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: thor
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: parallel
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - '>='
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  description: Run stuff in parallel
@@ -88,8 +88,8 @@ executables:
88
88
  extensions: []
89
89
  extra_rdoc_files: []
90
90
  files:
91
- - ".gitignore"
92
- - ".rspec"
91
+ - .gitignore
92
+ - .rspec
93
93
  - Gemfile
94
94
  - LICENSE.txt
95
95
  - README.md
@@ -112,20 +112,21 @@ require_paths:
112
112
  - lib
113
113
  required_ruby_version: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ">="
115
+ - - '>='
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  required_rubygems_version: !ruby/object:Gem::Requirement
119
119
  requirements:
120
- - - ">="
120
+ - - '>='
121
121
  - !ruby/object:Gem::Version
122
122
  version: '0'
123
123
  requirements: []
124
124
  rubyforge_project:
125
- rubygems_version: 2.2.0
125
+ rubygems_version: 2.3.0
126
126
  signing_key:
127
127
  specification_version: 4
128
128
  summary: Run ruby tasks in parallel
129
129
  test_files:
130
130
  - spec/lib/wolfpack.rb
131
131
  - spec/spec_helper.rb
132
+ has_rdoc: