clea 0.1.0 → 0.8.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 760fced33d5e22281c8b70e7ea9a9d69f65448bf
4
- data.tar.gz: f53ae60fada1746fa66bc3a8f28d649133dd1dc2
3
+ metadata.gz: 17b513d9fd5e7380c855d5a191963c4e676655cb
4
+ data.tar.gz: b05fd0d0515503c3c8ba92d4ca9476189e9c7442
5
5
  SHA512:
6
- metadata.gz: f9e204a37b3aa640f2b8a534a192ca1686456cdd7d8aa2bc23057984dd5835ec955f5cf1a51d50f05825a33ec9b7d2b9e4af2a7d4f08bf28dd0ef7bca816059a
7
- data.tar.gz: a1f3c88d796a74a22525477aab674c49eda26ee8c6799655e20b28da4921419c7e51b384b3da6a9fafe6b9a662ba16dab7decb80d3a1d9cc8ecde5ad075fb52a
6
+ metadata.gz: a01906407f476b6a6e89e72ada693f632c8e7296bb59f77330971e542823292636211bf48a9679d221dc5a68ec75a421597f947732cdbc5978506658bc9c0885
7
+ data.tar.gz: 8d972d7da49939b104bfb2eda48101f64803f799b85cecda5fbb17aa20438c214439961d179d06b6be855c90824a6ee4095af5e33afd6ac96b28d9d17b6e8370
data/Gemfile CHANGED
@@ -1,5 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
 
