klaro-client 0.5.0 → 0.5.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/klaro/client.rb +4 -0
- data/lib/klaro/client/request_handler.rb +28 -13
- data/lib/klaro/client/resource/story.rb +12 -6
- data/lib/klaro/client/version.rb +1 -1
- metadata +5 -12
- data/VERSION +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5254e23cef2ad85ee5aad4c5bcdd4a4171ee31e15553b5fca1707b659fd2546
|
4
|
+
data.tar.gz: ef6d17c7c3d7f9aad73c594f2fb1368078165e7be179dae4daf578c7b1310d7a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ab49ef56322aff2111b1c80e16cb83850da811704a4f61cea4441b337d873bef9dedefdf4df9f8e9f11073d250b08ea029656c318122383c4adfde8f13c7db6
|
7
|
+
data.tar.gz: 55f9d63ca3ae7afb22622e0354046f9b87e00723e33b40de52fa0da521108985a0ca90bebac59b2d22c0219ba10d82884cfd2aa56ef072e8ab6336999427f2a1
|
data/lib/klaro/client.rb
CHANGED
@@ -6,8 +6,10 @@ module Klaro
|
|
6
6
|
attr_reader :base_url, :token
|
7
7
|
|
8
8
|
def initialize(url)
|
9
|
-
@base_url = url
|
9
|
+
@base_url = url.gsub(/\/api\/?$/, "")
|
10
10
|
@token = nil
|
11
|
+
@subdomain = nil
|
12
|
+
@workspace = nil
|
11
13
|
end
|
12
14
|
|
13
15
|
def authenticated?
|
@@ -19,12 +21,20 @@ module Klaro
|
|
19
21
|
self
|
20
22
|
end
|
21
23
|
|
22
|
-
def
|
23
|
-
@
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
def with_project(subdomain)
|
25
|
+
@subdomain = subdomain
|
26
|
+
self
|
27
|
+
end
|
28
|
+
|
29
|
+
def authenticate(user, password, workspace = nil)
|
30
|
+
@workspace = workspace
|
31
|
+
@token = get_token(
|
32
|
+
Http
|
33
|
+
.headers({
|
34
|
+
'Content-Type' => 'application/json'
|
35
|
+
})
|
36
|
+
.post("#{base_url}/api/auth/tokens/", payload(user, password))
|
37
|
+
)
|
28
38
|
end
|
29
39
|
|
30
40
|
def get(endpoint, raw = false)
|
@@ -65,12 +75,17 @@ module Klaro
|
|
65
75
|
end
|
66
76
|
|
67
77
|
def http
|
68
|
-
Http.headers(
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
78
|
+
Http.headers(http_headers)
|
79
|
+
end
|
80
|
+
|
81
|
+
def http_headers
|
82
|
+
hs = {
|
83
|
+
"Authorization" => @token,
|
84
|
+
"Content-Type" => "application/json"
|
85
|
+
}
|
86
|
+
hs['Klaro-Project-Subdomain'] = @subdomain if @subdomain
|
87
|
+
hs['X-Klaro-ViewAs'] = @workspace if @workspace
|
88
|
+
hs
|
74
89
|
end
|
75
90
|
|
76
91
|
def info(msg)
|
@@ -2,18 +2,23 @@ module Klaro
|
|
2
2
|
class Client
|
3
3
|
class Story < Resource
|
4
4
|
|
5
|
+
def _title
|
6
|
+
self[:title] || self[:description]
|
7
|
+
end
|
8
|
+
|
5
9
|
def title
|
6
|
-
@title ||= MdText.new(self.
|
10
|
+
@title ||= MdText.new(self._title.split("\n").first, :summary)
|
7
11
|
end
|
8
12
|
|
9
13
|
def summary
|
10
|
-
@summary ||= MdText.new(self.
|
14
|
+
@summary ||= MdText.new(self._title.split("\n")[1..-1].join("\n"), :summary)
|
11
15
|
end
|
12
16
|
|
13
|
-
def
|
14
|
-
|
17
|
+
def details
|
18
|
+
details = self[:details] || self[:specification]
|
19
|
+
@specification ||= MdText.new(details, :details)
|
15
20
|
end
|
16
|
-
alias :
|
21
|
+
alias :specification :details
|
17
22
|
|
18
23
|
def linked_cards
|
19
24
|
@linked_cards ||= (self.linked || []).map{|s| Story.dress(s, @client) }
|
@@ -42,7 +47,8 @@ module Klaro
|
|
42
47
|
url = attachment.url
|
43
48
|
url += "?n=" + URI.encode_www_form_component(attachment.filename) unless url =~ /\?n=/
|
44
49
|
path = handle_image(url, root_path, target_folder, client)
|
45
|
-
attachment.
|
50
|
+
attachment.url = path
|
51
|
+
attachment
|
46
52
|
end
|
47
53
|
self.class.dress(self.to_h.merge(
|
48
54
|
attachments: as
|
data/lib/klaro/client/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: klaro-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- enspirit
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dotenv
|
@@ -44,20 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
48
|
-
- - ">="
|
49
|
-
- !ruby/object:Gem::Version
|
50
|
-
version: '3.4'
|
47
|
+
version: 3.5.1
|
51
48
|
type: :runtime
|
52
49
|
prerelease: false
|
53
50
|
version_requirements: !ruby/object:Gem::Requirement
|
54
51
|
requirements:
|
55
52
|
- - "~>"
|
56
53
|
- !ruby/object:Gem::Version
|
57
|
-
version:
|
58
|
-
- - ">="
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: '3.4'
|
54
|
+
version: 3.5.1
|
61
55
|
- !ruby/object:Gem::Dependency
|
62
56
|
name: i18n
|
63
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,7 +116,6 @@ extra_rdoc_files: []
|
|
122
116
|
files:
|
123
117
|
- Gemfile
|
124
118
|
- Rakefile
|
125
|
-
- VERSION
|
126
119
|
- lib/klaro/client.rb
|
127
120
|
- lib/klaro/client/errors.rb
|
128
121
|
- lib/klaro/client/request_handler.rb
|
@@ -155,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
155
148
|
- !ruby/object:Gem::Version
|
156
149
|
version: '0'
|
157
150
|
requirements: []
|
158
|
-
rubygems_version: 3.
|
151
|
+
rubygems_version: 3.0.8
|
159
152
|
signing_key:
|
160
153
|
specification_version: 4
|
161
154
|
summary: Klaro Client
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.3.0
|