Sha256: c16166232d06ad6783ba53f32946b3128605bd8392de519826457f8566722699

Contents?: true

Size: 738 Bytes

Versions: 2

Compression:

Stored size: 738 Bytes

Contents

module PivotalTrackerCli
  class UserCache

    def self.build_or_assign_user_cache(config, project_id, api_token)
      config['username_to_user_id_map'] || rebuild_user_cache(config, project_id, api_token)
    end

    def self.rebuild_user_cache(config, project_id, api_token)
      username_to_user_id_map = PivotalTrackerCli::Api.get_all_users_for_project(project_id, api_token)

      config['username_to_user_id_map'] = username_to_user_id_map

      File.open(ENV['HOME'] + '/.pt', 'w') do |f|
        f.write config.to_yaml
      end

      username_to_user_id_map
    end

    def self.get_user_ids_from_usernames(user_map, usernames)
      usernames.map do |username|
        user_map[username][:id]
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pivotal_tracker_cli-5.0.1 lib/user_cache.rb
pivotal_tracker_cli-5.0.0 lib/user_cache.rb