fig 0.1.62 → 0.1.64

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.
Files changed (43) hide show
  1. data/Changes +156 -0
  2. data/VERSION +1 -1
  3. data/bin/fig +9 -2
  4. data/bin/fig-debug +9 -2
  5. data/lib/fig/applicationconfiguration.rb +3 -2
  6. data/lib/fig/atexit.rb +37 -0
  7. data/lib/fig/backtrace.rb +23 -6
  8. data/lib/fig/command.rb +131 -31
  9. data/lib/fig/command/coveragesupport.rb +40 -0
  10. data/lib/fig/command/listing.rb +8 -8
  11. data/lib/fig/command/optionerror.rb +8 -0
  12. data/lib/fig/{options.rb → command/options.rb} +248 -144
  13. data/lib/fig/command/packageload.rb +161 -62
  14. data/lib/fig/configfileerror.rb +2 -0
  15. data/lib/fig/environment.rb +350 -246
  16. data/lib/fig/environmentvariables/casesensitive.rb +1 -1
  17. data/lib/fig/figrc.rb +78 -78
  18. data/lib/fig/grammar.treetop +204 -219
  19. data/lib/fig/log4rconfigerror.rb +2 -0
  20. data/lib/fig/operatingsystem.rb +382 -334
  21. data/lib/fig/package.rb +11 -33
  22. data/lib/fig/packagecache.rb +1 -1
  23. data/lib/fig/packagedescriptor.rb +103 -21
  24. data/lib/fig/packagedescriptorparseerror.rb +16 -0
  25. data/lib/fig/parser.rb +36 -19
  26. data/lib/fig/parserpackagebuildstate.rb +56 -0
  27. data/lib/fig/repository.rb +504 -259
  28. data/lib/fig/statement.rb +30 -12
  29. data/lib/fig/statement/archive.rb +8 -5
  30. data/lib/fig/statement/asset.rb +19 -0
  31. data/lib/fig/statement/command.rb +2 -2
  32. data/lib/fig/statement/configuration.rb +20 -20
  33. data/lib/fig/statement/include.rb +13 -34
  34. data/lib/fig/statement/override.rb +21 -7
  35. data/lib/fig/statement/path.rb +22 -2
  36. data/lib/fig/statement/resource.rb +14 -4
  37. data/lib/fig/statement/retrieve.rb +34 -4
  38. data/lib/fig/statement/set.rb +22 -2
  39. data/lib/fig/workingdirectorymaintainer.rb +197 -0
  40. data/lib/fig/workingdirectorymetadata.rb +45 -0
  41. metadata +52 -46
  42. data/lib/fig/retriever.rb +0 -141
  43. data/lib/fig/statement/publish.rb +0 -15
@@ -4,7 +4,7 @@ module Fig; end;
4
4
  module EnvironmentVariables; end
5
5
 
6
6
  # Manager of a set of environment variables where the variable names are
7
- # case-insensitive, e.g. on *nix.
7
+ # case-sensitive, e.g. on *nix.
8
8
  class Fig::EnvironmentVariables::CaseSensitive
9
9
  include Fig::EnvironmentVariables
10
10
 
@@ -5,105 +5,105 @@ require 'fig/configfileerror'
5
5
  require 'fig/operatingsystem'
6
6
  require 'fig/repository'
7
7
 
