event_reporter 1.0.1 → 1.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.
@@ -1,6 +1,9 @@
1
+ lib = File.expand_path('../lib/', __FILE__)
2
+ $:.unshift lib unless $:.include?(lib)
3
+
1
4
  Gem::Specification.new do |gem|
2
5
  gem.name = "event_reporter"
3
- gem.version = "1.0.1"
6
+ gem.version = "1.0.2"
4
7
  gem.author = "Raphael Weiner"
5
8
  gem.email = "raphael.weiner@gmail.com"
6
9
  gem.summary = "Loads csv of event attendees and allows for searching"
@@ -16,9 +19,9 @@ Gem::Specification.new do |gem|
16
19
  event_reporter.gemspec
17
20
  )
18
21
  gem.executables = [ 'event_reporter' ]
19
-
22
+
20
23
  gem.required_ruby_version = '>=1.9'
21
24
  gem.has_rdoc = false
22
25
  gem.add_dependency 'json'
23
26
  gem.add_dependency 'nokogiri'
24
- end
27
+ end
@@ -1,11 +1,11 @@
1
1
  module EventReporter
2
2
  Attendee = Struct.new(:last_name,
3
3
  :first_name,
4
- :email,
5
- :zipcode,
6
- :city,
7
- :state,
8
- :address,
4
+ :email,
5
+ :zipcode,
6
+ :city,
7
+ :state,
8
+ :address,
9
9
  :phone_number
10
10
  )
11
11
  end
@@ -19,7 +19,7 @@ module EventReporter
19
19
 
20
20
  def clean_state(state)
21
21
  state.to_s[0..1].upcase
22
- end
22
+ end
23
23
 
24
24
  def clean_address(address)
25
25
  address.to_s
@@ -36,6 +36,6 @@ module EventReporter
36
36
  '0'*10
37
37
  end
38
38
  end
39
- end
39
+ end
40
40
  end
41
41
  end
@@ -1,7 +1,7 @@
1
1
  module EventReporter
2
2
  class CSVParser
3
3
  def initialize(filename)
4
- csv_file = File.join(File.dirname(__FILE__), "../../bin/#{filename}")
4
+ csv_file = File.expand_path("../../../bin/#{filename}", __FILE__)
5
5
  throw(:top, "File not found :(") if !File.exists?(csv_file)
