engineyard-serverside 1.5.21 → 1.5.23.ruby19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (184) hide show
  1. data/lib/engineyard-serverside/cli.rb +39 -45
  2. data/lib/engineyard-serverside/configuration.rb +28 -4
  3. data/lib/engineyard-serverside/deploy.rb +5 -4
  4. data/lib/engineyard-serverside/logged_output.rb +3 -5
  5. data/lib/engineyard-serverside/server.rb +26 -2
  6. data/lib/engineyard-serverside/task.rb +2 -4
  7. data/lib/engineyard-serverside/version.rb +1 -1
  8. data/lib/engineyard-serverside.rb +8 -20
  9. data/spec/basic_deploy_spec.rb +1 -1
  10. data/spec/bundler_deploy_spec.rb +1 -1
  11. data/spec/nodejs_deploy_spec.rb +1 -1
  12. data/spec/rails31_deploy_spec.rb +1 -1
  13. data/spec/services_deploy_spec.rb +1 -1
  14. metadata +80 -233
  15. data/lib/vendor/dataflow/HISTORY +0 -52
  16. data/lib/vendor/dataflow/LICENSE +0 -19
  17. data/lib/vendor/dataflow/README.textile +0 -290
  18. data/lib/vendor/dataflow/Rakefile +0 -36
  19. data/lib/vendor/dataflow/dataflow/actor.rb +0 -22
  20. data/lib/vendor/dataflow/dataflow/equality.rb +0 -44
  21. data/lib/vendor/dataflow/dataflow/future_queue.rb +0 -24
  22. data/lib/vendor/dataflow/dataflow/port.rb +0 -54
  23. data/lib/vendor/dataflow/dataflow.rb +0 -124
  24. data/lib/vendor/dataflow/examples/barrier.rb +0 -9
  25. data/lib/vendor/dataflow/examples/data_driven.rb +0 -17
  26. data/lib/vendor/dataflow/examples/dataflow_http_gets.rb +0 -13
  27. data/lib/vendor/dataflow/examples/flow.rb +0 -20
  28. data/lib/vendor/dataflow/examples/future_http_gets.rb +0 -12
  29. data/lib/vendor/dataflow/examples/future_queue.rb +0 -11
  30. data/lib/vendor/dataflow/examples/instance_variables.rb +0 -15
  31. data/lib/vendor/dataflow/examples/laziness.rb +0 -9
  32. data/lib/vendor/dataflow/examples/local_variables.rb +0 -11
  33. data/lib/vendor/dataflow/examples/messages.rb +0 -26
  34. data/lib/vendor/dataflow/examples/port_http_gets.rb +0 -13
  35. data/lib/vendor/dataflow/examples/port_send.rb +0 -10
  36. data/lib/vendor/dataflow/examples/ring.rb +0 -21
  37. data/lib/vendor/dataflow/spec/actor_spec.rb +0 -28
  38. data/lib/vendor/dataflow/spec/anonymous_variables_spec.rb +0 -21
  39. data/lib/vendor/dataflow/spec/barrier_spec.rb +0 -25
  40. data/lib/vendor/dataflow/spec/by_need_spec.rb +0 -55
  41. data/lib/vendor/dataflow/spec/dataflow_spec.rb +0 -151
  42. data/lib/vendor/dataflow/spec/equality_spec.rb +0 -40
  43. data/lib/vendor/dataflow/spec/flow_spec.rb +0 -25
  44. data/lib/vendor/dataflow/spec/forker_spec.rb +0 -28
  45. data/lib/vendor/dataflow/spec/future_queue_spec.rb +0 -31
  46. data/lib/vendor/dataflow/spec/inspect_spec.rb +0 -19
  47. data/lib/vendor/dataflow/spec/need_later_spec.rb +0 -12
  48. data/lib/vendor/dataflow/spec/port_spec.rb +0 -26
  49. data/lib/vendor/dataflow/spec/spec.opts +0 -1
  50. data/lib/vendor/dataflow/spec/spec_helper.rb +0 -10
  51. data/lib/vendor/escape/Readme +0 -21
  52. data/lib/vendor/escape/doc_include/template/qualitysmith.rb +0 -631
  53. data/lib/vendor/json_pure/CHANGES +0 -166
  54. data/lib/vendor/json_pure/COPYING +0 -58
  55. data/lib/vendor/json_pure/GPL +0 -340
  56. data/lib/vendor/json_pure/README +0 -358
  57. data/lib/vendor/json_pure/Rakefile +0 -292
  58. data/lib/vendor/json_pure/TODO +0 -1
  59. data/lib/vendor/json_pure/VERSION +0 -1
  60. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkComparison.log +0 -52
  61. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast-autocorrelation.dat +0 -1000
  62. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast.dat +0 -1001
  63. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty-autocorrelation.dat +0 -900
  64. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty.dat +0 -901
  65. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe-autocorrelation.dat +0 -1000
  66. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe.dat +0 -1001
  67. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt.log +0 -261
  68. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast-autocorrelation.dat +0 -1000
  69. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast.dat +0 -1001
  70. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty-autocorrelation.dat +0 -1000
  71. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty.dat +0 -1001
  72. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe-autocorrelation.dat +0 -1000
  73. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe.dat +0 -1001
  74. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure.log +0 -262
  75. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator-autocorrelation.dat +0 -1000
  76. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator.dat +0 -1001
  77. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails.log +0 -82
  78. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkComparison.log +0 -34
  79. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser-autocorrelation.dat +0 -900
  80. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser.dat +0 -901
  81. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt.log +0 -81
  82. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser-autocorrelation.dat +0 -1000
  83. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser.dat +0 -1001
  84. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure.log +0 -82
  85. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser-autocorrelation.dat +0 -1000
  86. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser.dat +0 -1001
  87. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails.log +0 -82
  88. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser-autocorrelation.dat +0 -1000
  89. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser.dat +0 -1001
  90. data/lib/vendor/json_pure/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML.log +0 -82
  91. data/lib/vendor/json_pure/benchmarks/generator2_benchmark.rb +0 -222
  92. data/lib/vendor/json_pure/benchmarks/generator_benchmark.rb +0 -224
  93. data/lib/vendor/json_pure/benchmarks/ohai.json +0 -1216
  94. data/lib/vendor/json_pure/benchmarks/ohai.ruby +0 -1
  95. data/lib/vendor/json_pure/benchmarks/parser2_benchmark.rb +0 -251
  96. data/lib/vendor/json_pure/benchmarks/parser_benchmark.rb +0 -259
  97. data/lib/vendor/json_pure/bin/edit_json.rb +0 -9
  98. data/lib/vendor/json_pure/bin/prettify_json.rb +0 -75
  99. data/lib/vendor/json_pure/data/example.json +0 -1
  100. data/lib/vendor/json_pure/data/index.html +0 -38
  101. data/lib/vendor/json_pure/data/prototype.js +0 -4184
  102. data/lib/vendor/json_pure/ext/json/ext/generator/extconf.rb +0 -16
  103. data/lib/vendor/json_pure/ext/json/ext/generator/generator.c +0 -1323
  104. data/lib/vendor/json_pure/ext/json/ext/generator/generator.h +0 -170
  105. data/lib/vendor/json_pure/ext/json/ext/parser/extconf.rb +0 -15
  106. data/lib/vendor/json_pure/ext/json/ext/parser/parser.c +0 -1935
  107. data/lib/vendor/json_pure/ext/json/ext/parser/parser.h +0 -71
  108. data/lib/vendor/json_pure/ext/json/ext/parser/parser.rl +0 -792
  109. data/lib/vendor/json_pure/install.rb +0 -26
  110. data/lib/vendor/json_pure/tests/fixtures/fail1.json +0 -1
  111. data/lib/vendor/json_pure/tests/fixtures/fail10.json +0 -1
  112. data/lib/vendor/json_pure/tests/fixtures/fail11.json +0 -1
  113. data/lib/vendor/json_pure/tests/fixtures/fail12.json +0 -1
  114. data/lib/vendor/json_pure/tests/fixtures/fail13.json +0 -1
  115. data/lib/vendor/json_pure/tests/fixtures/fail14.json +0 -1
  116. data/lib/vendor/json_pure/tests/fixtures/fail18.json +0 -1
  117. data/lib/vendor/json_pure/tests/fixtures/fail19.json +0 -1
  118. data/lib/vendor/json_pure/tests/fixtures/fail2.json +0 -1
  119. data/lib/vendor/json_pure/tests/fixtures/fail20.json +0 -1
  120. data/lib/vendor/json_pure/tests/fixtures/fail21.json +0 -1
  121. data/lib/vendor/json_pure/tests/fixtures/fail22.json +0 -1
  122. data/lib/vendor/json_pure/tests/fixtures/fail23.json +0 -1
  123. data/lib/vendor/json_pure/tests/fixtures/fail24.json +0 -1
  124. data/lib/vendor/json_pure/tests/fixtures/fail25.json +0 -1
  125. data/lib/vendor/json_pure/tests/fixtures/fail27.json +0 -2
  126. data/lib/vendor/json_pure/tests/fixtures/fail28.json +0 -2
  127. data/lib/vendor/json_pure/tests/fixtures/fail3.json +0 -1
  128. data/lib/vendor/json_pure/tests/fixtures/fail4.json +0 -1
  129. data/lib/vendor/json_pure/tests/fixtures/fail5.json +0 -1
  130. data/lib/vendor/json_pure/tests/fixtures/fail6.json +0 -1
  131. data/lib/vendor/json_pure/tests/fixtures/fail7.json +0 -1
  132. data/lib/vendor/json_pure/tests/fixtures/fail8.json +0 -1
  133. data/lib/vendor/json_pure/tests/fixtures/fail9.json +0 -1
  134. data/lib/vendor/json_pure/tests/fixtures/pass1.json +0 -56
  135. data/lib/vendor/json_pure/tests/fixtures/pass15.json +0 -1
  136. data/lib/vendor/json_pure/tests/fixtures/pass16.json +0 -1
  137. data/lib/vendor/json_pure/tests/fixtures/pass17.json +0 -1
  138. data/lib/vendor/json_pure/tests/fixtures/pass2.json +0 -1
  139. data/lib/vendor/json_pure/tests/fixtures/pass26.json +0 -1
  140. data/lib/vendor/json_pure/tests/fixtures/pass3.json +0 -6
  141. data/lib/vendor/json_pure/tests/test_json.rb +0 -361
  142. data/lib/vendor/json_pure/tests/test_json_addition.rb +0 -162
  143. data/lib/vendor/json_pure/tests/test_json_encoding.rb +0 -68
  144. data/lib/vendor/json_pure/tests/test_json_fixtures.rb +0 -34
  145. data/lib/vendor/json_pure/tests/test_json_generate.rb +0 -122
  146. data/lib/vendor/json_pure/tests/test_json_rails.rb +0 -144
  147. data/lib/vendor/json_pure/tests/test_json_unicode.rb +0 -76
  148. data/lib/vendor/json_pure/tools/fuzz.rb +0 -139
  149. data/lib/vendor/json_pure/tools/server.rb +0 -61
  150. data/lib/vendor/open4/lib/open4.rb +0 -403
  151. data/lib/vendor/thor/CHANGELOG.rdoc +0 -89
  152. data/lib/vendor/thor/LICENSE +0 -20
  153. data/lib/vendor/thor/README.rdoc +0 -297
  154. data/lib/vendor/thor/Thorfile +0 -69
  155. data/lib/vendor/thor/bin/rake2thor +0 -86
  156. data/lib/vendor/thor/bin/thor +0 -6
  157. data/lib/vendor/thor/lib/thor/actions/create_file.rb +0 -103
  158. data/lib/vendor/thor/lib/thor/actions/directory.rb +0 -91
  159. data/lib/vendor/thor/lib/thor/actions/empty_directory.rb +0 -134
  160. data/lib/vendor/thor/lib/thor/actions/file_manipulation.rb +0 -223
  161. data/lib/vendor/thor/lib/thor/actions/inject_into_file.rb +0 -104
  162. data/lib/vendor/thor/lib/thor/actions.rb +0 -275
  163. data/lib/vendor/thor/lib/thor/base.rb +0 -540
  164. data/lib/vendor/thor/lib/thor/core_ext/file_binary_read.rb +0 -9
  165. data/lib/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +0 -75
  166. data/lib/vendor/thor/lib/thor/core_ext/ordered_hash.rb +0 -100
  167. data/lib/vendor/thor/lib/thor/error.rb +0 -30
  168. data/lib/vendor/thor/lib/thor/group.rb +0 -271
  169. data/lib/vendor/thor/lib/thor/invocation.rb +0 -180
  170. data/lib/vendor/thor/lib/thor/parser/argument.rb +0 -67
  171. data/lib/vendor/thor/lib/thor/parser/arguments.rb +0 -150
  172. data/lib/vendor/thor/lib/thor/parser/option.rb +0 -128
  173. data/lib/vendor/thor/lib/thor/parser/options.rb +0 -169
  174. data/lib/vendor/thor/lib/thor/parser.rb +0 -4
  175. data/lib/vendor/thor/lib/thor/rake_compat.rb +0 -66
  176. data/lib/vendor/thor/lib/thor/runner.rb +0 -314
  177. data/lib/vendor/thor/lib/thor/shell/basic.rb +0 -239
  178. data/lib/vendor/thor/lib/thor/shell/color.rb +0 -108
  179. data/lib/vendor/thor/lib/thor/shell.rb +0 -83
  180. data/lib/vendor/thor/lib/thor/task.rb +0 -102
  181. data/lib/vendor/thor/lib/thor/util.rb +0 -230
  182. data/lib/vendor/thor/lib/thor/version.rb +0 -3
  183. data/lib/vendor/thor/lib/thor.rb +0 -244
  184. data/lib/vendor/thor/thor.gemspec +0 -120
