boojs 0.0.5 → 0.0.7
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.
- checksums.yaml +4 -4
- data/README.md +19 -4
- data/bin/boojs +10 -4
- data/lib/boojs/version.rb +1 -1
- data/lib/boojs.rb +7 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8da38bda706d995bd7a62d65a42c24a5ee0af7cb
|
4
|
+
data.tar.gz: b3499b7c003f7723507204d8c0afdce039902bc5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
|
26
|
-
|
27
|
-
|
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
|
-
@
|
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 @
|
21
|
+
if @vfile
|
20
22
|
BooJS.verify File.read(@file)
|
21
23
|
else
|
22
|
-
|
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
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
|
-
|
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
|