Module: Cog::Config
- Includes:
- LanguageConfig, PluginConfig, ProjectConfig
- Included in:
- Cog
- Defined in:
- lib/cog/config.rb,
lib/cog/config/plugin_config.rb,
lib/cog/config/project_config.rb,
lib/cog/config/language_config.rb
Overview
This is a low level interface. It is mainly used by the Generator methods to determine where to find things, and where to put them.
Defined Under Namespace
Modules: LanguageConfig, PluginConfig, ProjectConfig
Instance Attribute Summary collapse
-
#generator_path ⇒ Array<String>
readonly
Directories in which to find generators.
-
#plugin_path ⇒ Array<String>
readonly
Directories in which to find plugins.
-
#template_path ⇒ Array<String>
readonly
Directories in which to find templates.
Attributes included from ProjectConfig
#project_cogfile_path, #project_generator_path, #project_path, #project_plugin_path, #project_root, #project_template_path
Instance Method Summary collapse
-
#gem_dir ⇒ String
Location of the installed cog gem.
-
#gems_root_dir ⇒ String?
If installed as a gem, return the parent directory of the gem’s location.
-
#prepare(opt = {}) ⇒ Object
Must be called once before using cog.
-
#show_fullpaths? ⇒ Boolean
When listing files, full paths should be shown.
-
#user_cogfile ⇒ String
Path to the current user’s cogfile.
-
#user_dir ⇒ String
Path to
${HOME}/.cog
.
Methods included from PluginConfig
#plugin, #plugins, #register_plugins
Methods included from LanguageConfig
#activate_language, #active_language, #language, #language_extensions, #language_for, #language_summary
Methods included from ProjectConfig
#project?, #supported_project_files
Instance Attribute Details
#generator_path ⇒ Array<String> (readonly)
15 16 17 |
# File 'lib/cog/config.rb', line 15 def generator_path @generator_path end |
Instance Method Details
#gem_dir ⇒ String
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/cog/config.rb', line 24 def gem_dir spec = Gem.loaded_specs['cog'] if spec.nil? # The current __FILE__ is: # ${COG_GEM_ROOT}/lib/cog/config.rb File. File.join(File.dirname(__FILE__), '..', '..') else spec.gem_dir end end |
#gems_root_dir ⇒ String?
36 37 38 39 |
# File 'lib/cog/config.rb', line 36 def gems_root_dir x = gem_dir File.(File.join(x, '..')) unless File.exists?(File.join(x, 'Gemfile')) end |
#prepare(opt = {}) ⇒ Object
Must be called once before using cog. In the context of a command-line invocation, this method will be called automatically. Outside of that context, for example in a unit test, it will have to be called manually.
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/cog/config.rb', line 61 def prepare(opt={}) throw :ConfigInstanceAlreadyPrepared if @prepared && !opt[:force_reset] @prepared = true @fullpaths = opt[:fullpaths] @project_path = nil @project_generator_path = nil @project_plugin_path = nil @project_template_path = nil @generator_path = [] @plugin_path = [] @template_path = [] @plugins = {} @target_language = Language.new @active_languages = [Language.new] # active language stack @language = {} @language_extension_map = {} process_cogfiles opt post_cogfile_processing build_language_extension_map end |
#show_fullpaths? ⇒ Boolean
52 53 54 |
# File 'lib/cog/config.rb', line 52 def show_fullpaths? @fullpaths end |
#user_cogfile ⇒ String
47 48 49 |
# File 'lib/cog/config.rb', line 47 def user_cogfile File.join user_dir, 'Cogfile' end |
#user_dir ⇒ String
42 43 44 |
# File 'lib/cog/config.rb', line 42 def user_dir File. File.join(ENV['HOME'], '.cog') end |