spade 0.0.8.1 → 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/.gitignore +0 -1
- data/.gitmodules +4 -4
- data/README.md +4 -0
- data/bin/spade +1 -1
- data/lib/spade.rb +0 -51
- data/lib/spade/cli.rb +10 -4
- data/lib/spade/version.rb +1 -1
- data/spade.gemspec +4 -21
- metadata +13 -482
- data/Gemfile +0 -3
- data/Gemfile.lock +0 -40
- data/lib/index.js +0 -14
- data/lib/node/loader.js +0 -146
- data/lib/node/sandbox.js +0 -44
- data/lib/spade.js +0 -1130
- data/lib/spade/bundle.rb +0 -171
- data/lib/spade/cli/base.rb +0 -354
- data/lib/spade/cli/owner.rb +0 -45
- data/lib/spade/cli/project_generator.rb +0 -58
- data/lib/spade/compiler.rb +0 -34
- data/lib/spade/console.rb +0 -39
- data/lib/spade/context.rb +0 -116
- data/lib/spade/credentials.rb +0 -36
- data/lib/spade/dependency_installer.rb +0 -103
- data/lib/spade/environment.rb +0 -35
- data/lib/spade/exports.rb +0 -71
- data/lib/spade/installer.rb +0 -40
- data/lib/spade/loader.rb +0 -238
- data/lib/spade/local.rb +0 -46
- data/lib/spade/package.rb +0 -157
- data/lib/spade/reactor.rb +0 -159
- data/lib/spade/remote.rb +0 -99
- data/lib/spade/repository.rb +0 -18
- data/lib/spade/server.rb +0 -66
- data/lib/spade/shell.rb +0 -36
- data/lib/spade/templates/project/LICENSE +0 -19
- data/lib/spade/templates/project/README.md +0 -21
- data/lib/spade/templates/project/lib/main.js +0 -9
- data/lib/spade/templates/project/project.json +0 -31
- data/lib/spade/templates/project/tests/main-test.js +0 -8
- data/package.json +0 -27
- data/packages/coffee-script/.gitignore +0 -8
- data/packages/coffee-script/.npmignore +0 -11
- data/packages/coffee-script/Cakefile +0 -229
- data/packages/coffee-script/LICENSE +0 -22
- data/packages/coffee-script/README +0 -47
- data/packages/coffee-script/Rakefile +0 -78
- data/packages/coffee-script/bin/cake +0 -7
- data/packages/coffee-script/bin/coffee +0 -7
- data/packages/coffee-script/documentation/coffee/aliases.coffee +0 -11
- data/packages/coffee-script/documentation/coffee/array_comprehensions.coffee +0 -2
- data/packages/coffee-script/documentation/coffee/block_comment.coffee +0 -6
- data/packages/coffee-script/documentation/coffee/cake_tasks.coffee +0 -9
- data/packages/coffee-script/documentation/coffee/classes.coffee +0 -25
- data/packages/coffee-script/documentation/coffee/comparisons.coffee +0 -5
- data/packages/coffee-script/documentation/coffee/conditionals.coffee +0 -13
- data/packages/coffee-script/documentation/coffee/default_args.coffee +0 -8
- data/packages/coffee-script/documentation/coffee/do.coffee +0 -4
- data/packages/coffee-script/documentation/coffee/embedded.coffee +0 -5
- data/packages/coffee-script/documentation/coffee/existence.coffee +0 -10
- data/packages/coffee-script/documentation/coffee/expressions.coffee +0 -9
- data/packages/coffee-script/documentation/coffee/expressions_assignment.coffee +0 -3
- data/packages/coffee-script/documentation/coffee/expressions_comprehension.coffee +0 -3
- data/packages/coffee-script/documentation/coffee/expressions_try.coffee +0 -7
- data/packages/coffee-script/documentation/coffee/fat_arrow.coffee +0 -6
- data/packages/coffee-script/documentation/coffee/functions.coffee +0 -2
- data/packages/coffee-script/documentation/coffee/heredocs.coffee +0 -7
- data/packages/coffee-script/documentation/coffee/heregexes.coffee +0 -11
- data/packages/coffee-script/documentation/coffee/interpolation.coffee +0 -6
- data/packages/coffee-script/documentation/coffee/multiple_return_values.coffee +0 -7
- data/packages/coffee-script/documentation/coffee/object_comprehensions.coffee +0 -4
- data/packages/coffee-script/documentation/coffee/object_extraction.coffee +0 -13
- data/packages/coffee-script/documentation/coffee/objects_and_arrays.coffee +0 -19
- data/packages/coffee-script/documentation/coffee/objects_reserved.coffee +0 -5
- data/packages/coffee-script/documentation/coffee/overview.coffee +0 -28
- data/packages/coffee-script/documentation/coffee/parallel_assignment.coffee +0 -6
- data/packages/coffee-script/documentation/coffee/patterns_and_splats.coffee +0 -7
- data/packages/coffee-script/documentation/coffee/prototypes.coffee +0 -3
- data/packages/coffee-script/documentation/coffee/range_comprehensions.coffee +0 -2
- data/packages/coffee-script/documentation/coffee/scope.coffee +0 -5
- data/packages/coffee-script/documentation/coffee/slices.coffee +0 -7
- data/packages/coffee-script/documentation/coffee/soaks.coffee +0 -1
- data/packages/coffee-script/documentation/coffee/splats.coffee +0 -27
- data/packages/coffee-script/documentation/coffee/splices.coffee +0 -5
- data/packages/coffee-script/documentation/coffee/strings.coffee +0 -8
- data/packages/coffee-script/documentation/coffee/switch.coffee +0 -10
- data/packages/coffee-script/documentation/coffee/try.coffee +0 -8
- data/packages/coffee-script/documentation/coffee/while.coffee +0 -10
- data/packages/coffee-script/documentation/css/docs.css +0 -374
- data/packages/coffee-script/documentation/css/idle.css +0 -64
- data/packages/coffee-script/documentation/docs/browser.html +0 -25
- data/packages/coffee-script/documentation/docs/cake.html +0 -43
- data/packages/coffee-script/documentation/docs/coffee-script.html +0 -51
- data/packages/coffee-script/documentation/docs/command.html +0 -161
- data/packages/coffee-script/documentation/docs/docco.css +0 -186
- data/packages/coffee-script/documentation/docs/grammar.html +0 -399
- data/packages/coffee-script/documentation/docs/helpers.html +0 -31
- data/packages/coffee-script/documentation/docs/index.html +0 -3
- data/packages/coffee-script/documentation/docs/lexer.html +0 -490
- data/packages/coffee-script/documentation/docs/nodes.html +0 -1338
- data/packages/coffee-script/documentation/docs/optparse.html +0 -78
- data/packages/coffee-script/documentation/docs/repl.html +0 -24
- data/packages/coffee-script/documentation/docs/rewriter.html +0 -251
- data/packages/coffee-script/documentation/docs/scope.html +0 -54
- data/packages/coffee-script/documentation/docs/underscore.html +0 -295
- data/packages/coffee-script/documentation/images/background.png +0 -0
- data/packages/coffee-script/documentation/images/banding.png +0 -0
- data/packages/coffee-script/documentation/images/button_bg.png +0 -0
- data/packages/coffee-script/documentation/images/button_bg_dark.gif +0 -0
- data/packages/coffee-script/documentation/images/button_bg_green.gif +0 -0
- data/packages/coffee-script/documentation/images/favicon.ico +0 -0
- data/packages/coffee-script/documentation/images/logo.png +0 -0
- data/packages/coffee-script/documentation/images/screenshadow.png +0 -0
- data/packages/coffee-script/documentation/index.html.erb +0 -1607
- data/packages/coffee-script/documentation/js/aliases.js +0 -17
- data/packages/coffee-script/documentation/js/array_comprehensions.js +0 -6
- data/packages/coffee-script/documentation/js/block_comment.js +0 -4
- data/packages/coffee-script/documentation/js/cake_tasks.js +0 -10
- data/packages/coffee-script/documentation/js/classes.js +0 -44
- data/packages/coffee-script/documentation/js/comparisons.js +0 -3
- data/packages/coffee-script/documentation/js/conditionals.js +0 -12
- data/packages/coffee-script/documentation/js/default_args.js +0 -7
- data/packages/coffee-script/documentation/js/do.js +0 -10
- data/packages/coffee-script/documentation/js/embedded.js +0 -4
- data/packages/coffee-script/documentation/js/existence.js +0 -6
- data/packages/coffee-script/documentation/js/expressions.js +0 -15
- data/packages/coffee-script/documentation/js/expressions_assignment.js +0 -2
- data/packages/coffee-script/documentation/js/expressions_comprehension.js +0 -9
- data/packages/coffee-script/documentation/js/expressions_try.js +0 -7
- data/packages/coffee-script/documentation/js/fat_arrow.js +0 -9
- data/packages/coffee-script/documentation/js/functions.js +0 -7
- data/packages/coffee-script/documentation/js/heredocs.js +0 -2
- data/packages/coffee-script/documentation/js/heregexes.js +0 -2
- data/packages/coffee-script/documentation/js/interpolation.js +0 -4
- data/packages/coffee-script/documentation/js/multiple_return_values.js +0 -5
- data/packages/coffee-script/documentation/js/object_comprehensions.js +0 -15
- data/packages/coffee-script/documentation/js/object_extraction.js +0 -10
- data/packages/coffee-script/documentation/js/objects_and_arrays.js +0 -17
- data/packages/coffee-script/documentation/js/objects_reserved.js +0 -4
- data/packages/coffee-script/documentation/js/overview.js +0 -35
- data/packages/coffee-script/documentation/js/parallel_assignment.js +0 -4
- data/packages/coffee-script/documentation/js/patterns_and_splats.js +0 -4
- data/packages/coffee-script/documentation/js/prototypes.js +0 -3
- data/packages/coffee-script/documentation/js/range_comprehensions.js +0 -9
- data/packages/coffee-script/documentation/js/scope.js +0 -8
- data/packages/coffee-script/documentation/js/slices.js +0 -4
- data/packages/coffee-script/documentation/js/soaks.js +0 -2
- data/packages/coffee-script/documentation/js/splats.js +0 -15
- data/packages/coffee-script/documentation/js/splices.js +0 -3
- data/packages/coffee-script/documentation/js/strings.js +0 -2
- data/packages/coffee-script/documentation/js/switch.js +0 -23
- data/packages/coffee-script/documentation/js/try.js +0 -8
- data/packages/coffee-script/documentation/js/while.js +0 -18
- data/packages/coffee-script/documentation/vendor/jquery-1.4.2.js +0 -6240
- data/packages/coffee-script/examples/beautiful_code/binary_search.coffee +0 -16
- data/packages/coffee-script/examples/beautiful_code/quicksort_runtime.coffee +0 -13
- data/packages/coffee-script/examples/beautiful_code/regular_expression_matcher.coffee +0 -34
- data/packages/coffee-script/examples/blocks.coffee +0 -54
- data/packages/coffee-script/examples/code.coffee +0 -167
- data/packages/coffee-script/examples/computer_science/README +0 -4
- data/packages/coffee-script/examples/computer_science/binary_search.coffee +0 -25
- data/packages/coffee-script/examples/computer_science/bubble_sort.coffee +0 -11
- data/packages/coffee-script/examples/computer_science/linked_list.coffee +0 -108
- data/packages/coffee-script/examples/computer_science/luhn_algorithm.coffee +0 -36
- data/packages/coffee-script/examples/computer_science/merge_sort.coffee +0 -19
- data/packages/coffee-script/examples/computer_science/selection_sort.coffee +0 -23
- data/packages/coffee-script/examples/poignant.coffee +0 -181
- data/packages/coffee-script/examples/potion.coffee +0 -206
- data/packages/coffee-script/examples/underscore.coffee +0 -682
- data/packages/coffee-script/examples/web_server.coffee +0 -12
- data/packages/coffee-script/extras/EXTRAS +0 -7
- data/packages/coffee-script/extras/coffee-script.js +0 -8
- data/packages/coffee-script/extras/jsl.conf +0 -44
- data/packages/coffee-script/index.html +0 -2515
- data/packages/coffee-script/lib/browser.js +0 -52
- data/packages/coffee-script/lib/cake.js +0 -76
- data/packages/coffee-script/lib/coffee-script.js +0 -82
- data/packages/coffee-script/lib/command.js +0 -263
- data/packages/coffee-script/lib/grammar.js +0 -581
- data/packages/coffee-script/lib/helpers.js +0 -66
- data/packages/coffee-script/lib/index.js +0 -8
- data/packages/coffee-script/lib/lexer.js +0 -633
- data/packages/coffee-script/lib/nodes.js +0 -2165
- data/packages/coffee-script/lib/optparse.js +0 -111
- data/packages/coffee-script/lib/parser.js +0 -649
- data/packages/coffee-script/lib/repl.js +0 -42
- data/packages/coffee-script/lib/rewriter.js +0 -353
- data/packages/coffee-script/lib/scope.js +0 -120
- data/packages/coffee-script/lib/spade-format.js +0 -45
- data/packages/coffee-script/package.json +0 -26
- data/packages/coffee-script/src/browser.coffee +0 -43
- data/packages/coffee-script/src/cake.coffee +0 -69
- data/packages/coffee-script/src/coffee-script.coffee +0 -92
- data/packages/coffee-script/src/command.coffee +0 -214
- data/packages/coffee-script/src/grammar.coffee +0 -590
- data/packages/coffee-script/src/helpers.coffee +0 -56
- data/packages/coffee-script/src/index.coffee +0 -2
- data/packages/coffee-script/src/lexer.coffee +0 -653
- data/packages/coffee-script/src/nodes.coffee +0 -1754
- data/packages/coffee-script/src/optparse.coffee +0 -99
- data/packages/coffee-script/src/repl.coffee +0 -42
- data/packages/coffee-script/src/rewriter.coffee +0 -326
- data/packages/coffee-script/src/scope.coffee +0 -94
- data/packages/coffee-script/test/arguments.coffee +0 -127
- data/packages/coffee-script/test/assignment.coffee +0 -98
- data/packages/coffee-script/test/break.coffee +0 -18
- data/packages/coffee-script/test/comments.coffee +0 -201
- data/packages/coffee-script/test/conditionals.coffee +0 -181
- data/packages/coffee-script/test/exception_handling.coffee +0 -90
- data/packages/coffee-script/test/helpers.coffee +0 -96
- data/packages/coffee-script/test/importing.coffee +0 -18
- data/packages/coffee-script/test/operators.coffee +0 -225
- data/packages/coffee-script/test/ranges_slices_and_splices.coffee +0 -186
- data/packages/coffee-script/test/regular_expressions.coffee +0 -56
- data/packages/coffee-script/test/test.html +0 -123
- data/packages/coffee-script/test/test_chaining.coffee +0 -77
- data/packages/coffee-script/test/test_classes.coffee +0 -372
- data/packages/coffee-script/test/test_compilation.coffee +0 -26
- data/packages/coffee-script/test/test_comprehensions.coffee +0 -318
- data/packages/coffee-script/test/test_existence.coffee +0 -165
- data/packages/coffee-script/test/test_functions.coffee +0 -379
- data/packages/coffee-script/test/test_heredocs.coffee +0 -111
- data/packages/coffee-script/test/test_literals.coffee +0 -270
- data/packages/coffee-script/test/test_option_parser.coffee +0 -27
- data/packages/coffee-script/test/test_pattern_matching.coffee +0 -162
- data/packages/coffee-script/test/test_returns.coffee +0 -63
- data/packages/coffee-script/test/test_splats.coffee +0 -102
- data/packages/coffee-script/test/test_strings.coffee +0 -118
- data/packages/coffee-script/test/test_switch.coffee +0 -103
- data/packages/coffee-script/test/test_while.coffee +0 -71
- data/packages/ivory/LICENSE.txt +0 -1
- data/packages/ivory/README.md +0 -19
- data/packages/ivory/lib/buffer.js +0 -111
- data/packages/ivory/lib/events.js +0 -137
- data/packages/ivory/lib/fs.js +0 -266
- data/packages/ivory/lib/main.js +0 -13
- data/packages/ivory/lib/path.js +0 -158
- data/packages/ivory/lib/ruby/buffer.rb +0 -145
- data/packages/ivory/lib/ruby/constants.rb +0 -585
- data/packages/ivory/lib/ruby/events.rb +0 -32
- data/packages/ivory/lib/ruby/fs.rb +0 -245
- data/packages/ivory/lib/ruby/process.rb +0 -28
- data/packages/ivory/lib/stream.js +0 -115
- data/packages/ivory/lib/util.js +0 -414
- data/packages/ivory/package.json +0 -11
- data/packages/jquery/main.js +0 -7179
- data/packages/jquery/package.json +0 -10
- data/packages/json/lib/main.js +0 -14
- data/packages/json/package.json +0 -8
- data/packages/lproj/README.md +0 -77
- data/packages/lproj/examples/demo-app/en.lproj/localized.strings +0 -2
- data/packages/lproj/examples/demo-app/fr.lproj/localized.strings +0 -3
- data/packages/lproj/examples/demo-app/index.html +0 -8
- data/packages/lproj/examples/demo-app/lib/main.js +0 -7
- data/packages/lproj/examples/demo-app/package.json +0 -9
- data/packages/lproj/lib/main.js +0 -78
- data/packages/lproj/lib/strings-format.js +0 -6
- data/packages/lproj/package.json +0 -9
- data/packages/optparse/README.md +0 -161
- data/packages/optparse/TODO +0 -1
- data/packages/optparse/examples/browser-test.html +0 -75
- data/packages/optparse/examples/nodejs-test.js +0 -90
- data/packages/optparse/lib/optparse.js +0 -309
- data/packages/optparse/package.json +0 -13
- data/packages/optparse/seed.yml +0 -5
- data/packages/text/lib/main.js +0 -8
- data/packages/text/package.json +0 -9
- data/packages/web-file/README.md +0 -7
- data/packages/web-file/lib/errors.js +0 -32
- data/packages/web-file/lib/file-reader.js +0 -10
- data/packages/web-file/lib/file-system.js +0 -234
- data/packages/web-file/lib/file-writer.js +0 -10
- data/packages/web-file/lib/file.js +0 -9
- data/packages/web-file/lib/main.js +0 -34
- data/packages/web-file/lib/platform.js +0 -25
- data/packages/web-file/lib/ruby/file.rb +0 -252
- data/packages/web-file/lib/ruby/file_reader.rb +0 -69
- data/packages/web-file/lib/ruby/file_system.rb +0 -134
- data/packages/web-file/lib/ruby/file_writer.rb +0 -78
- data/packages/web-file/package.json +0 -12
- data/packages/web-typed-array/README.md +0 -7
- data/packages/web-typed-array/lib/array-buffer-view.js +0 -9
- data/packages/web-typed-array/lib/array-buffer.js +0 -7
- data/packages/web-typed-array/lib/main.js +0 -33
- data/packages/web-typed-array/lib/platform.js +0 -20
- data/packages/web-typed-array/lib/ruby/array_buffer.rb +0 -31
- data/packages/web-typed-array/lib/ruby/array_buffer_view.rb +0 -130
- data/packages/web-typed-array/lib/ruby/typed_array.rb +0 -133
- data/packages/web-typed-array/lib/typed-array.js +0 -26
- data/packages/web-typed-array/package.json +0 -9
- data/spec/cli/build_spec.rb +0 -59
- data/spec/cli/install_spec.rb +0 -120
- data/spec/cli/installed_spec.rb +0 -55
- data/spec/cli/list_spec.rb +0 -75
- data/spec/cli/login_spec.rb +0 -76
- data/spec/cli/new_spec.rb +0 -5
- data/spec/cli/owner_spec.rb +0 -115
- data/spec/cli/push_spec.rb +0 -74
- data/spec/cli/uninstall_spec.rb +0 -58
- data/spec/cli/unpack_spec.rb +0 -73
- data/spec/cli/unyank_spec.rb +0 -74
- data/spec/cli/update_spec.rb +0 -8
- data/spec/cli/yank_spec.rb +0 -74
- data/spec/credentials_spec.rb +0 -24
- data/spec/fixtures/coffee-1.0.1.pre.spd +0 -0
- data/spec/fixtures/core-test-0.4.3.spd +0 -0
- data/spec/fixtures/core-test/bin/cot +0 -3
- data/spec/fixtures/core-test/lib/main.js +0 -1
- data/spec/fixtures/core-test/resources/runner.css +0 -0
- data/spec/fixtures/core-test/tests/test.js +0 -1
- data/spec/fixtures/ivory-0.0.1.spd +0 -0
- data/spec/fixtures/jquery-1.4.3.spd +0 -0
- data/spec/fixtures/optparse-1.0.1.spd +0 -0
- data/spec/fixtures/package.json +0 -30
- data/spec/gauntlet_spec.rb +0 -27
- data/spec/javascript/async-test.js +0 -123
- data/spec/javascript/compiler/javascript.js +0 -13
- data/spec/javascript/compiler/ruby.js +0 -14
- data/spec/javascript/loader-test.js +0 -64
- data/spec/javascript/normalize-test.js +0 -73
- data/spec/javascript/packages-test.js +0 -44
- data/spec/javascript/relative-require-test.js +0 -72
- data/spec/javascript/require-test.js +0 -117
- data/spec/javascript/sandbox/compile.js +0 -37
- data/spec/javascript/sandbox/creation.js +0 -44
- data/spec/javascript/sandbox/format.js +0 -79
- data/spec/javascript/sandbox/misc.js +0 -57
- data/spec/javascript/sandbox/preprocessor.js +0 -81
- data/spec/javascript/sandbox/require.js +0 -48
- data/spec/javascript/sandbox/run-command.js +0 -21
- data/spec/javascript/spade/externs.js +0 -14
- data/spec/javascript/spade/load-factory.js +0 -15
- data/spec/javascript/spade/misc.js +0 -23
- data/spec/javascript/spade/ready.js +0 -12
- data/spec/javascript/spade/register.js +0 -13
- data/spec/javascript_spec.rb +0 -7
- data/spec/package_spec.rb +0 -267
- data/spec/spec_helper.rb +0 -30
- data/spec/support/cli.rb +0 -94
- data/spec/support/core_test.rb +0 -59
- data/spec/support/fake.rb +0 -44
- data/spec/support/fake_gem_server.rb +0 -66
- data/spec/support/fake_gemcutter.rb +0 -49
- data/spec/support/matchers.rb +0 -31
- data/spec/support/path.rb +0 -54
- data/test-spade.html +0 -8
@@ -1,32 +0,0 @@
|
|
1
|
-
# ==========================================================================
|
2
|
-
# Project: Ivory
|
3
|
-
# Copyright: ©2010 Strobe Inc. All rights reserved.
|
4
|
-
# License: Licened under MIT license (see LICENSE)
|
5
|
-
# ==========================================================================
|
6
|
-
|
7
|
-
module Ivory
|
8
|
-
class EventEmitterExports < Spade::Exports
|
9
|
-
|
10
|
-
class EventEmitter
|
11
|
-
attr_accessor :_events
|
12
|
-
|
13
|
-
def emit(e, *args)
|
14
|
-
return unless @_events
|
15
|
-
case notify = @_events[e]
|
16
|
-
when V8::Function
|
17
|
-
notify.methodcall(self, *args)
|
18
|
-
when V8::Array
|
19
|
-
notify.each {|listener| listener.methodcall(self, *args) if listener}
|
20
|
-
else
|
21
|
-
return false
|
22
|
-
end
|
23
|
-
return true
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
Spade.exports = Ivory::EventEmitterExports
|
@@ -1,245 +0,0 @@
|
|
1
|
-
# ==========================================================================
|
2
|
-
# Project: Ivory
|
3
|
-
# Copyright: ©2010 Strobe Inc. All rights reserved.
|
4
|
-
# License: Licened under MIT license (see LICENSE)
|
5
|
-
# ==========================================================================
|
6
|
-
|
7
|
-
require 'fileutils'
|
8
|
-
|
9
|
-
module Ivory
|
10
|
-
class Fs < Spade::Exports
|
11
|
-
|
12
|
-
def initialize(ctx)
|
13
|
-
@ctx = ctx
|
14
|
-
@descriptors = {}
|
15
|
-
@descriptors[STDOUT] = Class.new do
|
16
|
-
def self.write(chars)
|
17
|
-
$stdout.write(chars.pack("C*"))
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def stdin
|
23
|
-
$stdin
|
24
|
-
end
|
25
|
-
|
26
|
-
def stdout
|
27
|
-
$stdout
|
28
|
-
end
|
29
|
-
|
30
|
-
def readFile(path, encoding, callback = nil)
|
31
|
-
async(callback) do
|
32
|
-
File.read(path)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def writeFile(path, data, encoding, callback=nil)
|
37
|
-
async(callback) do
|
38
|
-
File.open(path, 'w+') { |fd| fd.write(data); }
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def chmod(path, mode, callback = nil)
|
43
|
-
async(callback) do
|
44
|
-
File.chmod(mode, path)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def exists(path)
|
49
|
-
File.exists?(path)
|
50
|
-
end
|
51
|
-
|
52
|
-
def open(path, flags, mode, callback = nil)
|
53
|
-
async(callback) do
|
54
|
-
file = File.new(path, flags, mode)
|
55
|
-
file.fileno.tap do |fd|
|
56
|
-
@descriptors[fd] = file
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
def close(fd, callback = nil)
|
62
|
-
async(callback) do
|
63
|
-
file(fd) do |f|
|
64
|
-
f.close()
|
65
|
-
@descriptors.delete(fd)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
def read(fd, buffer, offset, length, position, callback = nil)
|
71
|
-
raise "Offset is out of bounds" unless offset <= buffer.length
|
72
|
-
raise "Length is extends beyond buffer" unless (offset + length) <= buffer.length
|
73
|
-
async(callback) do
|
74
|
-
file(fd) do |f|
|
75
|
-
f.seek(position) if position
|
76
|
-
data = buffer.send(:data)
|
77
|
-
bytes = f.read(length)
|
78
|
-
data[offset, bytes.length] = bytes.unpack('C*')
|
79
|
-
bytes.length
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
def write(fd, buffer, offset, length, position, callback = nil)
|
85
|
-
async(callback) do
|
86
|
-
file(fd) do |f|
|
87
|
-
f.seek(position) if position
|
88
|
-
data = buffer.send(:data)
|
89
|
-
f.write(data[offset, length])
|
90
|
-
end
|
91
|
-
length
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
def stat(path, callback = nil)
|
96
|
-
async(callback) do
|
97
|
-
Stats.new(File.stat(path))
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
def lstat(path, callback = nil)
|
102
|
-
async(callback) do
|
103
|
-
Stats.new(File.lstat(path))
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
def fstat(fd, callback = nil)
|
108
|
-
async(callback) do
|
109
|
-
file(fd) do |f|
|
110
|
-
Stats.new(f.stat)
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
def fsync(fd, callback = nil)
|
116
|
-
async(callback) do
|
117
|
-
file(fd) do |f|
|
118
|
-
f.fsync
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
def readlink(path, callback = nil)
|
124
|
-
async(callback) do
|
125
|
-
File.readlink(path)
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
def link(old_name, new_name, callback = nil)
|
130
|
-
async(callback) do
|
131
|
-
File.link(old_name, new_name)
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
def symlink(old_name, new_name, callback = nil)
|
136
|
-
async(callback) do
|
137
|
-
File.symlink(old_name, new_name)
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
def unlink(filename, callback = nil)
|
142
|
-
async(callback) do
|
143
|
-
File.unlink(filename)
|
144
|
-
end
|
145
|
-
end
|
146
|
-
|
147
|
-
def rename(old_name, new_name, callback = nil)
|
148
|
-
async(callback) do
|
149
|
-
File.rename(old_name, new_name)
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
def rmdir(dir, callback = nil)
|
154
|
-
async(callback) do
|
155
|
-
Dir.rmdir(dir)
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
def mkdir(name, mode, callback = nil)
|
160
|
-
async(callback) do
|
161
|
-
Dir.mkdir(name)
|
162
|
-
end
|
163
|
-
end
|
164
|
-
|
165
|
-
def mkdir_p(name, mode, callback = nil)
|
166
|
-
async(callback) do
|
167
|
-
FileUtils.mkdir_p(name, mode)
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
def readdir(path, callback = nil)
|
172
|
-
async(callback) do
|
173
|
-
Dir.entries(path).reject { |e| ['.', '..'].include?(e) }
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
#TODO: figure out how to call fdatasync from ruby
|
178
|
-
alias_method :fdatasync, :fsync
|
179
|
-
|
180
|
-
class Stats
|
181
|
-
def initialize(stat)
|
182
|
-
@stat = stat
|
183
|
-
end
|
184
|
-
|
185
|
-
def size
|
186
|
-
@stat.size
|
187
|
-
end
|
188
|
-
|
189
|
-
def mtime
|
190
|
-
@stat.mtime
|
191
|
-
end
|
192
|
-
|
193
|
-
def mode
|
194
|
-
@stat.mode
|
195
|
-
end
|
196
|
-
|
197
|
-
def isSymbolicLink(*a)
|
198
|
-
@stat.symlink?
|
199
|
-
end
|
200
|
-
|
201
|
-
def isDirectory(*a)
|
202
|
-
@stat.directory?
|
203
|
-
end
|
204
|
-
|
205
|
-
def dev
|
206
|
-
@stat.dev
|
207
|
-
end
|
208
|
-
|
209
|
-
def ino
|
210
|
-
@stat.ino
|
211
|
-
end
|
212
|
-
end
|
213
|
-
|
214
|
-
private
|
215
|
-
|
216
|
-
def file(fd)
|
217
|
-
if file = @descriptors[fd]
|
218
|
-
yield file
|
219
|
-
end
|
220
|
-
end
|
221
|
-
|
222
|
-
def async(callback)
|
223
|
-
if callback
|
224
|
-
begin
|
225
|
-
result = yield
|
226
|
-
begin
|
227
|
-
callback.call(false, result)
|
228
|
-
rescue Exception
|
229
|
-
end
|
230
|
-
rescue Exception => e
|
231
|
-
begin
|
232
|
-
callback.call(e,nil)
|
233
|
-
rescue Exception => e
|
234
|
-
end
|
235
|
-
end
|
236
|
-
else
|
237
|
-
yield
|
238
|
-
end
|
239
|
-
end
|
240
|
-
end
|
241
|
-
end
|
242
|
-
|
243
|
-
Spade.exports = Ivory::Fs
|
244
|
-
|
245
|
-
|
@@ -1,28 +0,0 @@
|
|
1
|
-
# ==========================================================================
|
2
|
-
# Project: Ivory
|
3
|
-
# Copyright: ©2010 Strobe Inc. All rights reserved.
|
4
|
-
# License: Licened under MIT license (see LICENSE)
|
5
|
-
# ==========================================================================
|
6
|
-
|
7
|
-
module Ivory
|
8
|
-
|
9
|
-
class Process
|
10
|
-
|
11
|
-
def initialize(ctx=nil)
|
12
|
-
@ctx = ctx
|
13
|
-
end
|
14
|
-
|
15
|
-
# *args req to make this appear as a func
|
16
|
-
def cwd(*args)
|
17
|
-
Dir.pwd
|
18
|
-
end
|
19
|
-
|
20
|
-
def stdout
|
21
|
-
$stdout
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
Spade.exports = Ivory::Process
|
@@ -1,115 +0,0 @@
|
|
1
|
-
// ==========================================================================
|
2
|
-
// Project: Ivory
|
3
|
-
// Copyright: ©2010 Strobe Inc. All rights reserved.
|
4
|
-
// License: Licened under MIT license
|
5
|
-
// ==========================================================================
|
6
|
-
|
7
|
-
var events = require('./events');
|
8
|
-
var util = require('./util');
|
9
|
-
|
10
|
-
function Stream() {
|
11
|
-
events.EventEmitter.call(this);
|
12
|
-
}
|
13
|
-
util.inherits(Stream, events.EventEmitter);
|
14
|
-
exports.Stream = Stream;
|
15
|
-
|
16
|
-
Stream.prototype.pipe = function(dest /* options, filter */) {
|
17
|
-
var source = this;
|
18
|
-
|
19
|
-
// parse arguments
|
20
|
-
var options, filter;
|
21
|
-
if (typeof arguments[1] == 'object') {
|
22
|
-
options = arguments[1];
|
23
|
-
filter = arguments[2];
|
24
|
-
} else {
|
25
|
-
filter = arguments[1];
|
26
|
-
}
|
27
|
-
|
28
|
-
function ondata(chunk) {
|
29
|
-
// FIXME shouldn't need to test writable - this is working around bug.
|
30
|
-
// .writable should not change before a 'end' event is fired.
|
31
|
-
if (dest.writable) {
|
32
|
-
if (false === dest.write(chunk)) source.pause();
|
33
|
-
}
|
34
|
-
}
|
35
|
-
|
36
|
-
if (!filter) {
|
37
|
-
source.on('data', ondata);
|
38
|
-
} else {
|
39
|
-
//
|
40
|
-
// TODO: needs tests
|
41
|
-
//
|
42
|
-
var wait = false;
|
43
|
-
var waitQueue = [];
|
44
|
-
|
45
|
-
function done () {
|
46
|
-
wait = false;
|
47
|
-
// Drain the waitQueue
|
48
|
-
if (dest.writable && waitQueue.length) {
|
49
|
-
wait = true;
|
50
|
-
filter(waitQueue.shift(), ondata, done);
|
51
|
-
}
|
52
|
-
}
|
53
|
-
|
54
|
-
source.on('data', function (d) {
|
55
|
-
if (wait) {
|
56
|
-
waitQueue.push(d);
|
57
|
-
source.pause();
|
58
|
-
} else {
|
59
|
-
wait = true;
|
60
|
-
filter(d, ondata, done);
|
61
|
-
}
|
62
|
-
});
|
63
|
-
}
|
64
|
-
|
65
|
-
|
66
|
-
function ondrain() {
|
67
|
-
if (source.readable) source.resume();
|
68
|
-
}
|
69
|
-
|
70
|
-
dest.on('drain', ondrain);
|
71
|
-
|
72
|
-
/*
|
73
|
-
* If the 'end' option is not supplied, dest.end() will be called when
|
74
|
-
* source gets the 'end' event.
|
75
|
-
*/
|
76
|
-
|
77
|
-
if (!options || options.end !== false) {
|
78
|
-
function onend() {
|
79
|
-
dest.end();
|
80
|
-
}
|
81
|
-
|
82
|
-
source.on('end', onend);
|
83
|
-
}
|
84
|
-
|
85
|
-
dest.on('close', function() {
|
86
|
-
source.removeListener('data', ondata);
|
87
|
-
dest.removeListener('drain', ondrain);
|
88
|
-
source.removeListener('end', onend);
|
89
|
-
});
|
90
|
-
|
91
|
-
|
92
|
-
/*
|
93
|
-
* Questionable:
|
94
|
-
*/
|
95
|
-
|
96
|
-
if (!source.pause) {
|
97
|
-
source.pause = function() {
|
98
|
-
source.emit('pause');
|
99
|
-
};
|
100
|
-
}
|
101
|
-
|
102
|
-
if (!source.resume) {
|
103
|
-
source.resume = function() {
|
104
|
-
source.emit('resume');
|
105
|
-
};
|
106
|
-
}
|
107
|
-
|
108
|
-
dest.on('pause', function() {
|
109
|
-
source.pause();
|
110
|
-
});
|
111
|
-
|
112
|
-
dest.on('resume', function() {
|
113
|
-
if (source.readable) source.resume();
|
114
|
-
});
|
115
|
-
};
|
data/packages/ivory/lib/util.js
DELETED
@@ -1,414 +0,0 @@
|
|
1
|
-
// ==========================================================================
|
2
|
-
// Project: Ivory
|
3
|
-
// Copyright: ©2010 Strobe Inc. All rights reserved.
|
4
|
-
// License: Licened under MIT license
|
5
|
-
// ==========================================================================
|
6
|
-
|
7
|
-
var process = require('./ruby/process');
|
8
|
-
var events = require('./events');
|
9
|
-
|
10
|
-
|
11
|
-
exports.print = function() {
|
12
|
-
for (var i = 0, len = arguments.length; i < len; ++i) {
|
13
|
-
process.stdout.write(String(arguments[i]));
|
14
|
-
}
|
15
|
-
};
|
16
|
-
|
17
|
-
|
18
|
-
exports.puts = function() {
|
19
|
-
for (var i = 0, len = arguments.length; i < len; ++i) {
|
20
|
-
process.stdout.write(arguments[i] + '\n');
|
21
|
-
}
|
22
|
-
};
|
23
|
-
|
24
|
-
exports.println = exports.puts;
|
25
|
-
|
26
|
-
exports.debug = function(x) {
|
27
|
-
console.debug(x);
|
28
|
-
};
|
29
|
-
|
30
|
-
|
31
|
-
exports.error = function(x) {
|
32
|
-
console.error(x);
|
33
|
-
};
|
34
|
-
var error = exports.error;
|
35
|
-
|
36
|
-
|
37
|
-
/**
|
38
|
-
* Echos the value of a value. Trys to print the value out
|
39
|
-
* in the best way possible given the different types.
|
40
|
-
*
|
41
|
-
* @param {Object} obj The object to print out.
|
42
|
-
* @param {Boolean} showHidden Flag that shows hidden (not enumerable)
|
43
|
-
* properties of objects.
|
44
|
-
* @param {Number} depth Depth in which to descend in object. Default is 2.
|
45
|
-
* @param {Boolean} colors Flag to turn on ANSI escape codes to color the
|
46
|
-
* output. Default is false (no coloring).
|
47
|
-
*/
|
48
|
-
exports.inspect = function(obj, showHidden, depth, colors) {
|
49
|
-
var seen = [];
|
50
|
-
|
51
|
-
var stylize = function(str, styleType) {
|
52
|
-
// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics
|
53
|
-
var styles =
|
54
|
-
{ 'bold' : [1, 22],
|
55
|
-
'italic' : [3, 23],
|
56
|
-
'underline' : [4, 24],
|
57
|
-
'inverse' : [7, 27],
|
58
|
-
'white' : [37, 39],
|
59
|
-
'grey' : [90, 39],
|
60
|
-
'black' : [30, 39],
|
61
|
-
'blue' : [34, 39],
|
62
|
-
'cyan' : [36, 39],
|
63
|
-
'green' : [32, 39],
|
64
|
-
'magenta' : [35, 39],
|
65
|
-
'red' : [31, 39],
|
66
|
-
'yellow' : [33, 39] };
|
67
|
-
|
68
|
-
var style =
|
69
|
-
{ 'special': 'cyan',
|
70
|
-
'number': 'blue',
|
71
|
-
'boolean': 'yellow',
|
72
|
-
'undefined': 'grey',
|
73
|
-
'null': 'bold',
|
74
|
-
'string': 'green',
|
75
|
-
'date': 'magenta',
|
76
|
-
// "name": intentionally not styling
|
77
|
-
'regexp': 'red' }[styleType];
|
78
|
-
|
79
|
-
if (style) {
|
80
|
-
return '\033[' + styles[style][0] + 'm' + str +
|
81
|
-
'\033[' + styles[style][1] + 'm';
|
82
|
-
} else {
|
83
|
-
return str;
|
84
|
-
}
|
85
|
-
};
|
86
|
-
if (! colors) {
|
87
|
-
stylize = function(str, styleType) { return str; };
|
88
|
-
}
|
89
|
-
|
90
|
-
function format(value, recurseTimes) {
|
91
|
-
// Provide a hook for user-specified inspect functions.
|
92
|
-
// Check that value is an object with an inspect function on it
|
93
|
-
if (value && typeof value.inspect === 'function' &&
|
94
|
-
// Filter out the util module, it's inspect function is special
|
95
|
-
value !== exports &&
|
96
|
-
// Also filter out any prototype objects using the circular check.
|
97
|
-
!(value.constructor && value.constructor.prototype === value)) {
|
98
|
-
return value.inspect(recurseTimes);
|
99
|
-
}
|
100
|
-
|
101
|
-
// Primitive types cannot have properties
|
102
|
-
switch (typeof value) {
|
103
|
-
case 'undefined':
|
104
|
-
return stylize('undefined', 'undefined');
|
105
|
-
|
106
|
-
case 'string':
|
107
|
-
var simple = JSON.stringify(value).replace(/'/g, "\\'")
|
108
|
-
.replace(/\\"/g, '"')
|
109
|
-
.replace(/(^"|"$)/g, "'");
|
110
|
-
return stylize(simple, 'string');
|
111
|
-
|
112
|
-
case 'number':
|
113
|
-
return stylize('' + value, 'number');
|
114
|
-
|
115
|
-
case 'boolean':
|
116
|
-
return stylize('' + value, 'boolean');
|
117
|
-
}
|
118
|
-
// For some reason typeof null is "object", so special case here.
|
119
|
-
if (value === null) {
|
120
|
-
return stylize('null', 'null');
|
121
|
-
}
|
122
|
-
|
123
|
-
// Look up the keys of the object.
|
124
|
-
var visible_keys = Object.keys(value);
|
125
|
-
var keys = showHidden ? Object.getOwnPropertyNames(value) : visible_keys;
|
126
|
-
|
127
|
-
// Functions without properties can be shortcutted.
|
128
|
-
if (typeof value === 'function' && keys.length === 0) {
|
129
|
-
if (isRegExp(value)) {
|
130
|
-
return stylize('' + value, 'regexp');
|
131
|
-
} else {
|
132
|
-
var name = value.name ? ': ' + value.name : '';
|
133
|
-
return stylize('[Function' + name + ']', 'special');
|
134
|
-
}
|
135
|
-
}
|
136
|
-
|
137
|
-
// Dates without properties can be shortcutted
|
138
|
-
if (isDate(value) && keys.length === 0) {
|
139
|
-
return stylize(value.toUTCString(), 'date');
|
140
|
-
}
|
141
|
-
|
142
|
-
var base, type, braces;
|
143
|
-
// Determine the object type
|
144
|
-
if (isArray(value)) {
|
145
|
-
type = 'Array';
|
146
|
-
braces = ['[', ']'];
|
147
|
-
} else {
|
148
|
-
type = 'Object';
|
149
|
-
braces = ['{', '}'];
|
150
|
-
}
|
151
|
-
|
152
|
-
// Make functions say that they are functions
|
153
|
-
if (typeof value === 'function') {
|
154
|
-
var n = value.name ? ': ' + value.name : '';
|
155
|
-
base = (isRegExp(value)) ? ' ' + value : ' [Function' + n + ']';
|
156
|
-
} else {
|
157
|
-
base = '';
|
158
|
-
}
|
159
|
-
|
160
|
-
// Make dates with properties first say the date
|
161
|
-
if (isDate(value)) {
|
162
|
-
base = ' ' + value.toUTCString();
|
163
|
-
}
|
164
|
-
|
165
|
-
if (keys.length === 0) {
|
166
|
-
return braces[0] + base + braces[1];
|
167
|
-
}
|
168
|
-
|
169
|
-
if (recurseTimes < 0) {
|
170
|
-
if (isRegExp(value)) {
|
171
|
-
return stylize('' + value, 'regexp');
|
172
|
-
} else {
|
173
|
-
return stylize('[Object]', 'special');
|
174
|
-
}
|
175
|
-
}
|
176
|
-
|
177
|
-
seen.push(value);
|
178
|
-
|
179
|
-
var output = keys.map(function(key) {
|
180
|
-
var name, str;
|
181
|
-
if (value.__lookupGetter__) {
|
182
|
-
if (value.__lookupGetter__(key)) {
|
183
|
-
if (value.__lookupSetter__(key)) {
|
184
|
-
str = stylize('[Getter/Setter]', 'special');
|
185
|
-
} else {
|
186
|
-
str = stylize('[Getter]', 'special');
|
187
|
-
}
|
188
|
-
} else {
|
189
|
-
if (value.__lookupSetter__(key)) {
|
190
|
-
str = stylize('[Setter]', 'special');
|
191
|
-
}
|
192
|
-
}
|
193
|
-
}
|
194
|
-
if (visible_keys.indexOf(key) < 0) {
|
195
|
-
name = '[' + key + ']';
|
196
|
-
}
|
197
|
-
if (!str) {
|
198
|
-
if (seen.indexOf(value[key]) < 0) {
|
199
|
-
if (recurseTimes === null) {
|
200
|
-
str = format(value[key]);
|
201
|
-
} else {
|
202
|
-
str = format(value[key], recurseTimes - 1);
|
203
|
-
}
|
204
|
-
if (str.indexOf('\n') > -1) {
|
205
|
-
if (isArray(value)) {
|
206
|
-
str = str.split('\n').map(function(line) {
|
207
|
-
return ' ' + line;
|
208
|
-
}).join('\n').substr(2);
|
209
|
-
} else {
|
210
|
-
str = '\n' + str.split('\n').map(function(line) {
|
211
|
-
return ' ' + line;
|
212
|
-
}).join('\n');
|
213
|
-
}
|
214
|
-
}
|
215
|
-
} else {
|
216
|
-
str = stylize('[Circular]', 'special');
|
217
|
-
}
|
218
|
-
}
|
219
|
-
if (typeof name === 'undefined') {
|
220
|
-
if (type === 'Array' && key.match(/^\d+$/)) {
|
221
|
-
return str;
|
222
|
-
}
|
223
|
-
name = JSON.stringify('' + key);
|
224
|
-
if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
|
225
|
-
name = name.substr(1, name.length - 2);
|
226
|
-
name = stylize(name, 'name');
|
227
|
-
} else {
|
228
|
-
name = name.replace(/'/g, "\\'")
|
229
|
-
.replace(/\\"/g, '"')
|
230
|
-
.replace(/(^"|"$)/g, "'");
|
231
|
-
name = stylize(name, 'string');
|
232
|
-
}
|
233
|
-
}
|
234
|
-
|
235
|
-
return name + ': ' + str;
|
236
|
-
});
|
237
|
-
|
238
|
-
seen.pop();
|
239
|
-
|
240
|
-
var numLinesEst = 0;
|
241
|
-
var length = output.reduce(function(prev, cur) {
|
242
|
-
numLinesEst++;
|
243
|
-
if (cur.indexOf('\n') >= 0) numLinesEst++;
|
244
|
-
return prev + cur.length + 1;
|
245
|
-
}, 0);
|
246
|
-
|
247
|
-
if (length > (require('readline').columns || 50)) {
|
248
|
-
output = braces[0] +
|
249
|
-
(base === '' ? '' : base + '\n ') +
|
250
|
-
' ' +
|
251
|
-
output.join(',\n ') +
|
252
|
-
' ' +
|
253
|
-
braces[1];
|
254
|
-
|
255
|
-
} else {
|
256
|
-
output = braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
|
257
|
-
}
|
258
|
-
|
259
|
-
return output;
|
260
|
-
}
|
261
|
-
return format(obj, (typeof depth === 'undefined' ? 2 : depth));
|
262
|
-
};
|
263
|
-
|
264
|
-
|
265
|
-
function isArray(ar) {
|
266
|
-
return ar instanceof Array ||
|
267
|
-
Array.isArray(ar) ||
|
268
|
-
(ar && ar !== Object.prototype && isArray(ar.__proto__));
|
269
|
-
}
|
270
|
-
|
271
|
-
|
272
|
-
function isRegExp(re) {
|
273
|
-
var s = '' + re;
|
274
|
-
return re instanceof RegExp || // easy case
|
275
|
-
// duck-type for context-switching evalcx case
|
276
|
-
typeof(re) === 'function' &&
|
277
|
-
re.constructor.name === 'RegExp' &&
|
278
|
-
re.compile &&
|
279
|
-
re.test &&
|
280
|
-
re.exec &&
|
281
|
-
s.match(/^\/.*\/[gim]{0,3}$/);
|
282
|
-
}
|
283
|
-
|
284
|
-
|
285
|
-
function isDate(d) {
|
286
|
-
if (d instanceof Date) return true;
|
287
|
-
if (typeof d !== 'object') return false;
|
288
|
-
var properties = Date.prototype && Object.getOwnPropertyNames(Date.prototype);
|
289
|
-
var proto = d.__proto__ && Object.getOwnPropertyNames(d.__proto__);
|
290
|
-
return JSON.stringify(proto) === JSON.stringify(properties);
|
291
|
-
}
|
292
|
-
|
293
|
-
|
294
|
-
var pWarning;
|
295
|
-
|
296
|
-
exports.p = function() {
|
297
|
-
if (!pWarning) {
|
298
|
-
pWarning = 'util.p will be removed in future versions of Node. ' +
|
299
|
-
'Use util.puts(util.inspect()) instead.\n';
|
300
|
-
exports.error(pWarning);
|
301
|
-
}
|
302
|
-
for (var i = 0, len = arguments.length; i < len; ++i) {
|
303
|
-
error(exports.inspect(arguments[i]));
|
304
|
-
}
|
305
|
-
};
|
306
|
-
|
307
|
-
|
308
|
-
function pad(n) {
|
309
|
-
return n < 10 ? '0' + n.toString(10) : n.toString(10);
|
310
|
-
}
|
311
|
-
|
312
|
-
|
313
|
-
var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
|
314
|
-
'Oct', 'Nov', 'Dec'];
|
315
|
-
|
316
|
-
// 26 Feb 16:19:34
|
317
|
-
function timestamp() {
|
318
|
-
var d = new Date();
|
319
|
-
var time = [pad(d.getHours()),
|
320
|
-
pad(d.getMinutes()),
|
321
|
-
pad(d.getSeconds())].join(':');
|
322
|
-
return [d.getDate(), months[d.getMonth()], time].join(' ');
|
323
|
-
}
|
324
|
-
|
325
|
-
|
326
|
-
exports.log = function(msg) {
|
327
|
-
exports.puts(timestamp() + ' - ' + msg.toString());
|
328
|
-
};
|
329
|
-
|
330
|
-
|
331
|
-
var execWarning;
|
332
|
-
exports.exec = function() {
|
333
|
-
if (!execWarning) {
|
334
|
-
execWarning = 'util.exec has moved to the "child_process" module.' +
|
335
|
-
' Please update your source code.';
|
336
|
-
error(execWarning);
|
337
|
-
}
|
338
|
-
return require('child_process').exec.apply(this, arguments);
|
339
|
-
};
|
340
|
-
|
341
|
-
|
342
|
-
exports.pump = function(readStream, writeStream, callback) {
|
343
|
-
var callbackCalled = false;
|
344
|
-
|
345
|
-
function call(a, b, c) {
|
346
|
-
if (callback && !callbackCalled) {
|
347
|
-
callback(a, b, c);
|
348
|
-
callbackCalled = true;
|
349
|
-
}
|
350
|
-
}
|
351
|
-
|
352
|
-
if (!readStream.pause) {
|
353
|
-
readStream.pause = function() {readStream.emit('pause');};
|
354
|
-
}
|
355
|
-
|
356
|
-
if (!readStream.resume) {
|
357
|
-
readStream.resume = function() {readStream.emit('resume');};
|
358
|
-
}
|
359
|
-
|
360
|
-
readStream.addListener('data', function(chunk) {
|
361
|
-
if (writeStream.write(chunk) === false) readStream.pause();
|
362
|
-
});
|
363
|
-
|
364
|
-
writeStream.addListener('pause', function() {
|
365
|
-
readStream.pause();
|
366
|
-
});
|
367
|
-
|
368
|
-
writeStream.addListener('drain', function() {
|
369
|
-
readStream.resume();
|
370
|
-
});
|
371
|
-
|
372
|
-
writeStream.addListener('resume', function() {
|
373
|
-
readStream.resume();
|
374
|
-
});
|
375
|
-
|
376
|
-
readStream.addListener('end', function() {
|
377
|
-
writeStream.end();
|
378
|
-
});
|
379
|
-
|
380
|
-
readStream.addListener('close', function() {
|
381
|
-
call();
|
382
|
-
});
|
383
|
-
|
384
|
-
readStream.addListener('error', function(err) {
|
385
|
-
writeStream.end();
|
386
|
-
call(err);
|
387
|
-
});
|
388
|
-
|
389
|
-
writeStream.addListener('error', function(err) {
|
390
|
-
readStream.destroy();
|
391
|
-
call(err);
|
392
|
-
});
|
393
|
-
};
|
394
|
-
|
395
|
-
|
396
|
-
/**
|
397
|
-
* Inherit the prototype methods from one constructor into another.
|
398
|
-
*
|
399
|
-
* The Function.prototype.inherits from lang.js rewritten as a standalone
|
400
|
-
* function (not on Function.prototype). NOTE: If this file is to be loaded
|
401
|
-
* during bootstrapping this function needs to be revritten using some native
|
402
|
-
* functions as prototype setup using normal JavaScript does not work as
|
403
|
-
* expected during bootstrapping (see mirror.js in r114903).
|
404
|
-
*
|
405
|
-
* @param {function} ctor Constructor function which needs to inherit the
|
406
|
-
* prototype.
|
407
|
-
* @param {function} superCtor Constructor function to inherit prototype from.
|
408
|
-
*/
|
409
|
-
exports.inherits = function(ctor, superCtor) {
|
410
|
-
ctor.super_ = superCtor;
|
411
|
-
ctor.prototype = Object.create(superCtor.prototype, {
|
412
|
-
constructor: { value: ctor, enumerable: false }
|
413
|
-
});
|
414
|
-
};
|