class Sfctl::Commands::Time::Connections::Get
Public Class Methods
new(options)
click to toggle source
# File lib/sfctl/commands/time/connections/get.rb, line 9 def initialize(options) @options = options @pastel = Pastel.new(enabled: !@options['no-color']) end
Public Instance Methods
execute(output: $stdout)
click to toggle source
# File lib/sfctl/commands/time/connections/get.rb, line 14 def execute(output: $stdout) read_link_config if config.fetch(:connections).nil? output.puts @pastel.yellow('You have no connections. Please add them before continue.') return end print_connections(output) rescue TTY::Config::ReadError error_message = 'Please initialize time before continue and ensure that your account authenticated.' output.puts @pastel.yellow(error_message) end
Private Instance Methods
print_connections(output)
click to toggle source
# File lib/sfctl/commands/time/connections/get.rb, line 30 def print_connections(output) config.fetch(:connections).each_key do |assignment_id| print_header!(output, assignment_id) case config.fetch(:connections, assignment_id, :provider) when TOGGL_PROVIDER print_toggl_connection!(output, assignment_id) when HARVEST_PROVIDER print_harvest_connection!(output, assignment_id) end print_footer!(output, assignment_id) end end
print_harvest_connection!(output, assignment_id)
click to toggle source
# File lib/sfctl/commands/time/connections/get.rb, line 63 def print_harvest_connection!(output, assignment_id) output.puts " provider: #{HARVEST_PROVIDER}" output.puts " project_id: #{config.fetch(:connections, assignment_id, :project_id)}" output.puts " task_id: #{config.fetch(:connections, assignment_id, :task_id)}" end
print_header!(output, assignment_id)
click to toggle source
# File lib/sfctl/commands/time/connections/get.rb, line 45 def print_header!(output, assignment_id) output.puts "Connection: #{config.fetch(:connections, assignment_id, :name)}" output.puts " service: #{config.fetch(:connections, assignment_id, :service)}" end
print_toggl_connection!(output, assignment_id)
click to toggle source
# File lib/sfctl/commands/time/connections/get.rb, line 56 def print_toggl_connection!(output, assignment_id) output.puts " provider: #{TOGGL_PROVIDER}" output.puts " workspace_id: #{config.fetch(:connections, assignment_id, :workspace_id)}" output.puts " project_ids: #{config.fetch(:connections, assignment_id, :project_ids)}" output.puts " task_ids: #{config.fetch(:connections, assignment_id, :task_ids)}" end