fig 0.1.65 → 0.1.67

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 (80) hide show
  1. data/Changes +29 -0
  2. data/bin/fig +1 -1
  3. data/bin/fig-debug +1 -1
  4. data/lib/fig.rb +3 -0
  5. data/lib/fig/{applicationconfiguration.rb → application_configuration.rb} +0 -0
  6. data/lib/fig/{atexit.rb → at_exit.rb} +0 -0
  7. data/lib/fig/command.rb +190 -200
  8. data/lib/fig/command/action.rb +83 -0
  9. data/lib/fig/command/action/clean.rb +33 -0
  10. data/lib/fig/command/action/get.rb +48 -0
  11. data/lib/fig/command/action/help.rb +29 -0
  12. data/lib/fig/command/action/list_configs.rb +39 -0
  13. data/lib/fig/command/action/list_dependencies.rb +19 -0
  14. data/lib/fig/command/action/list_dependencies/all_configs.rb +44 -0
  15. data/lib/fig/command/action/list_dependencies/default.rb +40 -0
  16. data/lib/fig/command/action/list_dependencies/tree.rb +40 -0
  17. data/lib/fig/command/action/list_dependencies/tree_all_configs.rb +40 -0
  18. data/lib/fig/command/action/list_local.rb +29 -0
  19. data/lib/fig/command/action/list_remote.rb +33 -0
  20. data/lib/fig/command/action/list_variables.rb +23 -0
  21. data/lib/fig/command/action/list_variables/all_configs.rb +61 -0
  22. data/lib/fig/command/action/list_variables/default.rb +48 -0
  23. data/lib/fig/command/action/list_variables/tree.rb +20 -0
  24. data/lib/fig/command/action/list_variables/tree_all_configs.rb +20 -0
  25. data/lib/fig/command/action/publish.rb +52 -0
  26. data/lib/fig/command/action/publish_local.rb +29 -0
  27. data/lib/fig/command/action/role/has_no_sub_action.rb +10 -0
  28. data/lib/fig/command/action/role/has_sub_action.rb +58 -0
  29. data/lib/fig/command/action/role/list_all_configs.rb +14 -0
  30. data/lib/fig/command/action/role/list_base_config.rb +14 -0
  31. data/lib/fig/command/action/role/list_dependencies_flat.rb +22 -0
  32. data/lib/fig/command/action/role/list_dependencies_in_a_tree.rb +21 -0
  33. data/lib/fig/command/action/role/list_variables_in_a_tree.rb +150 -0
  34. data/lib/fig/command/action/role/list_walking_dependency_tree.rb +90 -0
  35. data/lib/fig/command/action/role/publish.rb +90 -0
  36. data/lib/fig/command/action/role/update.rb +46 -0
  37. data/lib/fig/command/action/run_command_line.rb +45 -0
  38. data/lib/fig/command/action/run_command_statement.rb +52 -0
  39. data/lib/fig/command/action/update.rb +17 -0
  40. data/lib/fig/command/action/update_if_missing.rb +17 -0
  41. data/lib/fig/command/action/version.rb +27 -0
  42. data/lib/fig/command/{coveragesupport.rb → coverage_support.rb} +0 -0
  43. data/lib/fig/command/{optionerror.rb → option_error.rb} +1 -1
  44. data/lib/fig/command/options.rb +185 -127
  45. data/lib/fig/command/package_applier.rb +140 -0
  46. data/lib/fig/command/package_loader.rb +124 -0
  47. data/lib/fig/{configfileerror.rb → config_file_error.rb} +1 -1
  48. data/lib/fig/{environmentvariables.rb → environment_variables.rb} +0 -0
  49. data/lib/fig/{environmentvariables/caseinsensitive.rb → environment_variables/case_insensitive.rb} +1 -1
  50. data/lib/fig/{environmentvariables/casesensitive.rb → environment_variables/case_sensitive.rb} +1 -1
  51. data/lib/fig/figrc.rb +3 -3
  52. data/lib/fig/grammar.treetop +1 -1
  53. data/lib/fig/{backtrace.rb → include_backtrace.rb} +7 -2
  54. data/lib/fig/log4r/outputter.rb +1 -1
  55. data/lib/fig/{log4rconfigerror.rb → log4r_config_error.rb} +1 -1
  56. data/lib/fig/logging.rb +2 -2
  57. data/lib/fig/{networkerror.rb → network_error.rb} +1 -1
  58. data/lib/fig/{nosuchpackageconfigerror.rb → no_such_package_config_error.rb} +2 -2
  59. data/lib/fig/{notfounderror.rb → not_found_error.rb} +0 -0
  60. data/lib/fig/{operatingsystem.rb → operating_system.rb} +5 -5
  61. data/lib/fig/package.rb +3 -3
  62. data/lib/fig/{packagecache.rb → package_cache.rb} +0 -0
  63. data/lib/fig/{packagedescriptor.rb → package_descriptor.rb} +1 -1
  64. data/lib/fig/{packagedescriptorparseerror.rb → package_descriptor_parse_error.rb} +1 -1
  65. data/lib/fig/{packageparseerror.rb → package_parse_error.rb} +1 -1
  66. data/lib/fig/parser.rb +4 -4
  67. data/lib/fig/{parserpackagebuildstate.rb → parser_package_build_state.rb} +1 -1
  68. data/lib/fig/repository.rb +17 -17
  69. data/lib/fig/{repositoryerror.rb → repository_error.rb} +1 -1
  70. data/lib/fig/{environment.rb → runtime_environment.rb} +15 -8
  71. data/lib/fig/statement/include.rb +1 -1
  72. data/lib/fig/statement/override.rb +1 -1
  73. data/lib/fig/{urlaccesserror.rb → url_access_error.rb} +1 -1
  74. data/lib/fig/{userinputerror.rb → user_input_error.rb} +0 -0
  75. data/lib/fig/{workingdirectorymaintainer.rb → working_directory_maintainer.rb} +4 -4
  76. data/lib/fig/{workingdirectorymetadata.rb → working_directory_metadata.rb} +0 -0
  77. metadata +88 -54
  78. data/VERSION +0 -1
  79. data/lib/fig/command/listing.rb +0 -363
  80. data/lib/fig/command/packageload.rb +0 -236
