fig 0.1.73 → 0.1.75
Sign up to get free protection for your applications and to get access to all the features.
- data/Changes +75 -0
- data/lib/fig.rb +1 -1
- data/lib/fig/command.rb +36 -12
- data/lib/fig/command/action.rb +1 -1
- data/lib/fig/command/action/dump_package_definition_parsed.rb +4 -6
- data/lib/fig/command/action/run_command_statement.rb +3 -2
- data/lib/fig/command/options.rb +12 -3
- data/lib/fig/command/options/parser.rb +2 -0
- data/lib/fig/command/package_loader.rb +1 -0
- data/lib/fig/config_file_error.rb +1 -1
- data/lib/fig/grammar/base.rb +214 -0
- data/lib/fig/grammar/base.treetop +29 -0
- data/lib/fig/grammar/v0.rb +1493 -0
- data/lib/fig/grammar/v0.treetop +167 -0
- data/lib/fig/grammar/v1.rb +1478 -0
- data/lib/fig/grammar/v1.treetop +174 -0
- data/lib/fig/grammar/version.rb +144 -0
- data/lib/fig/grammar/version.treetop +22 -0
- data/lib/fig/grammar/version_identification.rb +113 -0
- data/lib/fig/grammar/version_identification.treetop +27 -0
- data/lib/fig/log4r_config_error.rb +1 -1
- data/lib/fig/no_such_package_config_error.rb +1 -1
- data/lib/fig/not_found_error.rb +7 -0
- data/lib/fig/operating_system.rb +31 -20
- data/lib/fig/package.rb +8 -3
- data/lib/fig/package_definition_text_assembler.rb +88 -0
- data/lib/fig/package_descriptor_parse_error.rb +1 -1
- data/lib/fig/parser.rb +115 -29
- data/lib/fig/parser_package_build_state.rb +38 -11
- data/lib/fig/repository.rb +5 -8
- data/lib/fig/repository_package_publisher.rb +114 -96
- data/lib/fig/runtime_environment.rb +42 -14
- data/lib/fig/statement.rb +133 -0
- data/lib/fig/statement/archive.rb +6 -4
- data/lib/fig/statement/asset.rb +28 -34
- data/lib/fig/statement/command.rb +6 -2
- data/lib/fig/statement/configuration.rb +4 -12
- data/lib/fig/statement/grammar_version.rb +22 -0
- data/lib/fig/statement/include.rb +5 -6
- data/lib/fig/statement/override.rb +6 -3
- data/lib/fig/statement/path.rb +12 -2
- data/lib/fig/statement/resource.rb +8 -8
- data/lib/fig/statement/retrieve.rb +11 -3
- data/lib/fig/statement/set.rb +12 -2
- data/lib/fig/unparser.rb +127 -0
- data/lib/fig/unparser/v0.rb +84 -0
- data/lib/fig/unparser/v1.rb +77 -0
- data/lib/fig/url.rb +7 -0
- metadata +139 -25
- data/lib/fig/grammar.treetop +0 -147
@@ -62,13 +62,12 @@ class Fig::Statement::Include < Fig::Statement
|
|
62
62
|
)
|
63
63
|
end
|
64
64
|
|
65
|
-
def
|
66
|
-
|
67
|
-
|
68
|
-
text += "/#{version()}" if version()
|
69
|
-
text += ":#{config_name()}" if config_name()
|
65
|
+
def unparse_as_version(unparser)
|
66
|
+
return unparser.include(self)
|
67
|
+
end
|
70
68
|
|
71
|
-
|
69
|
+
def minimum_grammar_version_required()
|
70
|
+
return 0
|
72
71
|
end
|
73
72
|
|
74
73
|
private
|
@@ -33,8 +33,11 @@ class Fig::Statement::Override < Fig::Statement
|
|
33
33
|
@version = version
|
34
34
|
end
|
35
35
|
|
36
|
-
def
|
37
|
-
return
|
38
|
-
|
36
|
+
def unparse_as_version(unparser)
|
37
|
+
return unparser.override(self)
|
38
|
+
end
|
39
|
+
|
40
|
+
def minimum_grammar_version_required()
|
41
|
+
return 0
|
39
42
|
end
|
40
43
|
end
|
data/lib/fig/statement/path.rb
CHANGED
@@ -36,7 +36,17 @@ class Fig::Statement::Path < Fig::Statement
|
|
36
36
|
@value = value
|
37
37
|
end
|
38
38
|
|
39
|
-
def
|
40
|
-
|
39
|
+
def is_environment_variable?()
|
40
|
+
return true
|
41
|
+
end
|
42
|
+
|
43
|
+
def unparse_as_version(unparser)
|
44
|
+
return unparser.path(self)
|
45
|
+
end
|
46
|
+
|
47
|
+
def minimum_grammar_version_required()
|
48
|
+
# TODO: fix this once going through
|
49
|
+
# Statement.strip_quotes_and_process_escapes()
|
50
|
+
return 0
|
41
51
|
end
|
42
52
|
end
|
@@ -1,8 +1,9 @@
|
|
1
|
-
require 'fig/repository'
|
2
1
|
require 'fig/statement'
|
3
2
|
require 'fig/statement/asset'
|
3
|
+
require 'fig/url'
|
4
4
|
|
5
5
|
module Fig; end
|
6
|
+
class Fig::Statement; end
|
6
7
|
|
7
8
|
# Specifies a file (possibly via a URL) that is part of the current package.
|
8
9
|
#
|
@@ -10,16 +11,15 @@ module Fig; end
|
|
10
11
|
class Fig::Statement::Resource < Fig::Statement
|
11
12
|
include Fig::Statement::Asset
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
def initialize(line_column, source_description, url)
|
14
|
+
def initialize(line_column, source_description, url, glob_if_not_url)
|
16
15
|
super(line_column, source_description)
|
17
16
|
|
18
|
-
|
17
|
+
@url = url
|
18
|
+
@glob_if_not_url = glob_if_not_url
|
19
19
|
end
|
20
20
|
|
21
21
|
def asset_name()
|
22
|
-
if Fig::
|
22
|
+
if Fig::URL.is_url?(url())
|
23
23
|
return standard_asset_name()
|
24
24
|
end
|
25
25
|
|
@@ -28,7 +28,7 @@ class Fig::Statement::Resource < Fig::Statement
|
|
28
28
|
return nil
|
29
29
|
end
|
30
30
|
|
31
|
-
def
|
32
|
-
|
31
|
+
def unparse_as_version(unparser)
|
32
|
+
return unparser.resource(self)
|
33
33
|
end
|
34
34
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'fig/logging'
|
2
|
+
require 'fig/operating_system'
|
2
3
|
require 'fig/statement'
|
3
4
|
|
4
5
|
module Fig; end
|
@@ -16,7 +17,10 @@ class Fig::Statement::Retrieve < Fig::Statement
|
|
16
17
|
|
17
18
|
# Yeah, it's not cross-platform, but File doesn't have an #absolute? method
|
18
19
|
# and this is better than nothing.
|
19
|
-
if
|
20
|
+
if (
|
21
|
+
path =~ %r< ^ [\\/] >x \
|
22
|
+
|| Fig::OperatingSystem.windows? && path =~ %r< ^ [a-z] : >xi
|
23
|
+
)
|
20
24
|
Fig::Logging.warn(
|
21
25
|
%Q<The retrieve path "#{path}"#{position_string()} looks like it is intended to be absolute; retrieve paths are always treated as relative.>
|
22
26
|
)
|
@@ -43,7 +47,11 @@ class Fig::Statement::Retrieve < Fig::Statement
|
|
43
47
|
@referenced = yea_or_nay
|
44
48
|
end
|
45
49
|
|
46
|
-
def
|
47
|
-
|
50
|
+
def unparse_as_version(unparser)
|
51
|
+
return unparser.retrieve(self)
|
52
|
+
end
|
53
|
+
|
54
|
+
def minimum_grammar_version_required()
|
55
|
+
return 0
|
48
56
|
end
|
49
57
|
end
|
data/lib/fig/statement/set.rb
CHANGED
@@ -35,7 +35,17 @@ class Fig::Statement::Set < Fig::Statement
|
|
35
35
|
@value = value
|
36
36
|
end
|
37
37
|
|
38
|
-
def
|
39
|
-
|
38
|
+
def is_environment_variable?()
|
39
|
+
return true
|
40
|
+
end
|
41
|
+
|
42
|
+
def unparse_as_version(unparser)
|
43
|
+
return unparser.set(self)
|
44
|
+
end
|
45
|
+
|
46
|
+
def minimum_grammar_version_required()
|
47
|
+
# TODO: fix this once going through
|
48
|
+
# Statement.strip_quotes_and_process_escapes()
|
49
|
+
return 0
|
40
50
|
end
|
41
51
|
end
|
data/lib/fig/unparser.rb
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
module Fig; end
|
2
|
+
|
3
|
+
module Fig::Unparser
|
4
|
+
def unparse(statements)
|
5
|
+
@text = ''
|
6
|
+
@indent_level = @initial_indent_level
|
7
|
+
|
8
|
+
statements.each { |statement| statement.unparse_as_version(self) }
|
9
|
+
|
10
|
+
text = @text
|
11
|
+
@text = nil
|
12
|
+
@indent_level = nil
|
13
|
+
|
14
|
+
return text
|
15
|
+
end
|
16
|
+
|
17
|
+
def archive(statement)
|
18
|
+
asset 'archive', statement
|
19
|
+
|
20
|
+
return
|
21
|
+
end
|
22
|
+
|
23
|
+
def command(statement)
|
24
|
+
raise NotImplementedError
|
25
|
+
end
|
26
|
+
|
27
|
+
def configuration(configuration_statement)
|
28
|
+
if ! @text.empty?
|
29
|
+
@text << "\n"
|
30
|
+
end
|
31
|
+
|
32
|
+
add_indent
|
33
|
+
@text << 'config '
|
34
|
+
@text << configuration_statement.name
|
35
|
+
@text << "\n"
|
36
|
+
|
37
|
+
@indent_level += 1
|
38
|
+
begin
|
39
|
+
configuration_statement.statements.each do
|
40
|
+
|statement|
|
41
|
+
|
42
|
+
statement.unparse_as_version(self)
|
43
|
+
end
|
44
|
+
ensure
|
45
|
+
@indent_level -= 1
|
46
|
+
end
|
47
|
+
|
48
|
+
add_indent
|
49
|
+
@text << "end\n"
|
50
|
+
|
51
|
+
return
|
52
|
+
end
|
53
|
+
|
54
|
+
def grammar_version(statement)
|
55
|
+
raise NotImplementedError
|
56
|
+
end
|
57
|
+
|
58
|
+
def include(statement)
|
59
|
+
add_indent
|
60
|
+
|
61
|
+
@text << 'include '
|
62
|
+
@text << Fig::PackageDescriptor.format(
|
63
|
+
statement.package_name, statement.version, statement.config_name
|
64
|
+
)
|
65
|
+
@text << "\n"
|
66
|
+
|
67
|
+
return
|
68
|
+
end
|
69
|
+
|
70
|
+
def override(statement)
|
71
|
+
add_indent
|
72
|
+
|
73
|
+
@text << 'override '
|
74
|
+
@text << Fig::PackageDescriptor.format(
|
75
|
+
statement.package_name, statement.version, nil
|
76
|
+
)
|
77
|
+
@text << "\n"
|
78
|
+
|
79
|
+
return
|
80
|
+
end
|
81
|
+
|
82
|
+
def path(statement)
|
83
|
+
environment_variable(statement, 'append')
|
84
|
+
|
85
|
+
return
|
86
|
+
end
|
87
|
+
|
88
|
+
def resource(statement)
|
89
|
+
asset 'resource', statement
|
90
|
+
|
91
|
+
return
|
92
|
+
end
|
93
|
+
|
94
|
+
def retrieve(statement)
|
95
|
+
raise NotImplementedError
|
96
|
+
end
|
97
|
+
|
98
|
+
def set(statement)
|
99
|
+
environment_variable(statement, 'set')
|
100
|
+
|
101
|
+
return
|
102
|
+
end
|
103
|
+
|
104
|
+
private
|
105
|
+
|
106
|
+
def asset(keyword, statement)
|
107
|
+
raise NotImplementedError
|
108
|
+
end
|
109
|
+
|
110
|
+
def asset_path(statement)
|
111
|
+
if @emit_as_input_or_to_be_published_values == :emit_as_input
|
112
|
+
return statement.url
|
113
|
+
end
|
114
|
+
|
115
|
+
return statement.asset_name
|
116
|
+
end
|
117
|
+
|
118
|
+
def environment_variable(statement, keyword)
|
119
|
+
raise NotImplementedError
|
120
|
+
end
|
121
|
+
|
122
|
+
def add_indent()
|
123
|
+
@text << @indent_string * @indent_level
|
124
|
+
|
125
|
+
return
|
126
|
+
end
|
127
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require 'fig/package_descriptor'
|
2
|
+
require 'fig/unparser'
|
3
|
+
|
4
|
+
module Fig; end
|
5
|
+
module Fig::Unparser; end
|
6
|
+
|
7
|
+
# Handles serializing of statements in the v0 grammar.
|
8
|
+
class Fig::Unparser::V0
|
9
|
+
include Fig::Unparser
|
10
|
+
|
11
|
+
def initialize(
|
12
|
+
emit_as_input_or_to_be_published_values,
|
13
|
+
indent_string = ' ' * 2,
|
14
|
+
initial_indent_level = 0
|
15
|
+
)
|
16
|
+
@emit_as_input_or_to_be_published_values =
|
17
|
+
emit_as_input_or_to_be_published_values
|
18
|
+
@indent_string = indent_string
|
19
|
+
@initial_indent_level = initial_indent_level
|
20
|
+
|
21
|
+
return
|
22
|
+
end
|
23
|
+
|
24
|
+
def command(statement)
|
25
|
+
add_indent
|
26
|
+
|
27
|
+
@text << %q<command ">
|
28
|
+
@text << statement.command
|
29
|
+
@text << %Q<"\n>
|
30
|
+
|
31
|
+
return
|
32
|
+
end
|
33
|
+
|
34
|
+
def grammar_version(statement)
|
35
|
+
add_indent
|
36
|
+
|
37
|
+
# Comment out so that older clients don't have issues.
|
38
|
+
@text << "# grammar v0\n"
|
39
|
+
|
40
|
+
return
|
41
|
+
end
|
42
|
+
|
43
|
+
def retrieve(statement)
|
44
|
+
add_indent
|
45
|
+
|
46
|
+
@text << 'retrieve '
|
47
|
+
@text << statement.var
|
48
|
+
@text << '->'
|
49
|
+
@text << statement.path
|
50
|
+
@text << "\n"
|
51
|
+
|
52
|
+
return
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def asset(keyword, statement)
|
58
|
+
path = asset_path statement
|
59
|
+
quote = path =~ /[*?\[\]{}]/ ? '' : %q<">
|
60
|
+
|
61
|
+
add_indent
|
62
|
+
@text << keyword
|
63
|
+
@text << ' '
|
64
|
+
@text << quote
|
65
|
+
@text << path
|
66
|
+
@text << quote
|
67
|
+
@text << "\n"
|
68
|
+
|
69
|
+
return
|
70
|
+
end
|
71
|
+
|
72
|
+
def environment_variable(statement, keyword)
|
73
|
+
add_indent
|
74
|
+
|
75
|
+
@text << keyword
|
76
|
+
@text << ' '
|
77
|
+
@text << statement.name
|
78
|
+
@text << '='
|
79
|
+
@text << statement.value
|
80
|
+
@text << "\n"
|
81
|
+
|
82
|
+
return
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'fig/unparser'
|
2
|
+
|
3
|
+
module Fig; end
|
4
|
+
module Fig::Unparser; end
|
5
|
+
|
6
|
+
# Handles serializing of statements in the v1 grammar.
|
7
|
+
class Fig::Unparser::V1
|
8
|
+
include Fig::Unparser
|
9
|
+
|
10
|
+
def initialize(
|
11
|
+
emit_as_input_or_to_be_published_values,
|
12
|
+
indent_string = ' ' * 2,
|
13
|
+
initial_indent_level = 0
|
14
|
+
)
|
15
|
+
@emit_as_input_or_to_be_published_values =
|
16
|
+
emit_as_input_or_to_be_published_values
|
17
|
+
@indent_string = indent_string
|
18
|
+
@initial_indent_level = initial_indent_level
|
19
|
+
|
20
|
+
return
|
21
|
+
end
|
22
|
+
|
23
|
+
def command(statement)
|
24
|
+
add_indent
|
25
|
+
|
26
|
+
@text << %q<command ">
|
27
|
+
@text << statement.command
|
28
|
+
@text << %Q<"\n>
|
29
|
+
|
30
|
+
return
|
31
|
+
end
|
32
|
+
|
33
|
+
def grammar_version(statement)
|
34
|
+
add_indent
|
35
|
+
|
36
|
+
@text << "grammar v1\n"
|
37
|
+
|
38
|
+
return
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def asset(keyword, statement)
|
44
|
+
quote = %q<'>
|
45
|
+
path = asset_path statement
|
46
|
+
|
47
|
+
if statement.glob_if_not_url?
|
48
|
+
quote = %q<">
|
49
|
+
path = path.gsub(/\\/, ('\\' * 4))
|
50
|
+
end
|
51
|
+
|
52
|
+
add_indent
|
53
|
+
@text << keyword
|
54
|
+
@text << ' '
|
55
|
+
@text << quote
|
56
|
+
@text << path
|
57
|
+
@text << quote
|
58
|
+
@text << "\n"
|
59
|
+
|
60
|
+
return
|
61
|
+
end
|
62
|
+
|
63
|
+
def environment_variable(statement, keyword)
|
64
|
+
# TODO: temporarily hack v0 grammar in here so we can test asset
|
65
|
+
# statements; proper implementation once asset statements are done.
|
66
|
+
add_indent
|
67
|
+
|
68
|
+
@text << keyword
|
69
|
+
@text << ' '
|
70
|
+
@text << statement.name
|
71
|
+
@text << '='
|
72
|
+
@text << statement.value
|
73
|
+
@text << "\n"
|
74
|
+
|
75
|
+
return
|
76
|
+
end
|
77
|
+
end
|