From d60e77b41633dff8b9459f41680d85057bc9c4a9 Mon Sep 17 00:00:00 2001 From: Eric LaForce Date: Sun, 23 Dec 2012 14:23:20 -0500 Subject: [PATCH 1/5] Added makefile --- .gitignore | 1 + makefile | 12 ++++++++++++ 2 files changed, 13 insertions(+) create mode 100644 makefile diff --git a/.gitignore b/.gitignore index c0fcad8..8f29ed4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +lib node_modules npm-debug.log *.DS_Store diff --git a/makefile b/makefile new file mode 100644 index 0000000..3798cb1 --- /dev/null +++ b/makefile @@ -0,0 +1,12 @@ +START=node lib/index.js + +run: build + $(START) package.json + +build: clean + coffee -o lib . + +clean: + rm -rf lib + +.PHONY: clean build run From 570a4dd3d9691319de1c6e84b72b0a9fa9c0c370 Mon Sep 17 00:00:00 2001 From: Eric LaForce Date: Sun, 23 Dec 2012 14:26:52 -0500 Subject: [PATCH 2/5] Updated README.md --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index c747c2a..cbacf11 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,15 @@ It can also handle gzipped files. If the extension is .gz, it will decompress th jwalk somefile.json.gz ``` +## Running from source +There is a makefile that tests agains the package.json file located within the repository. Simply type + +``` +make +``` + +to compile the source files into javascript and execute jwalk against package.json + ## Possible Commands Given the following json file From 72b7e74acf4c88400bde740e04916694482dae73 Mon Sep 17 00:00:00 2001 From: Eric LaForce Date: Sun, 23 Dec 2012 14:28:10 -0500 Subject: [PATCH 3/5] Fixed typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cbacf11..70f5888 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ jwalk somefile.json.gz ``` ## Running from source -There is a makefile that tests agains the package.json file located within the repository. Simply type +There is a makefile that tests against the package.json file located within the repository. Simply type ``` make From 859e1add89d742ef9ef9b0c5ee0fb211a94bd28b Mon Sep 17 00:00:00 2001 From: Eric LaForce Date: Sun, 23 Dec 2012 14:58:58 -0500 Subject: [PATCH 4/5] Added name based inspections --- src/commands/Command.coffee | 9 ++++++++- src/commands/Inspect.coffee | 13 ++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/commands/Command.coffee b/src/commands/Command.coffee index e95df19..1d53e33 100644 --- a/src/commands/Command.coffee +++ b/src/commands/Command.coffee @@ -12,6 +12,13 @@ class Command callback null, [[], str] inspect: (obj, depth) -> + console.log depth console.log util.inspect(obj, false, depth, true) -module.exports = Command \ No newline at end of file + inspectProperty: (obj, prop) -> + if obj[prop] != undefined + console.log util.inspect(obj[prop], false, 1, true) + else + console.log "Property does not exist" + +module.exports = Command diff --git a/src/commands/Inspect.coffee b/src/commands/Inspect.coffee index 91731ff..26493f1 100644 --- a/src/commands/Inspect.coffee +++ b/src/commands/Inspect.coffee @@ -6,8 +6,15 @@ class Inspect extends Command 'examines a single node' run: (context, args, callback) -> - depth = if args.length > 0 then Number(args[0]) else 1 - @inspect context.pointer, depth + depth = 1 + if args.length > 0 and isFinite args[0] + depth = Number args[0] + @inspect context.pointer, depth + else if args.length > 0 + @inspectProperty context.pointer, args[0] + else + depth = 1 + @inspect context.pointer, depth callback() -module.exports = Inspect \ No newline at end of file +module.exports = Inspect From 4de5b421d1a50780c89effe55bde353b8434fe2b Mon Sep 17 00:00:00 2001 From: Eric LaForce Date: Sun, 23 Dec 2012 15:00:47 -0500 Subject: [PATCH 5/5] Removed console log --- src/commands/Command.coffee | 1 - 1 file changed, 1 deletion(-) diff --git a/src/commands/Command.coffee b/src/commands/Command.coffee index 1d53e33..593c48f 100644 --- a/src/commands/Command.coffee +++ b/src/commands/Command.coffee @@ -12,7 +12,6 @@ class Command callback null, [[], str] inspect: (obj, depth) -> - console.log depth console.log util.inspect(obj, false, depth, true) inspectProperty: (obj, prop) ->