secret_santa 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/secret_santa.rb +11 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34261cce4517c5828a4ba6fd0f3a8652eb496405
|
4
|
+
data.tar.gz: 5c452fb3870b1084cb1e2d6b37597a14557f57ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2e774d631215beb31d5abd20e9aa6c4e95a3903007901783ec6418494e2057590f0e7618ecdbd1dbb9463beb60faaeeb05fd07f8989b24cd9093cb941344812
|
7
|
+
data.tar.gz: 4358f9d5920ecfb6888500a57865aafae2f9fb19e8a5d6ba77cb1e3b8166382b97957124799b512402f410439d451b3f1b5ba68bf10c0e77b79a42d2e3196b48
|
data/lib/secret_santa.rb
CHANGED
@@ -2,19 +2,22 @@ class SecretSanta
|
|
2
2
|
# Create the Secret Santa list
|
3
3
|
def self.create_list(names)
|
4
4
|
if names.length <= 2
|
5
|
-
|
5
|
+
'ERROR: List too short'
|
6
6
|
elsif names.length != names.uniq.length
|
7
|
-
|
7
|
+
'ERROR: Please enter unique names'
|
8
8
|
else
|
9
9
|
# Build the list
|
10
10
|
list = []
|
11
|
-
digraph_list = []
|
12
11
|
names.shuffle!
|
13
|
-
names.each_with_index
|
12
|
+
names.each_with_index do |name, i|
|
13
|
+
list << "#{name} -> #{names[i - 1]}"
|
14
|
+
end
|
14
15
|
# Write the list to a graphviz dot file
|
15
|
-
digraph_list = list.join(
|
16
|
+
digraph_list = list.join('; ')
|
16
17
|
digraph = "digraph {#{digraph_list}}\n"
|
17
|
-
File.open("#{Time.now.year}_secret_santa_list.dot", 'w')
|
18
|
+
File.open("#{Time.now.year}_secret_santa_list.dot", 'w') do |f|
|
19
|
+
f.write("#{digraph}")
|
20
|
+
end
|
18
21
|
# Return the list
|
19
22
|
puts "\n#{Time.now.year} Secret Santa List:"
|
20
23
|
puts list
|
@@ -24,8 +27,8 @@ class SecretSanta
|
|
24
27
|
|
25
28
|
# Get Secret Santa names and handle
|
26
29
|
def self.solicit_input
|
27
|
-
puts
|
30
|
+
puts 'Enter each name in the Secret Santa pool, separated by a space:'
|
28
31
|
names = gets.downcase.chomp
|
29
|
-
create_list(names.split(
|
32
|
+
create_list(names.split(' '))
|
30
33
|
end
|
31
34
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: secret_santa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jake Worth
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-22 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A Secret Santa engine, written in Ruby
|
14
14
|
email: jake@worth-chicago.co
|