script_executor 1.7.4 → 1.7.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES +4 -0
- data/lib/script_executor/scripts_parser.rb +19 -15
- data/lib/script_executor/version.rb +1 -1
- data/spec/scripts_parser_spec.rb +8 -4
- data/spec/support/script1.sh +15 -10
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14d76bcbd7dec002c5f8a212e401e85fc179d48d
|
4
|
+
data.tar.gz: fdd367cd483f92c06fca53ceed9071971ade9eb6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7cd378c64712dcfda80578495da636439cf31845c98350f0c574daa9ffb15ce4d772875996634c7cf284fd60a1eea1259f34973ddfda1de2adbe6023f5ad4f67
|
7
|
+
data.tar.gz: 15301ca977bf1cc446da11ebc71caa22ae5eb7ca1b601add1f28459e2366a18af72cd149b614f6d539b15193b02e716d8e5148167ca453f5a40d64707f4e2fdd
|
data/CHANGES
CHANGED
@@ -3,25 +3,29 @@ require 'parslet'
|
|
3
3
|
class ScriptsParser < Parslet::Parser
|
4
4
|
root :language
|
5
5
|
|
6
|
-
rule(:language)
|
6
|
+
rule(:language) { (shebang.maybe >> ignored >> scripts).as(:language) }
|
7
7
|
|
8
|
-
rule(:shebang)
|
8
|
+
rule(:shebang) { str('#') >> str('!') >> match['\w\d_/\s'].repeat(1).as(:shebang) }
|
9
|
+
rule(:ignored) { empty_lines >> (name.absent? >> comment).repeat(0).as(:ignored) >> empty_lines }
|
9
10
|
|
10
|
-
rule(:comment)
|
11
|
+
rule(:comment) { comment_char >> spaces >> (newline.absent? >> any).repeat(0).as(:comment) >> eol }
|
12
|
+
rule(:comment_char) { str(';') | str('#') }
|
11
13
|
|
12
|
-
rule(:scripts)
|
14
|
+
rule(:scripts) { script.repeat(0).as(:scripts) }
|
15
|
+
rule(:script) { (name >> empty_lines >> (name.absent? >> (comment | code_line)).repeat(0)).as(:script) }
|
13
16
|
|
14
|
-
rule(:name)
|
15
|
-
rule(:
|
17
|
+
rule(:name) { name_v1 |name_v2 }
|
18
|
+
rule(:name_v1) { spaces >> str('[') >> spaces >> name_chars.as(:name) >> str(']') >> spaces >> eol }
|
19
|
+
rule(:name_v2) { spaces >> comment_char >> spaces >> str('[') >> spaces >> name_chars.as(:name) >> str(']') >> spaces >> eol }
|
20
|
+
rule(:name_chars) { match['\w\d_'].repeat(1) }
|
16
21
|
|
17
|
-
rule(:
|
18
|
-
rule(:
|
19
|
-
rule(:code_chars) { any }
|
22
|
+
rule(:code_line) { (newline.absent? >> code_chars).repeat(1).as(:code_line) >> eol }
|
23
|
+
rule(:code_chars) { any }
|
20
24
|
|
21
|
-
rule(:empty_lines)
|
22
|
-
rule(:empty_line)
|
23
|
-
rule(:newline)
|
24
|
-
rule(:spaces)
|
25
|
-
rule(:eol)
|
26
|
-
rule(:eof)
|
25
|
+
rule(:empty_lines) { empty_line.repeat(0) }
|
26
|
+
rule(:empty_line) { spaces >> newline }
|
27
|
+
rule(:newline) { str("\n") >> match("\r").maybe }
|
28
|
+
rule(:spaces) { match["\s\t "].repeat(0) }
|
29
|
+
rule(:eol) { (newline.repeat(0) | eof) }
|
30
|
+
rule(:eof) { any.absent? }
|
27
31
|
end
|
data/spec/scripts_parser_spec.rb
CHANGED
@@ -55,17 +55,21 @@ describe ScriptsParser do
|
|
55
55
|
|
56
56
|
ap transform parsed_content
|
57
57
|
end
|
58
|
-
|
58
|
+
#
|
59
59
|
# it "test" do
|
60
60
|
# content = <<-DATA
|
61
61
|
# #!/usr/bin/env bash
|
62
62
|
#
|
63
|
+
# #######################################
|
64
|
+
#
|
63
65
|
# # Some description
|
64
|
-
# [name]
|
66
|
+
# # [name]
|
65
67
|
#
|
66
68
|
# # some comment
|
67
|
-
#
|
68
|
-
#
|
69
|
+
#
|
70
|
+
# aaa
|
71
|
+
# bbb
|
72
|
+
#
|
69
73
|
# DATA
|
70
74
|
#
|
71
75
|
# parsed_content = subject.parse(content)
|
data/spec/support/script1.sh
CHANGED
@@ -1,28 +1,32 @@
|
|
1
1
|
#!/usr/bin/env bash
|
2
2
|
|
3
|
-
|
3
|
+
|
4
|
+
# [test1]
|
4
5
|
# Some description
|
5
6
|
|
6
7
|
echo "<%= name %>"
|
7
8
|
|
8
|
-
|
9
|
+
|
10
|
+
#######################################
|
11
|
+
# [test2]
|
9
12
|
|
10
13
|
echo "test2"
|
11
14
|
|
15
|
+
|
12
16
|
#######################################
|
13
|
-
[echo]
|
17
|
+
# [echo]
|
14
18
|
|
15
19
|
echo "Hello world!"
|
16
20
|
|
17
21
|
|
18
22
|
#######################################
|
19
|
-
[ubuntu_update]
|
23
|
+
# [ubuntu_update]
|
20
24
|
|
21
25
|
sudo apt-get update
|
22
26
|
|
23
27
|
|
24
28
|
#######################################
|
25
|
-
[prepare_linux]
|
29
|
+
# [prepare_linux]
|
26
30
|
# Updates linux core packages
|
27
31
|
|
28
32
|
sudo apt-get update
|
@@ -51,7 +55,7 @@ sudo apt-get install -y libffi-dev
|
|
51
55
|
|
52
56
|
|
53
57
|
#######################################
|
54
|
-
[rvm]
|
58
|
+
# [rvm]
|
55
59
|
# Installs rvm
|
56
60
|
|
57
61
|
curl -L https://get.rvm.io | bash
|
@@ -60,7 +64,7 @@ curl -L https://get.rvm.io | bash
|
|
60
64
|
|
61
65
|
|
62
66
|
#######################################
|
63
|
-
[ruby]
|
67
|
+
# [ruby]
|
64
68
|
# Installs ruby
|
65
69
|
|
66
70
|
source /usr/local/rvm/scripts/rvm
|
@@ -69,14 +73,14 @@ rvm install ruby-2.2.3
|
|
69
73
|
|
70
74
|
|
71
75
|
#######################################
|
72
|
-
[node]
|
76
|
+
# [node]
|
73
77
|
# Installs node
|
74
78
|
|
75
79
|
sudo apt-get install -y node
|
76
80
|
|
77
81
|
|
78
82
|
#######################################
|
79
|
-
[rbenv ]
|
83
|
+
# [rbenv ]
|
80
84
|
# Installs node
|
81
85
|
|
82
86
|
sudo apt-get install -y rbenv
|
@@ -84,8 +88,9 @@ git clone git://github.com/jf/rbenv-gemset.git $HOME/.rbenv/plugins/rbenv-gemset
|
|
84
88
|
|
85
89
|
|
86
90
|
#######################################
|
87
|
-
[prepare]
|
91
|
+
# [prepare]
|
88
92
|
# to support nokogiri
|
93
|
+
|
89
94
|
sudo apt-get install -y libgmp-dev
|
90
95
|
|
91
96
|
# to support capybara-webkit
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: script_executor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Shvets
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: highline
|