gyaazle 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/lib/gyaazle.rb +3 -0
- data/lib/gyaazle/cli.rb +11 -1
- data/lib/gyaazle/client.rb +22 -17
- data/lib/gyaazle/version.rb +1 -1
- data/spec/gyaazle_cli_spec.rb +7 -10
- data/spec/gyaazle_client_spec.rb +4 -4
- data/spec/spec_helper.rb +10 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b888572168c7b80285d8843e723817669c8b28c
|
4
|
+
data.tar.gz: 20beb96d0312b5e07135ff01d45877e56b88c868
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0275fe6ec8712ec12c002ad5ef3e237ef1998651a038a79525b236e8d44b3f1c8a5003718a7ec1af896e65f5d4cc4d2510e62229e6cf964d27693cf29d94bb8f
|
7
|
+
data.tar.gz: 52ddc12e566a8a1be32f0e5845dd1a7dc09b69e0a5db607373803b5987bf6857b9f255403d294b2e84fa599500e26834bccd5b895915ad484cbdcb769a769767
|
data/.travis.yml
CHANGED
data/lib/gyaazle.rb
CHANGED
data/lib/gyaazle/cli.rb
CHANGED
@@ -60,7 +60,17 @@ TEXT
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def edit_config
|
63
|
-
|
63
|
+
tmpfile = Tempfile.new("gyaazle-")
|
64
|
+
tmpfile.close
|
65
|
+
FileUtils.cp(config.file, tmpfile.path)
|
66
|
+
system(ENV["EDITOR"], tmpfile.path)
|
67
|
+
begin
|
68
|
+
MultiJson.load File.read(tmpfile.path)
|
69
|
+
FileUtils.cp(tmpfile.path, config.file)
|
70
|
+
rescue MultiJson::LoadError => e
|
71
|
+
$stderr.puts e.message
|
72
|
+
$stderr.puts "Does not saved"
|
73
|
+
end
|
64
74
|
end
|
65
75
|
|
66
76
|
def initialize_tokens(verifier = nil)
|
data/lib/gyaazle/client.rb
CHANGED
@@ -61,23 +61,28 @@ module Gyaazle
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def set_permissions(file_id, permissions = nil)
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
64
|
+
permissions ||= credentials[:permissions] || {
|
65
|
+
# Reference:
|
66
|
+
# * https://developers.google.com/drive/manage-sharing
|
67
|
+
# * https://developers.google.com/drive/v2/reference/permissions#resource
|
68
|
+
:role => "reader",
|
69
|
+
:type => "anyone",
|
70
|
+
:value => "me",
|
71
|
+
:withLink => "true",
|
72
|
+
:additionalRoles => ["commenter"],
|
73
|
+
}
|
74
|
+
permissions = [permissions] if permissions.class != Array
|
75
|
+
permissions.each do |perm|
|
76
|
+
json = MultiJson.dump(perm)
|
77
|
+
agent.post_content(
|
78
|
+
"https://www.googleapis.com/drive/v2/files/#{file_id}/permissions",
|
79
|
+
json,
|
80
|
+
{
|
81
|
+
"Authorization" => authorization_header_value,
|
82
|
+
'Content-Type' => 'application/json;charset=utf-8',
|
83
|
+
}
|
84
|
+
)
|
85
|
+
end
|
81
86
|
end
|
82
87
|
|
83
88
|
def get_file_info(file_id)
|
data/lib/gyaazle/version.rb
CHANGED
data/spec/gyaazle_cli_spec.rb
CHANGED
@@ -114,19 +114,14 @@ describe Gyaazle::CLI do
|
|
114
114
|
|
115
115
|
before do
|
116
116
|
cli.stub(:check_credentials!)
|
117
|
-
|
118
|
-
@orig_stdout = $stdout
|
119
|
-
$stdout = File.new("/dev/null", "w")
|
120
|
-
end
|
121
|
-
|
122
|
-
after do
|
123
|
-
$stdout = @orig_stdout
|
124
117
|
end
|
125
118
|
|
126
119
|
it "invoke client.upload" do
|
127
120
|
cli.client.should_receive(:upload).with(files.first).and_return(:alternateLink => "dummy")
|
128
121
|
cli.client.should_receive(:set_permissions)
|
129
|
-
|
122
|
+
silence do
|
123
|
+
cli.upload
|
124
|
+
end
|
130
125
|
end
|
131
126
|
end
|
132
127
|
|
@@ -135,8 +130,10 @@ describe Gyaazle::CLI do
|
|
135
130
|
let(:cli) { Gyaazle::CLI.new(%W!-e --config #{conf}!) }
|
136
131
|
|
137
132
|
it "invoke #system with $EDITOR" do
|
138
|
-
cli.should_receive(:system).with(ENV["EDITOR"],
|
139
|
-
|
133
|
+
cli.should_receive(:system).at_least(1).with(ENV["EDITOR"], anything)
|
134
|
+
silence do
|
135
|
+
cli.edit_config
|
136
|
+
end
|
140
137
|
File.unlink(conf) if File.exists?(conf)
|
141
138
|
end
|
142
139
|
end
|
data/spec/gyaazle_client_spec.rb
CHANGED
@@ -24,7 +24,7 @@ describe Gyaazle::Client do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
describe "#folder_id" do
|
27
|
-
context "
|
27
|
+
context "folder_id given" do
|
28
28
|
before do
|
29
29
|
config.update(:folder_id => folder_id)
|
30
30
|
client.stub(:get_file_info).and_return({
|
@@ -35,13 +35,13 @@ describe Gyaazle::Client do
|
|
35
35
|
})
|
36
36
|
end
|
37
37
|
|
38
|
-
it "invoke #create_folder" do
|
38
|
+
it "not invoke #create_folder" do
|
39
39
|
client.should_not_receive(:create_folder)
|
40
40
|
client.folder_id.should == folder_id
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
context "
|
44
|
+
context "folder_id does not given" do
|
45
45
|
before do
|
46
46
|
config.update(:folder_id => nil)
|
47
47
|
end
|
@@ -52,7 +52,7 @@ describe Gyaazle::Client do
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
-
context "
|
55
|
+
context "folder_id given but its in trash" do
|
56
56
|
before do
|
57
57
|
config.update(:folder_id => folder_id)
|
58
58
|
client.stub(:get_file_info).and_return({
|
data/spec/spec_helper.rb
CHANGED
@@ -25,6 +25,16 @@ Dir["./spec/support/**/*.rb"].each{|file| require file }
|
|
25
25
|
require File.expand_path("../../lib/gyaazle.rb", __FILE__)
|
26
26
|
|
27
27
|
RSpec.configure do |config|
|
28
|
+
def silence
|
29
|
+
@orig_stdout = $stdout
|
30
|
+
@orig_stderr = $stderr
|
31
|
+
$stdout = File.new("/dev/null", "w")
|
32
|
+
$stderr = File.new("/dev/null", "w")
|
33
|
+
yield
|
34
|
+
ensure
|
35
|
+
$stdout = @orig_stdout
|
36
|
+
$stderr = @orig_stderr
|
37
|
+
end
|
28
38
|
end
|
29
39
|
# -- coding: utf-8
|
30
40
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gyaazle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- uu59
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-05-
|
11
|
+
date: 2013-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|