R3c 0.0.8 → 0.0.9
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 +4 -4
- data/lib/r3c/rest_helper.rb +25 -6
- data/lib/r3c/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5fe51ccd80003667c2ad3dc0abadddab02b00b3
|
4
|
+
data.tar.gz: 959e3978652765704fb4870e599602b52d5ff4c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d178c2e801af962c6c294a03626236bf400c7355d7feca2cab6f8348c402c73c70825260600bf06ee030cd5a3df5b8d38fc4a0ff239695d96a0aa30636d2efa0
|
7
|
+
data.tar.gz: 7ea9e1b6f36030f2e08218cbacc0606602608c0db9e6eaea5a720459311b81816a088c722bd66935c5130164b594f6b090f2e11f3c24e1dd757fadc339711c3f
|
data/lib/r3c/rest_helper.rb
CHANGED
@@ -6,9 +6,18 @@ module R3c
|
|
6
6
|
|
7
7
|
|
8
8
|
|
9
|
-
def self.upload(file
|
10
|
-
response =
|
11
|
-
|
9
|
+
def self.upload(file)
|
10
|
+
response = nil
|
11
|
+
params= {:multipart => true, :content_type => 'application/octet-stream'}
|
12
|
+
params= set_ssl_params(params)
|
13
|
+
if !R3c::BaseEntity.user
|
14
|
+
#response = RestClient.post("#{R3c::BaseEntity.site}/uploads.json?key=#{R3c::BaseEntity.headers['X-Redmine-API-Key']}", file, {:multipart => true, :content_type => 'application/octet-stream'})
|
15
|
+
response = RestClient.post("#{R3c::BaseEntity.site}/uploads.json?key=#{R3c::BaseEntity.headers['X-Redmine-API-Key']}", file, params)
|
16
|
+
else
|
17
|
+
params = add_auth(params)
|
18
|
+
response = RestClient.post("#{R3c::BaseEntity.site}/uploads.json", file, params)
|
19
|
+
end
|
20
|
+
JSON.parse(response)['upload']['token']
|
12
21
|
end
|
13
22
|
|
14
23
|
|
@@ -55,19 +64,29 @@ module R3c
|
|
55
64
|
|
56
65
|
private
|
57
66
|
def self.execute(params)
|
67
|
+
params = add_basic_auth(params)
|
68
|
+
params= set_ssl_params(params)
|
69
|
+
puts "rest-helper.rb->execute: params="+params.inspect.to_s
|
70
|
+
RestClient::Request.execute(params)
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.add_auth(params)
|
58
74
|
if R3c::BaseEntity.user
|
59
75
|
params[:user]= R3c::BaseEntity.user
|
60
76
|
params[:password]=R3c::BaseEntity.password
|
61
77
|
else
|
62
78
|
params[:url]= params[:url]+"?key=#{R3c::BaseEntity.headers['X-Redmine-API-Key']}"
|
63
79
|
end
|
64
|
-
|
80
|
+
return params
|
81
|
+
end
|
82
|
+
|
83
|
+
def self.set_ssl_params(params)
|
65
84
|
if R3c::BaseEntity.site.to_s.include?("https")
|
66
85
|
params[:verify_ssl]=R3c::BaseEntity.ssl_options[:verify_mode]
|
67
86
|
params= params.merge(R3c::BaseEntity.ssl_options)
|
68
|
-
puts "rest-helper.rb->execute: params="+params.inspect.to_s
|
69
87
|
end
|
70
|
-
|
88
|
+
return params
|
71
89
|
end
|
72
90
|
|
91
|
+
|
73
92
|
end
|
data/lib/r3c/version.rb
CHANGED