nora 0.6 → 0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/nora/core.rb +12 -8
  3. data/lib/nora/version.rb +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d2cbe310506ce1dbb0e53d86109c02e6cd01db00
4
- data.tar.gz: b7bd143d5a26164da78bb59d372c24f2fe58691f
3
+ metadata.gz: fccab401ac7eb09b7078c9c8cb94e1be04e2b7bd
4
+ data.tar.gz: 5fb238bea537fc61cb54b57a27651d5f8d0dd7dc
5
5
  SHA512:
6
- metadata.gz: 900c279ced7bf1575cbda007c8bc6280e4133ff9e9647bb57eae29e2a372ed724abaa4e725a629dce8ee65a1c39c3a341e60fdee06057f7e4f4514c181330306
7
- data.tar.gz: 0aca7480d32709a3805ce862496a9806f7033a70efd4e4985faca1f81fb91acd0ca6e7d551b37f480cefc69e77e4ed9f91dbb52d797f5d8d096f38f38637dab3
6
+ metadata.gz: 674557ebf7c90291761f684d521713a44b746ffd8a0a600784807616f00f3a97fd130af2832f4e2e1923305b77ab359df6009e972f79028e38fb0d971068a79c
7
+ data.tar.gz: 88c5b8b0ca68a77046bf60ba91b79c4cc1dd7cf1867c1a74546b318666e6f4b7fbc92845ce6255c09e8297a1abb3ea0a04ec5c3825fa7733faaf0ff9734e3831
@@ -65,15 +65,13 @@ module Nora
65
65
  end
66
66
 
67
67
  def run!
68
+ load_history! # Populate @history for load_calendars!
69
+ load_calendars! # Outside the loop to reduce calls to Google API.
68
70
  begin
69
- load_history!
70
- puts "Loading calendars..."
71
- load_calendars!
72
- puts "Creating groups..."
71
+ shuffle_emails!
73
72
  create_groups!
74
73
  rescue SystemStackError
75
74
  remove_oldest_pair!
76
-
77
75
  retry
78
76
  end
79
77
 
@@ -93,9 +91,9 @@ module Nora
93
91
  # calendar in the configuration file without us
94
92
  # having to manually add them in the UI.
95
93
  def load_calendars!
96
- puts "Loading calendars"
97
- @emails = CONFIGURATION["people"].map { |p| p["email"] }.shuffle
98
- @emails.each do |email|
94
+ puts "Loading calendars..."
95
+ @emails = CONFIGURATION["people"].map { |p| p["email"] }
96
+ (Set.new(@emails) - @history).each do |email|
99
97
  puts "Loading calendar: #{email}"
100
98
  @service.insert_calendar_list(
101
99
  Google::Apis::CalendarV3::CalendarListEntry.new(id: email)
@@ -103,6 +101,11 @@ module Nora
103
101
  end
104
102
  end
105
103
 
104
+ def shuffle_emails!
105
+ puts "Shuffling emails..."
106
+ @emails = @emails.shuffle
107
+ end
108
+
106
109
  def remove_oldest_pair!
107
110
  puts "Removing oldest pair and retrying..."
108
111
  File.open("past_pairings_tmp.txt", "w") do |file|
@@ -124,6 +127,7 @@ module Nora
124
127
  end
125
128
 
126
129
  def create_groups!
130
+ puts "Creating groups..."
127
131
  @emails.each_slice(group_size).each do |emails|
128
132
  return create_groups! unless (@history & emails.combination(2)).empty?
129
133
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nora
4
- VERSION = "0.6"
4
+ VERSION = "0.7"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nora
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.6'
4
+ version: '0.7'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jacob Evelyn
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-07-30 00:00:00.000000000 Z
11
+ date: 2018-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler