fig 0.1.73 → 0.1.75

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. data/Changes +75 -0
  2. data/lib/fig.rb +1 -1
  3. data/lib/fig/command.rb +36 -12
  4. data/lib/fig/command/action.rb +1 -1
  5. data/lib/fig/command/action/dump_package_definition_parsed.rb +4 -6
  6. data/lib/fig/command/action/run_command_statement.rb +3 -2
  7. data/lib/fig/command/options.rb +12 -3
  8. data/lib/fig/command/options/parser.rb +2 -0
  9. data/lib/fig/command/package_loader.rb +1 -0
  10. data/lib/fig/config_file_error.rb +1 -1
  11. data/lib/fig/grammar/base.rb +214 -0
  12. data/lib/fig/grammar/base.treetop +29 -0
  13. data/lib/fig/grammar/v0.rb +1493 -0
  14. data/lib/fig/grammar/v0.treetop +167 -0
  15. data/lib/fig/grammar/v1.rb +1478 -0
  16. data/lib/fig/grammar/v1.treetop +174 -0
  17. data/lib/fig/grammar/version.rb +144 -0
  18. data/lib/fig/grammar/version.treetop +22 -0
  19. data/lib/fig/grammar/version_identification.rb +113 -0
  20. data/lib/fig/grammar/version_identification.treetop +27 -0
  21. data/lib/fig/log4r_config_error.rb +1 -1
  22. data/lib/fig/no_such_package_config_error.rb +1 -1
  23. data/lib/fig/not_found_error.rb +7 -0
  24. data/lib/fig/operating_system.rb +31 -20
  25. data/lib/fig/package.rb +8 -3
  26. data/lib/fig/package_definition_text_assembler.rb +88 -0
  27. data/lib/fig/package_descriptor_parse_error.rb +1 -1
  28. data/lib/fig/parser.rb +115 -29
  29. data/lib/fig/parser_package_build_state.rb +38 -11
  30. data/lib/fig/repository.rb +5 -8
  31. data/lib/fig/repository_package_publisher.rb +114 -96
  32. data/lib/fig/runtime_environment.rb +42 -14
  33. data/lib/fig/statement.rb +133 -0
  34. data/lib/fig/statement/archive.rb +6 -4
  35. data/lib/fig/statement/asset.rb +28 -34
  36. data/lib/fig/statement/command.rb +6 -2
  37. data/lib/fig/statement/configuration.rb +4 -12
  38. data/lib/fig/statement/grammar_version.rb +22 -0
  39. data/lib/fig/statement/include.rb +5 -6
  40. data/lib/fig/statement/override.rb +6 -3
  41. data/lib/fig/statement/path.rb +12 -2
  42. data/lib/fig/statement/resource.rb +8 -8
  43. data/lib/fig/statement/retrieve.rb +11 -3
  44. data/lib/fig/statement/set.rb +12 -2
  45. data/lib/fig/unparser.rb +127 -0
  46. data/lib/fig/unparser/v0.rb +84 -0
  47. data/lib/fig/unparser/v1.rb +77 -0
  48. data/lib/fig/url.rb +7 -0
  49. metadata +139 -25
  50. data/lib/fig/grammar.treetop +0 -147
@@ -0,0 +1,174 @@
1
+ # Treetop (http://treetop.rubyforge.org/) grammar for package definitions in v1
2
+ # format.
3
+
4
+ # Some aspects of this grammar are significantly dumber than they could be
5
+ # because:
6
+ #
7
+ # * We want to treat statements as identically as possible to their
8
+ # command-line equivalents.
9
+ # * Treetop parse errors are pretty inscrutable at times and we can make
10
+ # error messages clearer by validating a lot of the terminals ourselves.
11
+
12
+ require 'treetop'
13
+
14
+ require 'fig/grammar/base'
15
+ require 'fig/grammar/version'
16
+
17
+ module Fig
18
+ module Grammar
19
+ grammar V1
20
+ include Fig::Grammar::Base
21
+ include Fig::Grammar::Version
22
+
23
+ rule package
24
+ optional_ws_or_comment grammar_version:grammar_version? statements:(package_statement_with_ws*) optional_ws_or_comment {
25
+ def to_package(directory, build_state)
26
+ return build_state.new_package_statement(
27
+ directory, grammar_version, statements
28
+ )
29
+ end
30
+ }
31
+ end
32
+
33
+ # Shim between "package" and "package_statement" rules to allow the
34
+ # compiled v0 and v1 grammars to have the same interface.
35
+ rule package_statement_with_ws
36
+ package_statement:package_statement ws_or_comment+ {
37
+ def to_package_statement(build_state)
38
+ return package_statement.to_package_statement(build_state)
39
+ end
40
+ }
41
+ end
42
+
43
+ rule package_statement
44
+ archive / resource / retrieve / config
45
+ end
46
+
47
+ rule archive
48
+ statement_start:'archive' ws_or_comment+ url:asset_url {
49
+ def to_package_statement(build_state)
50
+ return build_state.new_asset_statement(
51
+ Statement::Archive, statement_start, url
52
+ )
53
+ end
54
+ }
55
+ end
56
+
57
+ rule resource
58
+ statement_start:'resource' ws_or_comment+ url:asset_url {
59
+ def to_package_statement(build_state)
60
+ return build_state.new_asset_statement(
61
+ Statement::Resource, statement_start, url
62
+ )
63
+ end
64
+ }
65
+ end
66
+
67
+ rule asset_url
68
+ '"' [^"]* '"' /
69
+ "'" [^']* "'" /
70
+ [\S]+
71
+ end
72
+
73
+ rule retrieve
74
+ statement_start:'retrieve' ws_or_comment+ var:environment_variable_name '->' path:retrieve_path {
75
+ def to_package_statement(build_state)
76
+ return build_state.new_retrieve_statement(statement_start, var, path)
77
+ end
78
+ }
79
+ end
80
+
81
+ rule retrieve_path
82
+ [a-zA-Z0-9_/.\[\]-]+
83
+ end
84
+
85
+ rule config
86
+ statement_start:'config' ws_or_comment+ config_name ws_or_comment+ statements:config_statement_with_ws* 'end' {
87
+ def to_package_statement(build_state)
88
+ return build_state.new_configuration_statement(
89
+ statement_start, config_name, statements
90
+ )
91
+ end
92
+ }
93
+ end
94
+
95
+ rule config_name
96
+ [a-zA-Z0-9_.-]+
97
+ end
98
+
99
+ # Shim between "config" and "config_statement" rules to allow the
100
+ # compiled v0 and v1 grammars to have the same interface.
101
+ rule config_statement_with_ws
102
+ config_statement:config_statement ws_or_comment+ {
103
+ def to_config_statement(build_state)
104
+ return config_statement.to_config_statement(build_state)
105
+ end
106
+ }
107
+ end
108
+
109
+ rule config_statement
110
+ override / include / command / path / set
111
+ end
112
+
113
+ rule include
114
+ statement_start:'include' ws_or_comment+ descriptor_string {
115
+ def to_config_statement(build_state)
116
+ return build_state.new_include_statement(
117
+ statement_start, descriptor_string
118
+ )
119
+ end
120
+ }
121
+ end
122
+
123
+ rule override
124
+ statement_start:'override' ws_or_comment+ descriptor_string {
125
+ def to_config_statement(build_state)
126
+ return build_state.new_override_statement(
127
+ statement_start, descriptor_string
128
+ )
129
+ end
130
+ }
131
+ end
132
+
133
+ rule path
134
+ statement_start:('add' / 'append' / 'path') ws_or_comment+ name_value:[\S]+ {
135
+ def to_config_statement(build_state)
136
+ return build_state.new_environment_variable_statement(
137
+ Statement::Path, statement_start, name_value
138
+ )
139
+ end
140
+ }
141
+ end
142
+
143
+ rule environment_variable_name
144
+ [a-zA-Z0-9_]+
145
+ end
146
+
147
+ rule set
148
+ statement_start:'set' ws_or_comment+ name_value:[\S]+ {
149
+ def to_config_statement(build_state)
150
+ return build_state.new_environment_variable_statement(
151
+ Statement::Set, statement_start, name_value
152
+ )
153
+ end
154
+ }
155
+ end
156
+
157
+ rule command
158
+ statement_start:'command' ws_or_comment+ string {
159
+ def to_config_statement(build_state)
160
+ return build_state.new_command_statement(statement_start, string)
161
+ end
162
+ }
163
+ end
164
+
165
+ rule string
166
+ '"' value:[^"]* '"'
167
+ end
168
+
169
+ rule descriptor_string
170
+ [\S]+
171
+ end
172
+ end
173
+ end
174
+ end
@@ -0,0 +1,144 @@
1
+ # Autogenerated from a Treetop grammar. Edits may be lost.
2
+
3
+
4
+ # Treetop (http://treetop.rubyforge.org/) grammar for statement for declaring
5
+ # package definition versions.
6
+ #
7
+ # Needs to be mixed in with Fig::Grammar::Base.
8
+
9
+ require 'treetop'
10
+
11
+ module Fig
12
+ module Grammar
13
+ module Version
14
+ include Treetop::Runtime
15
+
16
+ def root
17
+ @root ||= :grammar_version
18
+ end
19
+
20
+ module GrammarVersion0
21
+ def statement_start
22
+ elements[0]
23
+ end
24
+
25
+ def version
26
+ elements[3]
27
+ end
28
+
29
+ end
30
+
31
+ module GrammarVersion1
32
+ def to_package_statement(build_state)
33
+ return build_state.new_grammar_version_statement(
34
+ statement_start, version
35
+ )
36
+ end
37
+ end
38
+
39
+ def _nt_grammar_version
40
+ start_index = index
41
+ if node_cache[:grammar_version].has_key?(index)
42
+ cached = node_cache[:grammar_version][index]
43
+ if cached
44
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
45
+ @index = cached.interval.end
46
+ end
47
+ return cached
48
+ end
49
+
50
+ i0, s0 = index, []
51
+ if has_terminal?('grammar', false, index)
52
+ r1 = instantiate_node(SyntaxNode,input, index...(index + 7))
53
+ @index += 7
54
+ else
55
+ terminal_parse_failure('grammar')
56
+ r1 = nil
57
+ end
58
+ s0 << r1
59
+ if r1
60
+ s2, i2 = [], index
61
+ loop do
62
+ r3 = _nt_ws_or_comment
63
+ if r3
64
+ s2 << r3
65
+ else
66
+ break
67
+ end
68
+ end
69
+ if s2.empty?
70
+ @index = i2
71
+ r2 = nil
72
+ else
73
+ r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
74
+ end
75
+ s0 << r2
76
+ if r2
77
+ if has_terminal?('v', false, index)
78
+ r4 = instantiate_node(SyntaxNode,input, index...(index + 1))
79
+ @index += 1
80
+ else
81
+ terminal_parse_failure('v')
82
+ r4 = nil
83
+ end
84
+ s0 << r4
85
+ if r4
86
+ s5, i5 = [], index
87
+ loop do
88
+ if has_terminal?('\G[\\d]', true, index)
89
+ r6 = true
90
+ @index += 1
91
+ else
92
+ r6 = nil
93
+ end
94
+ if r6
95
+ s5 << r6
96
+ else
97
+ break
98
+ end
99
+ end
100
+ if s5.empty?
101
+ @index = i5
102
+ r5 = nil
103
+ else
104
+ r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
105
+ end
106
+ s0 << r5
107
+ if r5
108
+ s7, i7 = [], index
109
+ loop do
110
+ r8 = _nt_ws
111
+ if r8
112
+ s7 << r8
113
+ else
114
+ break
115
+ end
116
+ end
117
+ r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
118
+ s0 << r7
119
+ end
120
+ end
121
+ end
122
+ end
123
+ if s0.last
124
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
125
+ r0.extend(GrammarVersion0)
126
+ r0.extend(GrammarVersion1)
127
+ else
128
+ @index = i0
129
+ r0 = nil
130
+ end
131
+
132
+ node_cache[:grammar_version][start_index] = r0
133
+
134
+ r0
135
+ end
136
+
137
+ end
138
+
139
+ class VersionParser < Treetop::Runtime::CompiledParser
140
+ include Version
141
+ end
142
+
143
+ end
144
+ end
@@ -0,0 +1,22 @@
1
+ # Treetop (http://treetop.rubyforge.org/) grammar for statement for declaring
2
+ # package definition versions.
3
+ #
4
+ # Needs to be mixed in with Fig::Grammar::Base.
5
+
6
+ require 'treetop'
7
+
8
+ module Fig
9
+ module Grammar
10
+ grammar Version
11
+ rule grammar_version
12
+ statement_start:'grammar' ws_or_comment+ 'v' version:[\d]+ ws* {
13
+ def to_package_statement(build_state)
14
+ return build_state.new_grammar_version_statement(
15
+ statement_start, version
16
+ )
17
+ end
18
+ }
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,113 @@
1
+ # Autogenerated from a Treetop grammar. Edits may be lost.
2
+
3
+
4
+ # Treetop (http://treetop.rubyforge.org/) grammar for determining package
5
+ # definition versions.
6
+
7
+ require 'treetop'
8
+
9
+ require 'fig/grammar/base'
10
+ require 'fig/grammar/version'
11
+
12
+ module Fig
13
+ module Grammar
14
+ module VersionIdentification
15
+ include Treetop::Runtime
16
+
17
+ def root
18
+ @root ||= :everything
19
+ end
20
+
21
+ include Fig::Grammar::Base
22
+
23
+ include Fig::Grammar::Version
24
+
25
+ module Everything0
26
+ def grammar_version
27
+ elements[1]
28
+ end
29
+
30
+ end
31
+
32
+ module Everything1
33
+ def get_grammar_version(build_state)
34
+ return if not grammar_version
35
+ return if grammar_version.text_value.empty?
36
+
37
+ return grammar_version.to_package_statement(build_state)
38
+ end
39
+ end
40
+
41
+ def _nt_everything
42
+ start_index = index
43
+ if node_cache[:everything].has_key?(index)
44
+ cached = node_cache[:everything][index]
45
+ if cached
46
+ cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
47
+ @index = cached.interval.end
48
+ end
49
+ return cached
50
+ end
51
+
52
+ i0, s0 = index, []
53
+ s1, i1 = [], index
54
+ loop do
55
+ r2 = _nt_ws_or_comment
56
+ if r2
57
+ s1 << r2
58
+ else
59
+ break
60
+ end
61
+ end
62
+ r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
63
+ s0 << r1
64
+ if r1
65
+ r4 = _nt_grammar_version
66
+ if r4
67
+ r3 = r4
68
+ else
69
+ r3 = instantiate_node(SyntaxNode,input, index...index)
70
+ end
71
+ s0 << r3
72
+ if r3
73
+ s5, i5 = [], index
74
+ loop do
75
+ if index < input_length
76
+ r6 = instantiate_node(SyntaxNode,input, index...(index + 1))
77
+ @index += 1
78
+ else
79
+ terminal_parse_failure("any character")
80
+ r6 = nil
81
+ end
82
+ if r6
83
+ s5 << r6
84
+ else
85
+ break
86
+ end
87
+ end
88
+ r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
89
+ s0 << r5
90
+ end
91
+ end
92
+ if s0.last
93
+ r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
94
+ r0.extend(Everything0)
95
+ r0.extend(Everything1)
96
+ else
97
+ @index = i0
98
+ r0 = nil
99
+ end
100
+
101
+ node_cache[:everything][start_index] = r0
102
+
103
+ r0
104
+ end
105
+
106
+ end
107
+
108
+ class VersionIdentificationParser < Treetop::Runtime::CompiledParser
109
+ include VersionIdentification
110
+ end
111
+
112
+ end
113
+ end