Module: EasyAppHelper::Scripts::Completion
- Included in:
- Master
- Defined in:
- lib/easy_app_helper/scripts/completion.rb
Instance Method Summary collapse
- #completion_script_changed?(script, target) ⇒ Boolean
- #deploy_zsh_completion_script(script, target) ⇒ Object
- #install_or_update_completion(script, target) ⇒ Object
Instance Method Details
#completion_script_changed?(script, target) ⇒ Boolean
24 25 26 27 28 29 30 31 |
# File 'lib/easy_app_helper/scripts/completion.rb', line 24 def completion_script_changed?(script, target) script_name = File.basename script target_script = File.join target, script_name return true unless File.exists? target_script sha1_source = Digest::SHA1.hexdigest File.read script sha1_target = Digest::SHA1.hexdigest File.read target_script sha1_source != sha1_target end |
#deploy_zsh_completion_script(script, target) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/easy_app_helper/scripts/completion.rb', line 9 def deploy_zsh_completion_script(script, target) FileUtils.mkpath target puts <<EOM ------------------------------------------------------------------------------------------ INFORMATION: A new version of the zsh completion for '#{EasyAppHelper.config.app_name} #{EasyAppHelper.config.app_version}' has been installed. You may want to restart a terminal to take it account. ------------------------------------------------------------------------------------------ EOM FileUtils.copy script, target end |
#install_or_update_completion(script, target) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/easy_app_helper/scripts/completion.rb', line 33 def install_or_update_completion(script, target) unless ENV['IGNORE_COMPLETION_UPDATE'] if File.exists?(script) deploy_zsh_completion_script script, target if completion_script_changed? script, target end end end |