semi 0.6.1 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -3
- data/lib/semi/config.rb +2 -2
- data/lib/semi/driver.rb +16 -3
- data/lib/semi/variable.rb +4 -4
- data/lib/semi/variables/base.rb +2 -2
- data/lib/semi/variables/boolean.rb +1 -1
- data/lib/semi/variables/integer.rb +1 -1
- data/lib/semi/variables/path.rb +6 -6
- data/lib/semi/variables/string.rb +1 -1
- data/lib/semi/variables/url.rb +7 -7
- data/lib/semi/version.rb +1 -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: 166865ef0a7ec6160d098a1c36c115e07ee61847
|
4
|
+
data.tar.gz: bdf2ff02a0f270c5f0e5e3e77b67d3a2d910fd3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8104ebb97b8f485c6a3a9098c37c8a86f183a7299925702a013dcfd297252faf0d98dfa3d44523d249428e6d2056e5ceddd2cbf3846a9b43d408e5e37dea4bd2
|
7
|
+
data.tar.gz: b2fbf40d912fdb43a695cdc99cc1f09f14665dfda3fe2ca825180a1b1892e09ce41d004f1e19c5d51aadb75470bed501ad762924614868d9083cc551a3fb5c70
|
data/README.md
CHANGED
@@ -42,7 +42,7 @@ Validators
|
|
42
42
|
Validators allow one to insure that the value of a variable is within a
|
43
43
|
specified range. Each key of the validate section is a name of a variable
|
44
44
|
that can be used in the ERB templates. The values are one or more
|
45
|
-
validation expressions to test the values against. The values may be
|
45
|
+
validation expressions to test the values against. The values may be
|
46
46
|
specified as a comma seperated string or as an array.
|
47
47
|
|
48
48
|
* required
|
@@ -82,7 +82,7 @@ Commands
|
|
82
82
|
--------
|
83
83
|
Additional commands can be added to the container in the commands section.
|
84
84
|
This is useful for adding automation and providing simple commands to
|
85
|
-
activate more complex commands in the container.
|
85
|
+
activate more complex commands in the container.
|
86
86
|
|
87
87
|
There is one special value (default) that will be used when the entrypoint
|
88
88
|
is not provided any arguements.
|
@@ -91,4 +91,13 @@ Templates
|
|
91
91
|
---------
|
92
92
|
Configuration files are marked up using standard ERB template statements.
|
93
93
|
|
94
|
-
All variables used in ERB templates need to be specified as lower case.
|
94
|
+
All variables used in ERB templates need to be specified as lower case.
|
95
|
+
|
96
|
+
Debugging
|
97
|
+
---------
|
98
|
+
Simple debugging output can be enabled by defining the environmental
|
99
|
+
variable $SEMI_DEBUG. As long as the variable is set to any value, debug
|
100
|
+
statements will be sent to the stdout file handle.
|
101
|
+
|
102
|
+
At this time the only real debug output is the command that will be
|
103
|
+
executed by semi.
|
data/lib/semi/config.rb
CHANGED
@@ -2,7 +2,7 @@ require 'yaml'
|
|
2
2
|
|
3
3
|
module Semi
|
4
4
|
class Config
|
5
|
-
|
5
|
+
|
6
6
|
attr_reader :defaults
|
7
7
|
attr_reader :files
|
8
8
|
attr_reader :validators
|
@@ -36,7 +36,7 @@ module Semi
|
|
36
36
|
if data.key? 'commands'
|
37
37
|
@commands = data['commands']
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
40
|
return data
|
41
41
|
end
|
42
42
|
|
data/lib/semi/driver.rb
CHANGED
@@ -72,11 +72,24 @@ module Semi
|
|
72
72
|
elsif @config.commands.include? args[0]
|
73
73
|
args = @config.commands[args[0]]
|
74
74
|
end
|
75
|
-
|
76
75
|
|
77
76
|
# Execute the command line
|
78
|
-
|
79
|
-
|
77
|
+
if os.environ['SEMI_DEBUG']
|
78
|
+
puts "Semi debug:: executing: #{args}"
|
79
|
+
end
|
80
|
+
begin
|
81
|
+
exec([args].flatten.join(' '))
|
82
|
+
rescue SystemCallError => e
|
83
|
+
if e.errno == Errno::ENOENT
|
84
|
+
puts "Command not found: executing: #{args}"
|
85
|
+
else
|
86
|
+
puts "Unknown system call failure: #{e.inspect}"
|
87
|
+
end
|
88
|
+
exit(e.errno)
|
89
|
+
rescue Exception => e
|
90
|
+
puts "Unknown exception: #{e.inspect}"
|
91
|
+
exit(99)
|
92
|
+
end
|
80
93
|
end
|
81
94
|
|
82
95
|
end
|
data/lib/semi/variable.rb
CHANGED
@@ -8,7 +8,7 @@ require 'semi/variables/url'
|
|
8
8
|
|
9
9
|
module Semi
|
10
10
|
|
11
|
-
class VariableError < RuntimeError; end
|
11
|
+
class VariableError < RuntimeError; end
|
12
12
|
|
13
13
|
module Variable
|
14
14
|
|
@@ -27,7 +27,7 @@ module Semi
|
|
27
27
|
return @@var_types[hints[0]].new(val)
|
28
28
|
end
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
# look for the obsure patterns before returning a string var
|
32
32
|
case
|
33
33
|
when Semi::Variables::Url::validate(val)
|
@@ -55,7 +55,7 @@ module Semi
|
|
55
55
|
unless ['Semi::Variables::String', 'String'].include? val.class.to_s
|
56
56
|
return val
|
57
57
|
end
|
58
|
-
|
58
|
+
|
59
59
|
check = true
|
60
60
|
while check
|
61
61
|
# Look for simple variable expansion
|
@@ -68,7 +68,7 @@ module Semi
|
|
68
68
|
check = false
|
69
69
|
end
|
70
70
|
end
|
71
|
-
|
71
|
+
|
72
72
|
return val
|
73
73
|
end
|
74
74
|
|
data/lib/semi/variables/base.rb
CHANGED
data/lib/semi/variables/path.rb
CHANGED
@@ -17,7 +17,7 @@ module Semi::Variables
|
|
17
17
|
def validate
|
18
18
|
self.validate(@value)
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
def self.validate(value)
|
22
22
|
if ['String', 'Semi::Variables::Path'].include? value.class.to_s
|
23
23
|
if @@path_re.match(value.to_s)
|
@@ -28,10 +28,10 @@ module Semi::Variables
|
|
28
28
|
end
|
29
29
|
false
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
# provide a simple scoring method to assist in identifying
|
33
33
|
# a string as a path. 0.0 is a pure string with no path
|
34
|
-
# markers,
|
34
|
+
# markers,
|
35
35
|
def self.path_score(path)
|
36
36
|
return 0.0 if path.empty?
|
37
37
|
|
@@ -41,17 +41,17 @@ module Semi::Variables
|
|
41
41
|
#puts "#{path} m/p/s = #{metach}/#{plen}/#{1.0 - (((plen - metach) * 1.0) / (plen + metach))}"
|
42
42
|
1.0 - (((plen - metach)*1.0) / (plen + metach))
|
43
43
|
end
|
44
|
-
|
44
|
+
|
45
45
|
def path
|
46
46
|
match = @@path_re.match(@value)
|
47
|
-
if match
|
47
|
+
if match
|
48
48
|
match['path']
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
52
|
def file
|
53
53
|
match = @@path_re.match(@value)
|
54
|
-
if match
|
54
|
+
if match
|
55
55
|
match['file']
|
56
56
|
end
|
57
57
|
end
|
data/lib/semi/variables/url.rb
CHANGED
@@ -29,42 +29,42 @@ module Semi::Variables
|
|
29
29
|
|
30
30
|
def proto
|
31
31
|
match = @@url_re.match(@value)
|
32
|
-
if match
|
32
|
+
if match
|
33
33
|
match['proto']
|
34
34
|
end
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
def host
|
38
38
|
match = @@url_re.match(@value)
|
39
|
-
if match
|
39
|
+
if match
|
40
40
|
match['host']
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
44
|
def port
|
45
45
|
match = @@url_re.match(@value)
|
46
|
-
if match
|
46
|
+
if match
|
47
47
|
match['port']
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
51
|
def path
|
52
52
|
match = @@url_re.match(@value)
|
53
|
-
if match
|
53
|
+
if match
|
54
54
|
match['path']
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
58
|
def file
|
59
59
|
match = @@url_re.match(@value)
|
60
|
-
if match
|
60
|
+
if match
|
61
61
|
match['file']
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
65
|
def params
|
66
66
|
match = @@url_re.match(@value)
|
67
|
-
if match
|
67
|
+
if match
|
68
68
|
match['params']
|
69
69
|
end
|
70
70
|
end
|
data/lib/semi/version.rb
CHANGED