Class: Singer::Paths
- Inherits:
-
Object
- Object
- Singer::Paths
- Defined in:
- lib/singer/paths.rb
Overview
helps find files
Class Method Summary collapse
- .output_path ⇒ Object
- .singer_config_dir ⇒ Object
- .templates_from_gem ⇒ Object
- .templates_from_user ⇒ Object
- .variable_name_can_be_substituted?(name) ⇒ Boolean
- .xdg_config_dir ⇒ Object
Class Method Details
.output_path ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/singer/paths.rb', line 20 def self.output_path(...) File.join(...).gsub(/__([[:alpha:]][[:word:]]+)__/) do |match| potential_config = $1.downcase if variable_name_can_be_substituted?(potential_config) CONFIGURATION.send(potential_config) else match end end end |
.singer_config_dir ⇒ Object
8 9 10 |
# File 'lib/singer/paths.rb', line 8 def self.singer_config_dir @singer_config_dir ||= File.join(xdg_config_dir, 'singer') end |
.templates_from_gem ⇒ Object
16 17 18 |
# File 'lib/singer/paths.rb', line 16 def self.templates_from_gem @templates_from_gem ||= File.('../../templates', __dir__) end |
.templates_from_user ⇒ Object
12 13 14 |
# File 'lib/singer/paths.rb', line 12 def self.templates_from_user @templates_from_user ||= File.join(singer_config_dir, 'templates') end |
.variable_name_can_be_substituted?(name) ⇒ Boolean
32 33 34 |
# File 'lib/singer/paths.rb', line 32 def self.variable_name_can_be_substituted?(name) CONFIGURATION.respond_to?(name) && !CONFIGURATION_VARIABLES_FORBIDDEN_IN_PATHS.include?(name) end |
.xdg_config_dir ⇒ Object
4 5 6 |
# File 'lib/singer/paths.rb', line 4 def self.xdg_config_dir @xdg_config_dir ||= ENV.fetch('XDG_CONFIG_DIR', File.join(Dir.home, '.config')) end |