@@ -0,0 +1,33 @@
1
+ require 'fig/command/action'
2
+ require 'fig/command/action/role/has_no_sub_action'
3
+
4
+ module Fig; end
5
+ class Fig::Command; end
6
+ module Fig::Command::Action; end
7
+
8
+ class Fig::Command::Action::ListRemote
9
+ include Fig::Command::Action
10
+ include Fig::Command::Action::Role::HasNoSubAction
11
+
12
+ def options()
13
+ return %w<--list-remote>
14
+ end
15
+
16
+ def descriptor_requirement()
17
+ return :warn
18
+ end
19
+
20
+ def load_base_package?()
21
+ return nil # Don't care.
22
+ end
23
+
24
+ def remote_operation_necessary?()
25
+ return true
26
+ end
27
+
28
+ def execute()
29
+ @execution_context.repository.list_remote_packages.sort.each {|item| puts item}
30
+
31
+ return EXIT_SUCCESS
32
+ end
33
+ end
@@ -0,0 +1,23 @@
1
+ require 'fig/command/action'
2
+ require 'fig/command/action/role/has_sub_action'
3
+
4
+ module Fig; end
5
+ class Fig::Command; end
6
+ module Fig::Command::Action; end
7
+
8
+ class Fig::Command::Action::ListVariables
9
+ include Fig::Command::Action
10
+ include Fig::Command::Action::Role::HasSubAction
11
+
12
+ def options()
13
+ if sub_action
14
+ return sub_action.options
15
+ end
16
+
17
+ return %w<--list-variables>
18
+ end
19
+
20
+ def reset_environment?()
21
+ return true
22
+ end
23
+ end
@@ -0,0 +1,61 @@
1
+ require 'set'
2
+
3
+ require 'fig/command/action'
4
+ require 'fig/command/action/role/list_all_configs'
5
+ require 'fig/command/action/role/list_walking_dependency_tree'
6
+ require 'fig/statement/path'
7
+ require 'fig/statement/set'
8
+
9
+ module Fig; end
10
+ class Fig::Command; end
11
+ module Fig::Command::Action; end
12
+ class Fig::Command::Action::ListVariables; end
13
+
14
+ class Fig::Command::Action::ListVariables::AllConfigs
15
+ include Fig::Command::Action
16
+ include Fig::Command::Action::Role::ListAllConfigs
17
+ include Fig::Command::Action::Role::ListWalkingDependencyTree
18
+
19
+ def options()
20
+ return %w<--list-variables --list-all-configs>
21
+ end
22
+
23
+ def descriptor_requirement()
24
+ return nil
25
+ end
26
+
27
+ def load_base_package?()
28
+ return true
29
+ end
30
+
31
+ def register_base_package?()
32
+ return nil # don't care
33
+ end
34
+
35
+ def apply_config?()
36
+ return nil # don't care
37
+ end
38
+
39
+ def execute()
40
+ variable_names = Set.new()
41
+
42
+ walk_dependency_tree(
43
+ @execution_context.base_package, base_display_config_names(), nil, 0
44
+ ) do
45
+ |package, config_name, depth|
46
+
47
+ package[config_name].walk_statements() do |statement|
48
+ case statement
49
+ when Fig::Statement::Path
50
+ variable_names << statement.name()
51
+ when Fig::Statement::Set
52
+ variable_names << statement.name()
53
+ end
54
+ end
55
+ end
56
+
57
+ variable_names.sort.each { |name| puts name }
58
+
59
+ return EXIT_SUCCESS
60
+ end
61
+ end
@@ -0,0 +1,48 @@
1
+ require 'fig/command/action'
2
+
3
+ module Fig; end
4
+ class Fig::Command; end
5
+ module Fig::Command::Action; end
6
+ class Fig::Command::Action::ListVariables; end
7
+
8
+ class Fig::Command::Action::ListVariables::Default
9
+ include Fig::Command::Action
10
+
11
+ def options()
12
+ return %w<--list-variables>
13
+ end
14
+
15
+ def descriptor_requirement()
16
+ return nil
17
+ end
18
+
19
+ def load_base_package?()
20
+ return true
21
+ end
22
+
23
+ def register_base_package?()
24
+ return true
25
+ end
26
+
27
+ def apply_config?()
28
+ return true
29
+ end
30
+
31
+ def apply_base_config?()
32
+ return true
33
+ end
34
+
35
+ def execute()
36
+ variables = @execution_context.environment.variables()
37
+
38
+ if variables.empty? and $stdout.tty?
39
+ puts '<no variables>'
40
+ else
41
+ variables.keys.sort.each do |variable|
42
+ puts variable + "=" + variables[variable]
43
+ end
44
+ end
45
+
46
+ return EXIT_SUCCESS
47
+ end
48
+ end
@@ -0,0 +1,20 @@
1
+ require 'fig/command/action'
2
+ require 'fig/command/action/role/list_base_config'
3
+ require 'fig/command/action/role/list_variables_in_a_tree'
4
+ require 'fig/command/action/role/list_walking_dependency_tree'
5
+
6
+ module Fig; end
7
+ class Fig::Command; end
8
+ module Fig::Command::Action; end
9
+ class Fig::Command::Action::ListVariables; end
10
+
11
+ class Fig::Command::Action::ListVariables::Tree
12
+ include Fig::Command::Action
13
+ include Fig::Command::Action::Role::ListBaseConfig
14
+ include Fig::Command::Action::Role::ListVariablesInATree
15
+ include Fig::Command::Action::Role::ListWalkingDependencyTree
16
+
17
+ def options()
18
+ return %w<--list-variables --list-tree>
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ require 'fig/command/action'
2
+ require 'fig/command/action/role/list_all_configs'
3
+ require 'fig/command/action/role/list_variables_in_a_tree'
4
+ require 'fig/command/action/role/list_walking_dependency_tree'
5
+
6
+ module Fig; end
7
+ class Fig::Command; end
8
+ module Fig::Command::Action; end
9
+ class Fig::Command::Action::ListVariables; end
10
+
11
+ class Fig::Command::Action::ListVariables::TreeAllConfigs
12
+ include Fig::Command::Action
13
+ include Fig::Command::Action::Role::ListAllConfigs
14
+ include Fig::Command::Action::Role::ListVariablesInATree
15
+ include Fig::Command::Action::Role::ListWalkingDependencyTree
16
+
17
+ def options()
18
+ return %w<--list-variables --list-tree --list-all-configs>
19
+ end
20
+ end
@@ -0,0 +1,52 @@
1
+ require 'fig/command/action'
2
+ require 'fig/command/action/role/has_no_sub_action'
3
+ require 'fig/command/action/role/publish'
4
+ require 'fig/logging'
5
+ require 'fig/user_input_error'
6
+
7
+ module Fig; end
8
+ class Fig::Command; end
9
+ module Fig::Command::Action; end
10
+
11
+ class Fig::Command::Action::Publish
12
+ include Fig::Command::Action
13
+ include Fig::Command::Action::Role::HasNoSubAction
14
+ include Fig::Command::Action::Role::Publish
15
+
16
+ def options()
17
+ return %w<--publish>
18
+ end
19
+
20
+ def remote_operation_necessary?()
21
+ return true
22
+ end
23
+
24
+ def execute()
25
+ publish_preflight()
26
+
27
+ Fig::Logging.info "Checking status of #{@descriptor.to_string()}..."
28
+
29
+ package_description =
30
+ Fig::PackageDescriptor.format(@descriptor.name, @descriptor.version, nil)
31
+ if @execution_context.repository.list_remote_packages.include?(
32
+ package_description
33
+ )
34
+ Fig::Logging.info "#{@descriptor.to_string()} has already been published."
35
+
36
+ if not @force
37
+ raise UserInputError.new(
38
+ 'Use the --force option if you really want to overwrite.'
39
+ )
40
+ else
41
+ Fig::Logging.info 'Overwriting...'
42
+ end
43
+ end
44
+
45
+ Fig::Logging.info "Publishing #{@descriptor.to_string()}."
46
+ @execution_context.repository.publish_package(
47
+ @publish_statements, @descriptor, false
48
+ )
49
+
50
+ return EXIT_SUCCESS
51
+ end
52
+ end
@@ -0,0 +1,29 @@
1
+ require 'fig/command/action'
2
+ require 'fig/command/action/role/has_no_sub_action'
3
+ require 'fig/command/action/role/publish'
4
+ require 'fig/logging'
5
+
6
+ module Fig; end
7
+ class Fig::Command; end
8
+ module Fig::Command::Action; end
9
+
10
+ class Fig::Command::Action::PublishLocal
11
+ include Fig::Command::Action
12
+ include Fig::Command::Action::Role::HasNoSubAction
13
+ include Fig::Command::Action::Role::Publish
14
+
15
+ def options()
16
+ return %w<--publish-local>
17
+ end
18
+
19
+ def execute()
20
+ publish_preflight()
21
+
22
+ Fig::Logging.info "Publishing #{@descriptor.to_string()}."
23
+ @execution_context.repository.publish_package(
24
+ @publish_statements, @descriptor, :publish_local
25
+ )
26
+
27
+ return EXIT_SUCCESS
28
+ end
29
+ end
@@ -0,0 +1,10 @@
1
+ module Fig; end
2
+ class Fig::Command; end
3
+ module Fig::Command::Action; end
4
+ module Fig::Command::Action::Role; end
5
+
6
+ module Fig::Command::Action::Role::HasNoSubAction
7
+ def sub_action?
8
+ false
9
+ end
10
+ end
@@ -0,0 +1,58 @@
1
+ module Fig; end
2
+ class Fig::Command; end
3
+ module Fig::Command::Action; end
4
+ module Fig::Command::Action::Role; end
5
+
6
+ module Fig::Command::Action::Role::HasSubAction
7
+ attr_accessor :sub_action
8
+
9
+ def sub_action?()
10
+ true
11
+ end
12
+
13
+ def check_sub_action_presence()
14
+ return if sub_action
15
+
16
+ raise 'Bug in code. Sub-action missing.'
17
+ end
18
+
19
+ def descriptor_requirement()
20
+ check_sub_action_presence()
21
+ return sub_action.descriptor_requirement()
22
+ end
23
+
24
+ def load_base_package?()
25
+ check_sub_action_presence()
26
+ return sub_action.load_base_package?
27
+ end
28
+
29
+ def register_base_package?()
30
+ check_sub_action_presence()
31
+ return sub_action.register_base_package?
32
+ end
33
+
34
+ def apply_config?()
35
+ check_sub_action_presence()
36
+ return sub_action.apply_config?
37
+ end
38
+
39
+ def apply_base_config?()
40
+ check_sub_action_presence()
41
+ return sub_action.apply_base_config?
42
+ end
43
+
44
+ def configure(options)
45
+ check_sub_action_presence()
46
+ return sub_action.configure(options)
47
+ end
48
+
49
+ def execution_context=(context)
50
+ check_sub_action_presence()
51
+ sub_action.execution_context = context
52
+ end
53
+
54
+ def execute()
55
+ check_sub_action_presence()
56
+ return sub_action.execute()
57
+ end
58
+ end
@@ -0,0 +1,14 @@
1
+ module Fig; end
2
+ class Fig::Command; end
3
+ module Fig::Command::Action; end
4
+ module Fig::Command::Action::Role; end
5
+
6
+ module Fig::Command::Action::Role::ListAllConfigs
7
+ def list_all_configs?
8
+ return true
9
+ end
10
+
11
+ def base_display_config_names()
12
+ return @execution_context.base_package.config_names
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ module Fig; end
2
+ class Fig::Command; end
3
+ module Fig::Command::Action; end
4
+ module Fig::Command::Action::Role; end
5
+
6
+ module Fig::Command::Action::Role::ListBaseConfig
7
+ def list_all_configs?
8
+ return false
9
+ end
10
+
11
+ def base_display_config_names()
12
+ return [@execution_context.base_config]
13
+ end
14
+ end
@@ -0,0 +1,22 @@
1
+ require 'fig/command/action'
2
+
3
+ module Fig; end
4
+ class Fig::Command; end
5
+ module Fig::Command::Action; end
6
+ module Fig::Command::Action::Role; end
7
+
8
+ module Fig::Command::Action::Role::ListDependenciesFlat
9
+ def execute()
10
+ packages = gather_package_dependency_configurations()
11
+
12
+ if packages.empty? and $stdout.tty?
13
+ puts '<no dependencies>'
14
+ else
15
+ strings = derive_package_strings(packages)
16
+
17
+ puts strings.uniq.sort.join("\n")
18
+ end
19
+
20
+ return Fig::Command::Action::EXIT_SUCCESS
21
+ end
22
+ end
@@ -0,0 +1,21 @@
1
+ require 'fig/command/action'
2
+
3
+ module Fig; end
4
+ class Fig::Command; end
5
+ module Fig::Command::Action; end
6
+ module Fig::Command::Action::Role; end
7
+
8
+ module Fig::Command::Action::Role::ListDependenciesInATree
9
+ def execute()
10
+ walk_dependency_tree(
11
+ @execution_context.base_package, base_display_config_names(), nil, 0
12
+ ) do
13
+ |package, config_name, depth|
14
+
15
+ print ' ' * (depth * 4)
16
+ puts package.to_s_with_config(config_name)
17
+ end
18
+
19
+ return Fig::Command::Action::EXIT_SUCCESS
20
+ end
21
+ end
@@ -0,0 +1,150 @@
1
+ require 'fig/command/action'
2
+ require 'fig/statement/path'
3
+ require 'fig/statement/set'
4
+
5
+ module Fig; end
6
+ class Fig::Command; end
7
+ module Fig::Command::Action; end
8
+ module Fig::Command::Action::Role; end
9
+
10
+ module Fig::Command::Action::Role::ListVariablesInATree
11
+ def descriptor_requirement()
12
+ return nil
13
+ end
14
+
15
+ def load_base_package?()
16
+ return true
17
+ end
18
+
19
+ def register_base_package?()
20
+ return nil # don't care
21
+ end
22
+
23
+ def apply_config?()
24
+ return nil # don't care
25
+ end
26
+
27
+ def execute()
28
+ # We can't just display as we walk the dependency tree because we need to
29
+ # know in advance how many configurations we're going display under
30
+ # another.
31
+ tree = build_variable_tree()
32
+
33
+ tree.child_configs().each do
34
+ |child|
35
+
36
+ display_variable_tree_level(child, '', '')
37
+ end
38
+
39
+ return Fig::Command::Action::EXIT_SUCCESS
40
+ end
41
+
42
+ private
43
+
44
+ VariableTreePackageConfig =
45
+ Struct.new(
46
+ :package, :config_name, :variable_statements, :child_configs, :parent
47
+ )
48
+
49
+ def build_variable_tree()
50
+ tree = VariableTreePackageConfig.new(nil, nil, nil, [], nil)
51
+ prior_depth = 0
52
+ prior_node = nil
53
+ current_parent = tree
54
+
55
+ walk_dependency_tree(
56
+ @execution_context.base_package, base_display_config_names(), nil, 0
57
+ ) do
58
+ |package, config_name, depth|
59
+
60
+ if depth < prior_depth
61
+ (depth .. (prior_depth - 1)).each do
62
+ current_parent = current_parent.parent
63
+ end
64
+ elsif depth == prior_depth + 1
65
+ current_parent = prior_node
66
+ elsif depth > prior_depth
67
+ raise "Bug in code! Descended more than one level! (#{prior_depth} to #{depth}"
68
+ end
69
+
70
+ variable_statements = gather_variable_statements(package[config_name])
71
+ node = VariableTreePackageConfig.new(
72
+ package, config_name, variable_statements, [], current_parent
73
+ )
74
+ current_parent.child_configs() << node
75
+
76
+ prior_depth = depth
77
+ prior_node = node
78
+ end
79
+
80
+ return tree
81
+ end
82
+
83
+ def gather_variable_statements(config_statement)
84
+ variable_statements = []
85
+ config_statement.walk_statements() do |statement|
86
+ case statement
87
+ when Fig::Statement::Path
88
+ variable_statements << statement
89
+ when Fig::Statement::Set
90
+ variable_statements << statement
91
+ end
92
+ end
93
+
94
+ return variable_statements
95
+ end
96
+
97
+ def display_variable_tree_level(node, base_indent, package_indent)
98
+ print package_indent
99
+ puts node.package().to_s_with_config(node.config_name())
100
+
101
+ display_variable_tree_level_variables(node, base_indent)
102
+
103
+ child_configs = node.child_configs()
104
+ child_count = child_configs.size()
105
+
106
+ new_indent = base_indent + (child_count > 0 ? '|' : ' ') + ' ' * 3
107
+ new_package_indent = base_indent + %q<'--->
108
+
109
+ (0 .. (child_count - 2)).each do
110
+ |child_index|
111
+
112
+ display_variable_tree_level(
113
+ child_configs[child_index], new_indent, new_package_indent
114
+ )
115
+ end
116
+
117
+ if child_count > 0
118
+ display_variable_tree_level(
119
+ child_configs[-1], (base_indent + ' ' * 4), new_package_indent
120
+ )
121
+ end
122
+ end
123
+
124
+ def display_variable_tree_level_variables(node, base_indent)
125
+ if node.child_configs().size() > 0
126
+ variable_indent = base_indent + '|' + ' ' * 3
127
+ else
128
+ variable_indent = base_indent + ' ' * 4
129
+ end
130
+
131
+ variable_statements = node.variable_statements()
132
+
133
+ name_width =
134
+ (variable_statements.map { |statement| statement.name().length() }).max()
135
+
136
+ variable_statements.each do
137
+ |statement|
138
+
139
+ print "#{variable_indent}"
140
+ print "#{statement.name().ljust(name_width)}"
141
+ print " = #{statement.value}"
142
+ if statement.is_a?(Fig::Statement::Path)
143
+ print ":$#{statement.name}"
144
+ end
145
+ print "\n"
146
+ end
147
+
148
+ return
149
+ end
150
+ end