R3c 0.0.5 → 0.0.6
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 -30
- data/lib/r3c/r3c.rb +39 -13
- data/lib/r3c/rest_helper.rb +49 -0
- 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: a2b970f2a8e10e16e9d23cea17bdab245eba09c9
|
4
|
+
data.tar.gz: 811116a7bd0d637a058dfe755ab765e2ad460a5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b48329923a182ad8f508b43a729da3426ba2826c7c24d8cf823b38177f2964fedb0115ca5b6b1898c5412fa2d36e6d0ae5fdf59e40c3efafd3436e5e467e6e3c
|
7
|
+
data.tar.gz: 230fb21d1e73d8a444410c5f4c8624b9a563e05c6af2d46a3aa053be6a3d95c7a6f31aa2e732f1b7f6cc17dd5d5a8c16c762b7bf4931fa53035b68fe38359dbd
|
data/lib/r3c.rb
CHANGED
@@ -1,43 +1,26 @@
|
|
1
1
|
require "r3c/r3c"
|
2
2
|
require "r3c/version"
|
3
3
|
require "rest-client"
|
4
|
+
require "r3c/rest_helper"
|
4
5
|
require "json"
|
5
6
|
|
6
7
|
module R3c
|
7
8
|
|
8
|
-
|
9
|
-
def self.upload(file)
|
10
|
-
response = RestClient.post("#{R3c::BaseEntity.site}/uploads.json?key=#{R3c::BaseEntity.headers['X-Redmine-API-Key']}", file, {:multipart => true, :content_type => 'application/octet-stream'})
|
11
|
-
token = JSON.parse(response)['upload']['token']
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.add_watcher(issue_id, user_id)
|
15
|
-
#POST /issues/[id]/watchers.[format]
|
16
|
-
response = RestClient.post("#{R3c::BaseEntity.site}/issues/#{issue_id}/watchers.xml?key=#{R3c::BaseEntity.headers['X-Redmine-API-Key']}", {user_id: user_id})
|
17
|
-
end
|
18
|
-
|
19
|
-
def self.remove_watcher(issue_id, user_id)
|
20
|
-
#DELETE /issues/[id]/watchers/[user_id].[format]
|
21
|
-
response = RestClient.delete("#{R3c::BaseEntity.site}/issues/#{issue_id}/watchers/#{user_id}.xml?key=#{R3c::BaseEntity.headers['X-Redmine-API-Key']}")
|
22
|
-
end
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
def self.version
|
9
|
+
def self.version
|
27
10
|
VERSION
|
28
|
-
|
11
|
+
end
|
29
12
|
|
30
|
-
|
31
|
-
|
32
|
-
|
13
|
+
def self.site site
|
14
|
+
R3c::BaseEntity.set_site(site)
|
15
|
+
end
|
33
16
|
|
34
|
-
|
35
|
-
|
36
|
-
|
17
|
+
def self.format format
|
18
|
+
R3c::BaseEntity.set_format(format)
|
19
|
+
end
|
37
20
|
|
38
21
|
def self.auth auth
|
39
22
|
R3c::BaseEntity.auth auth
|
40
|
-
|
23
|
+
end
|
41
24
|
|
42
25
|
|
43
26
|
private
|
@@ -55,10 +38,10 @@ end
|
|
55
38
|
end
|
56
39
|
|
57
40
|
|
58
|
-
|
59
|
-
|
41
|
+
R3c.site('http://localhost:3000/')
|
42
|
+
R3c.format(:xml)
|
60
43
|
|
61
|
-
|
44
|
+
R3c.auth({api: {key: '8091d55257c4c90b6d56e83322622cb5f4ecee64'}})
|
62
45
|
|
63
46
|
#~ file = File.read('c:\windows-version.txt')
|
64
47
|
#~ puts file.inspect.to_s
|
data/lib/r3c/r3c.rb
CHANGED
@@ -30,7 +30,7 @@ class BaseEntity < ActiveResource::Base
|
|
30
30
|
self.headers['X-Redmine-API-Key'] = api_key
|
31
31
|
end
|
32
32
|
|
33
|
-
def self.
|
33
|
+
def self.basic_auth(params)
|
34
34
|
self.user= params[:user]
|
35
35
|
self.password= params[:password]
|
36
36
|
end
|
@@ -41,26 +41,32 @@ class BaseEntity < ActiveResource::Base
|
|
41
41
|
|
42
42
|
end
|
43
43
|
|
44
|
-
|
45
|
-
#
|
44
|
+
# CRUD on Version
|
45
|
+
# Example: R3c.project.find(1).get(:versions)
|
46
46
|
class Version<BaseEntity
|
47
47
|
end
|
48
48
|
|
49
|
-
|
50
|
-
|
49
|
+
# CRUD on Membership
|
50
|
+
# Example: Get memberships: R3c.project.find(1).get(:memberships)
|
51
|
+
# Example: Create a membership: R3c.wiki_page.new
|
52
|
+
class Membership<BaseEntity
|
51
53
|
#self.prefix "/projects/editing_item"
|
52
54
|
#self.element_name ""
|
53
55
|
end
|
54
56
|
|
55
|
-
|
57
|
+
# List wiki on a project
|
58
|
+
# R3c.project.find(1).get("wiki/index")
|
59
|
+
|
60
|
+
# Get a wiki page by name
|
61
|
+
# R3c.project.find(1).get("wiki")
|
62
|
+
|
63
|
+
# Create a WikiPage
|
64
|
+
# R3c.wiki_page.new
|
65
|
+
class WikiPage<BaseEntity
|
56
66
|
#self.prefix "/projects/editing_item"
|
57
67
|
#self.element_name ""
|
58
68
|
end
|
59
69
|
|
60
|
-
class Enumeration<BaseEntity
|
61
|
-
end
|
62
|
-
# **************************** #
|
63
|
-
|
64
70
|
|
65
71
|
# CRUD on Project
|
66
72
|
# Call R3c.project.*
|
@@ -71,7 +77,21 @@ end
|
|
71
77
|
|
72
78
|
# CRUD on Issue
|
73
79
|
# Call R3c.issue.*
|
74
|
-
#
|
80
|
+
# Examples:
|
81
|
+
# R3c.issue.find 1
|
82
|
+
# issues =R3c.issue.find(:all, params: {tracker_id: 1}) #filtering (with defaul limit)
|
83
|
+
# issues =R3c.issue.find(:all, params: { limit: 5, offset:20}) #retrieving with specified limit and offset
|
84
|
+
# issues =R3c.issue.find(:all, params: { limit: 5, offset:20, tracker_id: 1}) #filtering and retrieving with specified limit and offset
|
85
|
+
# issues= R3c.project.find(1).get(:issues) #retrieving a project issues
|
86
|
+
# issues = R3c.issue.find(:all, params: {"query_id" => 12})
|
87
|
+
# issues=R3c.issue.find(1, params: {include: "watchers"})
|
88
|
+
# similarly you can include
|
89
|
+
# - children
|
90
|
+
# - attachments
|
91
|
+
# - relations
|
92
|
+
# - changesets
|
93
|
+
# - journals
|
94
|
+
# - watchers - Since 2.3.0
|
75
95
|
class Issue<BaseEntity
|
76
96
|
end
|
77
97
|
|
@@ -110,6 +130,7 @@ end
|
|
110
130
|
# CRUD on TimeEntry
|
111
131
|
# Call R3c.time_entry.*
|
112
132
|
# Example: R3c.time_entry.first
|
133
|
+
# Example: R3c.project.find(1).time_entries
|
113
134
|
class TimeEntry<BaseEntity
|
114
135
|
end
|
115
136
|
|
@@ -122,9 +143,14 @@ end
|
|
122
143
|
|
123
144
|
# CRUD on Query
|
124
145
|
# Call R3c.query.find(id)
|
125
|
-
#
|
146
|
+
# Examples:
|
147
|
+
# R3c.query.find 1
|
148
|
+
# R3c.query.all
|
149
|
+
# R3c.query.find :all
|
150
|
+
# R3c.issue.find(:all, params: {"query_id" => 12})
|
126
151
|
class Query<BaseEntity
|
127
|
-
end
|
152
|
+
end
|
153
|
+
|
128
154
|
|
129
155
|
end
|
130
156
|
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require "rest-client"
|
2
|
+
|
3
|
+
|
4
|
+
module R3c
|
5
|
+
|
6
|
+
def self.upload(file, format="xml")
|
7
|
+
response = RestClient.post("#{R3c::BaseEntity.site}/uploads.#{format}?key=#{R3c::BaseEntity.headers['X-Redmine-API-Key']}", file, {:multipart => true, :content_type => 'application/octet-stream'})
|
8
|
+
token = JSON.parse(response)['upload']['token']
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
#Note: see r3c.rb for example about how to retrieve watchers on an issue
|
13
|
+
#Example:
|
14
|
+
# R3c.add_watcher(1, 1)
|
15
|
+
def self.add_watcher(issue_id, user_id, format="xml")
|
16
|
+
#POST /issues/[id]/watchers.[format]
|
17
|
+
response = RestClient.post("#{R3c::BaseEntity.site}/issues/#{issue_id}/watchers.#{format}?key=#{R3c::BaseEntity.headers['X-Redmine-API-Key']}", {user_id: user_id})
|
18
|
+
return JSON.parse(response) if format == "json"
|
19
|
+
response
|
20
|
+
end
|
21
|
+
|
22
|
+
#Example:
|
23
|
+
# R3c.remove_watcher(1, 1)
|
24
|
+
def self.remove_watcher(issue_id, user_id, format="xml")
|
25
|
+
#DELETE /issues/[id]/watchers/[user_id].[format]
|
26
|
+
response = RestClient.delete("#{R3c::BaseEntity.site}/issues/#{issue_id}/watchers/#{user_id}.#{format}?key=#{R3c::BaseEntity.headers['X-Redmine-API-Key']}")
|
27
|
+
return JSON.parse(response) if format == "json"
|
28
|
+
response
|
29
|
+
end
|
30
|
+
|
31
|
+
#Example:
|
32
|
+
# R3c.enumerations("issue_priorities")
|
33
|
+
def self.enumerations(enumeration, format="xml")
|
34
|
+
#GET /enumerations/<enumeration>.[format] #enumeration= "issue_priorities" OR "time_entry_activities"
|
35
|
+
response = RestClient.get("#{R3c::BaseEntity.site}/enumerations/#{enumeration}.#{format}?key=#{R3c::BaseEntity.headers['X-Redmine-API-Key']}")
|
36
|
+
return JSON.parse(response) if format == "json"
|
37
|
+
response
|
38
|
+
end
|
39
|
+
|
40
|
+
#Example:
|
41
|
+
# R3c.search("sometext")
|
42
|
+
def self.search(q, format = "xml")
|
43
|
+
# GET '/search.xml', :q => 'recipe subproject commit', :all_words => ''
|
44
|
+
response = RestClient.get("#{R3c::BaseEntity.site}/search.#{format}/?key=#{R3c::BaseEntity.headers['X-Redmine-API-Key']}", {all_words: '', q: q})
|
45
|
+
return JSON.parse(response) if format == "json"
|
46
|
+
response
|
47
|
+
end
|
48
|
+
|
49
|
+
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.6
|
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-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activeresource
|
@@ -82,6 +82,7 @@ files:
|
|
82
82
|
- lib/Gemfile
|
83
83
|
- lib/r3c.rb
|
84
84
|
- lib/r3c/r3c.rb
|
85
|
+
- lib/r3c/rest_helper.rb
|
85
86
|
- lib/r3c/version.rb
|
86
87
|
homepage: https://github.com/wuatanabe/R3c
|
87
88
|
licenses:
|