@@ -1,139 +0,0 @@
1
- require 'json'
2
-
3
- require 'iconv'
4
- ISO_8859_1_TO_UTF8 = Iconv.new('utf-8', 'iso-8859-15')
5
- class ::String
6
- def to_utf8
7
- ISO_8859_1_TO_UTF8.iconv self
8
- end
9
- end
10
-
11
- class Fuzzer
12
- def initialize(n, freqs = {})
13
- sum = freqs.inject(0.0) { |s, x| s + x.last }
14
- freqs.each_key { |x| freqs[x] /= sum }
15
- s = 0.0
16
- freqs.each_key do |x|
17
- freqs[x] = s .. (s + t = freqs[x])
18
- s += t
19
- end
20
- @freqs = freqs
21
- @n = n
22
- @alpha = (0..0xff).to_a
23
- end
24
-
25
- def random_string
26
- s = ''
27
- 30.times { s << @alpha[rand(@alpha.size)] }
28
- s.to_utf8
29
- end
30
-
31
- def pick
32
- r = rand
33
- found = @freqs.find { |k, f| f.include? rand }
34
- found && found.first
35
- end
36
-
37
- def make_pick
38
- k = pick
39
- case
40
- when k == Hash, k == Array
41
- k.new
42
- when k == true, k == false, k == nil
43
- k
44
- when k == String
45
- random_string
46
- when k == Fixnum
47
- rand(2 ** 30) - 2 ** 29
48
- when k == Bignum
49
- rand(2 ** 70) - 2 ** 69
50
- end
51
- end
52
-
53
- def fuzz(current = nil)
54
- if @n > 0
55
- case current
56
- when nil
57
- @n -= 1
58
- current = fuzz [ Hash, Array ][rand(2)].new
59
- when Array
60
- while @n > 0
61
- @n -= 1
62
- current << case p = make_pick
63
- when Array, Hash
64
- fuzz(p)
65
- else
66
- p
67
- end
68
- end
69
- when Hash
70
- while @n > 0
71
- @n -= 1
72
- current[random_string] = case p = make_pick
73
- when Array, Hash
74
- fuzz(p)
75
- else
76
- p
77
- end
78
- end
79
- end
80
- end
81
- current
82
- end
83
- end
84
-
85
- class MyState < JSON.state
86
- WS = " \r\t\n"
87
-
88
- def initialize
89
- super(
90
- :indent => make_spaces,
91
- :space => make_spaces,
92
- :space_before => make_spaces,
93
- :object_nl => make_spaces,
94
- :array_nl => make_spaces,
95
- :max_nesting => false
96
- )
97
- end
98
-
99
- def make_spaces
100
- s = ''
101
- rand(1).times { s << WS[rand(WS.size)] }
102
- s
103
- end
104
- end
105
-
106
- n = (ARGV.shift || 500).to_i
107
- loop do
108
- fuzzer = Fuzzer.new(n,
109
- Hash => 25,
110
- Array => 25,
111
- String => 10,
112
- Fixnum => 10,
113
- Bignum => 10,
114
- nil => 5,
115
- true => 5,
116
- false => 5
117
- )
118
- o1 = fuzzer.fuzz
119
- json = JSON.generate o1, MyState.new
120
- if $DEBUG
121
- puts "-" * 80
122
- puts json, json.size
123
- else
124
- puts json.size
125
- end
126
- begin
127
- o2 = JSON.parse(json, :max_nesting => false)
128
- rescue JSON::ParserError => e
129
- puts "Caught #{e.class}: #{e.message}\n#{e.backtrace * "\n"}"
130
- puts "o1 = #{o1.inspect}", "json = #{json}", "json_str = #{json.inspect}"
131
- puts "locals = #{local_variables.inspect}"
132
- exit
133
- end
134
- if o1 != o2
135
- puts "mismatch", "o1 = #{o1.inspect}", "o2 = #{o2.inspect}",
136
- "json = #{json}", "json_str = #{json.inspect}"
137
- puts "locals = #{local_variables.inspect}"
138
- end
139
- end
@@ -1,61 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'webrick'
4
- include WEBrick
5
- $:.unshift 'ext'
6
- $:.unshift 'lib'
7
- require 'json'
8
-
9
- class JSONServlet < HTTPServlet::AbstractServlet
10
- @@count = 1
11
-
12
- def do_GET(req, res)
13
- obj = {
14
- "TIME" => Time.now.strftime("%FT%T"),
15
- "foo" => "Bär",
16
- "bar" => "© ≠ €!",
17
- 'a' => 2,
18
- 'b' => 3.141,
19
- 'COUNT' => @@count += 1,
20
- 'c' => 'c',
21
- 'd' => [ 1, "b", 3.14 ],
22
- 'e' => { 'foo' => 'bar' },
23
- 'g' => "松本行弘",
24
- 'h' => 1000.0,
25
- 'i' => 0.001,
26
- 'j' => "\xf0\xa0\x80\x81",
27
- }
28
- res.body = JSON.generate obj
29
- res['Content-Type'] = "application/json"
30
- end
31
- end
32
-
33
- def create_server(err, dir, port)
34
- dir = File.expand_path(dir)
35
- err.puts "Surf to:", "http://#{Socket.gethostname}:#{port}"
36
-
37
- s = HTTPServer.new(
38
- :Port => port,
39
- :DocumentRoot => dir,
40
- :Logger => WEBrick::Log.new(err),
41
- :AccessLog => [
42
- [ err, WEBrick::AccessLog::COMMON_LOG_FORMAT ],
43
- [ err, WEBrick::AccessLog::REFERER_LOG_FORMAT ],
44
- [ err, WEBrick::AccessLog::AGENT_LOG_FORMAT ]
45
- ]
46
- )
47
- s.mount("/json", JSONServlet)
48
- s
49
- end
50
-
51
- default_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'data'))
52
- dir = ARGV.shift || default_dir
53
- port = (ARGV.shift || 6666).to_i
54
- s = create_server(STDERR, dir, 6666)
55
- t = Thread.new { s.start }
56
- trap(:INT) do
57
- s.shutdown
58
- t.join
59
- exit
60
- end
61
- sleep
@@ -1,403 +0,0 @@
1
- # vim: ts=2:sw=2:sts=2:et:fdm=marker
2
- require 'fcntl'
3
- require 'timeout'
4
- require 'thread'
5
-
6
- module Open4
7
- #--{{{
8
- VERSION = '1.1.0'
9
- def self.version() VERSION end
10
-
11
- class Error < ::StandardError; end
12
-
13
- def popen4(*cmd, &b)
14
- #--{{{
15
- pw, pr, pe, ps = IO.pipe, IO.pipe, IO.pipe, IO.pipe
16
-
17
- verbose = $VERBOSE
18
- begin
19
- $VERBOSE = nil
20
- ps.first.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
21
- ps.last.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
22
-
23
- cid = fork {
24
- pw.last.close
25
- STDIN.reopen pw.first
26
- pw.first.close
27
-
28
- pr.first.close
29
- STDOUT.reopen pr.last
30
- pr.last.close
31
-
32
- pe.first.close
33
- STDERR.reopen pe.last
34
- pe.last.close
35
-
36
- STDOUT.sync = STDERR.sync = true
37
-
38
- begin
39
- exec(*cmd)
40
- raise 'forty-two'
41
- rescue Exception => e
42
- Marshal.dump(e, ps.last)
43
- ps.last.flush
44
- end
45
- ps.last.close unless (ps.last.closed?)
46
- exit!
47
- }
48
- ensure
49
- $VERBOSE = verbose
50
- end
51
-
52
- [pw.first, pr.last, pe.last, ps.last].each{|fd| fd.close}
53
-
54
- begin
55
- e = Marshal.load ps.first
56
- raise(Exception === e ? e : "unknown failure!")
57
- rescue EOFError # If we get an EOF error, then the exec was successful
58
- 42
59
- ensure
60
- ps.first.close
61
- end
62
-
63
- pw.last.sync = true
64
-
65
- pi = [pw.last, pr.first, pe.first]
66
-
67
- if b
68
- begin
69
- b[cid, *pi]
70
- Process.waitpid2(cid).last
71
- ensure
72
- pi.each{|fd| fd.close unless fd.closed?}
73
- end
74
- else
75
- [cid, pw.last, pr.first, pe.first]
76
- end
77
- #--}}}
78
- end
79
- alias open4 popen4
80
- module_function :popen4
81
- module_function :open4
82
-
83
- class SpawnError < Error
84
- #--{{{
85
- attr 'cmd'
86
- attr 'status'
87
- attr 'signals'
88
- def exitstatus
89
- @status.exitstatus
90
- end
91
- def initialize cmd, status
92
- @cmd, @status = cmd, status
93
- @signals = {}
94
- if status.signaled?
95
- @signals['termsig'] = status.termsig
96
- @signals['stopsig'] = status.stopsig
97
- end
98
- sigs = @signals.map{|k,v| "#{ k }:#{ v.inspect }"}.join(' ')
99
- super "cmd <#{ cmd }> failed with status <#{ exitstatus.inspect }> signals <#{ sigs }>"
100
- end
101
- #--}}}
102
- end
103
-
104
- class ThreadEnsemble
105
- #--{{{
106
- attr 'threads'
107
-
108
- def initialize cid
109
- @cid, @threads, @argv, @done, @running = cid, [], [], Queue.new, false
110
- @killed = false
111
- end
112
-
113
- def add_thread *a, &b
114
- @running ? raise : (@argv << [a, b])
115
- end
116
-
117
- #
118
- # take down process more nicely
119
- #
120
- def killall
121
- c = Thread.critical
122
- return nil if @killed
123
- Thread.critical = true
124
- (@threads - [Thread.current]).each{|t| t.kill rescue nil}
125
- @killed = true
126
- ensure
127
- Thread.critical = c
128
- end
129
-
130
- def run
131
- @running = true
132
-
133
- begin
134
- @argv.each do |a, b|
135
- @threads << Thread.new(*a) do |*a|
136
- begin
137
- b[*a]
138
- ensure
139
- killall rescue nil if $!
140
- @done.push Thread.current
141
- end
142
- end
143
- end
144
- rescue
145
- killall
146
- raise
147
- ensure
148
- all_done
149
- end
150
-
151
- @threads.map{|t| t.value}
152
- end
153
-
154
- def all_done
155
- @threads.size.times{ @done.pop }
156
- end
157
- #--}}}
158
- end
159
-
160
- def to timeout = nil
161
- #--{{{
162
- Timeout.timeout(timeout){ yield }
163
- #--}}}
164
- end
165
- module_function :to
166
-
167
- def new_thread *a, &b
168
- #--{{{
169
- cur = Thread.current
170
- Thread.new(*a) do |*a|
171
- begin
172
- b[*a]
173
- rescue Exception => e
174
- cur.raise e
175
- end
176
- end
177
- #--}}}
178
- end
179
- module_function :new_thread
180
-
181
- def getopts opts = {}
182
- #--{{{
183
- lambda do |*args|
184
- keys, default, ignored = args
185
- catch('opt') do
186
- [keys].flatten.each do |key|
187
- [key, key.to_s, key.to_s.intern].each do |key|
188
- throw 'opt', opts[key] if opts.has_key?(key)
189
- end
190
- end
191
- default
192
- end
193
- end
194
- #--}}}
195
- end
196
- module_function :getopts
197
-
198
- def relay src, dst = nil, t = nil
199
- #--{{{
200
- send_dst =
201
- if dst.respond_to?(:call)
202
- lambda{|buf| dst.call(buf)}
203
- elsif dst.respond_to?(:<<)
204
- lambda{|buf| dst << buf }
205
- else
206
- lambda{|buf| buf }
207
- end
208
-
209
- unless src.nil?
210
- if src.respond_to? :gets
211
- while buf = to(t){ src.gets }
212
- send_dst[buf]
213
- end
214
-
215
- elsif src.respond_to? :each
216
- q = Queue.new
217
- th = nil
218
-
219
- timer_set = lambda do |t|
220
- th = new_thread{ to(t){ q.pop } }
221
- end
222
-
223
- timer_cancel = lambda do |t|
224
- th.kill if th rescue nil
225
- end
226
-
227
- timer_set[t]
228
- begin
229
- src.each do |buf|
230
- timer_cancel[t]
231
- send_dst[buf]
232
- timer_set[t]
233
- end
234
- ensure
235
- timer_cancel[t]
236
- end
237
-
238
- elsif src.respond_to? :read
239
- buf = to(t){ src.read }
240
- send_dst[buf]
241
-
242
- else
243
- buf = to(t){ src.to_s }
244
- send_dst[buf]
245
- end
246
- end
247
- #--}}}
248
- end
249
- module_function :relay
250
-
251
- def spawn arg, *argv
252
- #--{{{
253
- argv.unshift(arg)
254
- opts = ((argv.size > 1 and Hash === argv.last) ? argv.pop : {})
255
- argv.flatten!
256
- cmd = argv.join(' ')
257
-
258
-
259
- getopt = getopts opts
260
-
261
- ignore_exit_failure = getopt[ 'ignore_exit_failure', getopt['quiet', false] ]
262
- ignore_exec_failure = getopt[ 'ignore_exec_failure', !getopt['raise', true] ]
263
- exitstatus = getopt[ %w( exitstatus exit_status status ) ]
264
- stdin = getopt[ %w( stdin in i 0 ) << 0 ]
265
- stdout = getopt[ %w( stdout out o 1 ) << 1 ]
266
- stderr = getopt[ %w( stderr err e 2 ) << 2 ]
267
- pid = getopt[ 'pid' ]
268
- timeout = getopt[ %w( timeout spawn_timeout ) ]
269
- stdin_timeout = getopt[ %w( stdin_timeout ) ]
270
- stdout_timeout = getopt[ %w( stdout_timeout io_timeout ) ]
271
- stderr_timeout = getopt[ %w( stderr_timeout ) ]
272
- status = getopt[ %w( status ) ]
273
- cwd = getopt[ %w( cwd dir ) ]
274
-
275
- exitstatus =
276
- case exitstatus
277
- when TrueClass, FalseClass
278
- ignore_exit_failure = true if exitstatus
279
- [0]
280
- else
281
- [*(exitstatus || 0)].map{|i| Integer i}
282
- end
283
-
284
- stdin ||= '' if stdin_timeout
285
- stdout ||= '' if stdout_timeout
286
- stderr ||= '' if stderr_timeout
287
-
288
- started = false
289
-
290
- status =
291
- begin
292
- chdir(cwd) do
293
- Timeout::timeout(timeout) do
294
- popen4(*argv) do |c, i, o, e|
295
- started = true
296
-
297
- %w( replace pid= << push update ).each do |msg|
298
- break(pid.send(msg, c)) if pid.respond_to? msg
299
- end
300
-
301
- te = ThreadEnsemble.new c
302
-
303
- te.add_thread(i, stdin) do |i, stdin|
304
- relay stdin, i, stdin_timeout
305
- i.close rescue nil
306
- end
307
-
308
- te.add_thread(o, stdout) do |o, stdout|
309
- relay o, stdout, stdout_timeout
310
- end
311
-
312
- te.add_thread(e, stderr) do |o, stderr|
313
- relay e, stderr, stderr_timeout
314
- end
315
-
316
- te.run
317
- end
318
- end
319
- end
320
- rescue
321
- raise unless(not started and ignore_exec_failure)
322
- end
323
-
324
- raise SpawnError.new(cmd, status) unless
325
- (ignore_exit_failure or (status.nil? and ignore_exec_failure) or exitstatus.include?(status.exitstatus))
326
-
327
- status
328
- #--}}}
329
- end
330
- module_function :spawn
331
-
332
- def chdir cwd, &block
333
- return(block.call Dir.pwd) unless cwd
334
- Dir.chdir cwd, &block
335
- end
336
- module_function :chdir
337
-
338
- def background arg, *argv
339
- #--{{{
340
- require 'thread'
341
- q = Queue.new
342
- opts = { 'pid' => q, :pid => q }
343
- case argv.last
344
- when Hash
345
- argv.last.update opts
346
- else
347
- argv.push opts
348
- end
349
- thread = Thread.new(arg, argv){|arg, argv| spawn arg, *argv}
350
- sc = class << thread; self; end
351
- sc.module_eval {
352
- define_method(:pid){ @pid ||= q.pop }
353
- define_method(:spawn_status){ @spawn_status ||= value }
354
- define_method(:exitstatus){ @exitstatus ||= spawn_status.exitstatus }
355
- }
356
- thread
357
- #--}}}
358
- end
359
- alias bg background
360
- module_function :background
361
- module_function :bg
362
-
363
- def maim pid, opts = {}
364
- #--{{{
365
- getopt = getopts opts
366
- sigs = getopt[ 'signals', %w(SIGTERM SIGQUIT SIGKILL) ]
367
- suspend = getopt[ 'suspend', 4 ]
368
- pid = Integer pid
369
- existed = false
370
- sigs.each do |sig|
371
- begin
372
- Process.kill sig, pid
373
- existed = true
374
- rescue Errno::ESRCH
375
- return(existed ? nil : true)
376
- end
377
- return true unless alive? pid
378
- sleep suspend
379
- return true unless alive? pid
380
- end
381
- return(not alive?(pid))
382
- #--}}}
383
- end
384
- module_function :maim
385
-
386
- def alive pid
387
- #--{{{
388
- pid = Integer pid
389
- begin
390
- Process.kill 0, pid
391
- true
392
- rescue Errno::ESRCH
393
- false
394
- end
395
- #--}}}
396
- end
397
- alias alive? alive
398
- module_function :alive
399
- module_function :'alive?'
400
- #--}}}
401
- end
402
-
403
- def open4(*cmd, &b) cmd.size == 0 ? Open4 : Open4::popen4(*cmd, &b) end
@@ -1,89 +0,0 @@
1
- == 0.13, released 2010-02-03
2
-
3
- * Several bug fixes
4
- * Decoupled Thor::Group and Thor, so it's easier to vendor
5
- * Added check_unknown_options! in case you want error messages to be raised in valid switches.
6
- * run(command) should return the results of command
7
-
8
- == 0.12, released 2010-01-02
9
-
10
- * Methods generated by attr_* are automatically not marked as tasks
11
- * inject_into_file does not add the same content twice, unless :force is set
12
- * Removed rr in favor to rspec mock framework
13
- * Improved output for thor -T
14
- * [#7] Do not force white color on status
15
- * [#8] Yield a block with the filename on directory
16
-
17
- == 0.11, released 2009-07-01
18
-
19
- * Added a rake compatibility layer. It allows you to use spec and rdoc tasks on
20
- Thor classes.
21
-
22
- * BACKWARDS INCOMPATIBLE: aliases are not generated automatically anymore
23
- since it wrong behavior to the invocation system.
24
-
25
- * thor help now show information about any class/task. All those calls are
26
- possible:
27
-
28
- thor help describe
29
- thor help describe:amazing
30
-
31
- Or even with default namespaces:
32
-
33
- thor help :spec
34
-
35
- * Thor::Runner now invokes the default task if none is supplied:
36
-
37
- thor describe # invokes the default task, usually help
38
-
39
- * Thor::Runner now works with mappings:
40
-
41
- thor describe -h
42
-
43
- * Added some documentation and code refactoring.
44
-
45
- == 0.9.8, released 2008-10-20
46
-
47
- * Fixed some tiny issues that were introduced lately.
48
-
49
- == 0.9.7, released 2008-10-13
50
-
51
- * Setting global method options on the initialize method works as expected:
52
- All other tasks will accept these global options in addition to their own.
53
- * Added 'group' notion to Thor task sets (class Thor); by default all tasks
54
- are in the 'standard' group. Running 'thor -T' will only show the standard
55
- tasks - adding --all will show all tasks. You can also filter on a specific
56
- group using the --group option: thor -T --group advanced
57
-
58
- == 0.9.6, released 2008-09-13
59
-
60
- * Generic improvements
61
-
62
- == 0.9.5, released 2008-08-27
63
-
64
- * Improve Windows compatibility
65
- * Update (incorrect) README and task.thor sample file
66
- * Options hash is now frozen (once returned)
67
- * Allow magic predicates on options object. For instance: `options.force?`
68
- * Add support for :numeric type
69
- * BACKWARDS INCOMPATIBLE: Refactor Thor::Options. You cannot access shorthand forms in options hash anymore (for instance, options[:f])
70
- * Allow specifying optional args with default values: method_options(:user => "mislav")
71
- * Don't write options for nil or false values. This allows, for example, turning color off when running specs.
72
- * Exit with the status of the spec command to help CI stuff out some.
73
-
74
- == 0.9.4, released 2008-08-13
75
-
76
- * Try to add Windows compatibility.
77
- * BACKWARDS INCOMPATIBLE: options hash is now accessed as a property in your class and is not passed as last argument anymore
78
- * Allow options at the beginning of the argument list as well as the end.
79
- * Make options available with symbol keys in addition to string keys.
80
- * Allow true to be passed to Thor#method_options to denote a boolean option.
81
- * If loading a thor file fails, don't give up, just print a warning and keep going.
82
- * Make sure that we re-raise errors if they happened further down the pipe than we care about.
83
- * Only delete the old file on updating when the installation of the new one is a success
84
- * Make it Ruby 1.8.5 compatible.
85
- * Don't raise an error if a boolean switch is defined multiple times.
86
- * Thor::Options now doesn't parse through things that look like options but aren't.
87
- * Add URI detection to install task, and make sure we don't append ".thor" to URIs
88
- * Add rake2thor to the gem binfiles.
89
- * Make sure local Thorfiles override system-wide ones.
@@ -1,20 +0,0 @@
1
- Copyright (c) 2008 Yehuda Katz
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.