klaro-client 0.4.3 → 0.5.2
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 +9 -5
- data/lib/klaro/client/resource.rb +21 -4
- data/lib/klaro/client/resource/attachment.rb +15 -0
- data/lib/klaro/client/resource/dimension.rb +1 -1
- data/lib/klaro/client/resource/story.rb +22 -7
- data/lib/klaro/client/support/md_text.rb +1 -1
- data/lib/klaro/client/version.rb +2 -2
- metadata +12 -19
- 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: d0fcb893254b798095805751fdebcea7a0ed6ab481decf7fa687393ba7e012ab
|
4
|
+
data.tar.gz: eec1632171921bf81f2c97c6c10a352a957c615e968d76296e4dc54ed0e96562
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ac3c1d551f1910aa193cc753fe036dc8fe360175963940f9a4c9d9b7281020b6a7e493b1bece4576bd7e974d04b4c07c75572f158d862566dd79616c80c7965
|
7
|
+
data.tar.gz: fdd82f48b35932038ab44ad0beccba73b710b1be2c3671af1e38088d501649a5e3124b4c01264af5cadc510bef6624c7cd06e81d8286e19d628ff20f30639e4a
|
data/lib/klaro/client.rb
CHANGED
@@ -11,6 +11,10 @@ module Klaro
|
|
11
11
|
@request = RequestHandler.new(base_url)
|
12
12
|
end
|
13
13
|
|
14
|
+
def absolute_url(url)
|
15
|
+
request.base_url + url
|
16
|
+
end
|
17
|
+
|
14
18
|
def with_token(*args, &bl)
|
15
19
|
request.with_token(*args, &bl)
|
16
20
|
end
|
@@ -20,23 +24,23 @@ module Klaro
|
|
20
24
|
end
|
21
25
|
|
22
26
|
def dimension(code_or_id)
|
23
|
-
Dimension.dress(request.get("/api/dimensions/#{code_or_id}"))
|
27
|
+
Dimension.dress(request.get("/api/dimensions/#{code_or_id}"), self)
|
24
28
|
end
|
25
29
|
|
26
30
|
def dimensions
|
27
|
-
Dimensions.dress(request.get('/api/dimensions'))
|
31
|
+
Dimensions.dress(request.get('/api/dimensions'), self)
|
28
32
|
end
|
29
33
|
|
30
34
|
def board(location_or_id)
|
31
|
-
Board.dress(request.get("/api/boards/#{location_or_id}"))
|
35
|
+
Board.dress(request.get("/api/boards/#{location_or_id}"), self)
|
32
36
|
end
|
33
37
|
|
34
38
|
def board_stories(location_or_id)
|
35
|
-
Stories.dress(request.get("/api/boards/#{location_or_id}/stories/"))
|
39
|
+
Stories.dress(request.get("/api/boards/#{location_or_id}/stories/"), self)
|
36
40
|
end
|
37
41
|
|
38
42
|
def story(id_or_identifier)
|
39
|
-
Story.dress(request.get("/api/stories/#{id_or_identifier}"))
|
43
|
+
Story.dress(request.get("/api/stories/#{id_or_identifier}"), self)
|
40
44
|
end
|
41
45
|
|
42
46
|
def upload_image(image_path)
|
@@ -2,16 +2,32 @@ module Klaro
|
|
2
2
|
class Client
|
3
3
|
class Resource < OpenStruct
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
def initialize(data, client)
|
6
|
+
super(data)
|
7
|
+
@client = client
|
7
8
|
end
|
8
9
|
|
10
|
+
class << self
|
11
|
+
|
12
|
+
def symbolize_keys(data)
|
13
|
+
Hash[data.each_pair.map{|k,v|
|
14
|
+
[k.to_sym, v]
|
15
|
+
}]
|
16
|
+
end
|
17
|
+
|
18
|
+
def dress(data, client)
|
19
|
+
new(symbolize_keys(data), client)
|
20
|
+
end
|
21
|
+
|
22
|
+
end # class << self
|
23
|
+
|
9
24
|
end # class Resource
|
10
25
|
class Collection
|
11
26
|
include Enumerable
|
12
27
|
|
13
|
-
def initialize(items)
|
28
|
+
def initialize(items, client)
|
14
29
|
@items = items.map{|i| self.class.dress_one(i) }
|
30
|
+
@client = client
|
15
31
|
end
|
16
32
|
|
17
33
|
def each(*args, &bl)
|
@@ -26,7 +42,7 @@ module Klaro
|
|
26
42
|
end
|
27
43
|
|
28
44
|
def dress_one(item)
|
29
|
-
@item_class.dress(item)
|
45
|
+
@item_class.dress(item, @client)
|
30
46
|
end
|
31
47
|
end
|
32
48
|
|
@@ -34,6 +50,7 @@ module Klaro
|
|
34
50
|
end # class Client
|
35
51
|
end # module Klaro
|
36
52
|
require_relative 'resource/story'
|
53
|
+
require_relative 'resource/attachment'
|
37
54
|
require_relative 'resource/stories'
|
38
55
|
require_relative 'resource/dimension'
|
39
56
|
require_relative 'resource/dimension_value'
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Klaro
|
2
|
+
class Client
|
3
|
+
class Attachment < Resource
|
4
|
+
|
5
|
+
def absUrl
|
6
|
+
@client.absolute_url(self.url)
|
7
|
+
end
|
8
|
+
|
9
|
+
def absThumbnailUrl
|
10
|
+
@client.absolute_url(self.thumbnailUrl)
|
11
|
+
end
|
12
|
+
|
13
|
+
end # class Attachment
|
14
|
+
end # class Client
|
15
|
+
end # module Klaro
|
@@ -15,6 +15,20 @@ module Klaro
|
|
15
15
|
end
|
16
16
|
alias :details :specification
|
17
17
|
|
18
|
+
def linked_cards
|
19
|
+
@linked_cards ||= (self.linked || []).map{|s| Story.dress(s, @client) }
|
20
|
+
end
|
21
|
+
|
22
|
+
def attachments
|
23
|
+
@attachments || super.map{|a| Attachment.dress(a, @client) }
|
24
|
+
end
|
25
|
+
|
26
|
+
def cover_attachment(force = false)
|
27
|
+
got = (self.attachments || []).find{|a| a[:isCover] }
|
28
|
+
got = (self.attachments || []).first if got.nil? and force
|
29
|
+
got
|
30
|
+
end
|
31
|
+
|
18
32
|
def to_url(with_identifier = true)
|
19
33
|
I18n.config.available_locales = [:en, :fr]
|
20
34
|
url = I18n.transliterate(title.to_s)
|
@@ -25,14 +39,15 @@ module Klaro
|
|
25
39
|
|
26
40
|
def download_and_relocate_attachments(root_path, target_folder, client)
|
27
41
|
as = self.attachments.map do |attachment|
|
28
|
-
url = attachment
|
29
|
-
url += "?n=" + URI.encode_www_form_component(attachment
|
42
|
+
url = attachment.url
|
43
|
+
url += "?n=" + URI.encode_www_form_component(attachment.filename) unless url =~ /\?n=/
|
30
44
|
path = handle_image(url, root_path, target_folder, client)
|
31
|
-
attachment.
|
45
|
+
attachment.url = path
|
46
|
+
attachment
|
32
47
|
end
|
33
|
-
self.class.
|
48
|
+
self.class.dress(self.to_h.merge(
|
34
49
|
attachments: as
|
35
|
-
))
|
50
|
+
), @client)
|
36
51
|
end
|
37
52
|
|
38
53
|
def download_and_relocate_images(root_path, target_folder, client)
|
@@ -42,9 +57,9 @@ module Klaro
|
|
42
57
|
image_relative_path = handle_image(url, root_path, target_folder, client)
|
43
58
|
"![#{label}](#{image_relative_path})"
|
44
59
|
end
|
45
|
-
self.class.
|
60
|
+
self.class.dress(self.to_h.merge(
|
46
61
|
specification: spec
|
47
|
-
))
|
62
|
+
), @client)
|
48
63
|
end
|
49
64
|
|
50
65
|
private
|
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.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- enspirit
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-07 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
|
@@ -114,19 +108,19 @@ dependencies:
|
|
114
108
|
- - "~>"
|
115
109
|
- !ruby/object:Gem::Version
|
116
110
|
version: '3.7'
|
117
|
-
description:
|
118
|
-
email:
|
111
|
+
description:
|
112
|
+
email:
|
119
113
|
executables: []
|
120
114
|
extensions: []
|
121
115
|
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
|
129
122
|
- lib/klaro/client/resource.rb
|
123
|
+
- lib/klaro/client/resource/attachment.rb
|
130
124
|
- lib/klaro/client/resource/board.rb
|
131
125
|
- lib/klaro/client/resource/dimension.rb
|
132
126
|
- lib/klaro/client/resource/dimension_value.rb
|
@@ -135,11 +129,11 @@ files:
|
|
135
129
|
- lib/klaro/client/resource/story.rb
|
136
130
|
- lib/klaro/client/support/md_text.rb
|
137
131
|
- lib/klaro/client/version.rb
|
138
|
-
homepage:
|
132
|
+
homepage:
|
139
133
|
licenses:
|
140
134
|
- MIT
|
141
135
|
metadata: {}
|
142
|
-
post_install_message:
|
136
|
+
post_install_message:
|
143
137
|
rdoc_options: []
|
144
138
|
require_paths:
|
145
139
|
- lib
|
@@ -154,9 +148,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
154
148
|
- !ruby/object:Gem::Version
|
155
149
|
version: '0'
|
156
150
|
requirements: []
|
157
|
-
|
158
|
-
|
159
|
-
signing_key:
|
151
|
+
rubygems_version: 3.2.1
|
152
|
+
signing_key:
|
160
153
|
specification_version: 4
|
161
154
|
summary: Klaro Client
|
162
155
|
test_files: []
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.3.0
|