boojs 0.0.5 → 0.0.7

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: eed1c825512f3fec05a1381da8b0445997b060c7
4
- data.tar.gz: cef397cf0d0c510e2aac130292d523c771516236
3
+ metadata.gz: 8da38bda706d995bd7a62d65a42c24a5ee0af7cb
4
+ data.tar.gz: b3499b7c003f7723507204d8c0afdce039902bc5
5
5
  SHA512:
6
- metadata.gz: 2e1af50ddcccc1cfb1dba19011c1f9600719fecff2d7e31a8ac51e14384c8eef0181df86bd1e231b25b53b16263f5cf0628589d81975583225f919de61f8b0ce
7
- data.tar.gz: 1bcfec3f84fba20cc1a6747b56f296e9738d98e2cc9ee2c0a507d8dc9411f0461b1a5f1fcdf470ae02656fe4015626dfa8c316b2d9ace0993297927e3abed27f
6
+ metadata.gz: c904fcd6c47abed9d068363edcae9593afc8acf73872761271b56379a4a18a0a6a152b07ec1e4dfed2ed83634cb9b8b41107ad780a948f8bd98d3b76b7a3931f
7
+ data.tar.gz: 86694a4018a91ecb89b87727175e623c94c32f1a1615ae1da9360eb86fa701fb2364f9b10610b09edd4fbd02d83e6dece36c0bfd57c7ba8190f0406819f0e2d0
data/README.md CHANGED
@@ -15,17 +15,32 @@ gem install boojs
15
15
  ```
16
16
 
17
17
  # Usage
18
+ #### SYNOPSIS
18
19
  ```sh
19
20
  boojs [-v file]
20
21
  ```
21
22
 
22
- There are two modes of operating.
23
+ #### DESCRIPTION
24
+ The following options are available:
25
+ * `-v` - Verify that a file contains no javascript syntax errors. Returns 0 if there are no errors.
23
26
 
27
+ #### EXAMPLES
28
+ Open a standard headless javascript browser REPL
29
+ ```sh
30
+ (sh)>boojs
31
+ ```
24
32
 
25
- 1. If you pass the `-v` flag with a file, boojs will `validate` the javascript file you passed. If it contains any syntax errors, or anything that would crash the execution of the javascript file, these are caught here. Useful for unit tests to make sure the JS files are executable. It will return 0 if the file is valid and 1 if the file is not valid.
26
- 2. If you do not pass the `-v` flag, boojs will accept JS input from stdin and emit JS output on stdout. If there is an exception, boojs
27
- will output the exception to stderr and return 1. In all other cases, boojs will not exit and you must send SIGINT to the process.
33
+ Pipe in a file
34
+ ```sh
35
+ (sh)>boojs < code.js
36
+ ```
28
37
 
38
+ Verify that a file contains no javascript errors
39
+ ```sh
40
+ (sh)>boojs -v code.js
41
+ (sh)>echo $?
42
+ 0
43
+ ```
29
44
 
30
45
  ## Requirements
31
46
 
data/bin/boojs CHANGED
@@ -6,18 +6,24 @@ require 'phantomjs'
6
6
  #Parse
7
7
  ##########################################
8
8
  parser = OptionParser.new do |opts|
9
- opts.banner = "Usage: boojs [-v file]"
9
+ opts.banner = "Usage: boojs [-v file] [file]"
10
10
 
11
11
  opts.on "-v FILE" do |f|
12
- @file = f
12
+ @vfile = f
13
13
  end
14
14
  end
15
15
  parser.parse!
16
+ file = ARGV.pop
16
17
  ##########################################
17
18
 
19
+
18
20
  #Run verify or run stdin/stdout mode?
19
- if @file
21
+ if @vfile
20
22
  BooJS.verify File.read(@file)
21
23
  else
22
- BooJS.pipe
24
+ if file
25
+ BooJS.pipe File.read(file)
26
+ else
27
+ BooJS.pipe
28
+ end
23
29
  end
data/lib/boojs/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module BooJS
2
- VERSION = '0.0.5'
2
+ VERSION = '0.0.7'
3
3
  end
data/lib/boojs.rb CHANGED
@@ -28,7 +28,8 @@ module BooJS
28
28
  system("phantomjs #{tmp.path} 2>&1") or raise "Verifying failed"
29
29
  end
30
30
 
31
- def self.pipe
31
+ #Optionally, accept code to inject
32
+ def self.pipe(str=nil)
32
33
  js = %{
33
34
  var system = require('system');
34
35
  function __spec_ping(str) {
@@ -52,6 +53,11 @@ module BooJS
52
53
  eval(line);
53
54
  }
54
55
  }
56
+
57
+ if str
58
+ js += "\n#{str}"
59
+ end
60
+
55
61
  phantom = Phantomjs.path
56
62
  tmp = Tempfile.new(SecureRandom.hex)
57
63
  tmp.puts js
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: boojs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - seo