secret_santa 0.0.2

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.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/bin/secret_santa +5 -0
  3. data/lib/secret_santa.rb +31 -0
  4. metadata +46 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a25f18576ec5f27b591edb9cefae2461d0ec9a2a
4
+ data.tar.gz: c0cff936e01201c8acc1ec74ce3d59821a63c00f
5
+ SHA512:
6
+ metadata.gz: 40b621ecbc7a3b746baa28864026b4055616f580b282c9bdd4cebfd10329cad9cc3265e7ace7d8ce2fc47ad7cb9cdf7b79e288449f29ed9610598cb167c0ab9d
7
+ data.tar.gz: d18e4293f181a0b5d8eadbeeb25c26d632198575f0dc767fff4c83dfaa5d1b278987fd0d0c14a5bf0463c40c7fb32a3179e0f32c77394aa8513024d86653236d
data/bin/secret_santa ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'secret_santa'
4
+ puts SecretSanta.solicit_input
5
+ system "dot #{Time.now.year}_secret_santa_list.dot -Tpng > #{Time.now.year}_secret_santa_list.png"
@@ -0,0 +1,31 @@
1
+ class SecretSanta
2
+ # Create the Secret Santa list
3
+ def self.create_list(names)
4
+ if names.length <= 2
5
+ "ERROR: List too short"
6
+ elsif names.length != names.uniq.length
7
+ "ERROR: Please enter unique names"
8
+ else
9
+ # Build the list
10
+ list = []
11
+ digraph_list = []
12
+ names.shuffle!
13
+ names.each_with_index { |name, i| list << "#{name} -> #{names[i - 1]}" }
14
+ # Write the list to a graphviz dot file
15
+ digraph_list = list.join("; ")
16
+ digraph = "digraph {#{digraph_list}}\n"
17
+ File.open("#{Time.now.year}_secret_santa_list.dot", 'w') { |f| f.write("#{digraph}") }
18
+ # Return the list
19
+ puts "\n#{Time.now.year} Secret Santa List:"
20
+ puts list
21
+ "\nList saved to #{Time.now.year}_secret_santa_list.png"
22
+ end
23
+ end
24
+
25
+ # Get Secret Santa names and handle
26
+ def self.solicit_input
27
+ puts "Enter each name in the Secret Santa pool, separated by a space:"
28
+ names = gets.downcase.chomp
29
+ create_list(names.split(" "))
30
+ end
31
+ end
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: secret_santa
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Jake Worth
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-18 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A Secret Santa engine, written in Ruby
14
+ email: jake@worth-chicago.co
15
+ executables:
16
+ - secret_santa
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/secret_santa.rb
21
+ - bin/secret_santa
22
+ homepage: https://github.com/jwworth/secret_santa
23
+ licenses:
24
+ - MIT
25
+ metadata: {}
26
+ post_install_message:
27
+ rdoc_options: []
28
+ require_paths:
29
+ - lib
30
+ required_ruby_version: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ required_rubygems_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ requirements: []
41
+ rubyforge_project:
42
+ rubygems_version: 2.0.14
43
+ signing_key:
44
+ specification_version: 4
45
+ summary: A Secret Santa engine, written in Ruby
46
+ test_files: []