R3c 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/r3c.rb +13 -0
- data/lib/r3c/r3c.rb +12 -0
- data/lib/r3c/rest_helper.rb +29 -5
- data/lib/r3c/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 891785aca6c9373f5d616109a1dd8671fe54a82b
|
4
|
+
data.tar.gz: 3db7c2db12dc86c51e5723451b96a646d79f4161
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c51fc0d15f1a1f08709a2d60ca3010a28022a8578b2261daee222edb3f65b0d71db4ed126495d84e4a9c5371cac9fb9158becb9be439fabc1a7d2e7f155c5573
|
7
|
+
data.tar.gz: fba8dbf911b4050dcf246627cca98972d6a5a79eda331241fbef262584d03800a372a17a8fde0e5a4d09acef35dff4c7f925da4a13239a59ef2b4d56b2105f31
|
data/lib/r3c.rb
CHANGED
@@ -21,7 +21,20 @@ module R3c
|
|
21
21
|
def self.auth auth
|
22
22
|
R3c::BaseEntity.auth auth
|
23
23
|
end
|
24
|
+
|
25
|
+
def self.ssl ssl_options
|
26
|
+
if R3c::BaseEntity.include?("https")
|
27
|
+
return R3c::BaseEntity.set_ssl ssl_options
|
28
|
+
end
|
29
|
+
end
|
24
30
|
|
31
|
+
def self.verify_ssl?
|
32
|
+
if R3c::BaseEntity.self.ssl_options[:verify_mode] == OpenSSL::SSL::VERIFY_NONE
|
33
|
+
return false
|
34
|
+
else
|
35
|
+
return true
|
36
|
+
end
|
37
|
+
end
|
25
38
|
|
26
39
|
private
|
27
40
|
|
data/lib/r3c/r3c.rb
CHANGED
@@ -8,6 +8,10 @@ class BaseEntity < ActiveResource::Base
|
|
8
8
|
self.format = :xml
|
9
9
|
|
10
10
|
def self.set_site(url)
|
11
|
+
if !self.ssl_options and url.include?("https")
|
12
|
+
self.ssl_options ={}
|
13
|
+
self.ssl_options[:verify_mode] =OpenSSL::SSL::VERIFY_PEER
|
14
|
+
end
|
11
15
|
self.site= url
|
12
16
|
end
|
13
17
|
|
@@ -25,6 +29,14 @@ class BaseEntity < ActiveResource::Base
|
|
25
29
|
end
|
26
30
|
end
|
27
31
|
|
32
|
+
def self.set_ssl(ssl_options)
|
33
|
+
self.ssl_options = {:cert => ssl_options[:cert],
|
34
|
+
:key => ssl_options[:key],
|
35
|
+
:ca_path => ssl_options[:ca_path],
|
36
|
+
:verify_mode => ssl_options[:verify_mode]
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
28
40
|
private
|
29
41
|
def self.api_key(api_key)
|
30
42
|
self.headers['X-Redmine-API-Key'] = api_key
|
data/lib/r3c/rest_helper.rb
CHANGED
@@ -3,18 +3,23 @@ require "rest-client"
|
|
3
3
|
|
4
4
|
module R3c
|
5
5
|
|
6
|
+
|
7
|
+
|
8
|
+
|
6
9
|
def self.upload(file, format="xml")
|
7
|
-
response =
|
10
|
+
response = execute(method: :post, url: "#{R3c::BaseEntity.site}/uploads.#{format}", file: file, :multipart => true, :content_type => 'application/octet-stream')
|
8
11
|
token = JSON.parse(response)['upload']['token']
|
9
12
|
end
|
10
13
|
|
11
14
|
|
15
|
+
|
16
|
+
|
12
17
|
#Note: see r3c.rb for example about how to retrieve watchers on an issue
|
13
18
|
#Example:
|
14
19
|
# R3c.add_watcher(1, 1)
|
15
20
|
def self.add_watcher(issue_id, user_id, format="xml")
|
16
21
|
#POST /issues/[id]/watchers.[format]
|
17
|
-
response =
|
22
|
+
response = execute(method: :post, url: "#{R3c::BaseEntity.site}/issues/#{issue_id}/watchers.#{format}", headers: {params: {user_id: user_id}})
|
18
23
|
return JSON.parse(response) if format == "json"
|
19
24
|
response
|
20
25
|
end
|
@@ -23,7 +28,7 @@ module R3c
|
|
23
28
|
# R3c.remove_watcher(1, 1)
|
24
29
|
def self.remove_watcher(issue_id, user_id, format="xml")
|
25
30
|
#DELETE /issues/[id]/watchers/[user_id].[format]
|
26
|
-
response =
|
31
|
+
response = execute(method: :delete, url: "#{R3c::BaseEntity.site}/issues/#{issue_id}/watchers/#{user_id}.#{format}")
|
27
32
|
return JSON.parse(response) if format == "json"
|
28
33
|
response
|
29
34
|
end
|
@@ -32,18 +37,37 @@ module R3c
|
|
32
37
|
# R3c.enumerations("issue_priorities")
|
33
38
|
def self.enumerations(enumeration, format="xml")
|
34
39
|
#GET /enumerations/<enumeration>.[format] #enumeration= "issue_priorities" OR "time_entry_activities"
|
35
|
-
response =
|
40
|
+
response = self.execute(method: :get, url: "#{R3c::BaseEntity.site}/enumerations/#{enumeration}.#{format}")
|
36
41
|
return JSON.parse(response) if format == "json"
|
37
42
|
response
|
38
43
|
end
|
39
44
|
|
45
|
+
|
46
|
+
|
40
47
|
#Example:
|
41
48
|
# R3c.search("sometext")
|
42
49
|
def self.search(q, format = "xml")
|
43
50
|
# GET '/search.xml', :q => 'recipe subproject commit', :all_words => ''
|
44
|
-
response =
|
51
|
+
response = execute(method: :get, url: "#{R3c::BaseEntity.site}/search.#{format}", headers: {params: {all_words: "", q: q}} )
|
45
52
|
return JSON.parse(response) if format == "json"
|
46
53
|
response
|
47
54
|
end
|
48
55
|
|
56
|
+
private
|
57
|
+
def self.execute(params)
|
58
|
+
if R3c::BaseEntity.user
|
59
|
+
params[:user]= R3c::BaseEntity.user
|
60
|
+
params[:password]=R3c::BaseEntity.password
|
61
|
+
else
|
62
|
+
params[:url]= params[:url]+"?key=#{R3c::BaseEntity.headers['X-Redmine-API-Key']}"
|
63
|
+
end
|
64
|
+
puts "rest-helper.rb->execute: params="+params.inspect.to_s
|
65
|
+
if R3c::BaseEntity.site.to_s.include?("https")
|
66
|
+
params[:verify_ssl]=R3c::BaseEntity.ssl_options[:verify_mode]
|
67
|
+
params= params.merge(R3c::BaseEntity.ssl_options)
|
68
|
+
puts "rest-helper.rb->execute: params="+params.inspect.to_s
|
69
|
+
end
|
70
|
+
RestClient::Request.execute(params)
|
71
|
+
end
|
72
|
+
|
49
73
|
end
|
data/lib/r3c/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: R3c
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paolo Freuli
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activeresource
|
@@ -109,3 +109,4 @@ signing_key:
|
|
109
109
|
specification_version: 4
|
110
110
|
summary: Rest Redmine Ruby Client
|
111
111
|
test_files: []
|
112
|
+
has_rdoc: false
|