Class: Origen::Application::Configuration
- Defined in:
- lib/origen/application/configuration.rb
Constant Summary collapse
- ATTRS_THAT_DEPEND_ON_TARGET =
Mark any attributes that are likely to depend on properties of the target here, this will raise an error if they are ever accessed before the target has been instantiated (a concern for Origen core developers only).
These attributes will also receive an enhanced accessor that accepts a block, see below for more details on this.
[ :output_directory, :reference_directory, :pattern_postfix, :pattern_prefix, :pattern_header, :current_plugin_pattern_header, :application_pattern_header, :shared_pattern_header, :release_directory, :pattern_name_translator, :pattern_directory, :pattern_output_directory, :proceed_with_pattern, :test_program_output_directory, :test_program_source_directory, :test_program_template_directory, :referenced_pattern_list, :program_prefix, :web_directory, :web_domain ]
- ATTRS_THAT_DONT_DEPEND_ON_TARGET =
Any attributes that want to accept a block, but not necessarily require the target can be added here
[ :release_instructions, :history_file, :log_directory, :copy_command, :diff_command, :remotes, :external_app_dirs ]
- ATTRS_THAT_CURRENT_PLUGIN_CAN_OVERRIDE =
If a current plugin is present then its value for these attributes will be used instead of that from the current application
[ :pattern_prefix, :pattern_postfix, :program_prefix, :pattern_header, :pattern_output_directory, :output_directory, :reference_directory, :test_program_output_directory, :test_program_template_directory, :referenced_pattern_list ]
- ATTRS_THAT_ARE_SET_TO_A_BLOCK =
[ :current_plugin_pattern_header, :application_pattern_header, :shared_pattern_header # :pattern_footer ]
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the configuration's application instance.
-
#compile_only_dot_erb_files ⇒ Object
Returns the value of attribute compile_only_dot_erb_files.
-
#copy_command ⇒ Object
Returns the value of attribute copy_command.
-
#default_lsf_action ⇒ Object
Returns the value of attribute default_lsf_action.
-
#default_plugin ⇒ Object
Returns the value of attribute default_plugin.
-
#diff_command ⇒ Object
Returns the value of attribute diff_command.
-
#disqus_shortname ⇒ Object
Returns the value of attribute disqus_shortname.
-
#erb_trim_mode ⇒ Object
Returns the value of attribute erb_trim_mode.
-
#external_app_dirs ⇒ Object
Returns the value of attribute external_app_dirs.
-
#gem_name ⇒ Object
Returns the value of attribute gem_name.
-
#history_file ⇒ Object
Returns the value of attribute history_file.
-
#initials ⇒ Object
Returns the value of attribute initials.
-
#instructions ⇒ Object
Returns the value of attribute instructions.
-
#lint_test ⇒ Object
Returns the value of attribute lint_test.
-
#log_directory ⇒ Object
Returns the value of attribute log_directory.
-
#name ⇒ Object
Returns the value of attribute name.
-
#output_directory ⇒ Object
Returns the value of attribute output_directory.
-
#pattern_directory ⇒ Object
Returns the value of attribute pattern_directory.
-
#pattern_header ⇒ Object
Returns the value of attribute pattern_header.
- #pattern_name_translator(name = nil, &block) ⇒ Object
-
#pattern_output_directory ⇒ Object
Returns the value of attribute pattern_output_directory.
-
#pattern_postfix ⇒ Object
Returns the value of attribute pattern_postfix.
-
#pattern_prefix ⇒ Object
Returns the value of attribute pattern_prefix.
- #proceed_with_pattern(name = nil, &block) ⇒ Object
-
#production_targets ⇒ Object
Returns the value of attribute production_targets.
-
#program_prefix ⇒ Object
Returns the value of attribute program_prefix.
-
#rc_tag_prepend_v ⇒ Object
Returns the value of attribute rc_tag_prepend_v.
-
#rc_url ⇒ Object
Returns the value of attribute rc_url.
-
#rc_workflow ⇒ Object
Returns the value of attribute rc_workflow.
-
#reference_directory ⇒ Object
Returns the value of attribute reference_directory.
-
#referenced_pattern_list ⇒ Object
Returns the value of attribute referenced_pattern_list.
-
#release_directory ⇒ Object
Returns the value of attribute release_directory.
-
#release_email_subject ⇒ Object
Returns the value of attribute release_email_subject.
-
#release_externally ⇒ Object
Returns the value of attribute release_externally.
-
#release_instructions ⇒ Object
Returns the value of attribute release_instructions.
-
#remotes ⇒ Object
Returns the value of attribute remotes.
-
#semantically_version ⇒ Object
Returns the value of attribute semantically_version.
-
#shared ⇒ Object
Returns the value of attribute shared.
-
#strict_errors ⇒ Object
Returns the value of attribute strict_errors.
-
#test_program_output_directory ⇒ Object
Returns the value of attribute test_program_output_directory.
-
#test_program_source_directory ⇒ Object
Returns the value of attribute test_program_source_directory.
-
#test_program_template_directory ⇒ Object
Returns the value of attribute test_program_template_directory.
-
#unmanaged_dirs ⇒ Object
Returns the value of attribute unmanaged_dirs.
-
#unmanaged_files ⇒ Object
Returns the value of attribute unmanaged_files.
-
#user_aliases ⇒ Object
Returns the value of attribute user_aliases.
-
#vault ⇒ Object
Returns the value of attribute vault.
-
#web_directory ⇒ Object
Returns the value of attribute web_directory.
-
#web_domain ⇒ Object
Returns the value of attribute web_domain.
-
#yammer_group ⇒ Object
Returns the value of attribute yammer_group.
Class Method Summary collapse
-
.add_attribute(name, options = {}) ⇒ Object
This defines an enhanced accessor for these attributes that allows them to be assigned to an anonymous function to calculate the value based on some property of the target objects.
Instance Method Summary collapse
-
#initialize(app) ⇒ Configuration
constructor
A new instance of Configuration.
- #log_deprecations ⇒ Object
- #lsf ⇒ Object
-
#method_missing(method, *_args, &_block) ⇒ Object
Prevent a new attribute from a future version of Origen from dying before the user can be prompted to upgrade.
-
#pattern_iterator {|Origen.generator.create_iterator| ... } ⇒ Object
Add a new pattern iterator.
Constructor Details
#initialize(app) ⇒ Configuration
Returns a new instance of Configuration.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/origen/application/configuration.rb', line 68 def initialize(app) @app = app @name = 'Unknown' @initials = 'NA' @semantically_version = false @compile_only_dot_erb_files = true # Functions used here since Origen.root is not available when this is first instantiated @output_directory = -> { "#{Origen.root}/output" } @reference_directory = lambda do if Origen.config.output_directory.to_s =~ /(\\|\/)output(\\|\/)/ Origen.config.output_directory.to_s.sub(/(\\|\/)output(\\|\/)/, '\1.ref\2') else "#{Origen.root}/.ref" end end @release_directory = -> { Origen.root } @release_email_subject = false @log_directory = -> { "#{Origen.root}/log" } @pattern_name_translator = ->(name) { name } @pattern_directory = -> { "#{Origen.root}/pattern" } @pattern_output_directory = -> { Origen.app.config.output_directory } @history_file = -> { "#{Origen.root}/doc/history" } @default_lsf_action = :clear @proceed_with_pattern = ->(_name) { true } @erb_trim_mode = '%' @referenced_pattern_list = -> { "#{Origen.root}/list/referenced.list" } @copy_command = -> { Origen.running_on_windows? ? 'copy' : 'cp' } @diff_command = -> { Origen.running_on_windows? ? 'start winmerge' : 'tkdiff' } @imports = [] @imports_dev = [] @external_app_dirs = [] @unmanaged_dirs = [] @unmanaged_files = [] @remotes = [] @lint_test = {} @user_aliases = {} @rc_tag_prepend_v = true end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *_args, &_block) ⇒ Object
Prevent a new attribute from a future version of Origen from dying before the user can be prompted to upgrade
208 209 210 211 |
# File 'lib/origen/application/configuration.rb', line 208 def method_missing(method, *_args, &_block) method = method.to_s.sub('=', '') Origen.log.warning "WARNING - unknown configuration attribute in #{app.name}: #{method}" end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the configuration's application instance
7 8 9 |
# File 'lib/origen/application/configuration.rb', line 7 def app @app end |
#compile_only_dot_erb_files ⇒ Object
Returns the value of attribute compile_only_dot_erb_files.
9 10 11 |
# File 'lib/origen/application/configuration.rb', line 9 def compile_only_dot_erb_files @compile_only_dot_erb_files end |
#copy_command ⇒ Object
Returns the value of attribute copy_command.
9 10 11 |
# File 'lib/origen/application/configuration.rb', line 9 def copy_command @copy_command end |
#default_lsf_action ⇒ Object
Returns the value of attribute default_lsf_action.
9 10 11 |
# File 'lib/origen/application/configuration.rb', line 9 def default_lsf_action @default_lsf_action end |
#default_plugin ⇒ Object
Returns the value of attribute default_plugin.
9 10 11 |
# File 'lib/origen/application/configuration.rb', line 9 def default_plugin @default_plugin end |
#diff_command ⇒ Object
Returns the value of attribute diff_command.
9 10 11 |
# File 'lib/origen/application/configuration.rb', line 9 def diff_command @diff_command end |
#disqus_shortname ⇒ Object
Returns the value of attribute disqus_shortname.
9 10 11 |
# File 'lib/origen/application/configuration.rb', line 9 def disqus_shortname @disqus_shortname end |
#erb_trim_mode ⇒ Object
Returns the value of attribute erb_trim_mode.
9 10 11 |
# File 'lib/origen/application/configuration.rb', line 9 def erb_trim_mode @erb_trim_mode end |
#external_app_dirs ⇒ Object
Returns the value of attribute external_app_dirs.
9 10 11 |
# File 'lib/origen/application/configuration.rb', line 9 def external_app_dirs @external_app_dirs end |
#gem_name ⇒ Object
Returns the value of attribute gem_name.
9 10 11 |
# File 'lib/origen/application/configuration.rb', line 9 def gem_name @gem_name end |
#history_file ⇒ Object
Returns the value of attribute history_file.
9 10 11 |
# File 'lib/origen/application/configuration.rb', line 9 def history_file @history_file end |
#initials ⇒ Object
Returns the value of attribute initials.
9 10 11 |
# File 'lib/origen/application/configuration.rb', line 9 def initials @initials end |
#instructions ⇒ Object
Returns the value of attribute instructions.
9 10 11 |
# File 'lib/origen/application/configuration.rb', line 9 def instructions @instructions end |
#lint_test ⇒ Object
Returns the value of attribute lint_test.
9 10 11 |
# File 'lib/origen/application/configuration.rb', line 9 def lint_test @lint_test end |
#log_directory ⇒ Object
Returns the value of attribute log_directory.
9 10 11 |
# File 'lib/origen/application/configuration.rb', line 9 def log_directory @log_directory end |
#name ⇒ Object
Returns the value of attribute name.
9 10 11 |
# File 'lib/origen/application/configuration.rb', line 9 def name @name end |
#output_directory ⇒ Object
Returns the value of attribute output_directory.
9 10 11 |
# File 'lib/origen/application/configuration.rb', line 9 def output_directory @output_directory end |
#pattern_directory ⇒ Object
Returns the value of attribute pattern_directory.
9 10 11 |
# File 'lib/origen/application/configuration.rb', line 9 def pattern_directory @pattern_directory end |
#pattern_header ⇒ Object
Returns the value of attribute pattern_header.
9 10 11 |
# File 'lib/origen/application/configuration.rb', line 9 def pattern_header @pattern_header end |
#pattern_name_translator(name = nil, &block) ⇒ Object
181 182 183 184 185 186 187 |
# File 'lib/origen/application/configuration.rb', line 181 def pattern_name_translator(name = nil, &block) if block @pattern_name_translator = block else @pattern_name_translator.call(name) end end |
#pattern_output_directory ⇒ Object
Returns the value of attribute pattern_output_directory.
9 10 11 |
# File 'lib/origen/application/configuration.rb', line 9 def pattern_output_directory @pattern_output_directory end |
#pattern_postfix ⇒ Object
Returns the value of attribute pattern_postfix.
9 10 11 |
# File 'lib/origen/application/configuration.rb', line 9 def pattern_postfix @pattern_postfix end |
#pattern_prefix ⇒ Object
Returns the value of attribute pattern_prefix.
9 10 11 |
# File 'lib/origen/application/configuration.rb', line 9 def pattern_prefix @pattern_prefix end |
#proceed_with_pattern(name = nil, &block) ⇒ Object
189 190 191 192 193 194 195 |
# File 'lib/origen/application/configuration.rb', line 189 def proceed_with_pattern(name = nil, &block) if block @proceed_with_pattern = block else @proceed_with_pattern.call(name) end end |
#production_targets ⇒ Object
Returns the value of attribute production_targets.
9 10 11 |
# File 'lib/origen/application/configuration.rb', line 9 def production_targets @production_targets end |
#program_prefix ⇒ Object
Returns the value of attribute program_prefix.
9 10 11 |
# File 'lib/origen/application/configuration.rb', line 9 def program_prefix @program_prefix end |
#rc_tag_prepend_v ⇒ Object
Returns the value of attribute rc_tag_prepend_v.
9 10 11 |
# File 'lib/origen/application/configuration.rb', line 9 def rc_tag_prepend_v @rc_tag_prepend_v end |
#rc_url ⇒ Object
Returns the value of attribute rc_url.
9 10 11 |
# File 'lib/origen/application/configuration.rb', line 9 def rc_url @rc_url end |
#rc_workflow ⇒ Object
Returns the value of attribute rc_workflow.
9 10 11 |
# File 'lib/origen/application/configuration.rb', line 9 def rc_workflow @rc_workflow end |
#reference_directory ⇒ Object
Returns the value of attribute reference_directory.
9 10 11 |
# File 'lib/origen/application/configuration.rb', line 9 def reference_directory @reference_directory end |
#referenced_pattern_list ⇒ Object
Returns the value of attribute referenced_pattern_list.
9 10 11 |
# File 'lib/origen/application/configuration.rb', line 9 def referenced_pattern_list @referenced_pattern_list end |
#release_directory ⇒ Object
Returns the value of attribute release_directory.
9 10 11 |
# File 'lib/origen/application/configuration.rb', line 9 def release_directory @release_directory end |
#release_email_subject ⇒ Object
Returns the value of attribute release_email_subject.
9 10 11 |
# File 'lib/origen/application/configuration.rb', line 9 def release_email_subject @release_email_subject end |
#release_externally ⇒ Object
Returns the value of attribute release_externally.
9 10 11 |
# File 'lib/origen/application/configuration.rb', line 9 def release_externally @release_externally end |
#release_instructions ⇒ Object
Returns the value of attribute release_instructions.
9 10 11 |
# File 'lib/origen/application/configuration.rb', line 9 def release_instructions @release_instructions end |
#remotes ⇒ Object
Returns the value of attribute remotes.
9 10 11 |
# File 'lib/origen/application/configuration.rb', line 9 def remotes @remotes end |
#semantically_version ⇒ Object
Returns the value of attribute semantically_version.
9 10 11 |
# File 'lib/origen/application/configuration.rb', line 9 def semantically_version @semantically_version end |
#shared ⇒ Object
Returns the value of attribute shared.
9 10 11 |
# File 'lib/origen/application/configuration.rb', line 9 def shared @shared end |
#strict_errors ⇒ Object
Returns the value of attribute strict_errors.
9 10 11 |
# File 'lib/origen/application/configuration.rb', line 9 def strict_errors @strict_errors end |
#test_program_output_directory ⇒ Object
Returns the value of attribute test_program_output_directory.
9 10 11 |
# File 'lib/origen/application/configuration.rb', line 9 def test_program_output_directory @test_program_output_directory end |
#test_program_source_directory ⇒ Object
Returns the value of attribute test_program_source_directory.
9 10 11 |
# File 'lib/origen/application/configuration.rb', line 9 def test_program_source_directory @test_program_source_directory end |
#test_program_template_directory ⇒ Object
Returns the value of attribute test_program_template_directory.
9 10 11 |
# File 'lib/origen/application/configuration.rb', line 9 def test_program_template_directory @test_program_template_directory end |
#unmanaged_dirs ⇒ Object
Returns the value of attribute unmanaged_dirs.
9 10 11 |
# File 'lib/origen/application/configuration.rb', line 9 def unmanaged_dirs @unmanaged_dirs end |
#unmanaged_files ⇒ Object
Returns the value of attribute unmanaged_files.
9 10 11 |
# File 'lib/origen/application/configuration.rb', line 9 def unmanaged_files @unmanaged_files end |
#user_aliases ⇒ Object
Returns the value of attribute user_aliases.
9 10 11 |
# File 'lib/origen/application/configuration.rb', line 9 def user_aliases @user_aliases end |
#vault ⇒ Object
Returns the value of attribute vault.
9 10 11 |
# File 'lib/origen/application/configuration.rb', line 9 def vault @vault end |
#web_directory ⇒ Object
Returns the value of attribute web_directory.
9 10 11 |
# File 'lib/origen/application/configuration.rb', line 9 def web_directory @web_directory end |
#web_domain ⇒ Object
Returns the value of attribute web_domain.
9 10 11 |
# File 'lib/origen/application/configuration.rb', line 9 def web_domain @web_domain end |
#yammer_group ⇒ Object
Returns the value of attribute yammer_group.
9 10 11 |
# File 'lib/origen/application/configuration.rb', line 9 def yammer_group @yammer_group end |
Class Method Details
.add_attribute(name, options = {}) ⇒ Object
This defines an enhanced accessor for these attributes that allows them to be assigned to an anonymous function to calculate the value based on some property of the target objects.
Without this the objects from the target could not be referenced in config/application.rb because they don't exist yet, for example this will not work because $dut has not yet been instantiated:
# config/application.rb
config.output_directory = "#{Origen.root}/output/#{$dut.class}"
However this accessor provides a way to do that via the following syntax:
# config/application.rb
config.output_directory do
"#{Origen.root}/output/#{$dut.class}"
end
Or on one line:
# config/application.rb
config.output_directory { "#{Origen.root}/output/#{$dut.class}" }
Or if you prefer the more explicit:
# config/application.rb
config.output_directory = ->{ "#{Origen.root}/output/#{$dut.class}" }
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/origen/application/configuration.rb', line 134 def self.add_attribute(name, = {}) = { depend_on_target: true }.merge() attr_writer name define_method name do |override = true, &block| if block # _given? instance_variable_set("@#{name}".to_sym, block) else if override && ATTRS_THAT_CURRENT_PLUGIN_CAN_OVERRIDE.include?(name) && app.current? && Origen.app.plugins.current var = Origen.app.plugins.current.config.send(name, override: false) end var ||= instance_variable_get("@#{name}".to_sym) || [:default] if var.respond_to?('call') if [:depend_on_target] # If an attempt has been made to access this attribute before the target has # been instantiated raise an error # Note Origen.app here instead of just app to ensure we are talking to the top level application, # that is the only one that has a target unless Origen.app.target_instantiated? fail "You have attempted to access Origen.config.#{name} before instantiating the target" end end # Some config variables should be left as a block/proc object. If this is one of those, just return the var. ATTRS_THAT_ARE_SET_TO_A_BLOCK.include?(name) ? var : var.call else var end end end end |
Instance Method Details
#log_deprecations ⇒ Object
62 63 64 65 66 |
# File 'lib/origen/application/configuration.rb', line 62 def log_deprecations # unless imports.empty? # Origen.deprecate "App #{app.name} uses config.imports this will be removed in Origen V3 and a Gemfile/.gemspec should be used instead" # end end |
#lsf ⇒ Object
202 203 204 |
# File 'lib/origen/application/configuration.rb', line 202 def lsf app.lsf.configuration end |