Module: FoundersTemplate::Utils
- Included in:
- CLI
- Defined in:
- lib/founders_template/utils.rb
Instance Method Summary collapse
- #add_to_envrc(variables) ⇒ Object
- #check_command(command) ⇒ Object
- #system_command?(command) ⇒ Boolean
- #template_file(template_file) ⇒ Object
Instance Method Details
#add_to_envrc(variables) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/founders_template/utils.rb', line 5 def add_to_envrc(variables) create_file '.envrc' unless File.exist?('.envrc') variables.each do |name, value| name = name.to_s append_to_file '.envrc', "export #{name}=#{value}\n" ENV[name] = value end run 'direnv allow .' end |
#check_command(command) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/founders_template/utils.rb', line 17 def check_command(command) return true if system_command?(command) say_status :missing, command false end |
#system_command?(command) ⇒ Boolean
24 25 26 |
# File 'lib/founders_template/utils.rb', line 24 def system_command?(command) system("which #{Shellwords.escape(command)} > /dev/null 2>&1") end |
#template_file(template_file) ⇒ Object
28 29 30 31 32 |
# File 'lib/founders_template/utils.rb', line 28 def template_file(template_file) template template_file.template_file, template_file.output_file, context: template_file.binding_for_render end |