class Object
Public Instance Methods
focus_line(level, in_focus, project_id)
click to toggle source
# File lib/bitbar_gitlab/gitlab_bitbar_lib_menu_utils.rb, line 150 def focus_line level, in_focus, project_id if in_focus puts "#{indent level}Clear focus | bash=#{shellwrap} param1=set param2=project_focus param3=0 terminal=false refresh=true" else puts "#{indent level}Set Focus | bash=#{shellwrap} param1=set param2=project_focus param3=#{project_id} terminal=false refresh=true" end end
indent(i)
click to toggle source
# File lib/bitbar_gitlab/gitlab_bitbar_lib_menu_utils.rb, line 159 def indent i scores = '' i.times do scores << '--' end scores end
install_bitbar_symlinks()
click to toggle source
# File lib/bitbar_gitlab/gitlab_bitbar_lib_install.rb, line 49 def install_bitbar_symlinks puts "Installing Symlinks to BitBar plugin folder" unless $conf.get_key :plugin_folder plugin_folder = `defaults read com.matryer.BitBar | grep pluginsDirectory | cut -d '"' -f2`.strip $conf.set_key :plugin_folder, plugin_folder end if File.exists? File.expand_path($conf.get_key :plugin_folder)+'/gitlab-bitbar-plugin.rb' File.delete File.expand_path($conf.get_key :plugin_folder)+'/gitlab-bitbar-plugin.rb' end File.symlink($conf.exe_file, File.expand_path($conf.get_key :plugin_folder)+'/gitlab-bitbar-plugin.rb') end
install_test_gitlab_connection()
click to toggle source
# File lib/bitbar_gitlab/gitlab_bitbar_lib_install.rb, line 62 def install_test_gitlab_connection puts "Testing GitLab connection" $gitlab = Gitlab.client(endpoint: $conf.get_key(:endpoint), private_token: $conf.get_key(:token)) begin user = $gitlab.user puts "User connected to this token: " + user.to_hash['name'] + "\n" puts puts "The configuration seems correct. you can now try using BitBar" rescue puts "ERROR Could not connect to the Gitlab API" puts puts "You may want to delete the configuration file and try to reconfigure" puts print "Shall I delete it for you? " delete_conf = STDIN.gets.chomp.upcase if delete_conf == "YES" or delete_conf == "Y" $conf.delete puts "Deleted conf file. You can run this install again" end puts end end
notify(option_string)
click to toggle source
# File lib/bitbar_gitlab/gitlab_bitbar_lib_notify.rb, line 1 def notify option_string if File.exists? "/usr/local/bin/terminal-notifier" system "/usr/local/bin/terminal-notifier #{option_string}" end end
pipeline_color(status)
click to toggle source
# File lib/bitbar_gitlab/gitlab_bitbar_lib_menu_utils.rb, line 47 def pipeline_color status if status == 'failed' 'color=red' elsif status == 'success' 'color=green' elsif status == 'running' 'color=blue' else 'color=black' end end
pipeline_text(status)
click to toggle source
# File lib/bitbar_gitlab/gitlab_bitbar_lib_menu_utils.rb, line 59 def pipeline_text status if status == 'success' 'passed' elsif status == 'running' 'is running' else status end end
run_install()
click to toggle source
# File lib/bitbar_gitlab/gitlab_bitbar_lib_install.rb, line 1 def run_install puts "Installing BitBar Gitlab Plugin by Pim Snel" if $conf.exists? $conf.try_exe_dir_exists puts "you seem to have a configations file." puts else newconf = {} puts "Creating a minimal configuration file..." puts puts "Enter the URL to your GitLab Environment" puts "E.g. https://gitlab.yourcompany.net (no ending slash)" puts print "Api URL: " api_address = STDIN.gets.chomp newconf['ENDPOINT'] = api_address + "/api/v4" puts puts "Enter a GitLab Access token for your GitLab Environment" puts "Create them at #{api_address}/profile/personal_access_tokens" puts print "Access Token: " newconf['TOKEN'] = STDIN.gets.chomp ## Check BitBar plugin folder plugin_folder = `defaults read com.matryer.BitBar | grep pluginsDirectory | cut -d '"' -f2`.strip if File.exists? File.expand_path(plugin_folder) puts "I found this BitBar plugin folder: " + plugin_folder + "\n" newconf['PLUGIN_FOLDER'] = plugin_folder else puts "Could not find the BitBar plugin folder." print "Please enter the plugin path: " newconf['PLUGIN_FOLDER'] = STDIN.gets.chomp end newconf['EXE_UTIL_DIR'] = $conf.exe_dir puts puts "writing configuration file..." puts $conf.save_init newconf end end
run_main()
click to toggle source
# File lib/bitbar_gitlab/gitlab_bitbar_lib_main.rb, line 1 def run_main puts "| templateImage=iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAAlwSFlzAAAWJQAAFiUBSVIk8AAAAVlpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADx4OnhtcG1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RRtEQCLw8dXLfiKi41gZU9r3VH60wLmuNUo+epBHz6FcwDkiz5bVIzwhdhZ5/Ygjxv9JPCsCXqtS2IcGLTnkUoNars1IL3rSOzsnIkTkkzgmG3ABAUmALyVa7wLbtM9/cJzjGkdDSw96kXdezHeTFuUGM99KUOA0fJQ9ZT8XifvIU/uF/L1EQA65YIuIzrW9WHzZ+ghakH61ZiAQKOSdHJSNNi1i+5D8AK2bT5eN3nW9CHwbxBxT9dsiurALvpVvQK4ofAUxF4nWMab2YgSCv4b9Zb8RrXHdx/JNE3N4pbwy7MBFuUjYV0Xgx9BH9muRmHeFTaO+IrD2imxiroV9WPSr7d7FS6ZYtkr0SvkCknRABE7kkuJHZ+1x2cCa/bLRuAYXb7Vo+JJ6nr8udo6Q96ZIAX9cVhaVWbY0YukClifxFRF3Ln8XRkacHryaFVE8Fin2iiwCcnkaRTBQfC869kH2IBGMFf06E9+HM5DWtq/s6BtPkP9qXooUeyjWi+Ck6AWcyj1Zxuf2QfjJmRd+hrRm4q5scpG84n6yaUJDN+OueAFrZAMv6rRs3gBADV/K3FHrjxdB3iaRpjuZCFwsPkhgh0hsM5NAmmtfu0YujS/ORNmvxGaRnZ4RZ4v4Jokg1Rc8FX5rPRp2xM3vLbJTLiN4JnJh34nWyPw/8KtK9aagO6Ux+/7LyBGnp4ftR1RTwz+EnjyMz43L0gAAAABJRU5ErkJggg==" puts "---" puts "Refresh | refresh=true" if $conf.key_is_set :project_focus puts "---" focus_project = $gitlab.project($conf.get_key :project_focus) puts "PROJECT: #{focus_project.to_hash['name']} | href=#{focus_project.to_hash['web_url']}" puts "Issues" project_menu focus_project, 1, true puts "---" end if $conf.key_is_set :pipeline_focus puts "---" focus_pipeline = $gitlab.project($conf.get_key :pipeline_focus) puts "PIPELINE: #{focus_pipeline.to_hash['name']} | href=#{focus_pipeline.to_hash['web_url']}" pipeline_focus_menu focus_pipeline, 0 puts "---" end if $conf.toggle_on? 'show_starred_projects' puts "Starred Projects" $gitlab.projects(per_page: 9999, starred: 1).collect do |pr| puts "#{indent 1}" + pr.to_hash['id'].to_s + ' ' + pr.to_hash['name'] project_menu pr, 2 end end if $conf.toggle_on? 'show_all_projects' puts "All Projects" $gitlab.projects(per_page: 9999).collect do |pr| puts "#{indent 1}" + pr.to_hash['id'].to_s + ' ' + pr.to_hash['name'] project_menu pr, 2 end end if $conf.toggle_on? 'show_starred_pipelines' puts "Starred Pipelines" $gitlab.projects(per_page: 9999, starred: 1).collect do |pr| puts "#{indent 1}" + pr.to_hash['id'].to_s + ' ' + pr.to_hash['name'] pipeline_menu pr, 2 end end if $conf.toggle_on? 'show_all_pipelines' puts "All Pipelines" $gitlab.projects(per_page: 9999).collect do |pr| puts "#{indent 1}" + pr.to_hash['id'].to_s + ' ' + pr.to_hash['name'] pipeline_menu pr, 2 end end puts "---" puts "Toggles" toggle_line 1, 'show_starred_projects', "Show starred projects", "Hide starred projects" toggle_line 1, 'show_all_projects', "Show all projects", "Hide all projects" puts "#{indent 1}Clear issue focus | bash=#{shellwrap} param1=set param2=pipeline_focus param3=0 terminal=false refresh=true" puts "#{indent 1}---" toggle_line 1, 'show_starred_pipelines', "Show starred pipelines", "Hide starred pipelines" toggle_line 1, 'show_all_pipelines', "Show all pipelines", "Hide all pipelines" puts "#{indent 1}Clear pipeline focus | bash=#{shellwrap} param1=set param2=pipeline_focus param3=0 terminal=false refresh=true" end
shellwrap()
click to toggle source
# File lib/bitbar_gitlab/gitlab_bitbar_lib_menu_utils.rb, line 3 def shellwrap "#{$conf.get_key :exe_util_dir}/shellwrap.sh" end
toggle_line(level, key, on_text, off_text)
click to toggle source
# File lib/bitbar_gitlab/gitlab_bitbar_lib_menu_utils.rb, line 167 def toggle_line level, key, on_text, off_text if $conf.toggle_on? key #if CONFIG['TOGGLE_'+key.upcase] && CONFIG['TOGGLE_'+key.upcase]!=0 text=off_text status=0 else text=on_text status=1 end puts "#{indent level}#{text} | bash=#{shellwrap} param1=set param2=TOGGLE_#{key.upcase} param3=#{status.to_s} terminal=false refresh=true" end