boojs 0.0.7 → 0.0.9
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 +2 -2
- data/lib/boojs/version.rb +1 -1
- data/lib/boojs.rb +5 -8
- data/m. +0 -0
- data/spec/cli_spec.rb +69 -53
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b7817de66bca23b46ce2c9e689dd197b3b2decb
|
4
|
+
data.tar.gz: 3c8dbeafb87ee5ad9d8a9648d23dae4929f0e1d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d86941a1543bb6d9321c3ac7e2c0c29515b87b146c9bb6e029be8c561d340e338291a622e0d849e948b56ae6a73f17006bef553e5e9875c055b58e48b5699cc
|
7
|
+
data.tar.gz: 4d95affb2ea7c3a648c4b5e955c01b65aeba216d1b744ffc9056ebd6d7324fc61f356bddaea96bc215c03a3c70d1518cbe8d8abbf6cd0c7f46bb70290084e610
|
data/README.md
CHANGED
@@ -30,9 +30,9 @@ Open a standard headless javascript browser REPL
|
|
30
30
|
(sh)>boojs
|
31
31
|
```
|
32
32
|
|
33
|
-
|
33
|
+
Execute a file first, then enter pipe mode (repl like)
|
34
34
|
```sh
|
35
|
-
(sh)>boojs
|
35
|
+
(sh)>boojs code.js
|
36
36
|
```
|
37
37
|
|
38
38
|
Verify that a file contains no javascript errors
|
data/lib/boojs/version.rb
CHANGED
data/lib/boojs.rb
CHANGED
@@ -47,16 +47,13 @@ module BooJS
|
|
47
47
|
system.stderr.writeLine("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
|
48
48
|
phantom.exit(1);
|
49
49
|
}
|
50
|
-
|
51
|
-
while (true) {
|
52
|
-
var line = system.stdin.readLine();
|
53
|
-
eval(line);
|
54
|
-
}
|
55
50
|
}
|
51
|
+
|
52
|
+
#Any code the user wanted
|
53
|
+
js += "\n#{str}" if str
|
56
54
|
|
57
|
-
|
58
|
-
|
59
|
-
end
|
55
|
+
#Repl
|
56
|
+
js += "\nwhile (true) { var line = system.stdin.readLine(); eval(line); }"
|
60
57
|
|
61
58
|
phantom = Phantomjs.path
|
62
59
|
tmp = Tempfile.new(SecureRandom.hex)
|
data/m.
ADDED
File without changes
|
data/spec/cli_spec.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'open3'
|
2
|
+
require 'tempfile'
|
2
3
|
require 'securerandom'
|
3
4
|
|
4
5
|
describe "CLI" do
|
@@ -7,72 +8,87 @@ describe "CLI" do
|
|
7
8
|
`ps -ax | grep phantomjs | grep -v phantomjs | awk '{print $1}' | xargs kill -9`
|
8
9
|
end
|
9
10
|
|
10
|
-
it "Will not exit in pipe mode" do
|
11
|
-
|
12
|
-
Thread.new do
|
13
|
-
|
14
|
-
|
15
|
-
end
|
11
|
+
# it "Will not exit in pipe mode" do
|
12
|
+
#@finished = false
|
13
|
+
#Thread.new do
|
14
|
+
#`ruby -I./lib ./bin/boojs`
|
15
|
+
#@finished = true
|
16
|
+
#end
|
16
17
|
|
17
|
-
sleep 5
|
18
|
-
expect(@finished).to eq(false)
|
19
|
-
end
|
18
|
+
#sleep 5
|
19
|
+
#expect(@finished).to eq(false)
|
20
|
+
#end
|
20
21
|
|
21
|
-
it "Replies with pong$KEY when given ping('$key')" do
|
22
|
-
key = SecureRandom.hex
|
23
|
-
Thread.new do
|
24
|
-
Open3.popen3("ruby -I./lib ./bin/boojs") do |i, o, e, t|
|
25
|
-
i.puts "__spec_ping('#{key}')"
|
26
|
-
|
27
|
-
end
|
28
|
-
end
|
22
|
+
#it "Replies with pong$KEY when given ping('$key')" do
|
23
|
+
#key = SecureRandom.hex
|
24
|
+
#Thread.new do
|
25
|
+
#Open3.popen3("ruby -I./lib ./bin/boojs") do |i, o, e, t|
|
26
|
+
#i.puts "__spec_ping('#{key}')"
|
27
|
+
#@back = o.gets.chomp
|
28
|
+
#end
|
29
|
+
#end
|
29
30
|
|
30
|
-
sleep 5
|
31
|
-
expect(@back).to eq("pong"+key)
|
32
|
-
end
|
31
|
+
#sleep 5
|
32
|
+
#expect(@back).to eq("pong"+key)
|
33
|
+
#end
|
33
34
|
|
34
|
-
it "Replies with pong$KEY when given ping('$key') twice" do
|
35
|
-
keyA = SecureRandom.hex
|
36
|
-
keyB = SecureRandom.hex
|
35
|
+
#it "Replies with pong$KEY when given ping('$key') twice" do
|
36
|
+
#keyA = SecureRandom.hex
|
37
|
+
#keyB = SecureRandom.hex
|
37
38
|
|
38
|
-
Thread.new do
|
39
|
-
Open3.popen3("ruby -I./lib ./bin/boojs") do |i, o, e, t|
|
40
|
-
i.puts "__spec_ping('#{keyA}')"
|
41
|
-
|
42
|
-
i.puts "__spec_ping('#{keyB}')"
|
43
|
-
|
44
|
-
end
|
45
|
-
end
|
39
|
+
#Thread.new do
|
40
|
+
#Open3.popen3("ruby -I./lib ./bin/boojs") do |i, o, e, t|
|
41
|
+
#i.puts "__spec_ping('#{keyA}')"
|
42
|
+
#@backA = o.gets.chomp
|
43
|
+
#i.puts "__spec_ping('#{keyB}')"
|
44
|
+
#@backB = o.gets.chomp
|
45
|
+
#end
|
46
|
+
#end
|
46
47
|
|
47
|
-
sleep 5
|
48
|
-
expect(@backA).to eq("pong"+keyA)
|
49
|
-
expect(@backB).to eq("pong"+keyB)
|
50
|
-
end
|
48
|
+
#sleep 5
|
49
|
+
#expect(@backA).to eq("pong"+keyA)
|
50
|
+
#expect(@backB).to eq("pong"+keyB)
|
51
|
+
#end
|
51
52
|
|
52
|
-
it "Emits stderr and not stdout when an error has occurred" do
|
53
|
-
Thread.new do
|
54
|
-
Open3.popen3("ruby -I./lib ./bin/boojs") do |i, o, e, t|
|
55
|
-
i.puts "no_such_variable"
|
56
|
-
|
57
|
-
|
58
|
-
end
|
59
|
-
end
|
53
|
+
#it "Emits stderr and not stdout when an error has occurred" do
|
54
|
+
#Thread.new do
|
55
|
+
#Open3.popen3("ruby -I./lib ./bin/boojs") do |i, o, e, t|
|
56
|
+
#i.puts "no_such_variable"
|
57
|
+
#@error = e.gets.chomp
|
58
|
+
#@out = o.gets.chomp
|
59
|
+
#end
|
60
|
+
#end
|
60
61
|
|
61
|
-
sleep 5
|
62
|
-
expect(@error.length).not_to eq(0)
|
63
|
-
expect(@out).to eq(nil)
|
64
|
-
end
|
62
|
+
#sleep 5
|
63
|
+
#expect(@error.length).not_to eq(0)
|
64
|
+
#expect(@out).to eq(nil)
|
65
|
+
#end
|
66
|
+
|
67
|
+
#it "Exits with a return code of 1 with error" do
|
68
|
+
#Thread.new do
|
69
|
+
#Open3.popen3("ruby -I./lib ./bin/boojs") do |i, o, e, t|
|
70
|
+
#i.puts "no_such_variable"
|
71
|
+
#@error = e.gets.chomp
|
72
|
+
#@exit = t.value
|
73
|
+
#end
|
74
|
+
#end
|
75
|
+
|
76
|
+
#sleep 5
|
77
|
+
#expect(@exit.exitstatus).to eq(1)
|
78
|
+
#end
|
79
|
+
|
80
|
+
it "Can be passed a file as an argument" do
|
81
|
+
f = Tempfile.new(SecureRandom.hex)
|
82
|
+
f.puts "console.log('hello');"
|
83
|
+
f.close
|
65
84
|
|
66
|
-
it "Exits with a return code of 1 with error" do
|
67
85
|
Thread.new do
|
68
|
-
Open3.popen3(
|
69
|
-
|
70
|
-
@error = e.gets.chomp
|
71
|
-
@exit = t.value
|
86
|
+
Open3.popen3(%{ruby -I./lib ./bin/boojs #{f.path}}) do |i, o, e, t|
|
87
|
+
@read = o.gets.chomp
|
72
88
|
end
|
73
89
|
end
|
74
90
|
|
75
91
|
sleep 5
|
76
|
-
expect(@
|
92
|
+
expect(@read).to eq("hello")
|
77
93
|
end
|
78
94
|
end
|
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.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- seo
|
@@ -99,6 +99,7 @@ files:
|
|
99
99
|
- lib/boojs.rb
|
100
100
|
- lib/boojs/version.rb
|
101
101
|
- logo.png
|
102
|
+
- m.
|
102
103
|
- spec/cli_spec.rb
|
103
104
|
homepage: https://github.com/sotownsend/BooJS
|
104
105
|
licenses:
|