gmail_todo 0.0.3 → 0.0.4

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/bin/todo +3 -2
  3. data/lib/gmail_todo.rb +32 -15
  4. metadata +31 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 57a7c0f0c855ef957b1b607977058479743f5e73
4
- data.tar.gz: 15f8404a81ddccdb6ceaa07ae94c47d9196ab4e2
3
+ metadata.gz: 9f59cba90f14340495f4b198c0cdfad6d8b152be
4
+ data.tar.gz: f9f85acfee10a1d8c13aa4342728713b0ce6bb57
5
5
  SHA512:
6
- metadata.gz: 6cc0fa462eab24498f0aaa3c684967ee8e87b3631f20ae9c43aab8f7cf2cdaf0a1edddb70c826b21e7b71bdd785f11feaf2c84a809d3ac356ba30db55a487f5a
7
- data.tar.gz: 97fb8c37442b7963dd4865f802a7e3ea825d9821c7b4f63aafa366a59db613204289925b4fc0e363324d12c86bd95998347ea4243f0085c39626c8504c91de6d
6
+ metadata.gz: 16ca7a24ce3043d751dd10ab94a7b7ddf855bd7c1171305275c058f25e63dc28e701d69836777d3893d81eb0e4aa4eec24b5c8b62df602356f415806fdbe0e32
7
+ data.tar.gz: 65909e8148094b1c3a54bd611c4812ad09c416f5d6f661b391f2738a7293b9206750e4136dd01695008b3b12b47006593afcbc07cb06440e22501c064fa2793f
data/bin/todo CHANGED
@@ -2,7 +2,8 @@
2
2
 
3
3
  require File.expand_path('../../lib/gmail_todo', __FILE__)
4
4
 
5
+ mailer = GmailToDo.new
6
+
5
7
  fork do
6
- mailer = GmailToDo.new
7
- mailer.send_todo ARGV[0], ARGV[1]
8
+ mailer.send ARGV[0], ARGV[1]
8
9
  end
@@ -2,25 +2,20 @@ require 'gmail'
2
2
 
3
3
  class GmailToDo
4
4
 
5
- LOCAL_CREDENTIALS = ENV['HOME'] + '/.gmail_todo/credentials.yml' unless defined?(LOCAL_CREDENTIALS)
6
- DEFAULT_CREDENTIALS = File.dirname(__FILE__) + '/credentials.yml' unless defined?(DEFAULT_CREDENTIALS)
5
+ CREDENTIALS = ENV['HOME'] + '/.gmail_todo_credentials.yml'
7
6
 
8
- def initialize
9
- file = File.exists?(LOCAL_CREDENTIALS) ? LOCAL_CREDENTIALS : DEFAULT_CREDENTIALS
10
- credentials = YAML.load(File.read(file))
11
- @username = credentials["gmail"]["username"]
12
- @password = credentials["gmail"]["password"]
13
- end
7
+ attr_reader :username
8
+ attr_reader :password
14
9
 
15
- def username
16
- @username
17
- end
18
-
19
- def password
20
- @password
10
+ def initialize
11
+ if File.exists?(CREDENTIALS)
12
+ load_credentials
13
+ else
14
+ prompt_for_credentials
15
+ end
21
16
  end
22
17
 
23
- def send_todo(todo, details = nil)
18
+ def send(todo, details = nil)
24
19
  gmail = Gmail.connect(username, password)
25
20
 
26
21
  gmail.deliver do
@@ -32,4 +27,26 @@ class GmailToDo
32
27
  gmail.logout
33
28
  end
34
29
 
30
+ private
31
+
32
+ def load_credentials
33
+ credentials = YAML.load(File.read(CREDENTIALS))
34
+ @username = credentials["gmail"]["username"]
35
+ @password = credentials["gmail"]["password"]
36
+ end
37
+
38
+ def prompt_for_credentials
39
+ puts "Enter your gmail username: "
40
+ @username = $stdin.gets.chomp
41
+ puts "Enter your gmail password or token: "
42
+ @password = $stdin.gets.chomp
43
+
44
+ save_credentials
45
+ end
46
+
47
+ def save_credentials
48
+ credentials = {gmail: {username: username, password: password}}
49
+ File.open(CREDENTIALS, 'w') {|f| f.write credentials.to_yaml }
50
+ end
51
+
35
52
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gmail_todo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Hughes
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-28 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2015-02-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: gmail
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  description: Do you use your inbox as a todo list? Quickly fire yourself a todo from
14
28
  your terminal!
15
29
  email: kevinhughes27@gmail.com
@@ -20,22 +34,32 @@ extra_rdoc_files: []
20
34
  files:
21
35
  - bin/todo
22
36
  - lib/gmail_todo.rb
23
- homepage: https://github.com/pickle27/gmail_todo
37
+ homepage: https://github.com/kevinhughes27/gmail_todo
24
38
  licenses:
25
39
  - MIT
26
40
  metadata: {}
27
- post_install_message:
41
+ post_install_message: |2+
42
+
43
+ Thanks for installing gmail_todo!
44
+
45
+ To get started run `todo` from the console. If you haven't
46
+ entered credentials yet then you will get a prompt. If you
47
+ have 2 factor auth turned on for your gmail account (which
48
+ you should) then you'll need an app token. You can get a
49
+ token by going to `account -> security -> app passwords` of
50
+ your gmail account.
51
+
28
52
  rdoc_options: []
29
53
  require_paths:
30
54
  - lib
31
55
  required_ruby_version: !ruby/object:Gem::Requirement
32
56
  requirements:
33
- - - '>='
57
+ - - ">="
34
58
  - !ruby/object:Gem::Version
35
59
  version: '0'
36
60
  required_rubygems_version: !ruby/object:Gem::Requirement
37
61
  requirements:
38
- - - '>='
62
+ - - ">="
39
63
  - !ruby/object:Gem::Version
40
64
  version: '0'
41
65
  requirements: []