6
6
  @contents = CSV.open(csv_file,
7
7
  :headers => true,
@@ -20,7 +20,7 @@ module EventReporter
20
20
  phone_number = Cleaners::clean_phone_number(line[:homephone])
21
21
  Attendee.new(last_name,
22
22
  first_name,
23
- email,
23
+ email,
24
24
  zipcode,
25
25
  city,
26
26
  state,
@@ -30,4 +30,4 @@ module EventReporter
30
30
  end
31
31
  end
32
32
  end
33
- end
33
+ end
@@ -65,8 +65,8 @@ module EventReporter
65
65
  def parse_atts_crits(input)
66
66
  attribute = input[0]
67
67
  criterias = input[1..-1].join(" ").split(",")
68
-
69
- criterias.map! do |criteria|
68
+
69
+ criterias.map! do |criteria|
70
70
  criteria.gsub("(", "").gsub(")", "").strip
71
71
  end
72
72
 
@@ -23,7 +23,7 @@ module EventReporter
23
23
  end
24
24
 
25
25
  def queue_print(queue)
26
- if queue.empty?
26
+ if queue.empty?
27
27
  puts "Nothing in queue!"
28
28
  else
29
29
  columns_length = find_column_lengths(queue)
@@ -67,7 +67,7 @@ module EventReporter
67
67
  queue.sort! do |attendee1, attendee2|
68
68
  attendee1[attribute] <=> attendee2[attribute]
69
69
  end
70
-
70
+
71
71
  queue_print(queue)
72
72
  end
73
73
  end
@@ -73,7 +73,8 @@ module EventReporter
73
73
  end
74
74
 
75
75
  def load_help_text
76
- YAML.load_file('bin/help.yml')
76
+ file_path = File.expand_path("../../../bin/help.yml", __FILE__)
77
+ YAML.load_file(file_path)
77
78
  end
78
79
  end
79
- end
80
+ end
@@ -3,43 +3,44 @@ module EventReporter
3
3
  class << self
4
4
  def route_save_to(filename, queue)
5
5
  throw(:top, "Please enter a filename to save to") if filename.nil?
6
-
6
+
7
7
  extension = filename.split(".")[1]
8
8
  method = "save_to_#{extension}"
9
-
9
+
10
10
  if respond_to? method
11
- send(method, filename, queue)
11
+ file_path = File.expand_path("../../../bin/#{filename}", __FILE__)
12
+ send(method, file_path, queue)
12
13
  else
13
14
  throw(:top, "Extension not valid! (try .csv, .xml, .txt, .json)")
14
15
  end
15
16
  end
16
17
 
17
- def save_to_csv(filename, queue)
18
- CSV.open("bin/#{filename}", "w") do |csv|
18
+ def save_to_csv(file_path, queue)
19
+ CSV.open("#{file_path}", "w") do |csv|
19
20
  csv << HEADERS.map do |header|
20
21
  header.downcase == 'phone_number' ? 'HomePhone' : header
21
22
  end
22
- queue.each do |attendee|
23
+ queue.each do |attendee|
23
24
  csv << [attendee.last_name,
24
25
  attendee.first_name,
25
26
  attendee.email,
26
27
  attendee.zipcode,
27
28
  attendee.city,
28
- attendee.state,
29
+ attendee.state,
29
30
  attendee.address,
30
31
  attendee.phone_number]
31
32
  end
32
33
  end
33
- success(filename)
34
+ success(file_path)
34
35
  end
35
36
 
36
- def save_to_txt(filename, queue)
37
+ def save_to_txt(file_path, queue)
37
38
  columns_length = Print.find_column_lengths(queue)
38
- File.open("bin/#{filename}", "w") do |txt|
39
+ File.open("#{file_path}", "w") do |txt|
39
40
  save_to_txt_headers(txt, columns_length)
40
41
  save_to_txt_contents(txt, columns_length, queue)
41
42
  end
42
- success(filename)
43
+ success(file_path)
43
44
  end
44
45
 
45
46
  def save_to_txt_headers(txt, columns_length)
@@ -55,17 +56,17 @@ module EventReporter
55
56
  column_width = columns_length[header.to_sym]
56
57
  txt.print "#{attendee[header].ljust(column_width)} "
57
58
  end
58
- end
59
+ end
59
60
  end
60
61
 
61
- def save_to_json(filename, queue)
62
- File.open("bin/#{filename}", "w") do |json|
62
+ def save_to_json(file_path, queue)
63
+ File.open("#{file_path}", "w") do |json|
63
64
  json.puts queue.to_json
64
65
  end
65
- success(filename)
66
+ success(file_path)
66
67
  end
67
68
 
68
- def save_to_xml(filename, queue)
69
+ def save_to_xml(file_path, queue)
69
70
  queue_xml = Nokogiri::XML::Builder.new do |xml|
70
71
  xml.root {
71
72
  xml.event_attendees {
@@ -73,14 +74,14 @@ module EventReporter
73
74
  }
74
75
  }
75
76
  end
76
- File.open("bin/#{filename}", "w") do |xml|
77
+ File.open("#{file_path}", "w") do |xml|
77
78
  xml.puts queue_xml.to_xml
78
79
  end
79
- success(filename)
80
+ success(file_path)
80
81
  end
81
82
 
82
- def success(filename)
83
- puts "Saved to #{filename}"
83
+ def success(file_path)
84
+ puts "Saved file #{file_path.split('/').last}"
84
85
  end
85
86
 
86
87
  def build_attendees_xml(xml, queue)
@@ -99,4 +100,4 @@ module EventReporter
99
100
  end
100
101
  end
101
102
  end
102
- end
103
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: event_reporter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-11 00:00:00.000000000 Z
12
+ date: 2013-02-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
@@ -54,7 +54,6 @@ files:
54
54
  - bin/event_attendees.csv
55
55
  - bin/event_reporter
56
56
  - bin/help.yml
57
- - bin/results.csv
58
57
  - lib/event_reporter/accept_any_input.rb
59
58
  - lib/event_reporter/attendee.rb
60
59
  - lib/event_reporter/cache.rb
data/bin/results.csv DELETED
@@ -1,6 +0,0 @@
1
- last_name,first_name,email,zipcode,city,state,address,HomePhone
2
- Waickman,Sarah,pvssino_a@jumpstartlab.com,42101,Bowling green,KY,1538 Chestnut Street,6153306000
3
- Ruud,Sarah,lprissa.S.Knodel@jumpstartlab.com,40508,Lexington,KY,300 N. Broadway,6067480000
4
- Dyment,John,lqeisler@jumpstartlab.com,40741,London,KY,216 Johnson Addition,6068624000
5
- Dayananda,John,kyllacamerak@jumpstartlab.com,40206,Louisville,KY,513 Emery Rd.,5027410000
6
- Catlin,Sarah,tlacyjamesrossi3@jumpstartlab.com,40206,Louisville,KY,114 N Galt Ave,5029386000