8
- module Fig
9
- # Parse multiple figrc files and assemble them into a single
10
- # ApplicationConfiguration object.
11
- class FigRC
12
- REPOSITORY_CONFIGURATION =
13
- "#{Repository::METADATA_SUBDIRECTORY}/figrc"
14
-
15
- def self.find(
16
- override_path, repository_url, login, fig_home, disable_figrc = false
8
+ module Fig; end
9
+
10
+ # Parse multiple figrc files and assemble them into a single
11
+ # ApplicationConfiguration object.
12
+ class Fig::FigRC
13
+ REPOSITORY_CONFIGURATION =
14
+ "#{Fig::Repository::METADATA_SUBDIRECTORY}/figrc"
15
+
16
+ def self.find(
17
+ override_path, repository_url, login, fig_home, disable_figrc = false
18
+ )
19
+ configuration = Fig::ApplicationConfiguration.new(repository_url)
20
+
21
+ handle_override_configuration(configuration, override_path)
22
+ handle_figrc(configuration) if not disable_figrc
23
+ handle_repository_configuration(
24
+ configuration, repository_url, login, fig_home
17
25
  )
18
- configuration = ApplicationConfiguration.new(repository_url)
19
26
 
20
- handle_override_configuration(configuration, override_path)
21
- handle_figrc(configuration) if not disable_figrc
22
- handle_repository_configuration(
23
- configuration, repository_url, login, fig_home
24
- )
27
+ return configuration
28
+ end
25
29
 
26
- return configuration
27
- end
30
+ private
28
31
 
29
- private
30
-
31
- def self.handle_override_configuration(configuration, override_path)
32
- begin
33
- if not override_path.nil?
34
- configuration.push_dataset(
35
- JSON.parse(File::open(override_path).read)
36
- )
37
- end
38
- rescue JSON::ParserError => exception
39
- translate_parse_error(exception, override_path)
32
+ def self.handle_override_configuration(configuration, override_path)
33
+ begin
34
+ if not override_path.nil?
35
+ configuration.push_dataset(
36
+ JSON.parse(File::open(override_path).read)
37
+ )
40
38
  end
41
-
42
- return
39
+ rescue JSON::ParserError => exception
40
+ translate_parse_error(exception, override_path)
43
41
  end
44
42
 
45
- def self.handle_figrc(configuration)
46
- user_figrc_path = File.expand_path('~/.figrc')
47
- return if not File.exists? user_figrc_path
43
+ return
44
+ end
48
45
 
49
- begin
50
- configuration.push_dataset(
51
- JSON.parse(File::open(user_figrc_path).read)
52
- )
53
- rescue JSON::ParserError => exception
54
- translate_parse_error(exception, user_figrc_path)
55
- end
46
+ def self.handle_figrc(configuration)
47
+ user_figrc_path = File.expand_path('~/.figrc')
48
+ return if not File.exists? user_figrc_path
56
49
 
57
- return
50
+ begin
51
+ configuration.push_dataset(
52
+ JSON.parse(File::open(user_figrc_path).read)
53
+ )
54
+ rescue JSON::ParserError => exception
55
+ translate_parse_error(exception, user_figrc_path)
58
56
  end
59
57
 
60
- def self.handle_repository_configuration(
61
- configuration, repository_url, login, fig_home
62
- )
63
- return if repository_url.nil?
58
+ return
59
+ end
64
60
 
65
- figrc_url = "#{repository_url}/#{REPOSITORY_CONFIGURATION}"
66
- repo_figrc_path =
67
- File.expand_path(File.join(fig_home, REPOSITORY_CONFIGURATION))
61
+ def self.handle_repository_configuration(
62
+ configuration, repository_url, login, fig_home
63
+ )
64
+ return if repository_url.nil?
68
65
 
69
- os = OperatingSystem.new(login)
66
+ figrc_url = "#{repository_url}/#{REPOSITORY_CONFIGURATION}"
67
+ repo_figrc_path =
68
+ File.expand_path(File.join(fig_home, REPOSITORY_CONFIGURATION))
70
69
 
71
- repo_config_exists = nil
72
- begin
73
- os.download( figrc_url, repo_figrc_path )
74
- repo_config_exists = true
75
- rescue NotFoundError => e
76
- repo_config_exists = false
77
- end
70
+ os = Fig::OperatingSystem.new(login)
78
71
 
79
- return configuration if not repo_config_exists
72
+ repo_config_exists = nil
73
+ begin
74
+ os.download( figrc_url, repo_figrc_path )
75
+ repo_config_exists = true
76
+ rescue Fig::NotFoundError => e
77
+ repo_config_exists = false
78
+ end
80
79
 
81
- begin
82
- configuration.push_dataset(
83
- JSON.parse(File.open(repo_figrc_path).read)
84
- )
85
- rescue JSON::ParserError => exception
86
- translate_parse_error(exception, figrc_url)
87
- end
80
+ return configuration if not repo_config_exists
88
81
 
89
- return
82
+ begin
83
+ configuration.push_dataset(
84
+ JSON.parse(File.open(repo_figrc_path).read)
85
+ )
86
+ rescue JSON::ParserError => exception
87
+ translate_parse_error(exception, figrc_url)
90
88
  end
91
89
 
92
- def self.translate_parse_error(json_parse_error, config_file_path)
93
- message = json_parse_error.message
94
- message.chomp!
90
+ return
91
+ end
95
92
 
96
- # JSON::ParserError tends to include final newline inside of single
97
- # quotes, which makes error messages ugly.
98
- message.sub!(/ \n+ ' \z /xm, %q<'>)
93
+ def self.translate_parse_error(json_parse_error, config_file_path)
94
+ message = json_parse_error.message
95
+ message.chomp!
99
96
 
100
- # Also, there's a useless source code line number in the message.
101
- message.sub!(/ \A \d+ : \s+ /xm, %q<>)
97
+ # JSON::ParserError tends to include final newline inside of single
98
+ # quotes, which makes error messages ugly.
99
+ message.sub!(/ \n+ ' \z /xm, %q<'>)
102
100
 
103
- raise ConfigFileError.new(
104
- "Parse issue with #{config_file_path}: #{message}",
105
- config_file_path
106
- )
107
- end
101
+ # Also, there's a useless source code line number in the message.
102
+ message.sub!(/ \A \d+ : \s+ /xm, %q<>)
103
+
104
+ raise Fig::ConfigFileError.new(
105
+ "Parse issue with #{config_file_path}: #{message}",
106
+ config_file_path
107
+ )
108
108
  end
109
109
  end
@@ -1,3 +1,5 @@
1
+ # Treetop (http://treetop.rubyforge.org/) grammar for package definitions.
2
+
1
3
  require 'fig/package'
2
4
  require 'fig/packagedescriptor'
3
5
  require 'fig/parser'
@@ -7,231 +9,214 @@ require 'fig/statement/configuration'
7
9
  require 'fig/statement/include'
8
10
  require 'fig/statement/override'
9
11
  require 'fig/statement/path'
10
- require 'fig/statement/publish'
11
12
  require 'fig/statement/resource'
12
13
  require 'fig/statement/retrieve'
13
14
  require 'fig/statement/set'
14
15
 
15
16
  module Fig
16
-
17
- grammar Fig
18
- rule package
19
- optional_ws statements:(package_statement*) optional_ws {
20
- def to_package(descriptor, directory)
21
- Package.new(
22
- descriptor.name,
23
- descriptor.version,
24
- directory,
25
- statements.elements.map do
26
- |statement|
27
- statement.to_package_statement(descriptor)
28
- end
29
- )
30
- end
31
- }
32
- end
33
-
34
- rule package_statement
35
- archive / resource / retrieve / config
36
- end
37
-
38
- rule archive
39
- statement_start:"archive" ws resource_url {
40
- def to_package_statement(descriptor)
41
- Statement::Archive.new(
42
- Parser.node_location(statement_start), resource_url.value.text_value
43
- )
44
- end
45
- }
46
- end
47
-
48
- rule resource
49
- statement_start:"resource" ws resource_url {
50
- def to_package_statement(descriptor)
51
- Statement::Resource.new(
52
- Parser.node_location(statement_start), resource_url.value.text_value
53
- )
54
- end
55
- }
56
- end
57
-
58
- rule retrieve
59
- statement_start:"retrieve" ws var:retrieve_variable_name "->" path:retrieve_path ws {
60
- def to_package_statement(descriptor)
61
- Statement::Retrieve.new(
62
- Parser.node_location(statement_start),
63
- var.text_value,
64
- path.text_value
65
- )
66
- end
67
- }
68
- end
69
-
70
- rule retrieve_variable_name
71
- [@a-zA-Z0-9/._]+
72
- end
73
-
74
- rule retrieve_path
75
- [a-zA-Z0-9_/.\[\]-]+
76
- end
77
-
78
- rule config
79
- statement_start:"config" ws config_name ws statements:config_statement* "end" ws {
80
- def to_package_statement(descriptor)
81
- Statement::Configuration.new(
82
- Parser.node_location(statement_start),
83
- config_name.text_value,
84
- statements.elements.map do
85
- |statement|
86
- statement.to_config_statement(descriptor)
87
- end
88
- )
89
- end
90
- }
91
- end
92
-
93
- rule config_statement
94
- include / command / path / set
95
- end
96
-
97
- rule include
98
- statement_start:"include" ws descriptor overrides:(override*) {
99
- def to_config_statement(containing_package_descriptor)
100
- Statement::Include.new(
101
- Parser.node_location(statement_start),
102
- PackageDescriptor.parse(descriptor.text_value.strip),
103
- overrides.elements.map{ |e| e.to_override },
104
- containing_package_descriptor
105
- )
106
- end
107
- }
108
- end
109
-
110
- rule override
111
- statement_start:"override" ws package_name "/" version_name ws {
112
- def to_override
113
- return Statement::Override.new(
114
- Parser.node_location(statement_start),
115
- package_name.text_value,
116
- version_name.text_value
117
- )
118
- end
119
- }
120
- end
121
-
122
- rule path
123
- statement_start:("append" / "path" / "add") ws name:environment_variable_name "=" value:path_value ws {
124
- def to_config_statement(descriptor)
125
- Statement::Path.new(
126
- Parser.node_location(statement_start),
127
- name.text_value,
128
- value.text_value
129
- )
130
- end
131
- }
132
- end
133
-
134
- rule environment_variable_name
135
- [a-zA-Z0-9_]+
136
- end
137
-
138
- rule path_value
139
- # Characters blocked in the value:
140
- # ;: - Windows/*nix path separators
141
- # "<>| - Characters not allowed in filenames on Windows
142
- # \s - Necessary for the "ws" token to work
143
- [^;:"<>|\s]+
144
- end
145
-
146
- rule set
147
- statement_start:"set" ws name:environment_variable_name "=" value:set_value ws {
148
- def to_config_statement(descriptor)
149
- Statement::Set.new(
150
- Parser.node_location(statement_start),
151
- name.text_value,
152
- value.text_value
153
- )
154
- end
155
- }
156
- end
157
-
158
- rule set_value
159
- [\S]*
160
- end
161
-
162
- rule command
163
- statement_start:"command" ws string {
164
- def to_config_statement(descriptor)
165
- Statement::Command.new(
166
- Parser.node_location(statement_start), string.value.text_value
167
- )
168
- end
169
- }
170
- end
171
-
172
- rule string
173
- '"' value:(!'"' . )* '"' ws
174
- end
175
-
176
- rule descriptor
177
- ((package:package_name ("/" version:version_name)? (":" config:config_name)? ws) /
178
- (":" config:config_name ws)) {
179
- def get_version
180
- elements.each do |element|
181
- if element.respond_to?(:version)
182
- return element.version.text_value
183
- end
17
+ grammar Fig
18
+ rule package
19
+ optional_ws statements:(package_statement*) optional_ws {
20
+ def to_package(directory, build_state)
21
+ Package.new(
22
+ build_state.descriptor.name,
23
+ build_state.descriptor.version,
24
+ directory,
25
+ statements.elements.map do
26
+ |statement|
27
+ statement.to_package_statement(build_state)
28
+ end
29
+ )
184
30
  end
185
- nil
186
- end
187
- def get_config
188
- return self.config.text_value if self.respond_to?(:config)
189
- elements.each do |element|
190
- if element.respond_to?(:config)
191
- return element.config.text_value
192
- end
31
+ }
32
+ end
33
+
34
+ rule package_statement
35
+ archive / resource / retrieve / config
36
+ end
37
+
38
+ rule archive
39
+ statement_start:"archive" ws resource_url {
40
+ def to_package_statement(build_state)
41
+ Statement::Archive.new(
42
+ build_state.node_location(statement_start),
43
+ build_state.source_description,
44
+ resource_url.value.text_value
45
+ )
193
46
  end
194
- nil
195
- end
196
- }
197
- end
198
-
199
- rule package_name
200
- [a-zA-Z0-9_.-]+
201
- end
202
-
203
- rule version_name
204
- [a-zA-Z0-9_.-]+
205
- end
206
-
207
- rule config_name
208
- [a-zA-Z0-9_.-]+
209
- end
210
-
211
- rule resource_url
212
- # Unquoted allows globbing for files, quoted does not.
213
- #
214
- # Unquoted, anything but:
215
- # @ - To allow for package substitution
216
- # "<>| - Characters not allowed in filenames on Windows
217
- # \s - Necessary for the "ws" token to work
218
- (value:[^@"<>|\s]+ ws)
219
-
220
- # Unquoted, anything but:
221
- # @ - To allow for package substitution
222
- # "<>| - Characters not allowed in filenames on Windows
223
- # *?\[\]{} - Characters significant to Dir.glob()
224
- # \s - We just don't want these. :] (May need to allow space.)
225
- / ('"' value:[^@"<>|*?\[\]{}\s]+ '"' ws)
226
- end
227
-
228
- rule ws
229
- [ \n\r\t]+
230
- end
231
-
232
- rule optional_ws
233
- [ \n\r\t]*
47
+ }
48
+ end
49
+
50
+ rule resource
51
+ statement_start:"resource" ws resource_url {
52
+ def to_package_statement(build_state)
53
+ Statement::Resource.new(
54
+ build_state.node_location(statement_start),
55
+ build_state.source_description,
56
+ resource_url.value.text_value
57
+ )
58
+ end
59
+ }
60
+ end
61
+
62
+ rule retrieve
63
+ statement_start:"retrieve" ws var:environment_variable_name "->" path:retrieve_path ws {
64
+ def to_package_statement(build_state)
65
+ Statement::Retrieve.new(
66
+ build_state.node_location(statement_start),
67
+ build_state.source_description,
68
+ var.text_value,
69
+ path.text_value
70
+ )
71
+ end
72
+ }
73
+ end
74
+
75
+ rule retrieve_path
76
+ [a-zA-Z0-9_/.\[\]-]+
77
+ end
78
+
79
+ rule config
80
+ statement_start:"config" ws config_name ws statements:config_statement* "end" ws {
81
+ def to_package_statement(build_state)
82
+ Statement::Configuration.new(
83
+ build_state.node_location(statement_start),
84
+ build_state.source_description,
85
+ config_name.text_value,
86
+ statements.elements.map do
87
+ |statement|
88
+ statement.to_config_statement(build_state)
89
+ end
90
+ )
91
+ end
92
+ }
93
+ end
94
+
95
+ rule config_name
96
+ [a-zA-Z0-9_.-]+
97
+ end
98
+
99
+ rule config_statement
100
+ override / include / command / path / set
101
+ end
102
+
103
+ rule include
104
+ statement_start:"include" ws descriptor_string ws {
105
+ def to_config_statement(build_state)
106
+ include_descriptor =
107
+ Statement::Include.parse_descriptor(
108
+ descriptor_string.text_value.strip,
109
+ :source_description =>
110
+ build_state.node_location_description(descriptor_string),
111
+ :validation_context => ' for an include statement'
112
+ )
113
+
114
+ Statement::Include.new(
115
+ build_state.node_location(statement_start),
116
+ build_state.source_description,
117
+ include_descriptor,
118
+ build_state.descriptor
119
+ )
120
+ end
121
+ }
122
+ end
123
+
124
+ rule override
125
+ statement_start:"override" ws descriptor_string ws {
126
+ def to_config_statement(build_state)
127
+ descriptor =
128
+ Statement::Override.parse_descriptor(
129
+ descriptor_string.text_value.strip,
130
+ :source_description =>
131
+ build_state.node_location_description(descriptor_string),
132
+ :validation_context => ' for an override statement'
133
+ )
134
+
135
+ return Statement::Override.new(
136
+ build_state.node_location(statement_start),
137
+ build_state.source_description,
138
+ descriptor.name,
139
+ descriptor.version
140
+ )
141
+ end
142
+ }
143
+ end
144
+
145
+ rule path
146
+ statement_start:("add" / "append" / "path") ws name_value:[\S]+ ws {
147
+ def to_config_statement(build_state)
148
+ return build_state.new_environment_variable_statement(
149
+ Statement::Path, statement_start, name_value
150
+ )
151
+ end
152
+ }
153
+ end
154
+
155
+ rule environment_variable_name
156
+ [a-zA-Z0-9_]+
157
+ end
158
+
159
+ rule set
160
+ statement_start:"set" ws name_value:[\S]+ ws {
161
+ def to_config_statement(build_state)
162
+ return build_state.new_environment_variable_statement(
163
+ Statement::Set, statement_start, name_value
164
+ )
165
+ end
166
+ }
167
+ end
168
+
169
+ rule command
170
+ statement_start:"command" ws string {
171
+ def to_config_statement(build_state)
172
+ Statement::Command.new(
173
+ build_state.node_location(statement_start),
174
+ build_state.source_description,
175
+ string.value.text_value
176
+ )
177
+ end
178
+ }
179
+ end
180
+
181
+ rule string
182
+ '"' value:(!'"' . )* '"' ws
183
+ end
184
+
185
+ rule descriptor_string
186
+ [\S]+
187
+ end
188
+
189
+ rule package_name
190
+ [a-zA-Z0-9_.-]+
191
+ end
192
+
193
+ rule version_name
194
+ [a-zA-Z0-9_.-]+
195
+ end
196
+
197
+ rule resource_url
198
+ # Unquoted allows globbing for files, quoted does not.
199
+ #
200
+ # Unquoted, anything but:
201
+ # @ - To allow for package substitution
202
+ # "<>| - Characters not allowed in filenames on Windows
203
+ # \s - Necessary for the "ws" token to work
204
+ (value:[^@"<>|\s]+ ws)
205
+
206
+ # Quoted, anything but:
207
+ # @ - To allow for package substitution
208
+ # "<>| - Characters not allowed in filenames on Windows
209
+ # *?\[\]{} - Characters significant to Dir.glob()
210
+ # \s - We just don't want these. :] (May need to allow space.)
211
+ / ('"' value:[^@"<>|*?\[\]{}\s]+ '"' ws)
212
+ end
213
+
214
+ rule ws
215
+ [ \n\r\t]+
216
+ end
217
+
218
+ rule optional_ws
219
+ [ \n\r\t]*
220
+ end
234
221
  end
235
222
  end
236
-
237
- end