klaro-client 0.4.3 → 0.4.4
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '08aa3f977345513aca8d374ebe5e837d580bd95cf75da1bf555bd170858f3401'
|
4
|
+
data.tar.gz: 4ce2e6929c252660a35c13aa317ac8de7a4c715d4bf5b717119b61bb32a6929f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01a6d53e1763a1b8e37b3777ab56bc2edd24cc28b4d6de447df8af75bc8c513bc45a9c7d9832e6fe942eff82d712b5aefad258a1035035b9f0d5e60a5e0f70cf
|
7
|
+
data.tar.gz: 27f1f1183ec289d2b2ae2b4ae6cfc0a1a14d7f42d1f31c7ee9a123291c4d320e11eee2c9d078019ddf1de65649636a180d3368695e8269c4ab5ebd9bd8925e92
|
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,16 @@ module Klaro
|
|
15
15
|
end
|
16
16
|
alias :details :specification
|
17
17
|
|
18
|
+
def attachments
|
19
|
+
@attachments || super.map{|a| Attachment.dress(a, @client) }
|
20
|
+
end
|
21
|
+
|
22
|
+
def cover_attachment(force = false)
|
23
|
+
got = (self.attachments || []).find{|a| a[:isCover] }
|
24
|
+
got = (self.attachments || []).first if got.nil? and force
|
25
|
+
got
|
26
|
+
end
|
27
|
+
|
18
28
|
def to_url(with_identifier = true)
|
19
29
|
I18n.config.available_locales = [:en, :fr]
|
20
30
|
url = I18n.transliterate(title.to_s)
|
@@ -25,14 +35,14 @@ module Klaro
|
|
25
35
|
|
26
36
|
def download_and_relocate_attachments(root_path, target_folder, client)
|
27
37
|
as = self.attachments.map do |attachment|
|
28
|
-
url = attachment
|
29
|
-
url += "?n=" + URI.encode_www_form_component(attachment
|
38
|
+
url = attachment.url
|
39
|
+
url += "?n=" + URI.encode_www_form_component(attachment.filename) unless url =~ /\?n=/
|
30
40
|
path = handle_image(url, root_path, target_folder, client)
|
31
|
-
attachment.merge(
|
41
|
+
attachment.merge(url => path)
|
32
42
|
end
|
33
|
-
self.class.
|
43
|
+
self.class.dress(self.to_h.merge(
|
34
44
|
attachments: as
|
35
|
-
))
|
45
|
+
), @client)
|
36
46
|
end
|
37
47
|
|
38
48
|
def download_and_relocate_images(root_path, target_folder, client)
|
@@ -42,9 +52,9 @@ module Klaro
|
|
42
52
|
image_relative_path = handle_image(url, root_path, target_folder, client)
|
43
53
|
""
|
44
54
|
end
|
45
|
-
self.class.
|
55
|
+
self.class.dress(self.to_h.merge(
|
46
56
|
specification: spec
|
47
|
-
))
|
57
|
+
), @client)
|
48
58
|
end
|
49
59
|
|
50
60
|
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.
|
4
|
+
version: 0.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- enspirit
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-04-
|
11
|
+
date: 2020-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dotenv
|
@@ -127,6 +127,7 @@ files:
|
|
127
127
|
- lib/klaro/client/errors.rb
|
128
128
|
- lib/klaro/client/request_handler.rb
|
129
129
|
- lib/klaro/client/resource.rb
|
130
|
+
- lib/klaro/client/resource/attachment.rb
|
130
131
|
- lib/klaro/client/resource/board.rb
|
131
132
|
- lib/klaro/client/resource/dimension.rb
|
132
133
|
- lib/klaro/client/resource/dimension_value.rb
|