gmail_cli 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +1 -0
- data/.rspec +2 -0
- data/.travis.yml +11 -0
- data/Guardfile +1 -1
- data/README.md +16 -14
- data/Rakefile +0 -8
- data/gmail_cli.gemspec +7 -9
- data/lib/gmail_cli/version.rb +1 -1
- data/spec/unit/imap_spec.rb +40 -43
- data/spec/unit/logger_spec.rb +6 -6
- data/spec/unit/oauth2_helper_spec.rb +76 -40
- data/spec/unit/shell_spec.rb +4 -4
- data/spec/unit/tasks_spec.rb +2 -2
- metadata +23 -69
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MDg5MjU0MTQ2NGU0NDM2MTU5NjliMGE0NzU0NmYwNzA0MTRhYzc5ZQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NzQzNWJkM2QwNGU0NzQ5OTYyMTNmYjllYjE1YzY3ZjNmZTRiNGY3YQ==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NDM3ZWY3NTZiOTQwOTBlNGM4OTdhY2EwOGQ5ZjY0NTgwZmIwOTJmODY0NTU5
|
10
|
+
NWJkODVjNjJiZjIwYWFlNWJlMjYyNjc1ZGY3MTU4Mjc4NzViNGE3ZDc4YjM0
|
11
|
+
ZjkwZDc5NzZmYWQyOTkzMjMyZjUzOTE3MjBmZTcxMjlkNTFiNTQ=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
Yzk5ODkyMTI3NTc1MTAyN2Y5MmU2NmUwZjZjZmM2NTFiNDNiNTFiYWFlYjZm
|
14
|
+
MzI2YTJjYzBjN2YyNDc5NWNkOGM2MjVjYTI3YzQxYTM5ZDgyNmIzNDRiYmM5
|
15
|
+
ZDkxNWJjNjI4ZmUwOWMzYThhNGVlM2EwYzE4ZDk2NzEwYWI5M2U=
|
data/.gitignore
CHANGED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Guardfile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# A sample Guardfile
|
2
2
|
# More info at https://github.com/guard/guard#readme
|
3
3
|
|
4
|
-
guard
|
4
|
+
guard :rspec, cmd: 'bundle exec rspec', all_on_start: false, all_after_pass: false do
|
5
5
|
watch(%r{^spec/.+_spec\.rb$})
|
6
6
|
watch(%r{^lib/gmail_cli/(.+)\.rb$}) { |m| "spec/unit/#{m[1]}_spec.rb" }
|
7
7
|
watch('spec/spec_helper.rb') { "spec" }
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# GmailCli
|
1
|
+
# GmailCli [![Build Status](https://secure.travis-ci.org/evendis/gmail_cli.png?branch=master)](http://travis-ci.org/evendis/gmail_cli)
|
2
2
|
|
3
3
|
GmailCli packages the key tools and adds a sprinkling of goodness to make it just that much easier
|
4
4
|
to write primarily command-line utilities for Gmail/GoogleApps.
|
@@ -31,7 +31,7 @@ Or install it yourself as:
|
|
31
31
|
|
32
32
|
There are three basic steps required:
|
33
33
|
|
34
|
-
1. Create your API project
|
34
|
+
1. Create your API project credentials in the [Google APIs console](https://code.google.com/apis/console/), from the "API Access" tab.
|
35
35
|
|
36
36
|
2. Authorize your credentials to access a specific account.
|
37
37
|
This requires human intervention to explicitly make the approval.
|
@@ -45,37 +45,39 @@ without manual intervention so you don't have to keep going back to step 2 each
|
|
45
45
|
|
46
46
|
### How to authorize your OAuth2 credentials - command line approach
|
47
47
|
|
48
|
-
|
48
|
+
$ gmail_cli authorize
|
49
49
|
|
50
50
|
This will prompt you for required information (client_id, client_secret), or you can provide on the command line:
|
51
51
|
|
52
|
-
|
52
|
+
$ gmail_cli authorize --client_id 'my id' --client_secret 'my secret'
|
53
53
|
|
54
54
|
|
55
55
|
### How to authorize your OAuth2 credentials - Rake approach
|
56
56
|
|
57
57
|
In your Rakefile, include the line:
|
58
58
|
|
59
|
-
|
59
|
+
require 'gmail_cli/tasks'
|
60
60
|
|
61
61
|
Then from the command line you can:
|
62
62
|
|
63
|
-
|
63
|
+
$ rake gmail_cli:authorize
|
64
64
|
|
65
65
|
This will prompt you for required information (client_id, client_secret), or you can provide on the command line:
|
66
66
|
|
67
|
-
|
67
|
+
$ rake gmail_cli:authorize client_id='my id' client_secret='my secret'
|
68
68
|
|
69
69
|
|
70
70
|
### How to get an OAuth2-authorised IMAP connection to Gmail:
|
71
71
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
72
|
+
# how you store or set the credentials Hash is up to you, but it should have the following keys:
|
73
|
+
credentials = {
|
74
|
+
client_id: 'xxxx',
|
75
|
+
client_secret: 'yyyy',
|
76
|
+
access_token: 'aaaa',
|
77
|
+
refresh_token: 'rrrr',
|
78
|
+
username: 'name@gmail.com'
|
79
|
+
}
|
80
|
+
imap = GmailCli.imap_connection(credentials)
|
79
81
|
|
80
82
|
On return, <tt>imap</tt> will either be an open Net::IMAP connection, or an error will have been raised. Possible exceptions include:
|
81
83
|
|
data/Rakefile
CHANGED
@@ -11,14 +11,6 @@ end
|
|
11
11
|
|
12
12
|
task :default => :spec
|
13
13
|
|
14
|
-
require 'rdoc/task'
|
15
|
-
RDoc::Task.new do |rdoc|
|
16
|
-
rdoc.main = "README.md"
|
17
|
-
rdoc.rdoc_dir = 'rdoc'
|
18
|
-
rdoc.title = "Gmail CLI"
|
19
|
-
rdoc.rdoc_files.include('README*', 'lib/**/*.rb')
|
20
|
-
end
|
21
|
-
|
22
14
|
desc "Open an irb session preloaded with this library"
|
23
15
|
task :console do
|
24
16
|
sh "irb -rubygems -I lib -r gmail_cli.rb"
|
data/gmail_cli.gemspec
CHANGED
@@ -18,15 +18,13 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_runtime_dependency
|
22
|
-
spec.add_runtime_dependency
|
23
|
-
spec.add_runtime_dependency
|
21
|
+
spec.add_runtime_dependency 'getoptions', "~> 0.3"
|
22
|
+
spec.add_runtime_dependency 'gmail_xoauth', "~> 0.4.1"
|
23
|
+
spec.add_runtime_dependency 'google-api-client', "~> 0.7"
|
24
24
|
|
25
|
-
spec.add_development_dependency
|
26
|
-
spec.add_development_dependency
|
27
|
-
spec.add_development_dependency
|
28
|
-
spec.add_development_dependency
|
29
|
-
spec.add_development_dependency(%q<guard-rspec>, ["~> 3.0.2"])
|
30
|
-
spec.add_development_dependency(%q<rb-fsevent>, ["~> 0.9.3"])
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
26
|
+
spec.add_development_dependency "rake"
|
27
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
28
|
+
spec.add_development_dependency "guard-rspec"
|
31
29
|
|
32
30
|
end
|
data/lib/gmail_cli/version.rb
CHANGED
data/spec/unit/imap_spec.rb
CHANGED
@@ -5,83 +5,80 @@ describe GmailCli do
|
|
5
5
|
|
6
6
|
describe "##imap_connection" do
|
7
7
|
subject { GmailCli.imap_connection(options) }
|
8
|
-
it "
|
9
|
-
GmailCli::Imap.
|
10
|
-
|
8
|
+
it "returns a connected GmailCli::Imap" do
|
9
|
+
expect_any_instance_of(GmailCli::Imap).to receive(:connect!).and_return('result!')
|
10
|
+
expect(subject).to eql('result!')
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
14
|
describe "::Imap" do
|
15
15
|
let(:imap) { GmailCli::Imap.new(options) }
|
16
16
|
subject { imap }
|
17
|
+
it "has the expected default settings" do
|
18
|
+
expect(subject.username).to be_nil
|
19
|
+
expect(subject.host).to eql('imap.gmail.com')
|
20
|
+
expect(subject.host_options).to eql({port: 993, ssl: true})
|
21
|
+
end
|
17
22
|
|
18
23
|
describe "#username" do
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
let(:options) { {username: expected} }
|
24
|
-
it { should eql(expected) }
|
24
|
+
let(:expected) { 'test@test.com' }
|
25
|
+
let(:options) { {username: expected} }
|
26
|
+
it "can be set through options" do
|
27
|
+
expect(subject.username).to eql(expected)
|
25
28
|
end
|
26
29
|
end
|
27
30
|
|
28
31
|
describe "#host" do
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
let(:options) { {host: expected} }
|
34
|
-
it { should eql(expected) }
|
32
|
+
let(:expected) { 'test.com' }
|
33
|
+
let(:options) { {host: expected} }
|
34
|
+
it "can be set through options" do
|
35
|
+
expect(subject.host).to eql(expected)
|
35
36
|
end
|
36
37
|
end
|
37
38
|
|
38
39
|
describe "#host_options" do
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
let(:options) { {host_options: expected} }
|
44
|
-
it { should eql(expected) }
|
40
|
+
let(:expected) { {port: 111} }
|
41
|
+
let(:options) { {host_options: expected} }
|
42
|
+
it "can be set through options" do
|
43
|
+
expect(subject.host_options).to eql(expected)
|
45
44
|
end
|
46
45
|
end
|
47
46
|
|
48
47
|
describe "#oauth_options" do
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
client_secret: nil,
|
53
|
-
access_token: nil,
|
54
|
-
refresh_token: nil
|
55
|
-
}) }
|
56
|
-
context "when some given in options" do
|
57
|
-
let(:options) { {client_id: 'abcd'} }
|
58
|
-
it { should eql({
|
59
|
-
client_id: 'abcd',
|
48
|
+
it "is all nil by default" do
|
49
|
+
expect(subject.oauth_options).to eql({
|
50
|
+
client_id: nil,
|
60
51
|
client_secret: nil,
|
61
52
|
access_token: nil,
|
62
53
|
refresh_token: nil
|
63
|
-
})
|
54
|
+
})
|
55
|
+
end
|
56
|
+
context "when some given in options" do
|
57
|
+
let(:options) { {client_id: 'abcd'} }
|
58
|
+
it "sets selected items correctly" do
|
59
|
+
expect(subject.oauth_options).to eql({
|
60
|
+
client_id: 'abcd',
|
61
|
+
client_secret: nil,
|
62
|
+
access_token: nil,
|
63
|
+
refresh_token: nil
|
64
|
+
})
|
65
|
+
end
|
64
66
|
end
|
65
67
|
context "when all given in options" do
|
66
68
|
let(:options) { {client_id: 'abcd', client_secret: 'efg', access_token: '123', refresh_token: '456'} }
|
67
|
-
it
|
69
|
+
it "sets all items correctly" do
|
70
|
+
expect(subject.oauth_options).to eql({
|
68
71
|
client_id: 'abcd',
|
69
72
|
client_secret: 'efg',
|
70
73
|
access_token: '123',
|
71
74
|
refresh_token: '456'
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
end
|
76
|
-
describe "#oauth_access_token" do
|
77
|
-
subject { imap.oauth_access_token }
|
78
|
-
it { should eql('123') }
|
75
|
+
})
|
76
|
+
expect(subject.options.keys).to_not include(:client_id)
|
77
|
+
expect(subject.oauth_access_token).to eql('123')
|
79
78
|
end
|
80
79
|
end
|
81
80
|
end
|
82
81
|
|
83
|
-
|
84
|
-
|
85
82
|
end
|
86
83
|
|
87
84
|
end
|
data/spec/unit/logger_spec.rb
CHANGED
@@ -4,22 +4,22 @@ describe GmailCli::Logger do
|
|
4
4
|
let(:logger) { GmailCli::Logger }
|
5
5
|
let(:trace_something) { logger.trace 'somthing', 'bogative' }
|
6
6
|
|
7
|
-
it "
|
8
|
-
$stderr.
|
7
|
+
it "does not log when verbose mode not enabled" do
|
8
|
+
expect($stderr).to receive(:puts).never
|
9
9
|
trace_something
|
10
10
|
end
|
11
11
|
|
12
|
-
it "
|
12
|
+
it "logs when verbose mode enabled" do
|
13
13
|
logger.set_log_mode(true)
|
14
|
-
$stderr.
|
14
|
+
expect($stderr).to receive(:puts).and_return(nil)
|
15
15
|
trace_something
|
16
16
|
logger.set_log_mode(false)
|
17
17
|
end
|
18
18
|
|
19
|
-
it "
|
19
|
+
it "does not log when verbose mode enabled then disabled" do
|
20
20
|
logger.set_log_mode(true)
|
21
21
|
logger.set_log_mode(false)
|
22
|
-
$stderr.
|
22
|
+
expect($stderr).to receive(:puts).never
|
23
23
|
trace_something
|
24
24
|
end
|
25
25
|
|
@@ -8,38 +8,48 @@ describe GmailCli::Oauth2Helper do
|
|
8
8
|
|
9
9
|
before do
|
10
10
|
# silence echo
|
11
|
-
resource_class.
|
11
|
+
allow_any_instance_of(resource_class).to receive(:echo).and_return(nil)
|
12
12
|
end
|
13
13
|
|
14
14
|
describe "##authorize!" do
|
15
15
|
subject { resource_class.authorize!(options) }
|
16
|
-
it "
|
17
|
-
resource_class.
|
18
|
-
|
16
|
+
it "invokes authorize! on instance" do
|
17
|
+
expect_any_instance_of(resource_class).to receive(:authorize!).and_return('result!')
|
18
|
+
expect(subject).to eql('result!')
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
22
|
describe "#client_id" do
|
23
23
|
subject { instance.client_id }
|
24
|
-
it
|
24
|
+
it "is nil by default" do
|
25
|
+
expect(subject).to be_nil
|
26
|
+
end
|
25
27
|
context "when given in options" do
|
26
28
|
let(:options) { {client_id: expected} }
|
27
|
-
it
|
29
|
+
it "returns the setting" do
|
30
|
+
expect(subject).to eql(expected)
|
31
|
+
end
|
28
32
|
end
|
29
33
|
end
|
30
34
|
|
31
35
|
describe "#client_secret" do
|
32
36
|
subject { instance.client_secret }
|
33
|
-
it
|
37
|
+
it "is nil by default" do
|
38
|
+
expect(subject).to be_nil
|
39
|
+
end
|
34
40
|
context "when given in options" do
|
35
41
|
let(:options) { {client_secret: expected} }
|
36
|
-
it
|
42
|
+
it "returns the setting" do
|
43
|
+
expect(subject).to eql(expected)
|
44
|
+
end
|
37
45
|
end
|
38
46
|
end
|
39
47
|
|
40
48
|
describe "#authorization_code" do
|
41
49
|
subject { instance.authorization_code }
|
42
|
-
it
|
50
|
+
it "is nil by default" do
|
51
|
+
expect(subject).to be_nil
|
52
|
+
end
|
43
53
|
context "cannot be given in options" do
|
44
54
|
let(:options) { {authorization_code: expected} }
|
45
55
|
it { should be_nil }
|
@@ -48,55 +58,79 @@ describe GmailCli::Oauth2Helper do
|
|
48
58
|
|
49
59
|
describe "#access_token" do
|
50
60
|
subject { instance.access_token }
|
51
|
-
it
|
61
|
+
it "is nil by default" do
|
62
|
+
expect(subject).to be_nil
|
63
|
+
end
|
52
64
|
context "when given in options" do
|
53
65
|
let(:options) { {access_token: expected} }
|
54
|
-
it
|
66
|
+
it "returns the setting" do
|
67
|
+
expect(subject).to eql(expected)
|
68
|
+
end
|
55
69
|
end
|
56
70
|
end
|
57
71
|
|
58
72
|
describe "#refresh_token" do
|
59
73
|
subject { instance.refresh_token }
|
60
|
-
it
|
74
|
+
it "is nil by default" do
|
75
|
+
expect(subject).to be_nil
|
76
|
+
end
|
61
77
|
context "when given in options" do
|
62
78
|
let(:options) { {refresh_token: expected} }
|
63
|
-
it
|
79
|
+
it "returns the setting" do
|
80
|
+
expect(subject).to eql(expected)
|
81
|
+
end
|
64
82
|
end
|
65
83
|
end
|
66
84
|
|
67
85
|
describe "#scope" do
|
68
86
|
subject { instance.scope }
|
69
|
-
it
|
87
|
+
it "is set by default" do
|
88
|
+
expect(subject).to eql('https://mail.google.com/')
|
89
|
+
end
|
70
90
|
context "when given in options" do
|
71
91
|
let(:options) { {scope: expected} }
|
72
|
-
it
|
92
|
+
it "returns the setting" do
|
93
|
+
expect(subject).to eql(expected)
|
94
|
+
end
|
73
95
|
end
|
74
96
|
end
|
75
97
|
|
76
98
|
describe "#redirect_uri" do
|
77
99
|
subject { instance.redirect_uri }
|
78
|
-
it
|
100
|
+
it "is set by default" do
|
101
|
+
expect(subject).to eql('urn:ietf:wg:oauth:2.0:oob')
|
102
|
+
end
|
79
103
|
context "when given in options" do
|
80
104
|
let(:options) { {redirect_uri: expected} }
|
81
|
-
it
|
105
|
+
it "returns the setting" do
|
106
|
+
expect(subject).to eql(expected)
|
107
|
+
end
|
82
108
|
end
|
83
109
|
end
|
84
110
|
|
85
111
|
describe "#application_name" do
|
86
112
|
subject { instance.application_name }
|
87
|
-
it
|
113
|
+
it "is set by default" do
|
114
|
+
expect(subject).to eql('gmail_cli')
|
115
|
+
end
|
88
116
|
context "when given in options" do
|
89
117
|
let(:options) { {application_name: expected} }
|
90
|
-
it
|
118
|
+
it "returns the setting" do
|
119
|
+
expect(subject).to eql(expected)
|
120
|
+
end
|
91
121
|
end
|
92
122
|
end
|
93
123
|
|
94
124
|
describe "#application_version" do
|
95
125
|
subject { instance.application_version }
|
96
|
-
it
|
126
|
+
it "is set by default" do
|
127
|
+
expect(subject).to eql(GmailCli::VERSION)
|
128
|
+
end
|
97
129
|
context "when given in options" do
|
98
130
|
let(:options) { {application_version: expected} }
|
99
|
-
it
|
131
|
+
it "returns the setting" do
|
132
|
+
expect(subject).to eql(expected)
|
133
|
+
end
|
100
134
|
end
|
101
135
|
end
|
102
136
|
|
@@ -106,13 +140,13 @@ describe GmailCli::Oauth2Helper do
|
|
106
140
|
context "when value already set" do
|
107
141
|
let(:options) { {client_id: 'set'} }
|
108
142
|
it "should not ask_for_entry when already set" do
|
109
|
-
instance.
|
143
|
+
expect(instance).to receive(:ask_for_entry).never
|
110
144
|
subject
|
111
145
|
end
|
112
146
|
end
|
113
147
|
context "when value not already set" do
|
114
148
|
it "should ask_for_entry when already set" do
|
115
|
-
instance.
|
149
|
+
expect(instance).to receive(:ask_for_entry).and_return('got it')
|
116
150
|
subject
|
117
151
|
end
|
118
152
|
end
|
@@ -120,8 +154,8 @@ describe GmailCli::Oauth2Helper do
|
|
120
154
|
|
121
155
|
describe "#authorize!" do
|
122
156
|
subject { instance.authorize! }
|
123
|
-
it "
|
124
|
-
instance.
|
157
|
+
it "invokes get_access_token" do
|
158
|
+
expect(instance).to receive(:get_access_token!).and_return(nil)
|
125
159
|
subject
|
126
160
|
end
|
127
161
|
end
|
@@ -129,7 +163,9 @@ describe GmailCli::Oauth2Helper do
|
|
129
163
|
describe "#api_client" do
|
130
164
|
let(:options) { {client_id: 'client_id', client_secret: 'client_secret'} }
|
131
165
|
subject { instance.api_client }
|
132
|
-
it
|
166
|
+
it "returns an initialised Google API client" do
|
167
|
+
expect(subject).to be_a(Google::APIClient)
|
168
|
+
end
|
133
169
|
end
|
134
170
|
|
135
171
|
describe "#get_access_token!" do
|
@@ -138,14 +174,14 @@ describe GmailCli::Oauth2Helper do
|
|
138
174
|
let(:mock_refresh_token) { "ya29.AHES6ZS_KHUpdO5P0nyvADWf4tL5o8e8C_q5UK0HyyYOF3jw" }
|
139
175
|
let(:mock_fetch_access_token_response) { {"access_token"=>mock_access_token, "token_type"=>"Bearer", "expires_in"=>3600, "refresh_token"=>mock_refresh_token} }
|
140
176
|
subject { instance.get_access_token! }
|
141
|
-
it "
|
142
|
-
instance.api_client.
|
143
|
-
instance.
|
144
|
-
instance.
|
145
|
-
instance.
|
146
|
-
subject.
|
147
|
-
instance.access_token.
|
148
|
-
instance.refresh_token.
|
177
|
+
it "orchestrates the fetch_access_token process correctly" do
|
178
|
+
expect(instance.api_client).to be_a(Google::APIClient)
|
179
|
+
expect(instance).to receive(:get_authorization_uri).and_return('http://here')
|
180
|
+
expect(instance).to receive(:ensure_provided).with(:authorization_code).and_return('authorization_code')
|
181
|
+
expect(instance).to receive(:fetch_access_token!).and_return(mock_fetch_access_token_response)
|
182
|
+
expect(subject).to eql(mock_access_token)
|
183
|
+
expect(instance.access_token).to eql(mock_access_token)
|
184
|
+
expect(instance.refresh_token).to eql(mock_refresh_token)
|
149
185
|
end
|
150
186
|
end
|
151
187
|
|
@@ -155,12 +191,12 @@ describe GmailCli::Oauth2Helper do
|
|
155
191
|
let(:mock_refresh_token) { "ya29.AHES6ZS_KHUpdO5P0nyvADWf4tL5o8e8C_q5UK0HyyYOF3jw" }
|
156
192
|
let(:mock_fetch_refresh_token_response) { {"access_token"=>mock_access_token, "token_type"=>"Bearer", "expires_in"=>3600} }
|
157
193
|
subject { instance.refresh_access_token! }
|
158
|
-
it "
|
159
|
-
instance.api_client.
|
160
|
-
instance.
|
161
|
-
subject.
|
162
|
-
instance.access_token.
|
163
|
-
instance.refresh_token.
|
194
|
+
it "orchestrates the fetch_access_token process correctly" do
|
195
|
+
expect(instance.api_client).to be_a(Google::APIClient)
|
196
|
+
expect(instance).to receive(:fetch_refresh_token!).and_return(mock_fetch_refresh_token_response)
|
197
|
+
expect(subject).to eql(mock_access_token)
|
198
|
+
expect(instance.access_token).to eql(mock_access_token)
|
199
|
+
expect(instance.refresh_token).to eql(mock_refresh_token)
|
164
200
|
end
|
165
201
|
end
|
166
202
|
|
data/spec/unit/shell_spec.rb
CHANGED
@@ -7,14 +7,14 @@ describe GmailCli::Shell do
|
|
7
7
|
let(:shell) { GmailCli::Shell.new(getoptions,argv) }
|
8
8
|
|
9
9
|
before do
|
10
|
-
$stderr.
|
10
|
+
allow($stderr).to receive(:puts) # silence console feedback chatter
|
11
11
|
end
|
12
12
|
|
13
13
|
describe "#usage" do
|
14
14
|
let(:options) { ['-h'] }
|
15
15
|
let(:argv) { [] }
|
16
|
-
it "
|
17
|
-
shell.
|
16
|
+
it "prints usage when run" do
|
17
|
+
expect(shell).to receive(:usage)
|
18
18
|
shell.run
|
19
19
|
end
|
20
20
|
end
|
@@ -23,7 +23,7 @@ describe GmailCli::Shell do
|
|
23
23
|
let(:options) { [] }
|
24
24
|
let(:argv) { ["authorize"] }
|
25
25
|
it "should invoke authorize when run" do
|
26
|
-
GmailCli::Oauth2Helper.
|
26
|
+
expect(GmailCli::Oauth2Helper).to receive(:authorize!)
|
27
27
|
shell.run
|
28
28
|
end
|
29
29
|
end
|
data/spec/unit/tasks_spec.rb
CHANGED
@@ -11,8 +11,8 @@ describe "Rake Task gmail_cli:" do
|
|
11
11
|
Rake.application.invoke_task task_name
|
12
12
|
end
|
13
13
|
|
14
|
-
it "
|
15
|
-
GmailCli::Oauth2Helper.
|
14
|
+
it "runs successfully" do
|
15
|
+
expect_any_instance_of(GmailCli::Oauth2Helper).to receive(:authorize!).and_return(nil)
|
16
16
|
expect { run_rake_task }.to_not raise_error
|
17
17
|
end
|
18
18
|
|
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gmail_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Paul Gallagher
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2015-07-03 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: getoptions
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,7 +20,6 @@ dependencies:
|
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
@@ -30,7 +27,6 @@ dependencies:
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: gmail_xoauth
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
31
|
- - ~>
|
36
32
|
- !ruby/object:Gem::Version
|
@@ -38,7 +34,6 @@ dependencies:
|
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
38
|
- - ~>
|
44
39
|
- !ruby/object:Gem::Version
|
@@ -46,115 +41,73 @@ dependencies:
|
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: google-api-client
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
45
|
- - ~>
|
52
46
|
- !ruby/object:Gem::Version
|
53
|
-
version: 0.
|
47
|
+
version: '0.7'
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
52
|
- - ~>
|
60
53
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.
|
54
|
+
version: '0.7'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: bundler
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
|
-
requirements:
|
67
|
-
- - ! '>'
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: '1.3'
|
70
|
-
type: :development
|
71
|
-
prerelease: false
|
72
|
-
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
|
-
requirements:
|
75
|
-
- - ! '>'
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: '1.3'
|
78
|
-
- !ruby/object:Gem::Dependency
|
79
|
-
name: rake
|
80
|
-
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
58
|
requirements:
|
83
59
|
- - ~>
|
84
60
|
- !ruby/object:Gem::Version
|
85
|
-
version:
|
61
|
+
version: '1.6'
|
86
62
|
type: :development
|
87
63
|
prerelease: false
|
88
64
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
65
|
requirements:
|
91
66
|
- - ~>
|
92
67
|
- !ruby/object:Gem::Version
|
93
|
-
version:
|
68
|
+
version: '1.6'
|
94
69
|
- !ruby/object:Gem::Dependency
|
95
|
-
name:
|
70
|
+
name: rake
|
96
71
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
72
|
requirements:
|
99
|
-
- -
|
73
|
+
- - ! '>='
|
100
74
|
- !ruby/object:Gem::Version
|
101
|
-
version:
|
75
|
+
version: '0'
|
102
76
|
type: :development
|
103
77
|
prerelease: false
|
104
78
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
79
|
requirements:
|
107
|
-
- -
|
80
|
+
- - ! '>='
|
108
81
|
- !ruby/object:Gem::Version
|
109
|
-
version:
|
82
|
+
version: '0'
|
110
83
|
- !ruby/object:Gem::Dependency
|
111
|
-
name:
|
84
|
+
name: rspec
|
112
85
|
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
86
|
requirements:
|
115
87
|
- - ~>
|
116
88
|
- !ruby/object:Gem::Version
|
117
|
-
version: '3.
|
89
|
+
version: '3.0'
|
118
90
|
type: :development
|
119
91
|
prerelease: false
|
120
92
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
93
|
requirements:
|
123
94
|
- - ~>
|
124
95
|
- !ruby/object:Gem::Version
|
125
|
-
version: '3.
|
96
|
+
version: '3.0'
|
126
97
|
- !ruby/object:Gem::Dependency
|
127
98
|
name: guard-rspec
|
128
99
|
requirement: !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
|
-
requirements:
|
131
|
-
- - ~>
|
132
|
-
- !ruby/object:Gem::Version
|
133
|
-
version: 3.0.2
|
134
|
-
type: :development
|
135
|
-
prerelease: false
|
136
|
-
version_requirements: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
|
-
requirements:
|
139
|
-
- - ~>
|
140
|
-
- !ruby/object:Gem::Version
|
141
|
-
version: 3.0.2
|
142
|
-
- !ruby/object:Gem::Dependency
|
143
|
-
name: rb-fsevent
|
144
|
-
requirement: !ruby/object:Gem::Requirement
|
145
|
-
none: false
|
146
100
|
requirements:
|
147
|
-
- -
|
101
|
+
- - ! '>='
|
148
102
|
- !ruby/object:Gem::Version
|
149
|
-
version: 0
|
103
|
+
version: '0'
|
150
104
|
type: :development
|
151
105
|
prerelease: false
|
152
106
|
version_requirements: !ruby/object:Gem::Requirement
|
153
|
-
none: false
|
154
107
|
requirements:
|
155
|
-
- -
|
108
|
+
- - ! '>='
|
156
109
|
- !ruby/object:Gem::Version
|
157
|
-
version: 0
|
110
|
+
version: '0'
|
158
111
|
description: A simple toolbox for build utilities that talk to Gmail with OAuth2
|
159
112
|
email:
|
160
113
|
- gallagher.paul@gmail.com
|
@@ -164,6 +117,8 @@ extensions: []
|
|
164
117
|
extra_rdoc_files: []
|
165
118
|
files:
|
166
119
|
- .gitignore
|
120
|
+
- .rspec
|
121
|
+
- .travis.yml
|
167
122
|
- Gemfile
|
168
123
|
- Guardfile
|
169
124
|
- LICENSE.txt
|
@@ -187,27 +142,26 @@ files:
|
|
187
142
|
homepage: https://github.com/evendis/gmail_cli
|
188
143
|
licenses:
|
189
144
|
- MIT
|
145
|
+
metadata: {}
|
190
146
|
post_install_message:
|
191
147
|
rdoc_options: []
|
192
148
|
require_paths:
|
193
149
|
- lib
|
194
150
|
required_ruby_version: !ruby/object:Gem::Requirement
|
195
|
-
none: false
|
196
151
|
requirements:
|
197
152
|
- - ! '>='
|
198
153
|
- !ruby/object:Gem::Version
|
199
154
|
version: '0'
|
200
155
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
201
|
-
none: false
|
202
156
|
requirements:
|
203
157
|
- - ! '>='
|
204
158
|
- !ruby/object:Gem::Version
|
205
159
|
version: '0'
|
206
160
|
requirements: []
|
207
161
|
rubyforge_project:
|
208
|
-
rubygems_version:
|
162
|
+
rubygems_version: 2.4.5
|
209
163
|
signing_key:
|
210
|
-
specification_version:
|
164
|
+
specification_version: 4
|
211
165
|
summary: GmailCli packages the key tools and adds a sprinkling of goodness to make
|
212
166
|
it just that much easier to write primarily command-line utilities for Gmail/GoogleApps
|
213
167
|
test_files:
|