4
- # Specify your gem's dependencies in gemma.gemspec
4
+ # Specify your gem's dependencies in clea.gemspec
5
5
  gemspec
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- clea (0.1.0)
4
+ clea (0.8.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Clea
2
2
 
3
- Clea (short for "Gem Mail") is a simple command line application for sending emails from the console using your gmail account and Ruby's SMTP library. Clea is perfect for getting a quick message out without fumbling with clunky mail clients or web apps.
3
+ Clea (Command Line Email Application) is a simple command line application for sending emails from the console using your gmail account and Ruby's SMTP library. Clea is perfect for getting a quick message out without fumbling with clunky mail clients or web apps.
4
4
 
5
5
  ## Installation
6
6
 
@@ -12,7 +12,7 @@ gem 'clea'
12
12
 
13
13
  And then execute:
14
14
 
15
- $ bundle
15
+ $ bundle install
16
16
 
17
17
  Or install it yourself as:
18
18
 
@@ -20,7 +20,9 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
- Ensure the clea executable is in your path and enter 'clea' in the console. Follow the prompts to send your email message. Gemma currently works only with gmail accounts.
23
+ Ensure the clea executable is in your path and enter 'clea' in the console. Follow the prompts to send your email message. The first time you user clea, clea stores your gmail account information in a pstore file in the gem directory. To reset your information, delete "my-clea-info.pstore".
24
+
25
+ **NOTE:** As of version 0.8, clea only supports sending from a gmail address.
24
26
 
25
27
  ## Development
26
28
 
data/bin/clea CHANGED
@@ -4,4 +4,19 @@ require 'clea'
4
4
 
5
5
  sender = Clea::Sender.new
6
6
 
7
- sender.send_message
7
+ if sender.check_sender_info == nil
8
+ sender.get_sender_alias
9
+ sender.get_sender_gmail
10
+ sender.get_sender_password
11
+ sender.write_sender_data
12
+ end
13
+
14
+ sender.get_recipient_data
15
+ sender.get_message
16
+ sender.compose
17
+ sender.send_message
18
+
19
+ 30.times { print "*" }
20
+ puts "\n\n Message successfully sent! \n\n"
21
+ 30.times { print "*" }
22
+ print "\n"
data/clea.gemspec CHANGED
@@ -23,11 +23,14 @@ Gem::Specification.new do |spec|
23
23
  end
24
24
 
25
25
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
- spec.bindir = "exe"
27
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
+ spec.bindir = "bin"
27
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
28
28
  spec.require_paths = ["lib"]
29
29
 
30
30
  spec.add_development_dependency "bundler", "~> 1.11"
31
31
  spec.add_development_dependency "rake", "~> 10.0"
32
32
  spec.add_development_dependency "rspec", "~> 3.0"
33
+ spec.add_runtime_dependency "ValidateEmail", "~> 1.0"
33
34
  end
35
+
36
+ # spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
data/lib/clea.rb CHANGED
@@ -1,37 +1,145 @@
1
1
  require "clea/version"
2
2
  require "net/smtp"
3
+ require "pstore"
4
+ require "ValidateEmail"
3
5
 
4
6
  module Clea
5
7
  class Sender
6
- def send_message
7
- puts "Enter your GMail username:"
8
+ # Set up persistent user info hash and return the user's email address if it already exists
9
+ def check_sender_info
10
+ @sender_info = PStore.new("my-clea-info.pstore")
11
+ senders_from = @sender_info.transaction { @sender_info[:from_address] }
12
+ return senders_from
13
+ end
8
14
 
9
- username = gets.chomp
15
+ # Get user's alias and confirm
16
+ def get_sender_alias
17
+ puts "What is your name?"
18
+ while @from_alias = gets.chomp
19
+ catch :badalias do
20
+ puts "Are you sure your name is #{@from_alias}? [y/n]:"
21
+ while alias_confirmation = gets.chomp
22
+ case alias_confirmation
23
+ when 'y'
24
+ return
25
+ else
26
+ puts "Please re-enter your name:"
27
+ throw :badalias
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
10
33
 
11
- puts "Enter your password:"
34
+ # Get, validate, and confirm user's email address
35
+ def get_sender_gmail
36
+ puts "Enter your gmail address:"
37
+ while @from_address = gets.chomp
38
+ catch :badfrom do
39
+ if ValidateEmail.validate(@from_address) == true
40
+ puts "Is your email address #{@from_address}? [y/n]:"
41
+ while address_confirmation = gets.chomp
42
+ case address_confirmation
43
+ when 'y'
44
+ return
45
+ else
46
+ puts "Please re-enter your gmail address:"
47
+ throw :badfrom
48
+ end
49
+ end
50
+ else
51
+ puts "Email invalid! Please enter a valid email address:"
52
+ end
53
+ end
54
+ end
55
+ end
12
56
 
13
- password = gets.chomp
57
+ # Get and confirm user's password
58
+ def get_sender_password
59
+ puts "Enter your password:"
60
+ while @password = gets.chomp
61
+ catch :badpass do
62
+ puts "Are you sure your password is #{@password}? [y/n]:"
63
+ while pass_confirmation = gets.chomp
64
+ case pass_confirmation
65
+ when 'y'
66
+ return
67
+ else
68
+ puts "Please re-enter your password:"
69
+ throw :badpass
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
14
75
 
15
- puts "Enter the recipient's Email address"
76
+ # Write all user info to the persistent hash
77
+ def write_sender_data
78
+ @sender_info.transaction do
79
+ @sender_info[:password] = @password
80
+ @sender_info[:from_address] = @from_address
81
+ @sender_info[:from_alias] = @from_alias
82
+ end
83
+ end
16
84
 
17
- recipient = gets.chomp
85
+ # Get, validate, and confirm the recipient's email address. This data does not persist.
86
+ def get_recipient_data
87
+ puts "Enter the recipient's email address:"
88
+ while @to_address = gets.chomp
89
+ catch :badto do
90
+ if ValidateEmail.validate(@to_address) == true
91
+ puts "Is the recipient's email address #{@to_address}? [y/n]:"
92
+ while to_address_confirmation = gets.chomp
93
+ case to_address_confirmation
94
+ when 'y'
95
+ return
96
+ else
97
+ puts "Please re-enter the recipient's email address:"
98
+ throw :badto
99
+ end
100
+ end
101
+ else
102
+ puts "Email invalid! Please enter a valid email address:"
103
+ end
104
+ end
105
+ end
106
+ end
18
107
 
108
+ # Get message content
109
+ def get_message
19
110
  puts "What is the subject of the email?"
20
-
21
- subject_line = gets.chomp
111
+ @subject_line = gets.chomp
22
112
 
23
113
  puts "Enter your message:"
114
+ @body = gets.chomp
115
+ end
24
116
 
25
- message = gets.chomp
117
+ # Compose message as heredoc
118
+ def compose
119
+ # Read from persistent user info hash and assign instance variables
120
+ @stored_from_alias = @sender_info.transaction { @sender_info[:from_alias] }
121
+ @stored_from_address = @sender_info.transaction { @sender_info[:from_address] }
122
+ @msg = <<-END_OF_MESSAGE
123
+ From: #{@stored_from_alias} <#{@stored_from_address}>
124
+ To: <#{@to_address}>
125
+ Subject: #{@subject_line}
26
126
 
27
- smtp = Net::SMTP.new('smtp.gmail.com', 587)
127
+ #{@body}
128
+ END_OF_MESSAGE
129
+ end
28
130
 
131
+ # Open SMTP connection, pass user info as arguments, send message and close connection
132
+ def send_message
133
+ # Read the user's password from the persistent hash
134
+ stored_password = @sender_info.transaction { @sender_info[:password] }
135
+ # Initialize the gmail SMTP connection and upgrade to SSL/TLS
136
+ smtp = Net::SMTP.new('smtp.gmail.com', 587)
29
137
  smtp.enable_starttls
30
-
31
- smtp.start('gmail.com', username, password, :login) do
32
- smtp.send_message(message, username, recipient)
138
+ # Open SMTP connection, send message, close the connection
139
+ smtp.start('gmail.com', @stored_from_address, stored_password, :login) do
140
+ smtp.send_message(@msg, @_stored_from_address, @to_address)
33
141
  end
34
-
35
142
  end
143
+
36
144
  end
37
145
  end
data/lib/clea/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Clea
2
- VERSION = "0.1.0"
2
+ VERSION = "0.8.0"
3
3
  end
data/my_info.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ #Ignore user data
2
+ *.pstore
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clea
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kyle Cierzan
8
8
  - Jeff Schneider
9
9
  - David Valencia
10
10
  autorequire:
11
- bindir: exe
11
+ bindir: bin
12
12
  cert_chain: []
13
- date: 2016-04-14 00:00:00.000000000 Z
13
+ date: 2016-04-20 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -54,10 +54,27 @@ dependencies:
54
54
  - - "~>"
55
55
  - !ruby/object:Gem::Version
56
56
  version: '3.0'
57
+ - !ruby/object:Gem::Dependency
58
+ name: ValidateEmail
59
+ requirement: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: '1.0'
64
+ type: :runtime
65
+ prerelease: false
66
+ version_requirements: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - "~>"
69
+ - !ruby/object:Gem::Version
70
+ version: '1.0'
57
71
  description: For when alt-tabbing away from the terminal is just too much to ask...
58
72
  email:
59
73
  - kcierzan+clea@gmail.com
60
- executables: []
74
+ executables:
75
+ - clea
76
+ - console
77
+ - setup
61
78
  extensions: []
62
79
  extra_rdoc_files: []
63
80
  files:
@@ -73,6 +90,7 @@ files:
73
90
  - clea.gemspec
74
91
  - lib/clea.rb
75
92
  - lib/clea/version.rb
93
+ - my_info.gitignore
76
94
  homepage: https://github.com/kcierzan/clea
77
95
  licenses:
78
96
  - MIT