klaro-client 0.5.0 → 0.5.5

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: 0b7b19ab7905f35aa15fb577103003b7b6ff544925653cd81107d40b11ecdcc5
4
- data.tar.gz: cb069e6663aaf958431d2423151fb63b6cfb7029ce6a02c15e32c9c54dca10dd
3
+ metadata.gz: b5254e23cef2ad85ee5aad4c5bcdd4a4171ee31e15553b5fca1707b659fd2546
4
+ data.tar.gz: ef6d17c7c3d7f9aad73c594f2fb1368078165e7be179dae4daf578c7b1310d7a
5
5
  SHA512:
6
- metadata.gz: e8b9f60a516f7c591bd131515b716c110c9f82c3bdc179120b2be60409df05a3d48f982c70c6bcd63f84795261b8999bb4e6eded377c888f235f32c36c80c453
7
- data.tar.gz: 3ff5d8819721a23b2be719baac8013dbbcbeccb0fa256754540b2729c83acc78a6c5f0a2198b98257804a3b2745f9328a59f5bb041bf61a3ad2392444c6e4a3c
6
+ metadata.gz: 0ab49ef56322aff2111b1c80e16cb83850da811704a4f61cea4441b337d873bef9dedefdf4df9f8e9f11073d250b08ea029656c318122383c4adfde8f13c7db6
7
+ data.tar.gz: 55f9d63ca3ae7afb22622e0354046f9b87e00723e33b40de52fa0da521108985a0ca90bebac59b2d22c0219ba10d82884cfd2aa56ef072e8ab6336999427f2a1
data/lib/klaro/client.rb CHANGED
@@ -19,6 +19,10 @@ module Klaro
19
19
  request.with_token(*args, &bl)
20
20
  end
21
21
 
22
+ def with_project(*args, &bl)
23
+ request.with_project(*args, &bl)
24
+ end
25
+
22
26
  def login(*args, &bl)
23
27
  request.authenticate(*args, &bl)
24
28
  end
@@ -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 authenticate(user, password)
23
- @token = get_token Http
24
- .headers({
25
- 'Content-Type' => 'application/json'
26
- })
27
- .post("#{base_url}/api/auth/tokens/", payload(user, password))
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
- "Authorization" => @token,
71
- "Content-Type" => "application/json"
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.description.split("\n").first, :summary)
10
+ @title ||= MdText.new(self._title.split("\n").first, :summary)
7
11
  end
8
12
 
9
13
  def summary
10
- @summary ||= MdText.new(self.description.split("\n")[1..-1].join("\n"), :summary)
14
+ @summary ||= MdText.new(self._title.split("\n")[1..-1].join("\n"), :summary)
11
15
  end
12
16
 
13
- def specification
14
- @specification ||= MdText.new(super, :details)
17
+ def details
18
+ details = self[:details] || self[:specification]
19
+ @specification ||= MdText.new(details, :details)
15
20
  end
16
- alias :details :specification
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.merge(url => path)
50
+ attachment.url = path
51
+ attachment
46
52
  end
47
53
  self.class.dress(self.to_h.merge(
48
54
  attachments: as
@@ -3,7 +3,7 @@ module Klaro
3
3
  module Version
4
4
  MAJOR = 0
5
5
  MINOR = 5
6
- TINY = 0
6
+ TINY = 5
7
7
  end
8
8
  VERSION = "#{Version::MAJOR}.#{Version::MINOR}.#{Version::TINY}"
9
9
  end # class Client
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.0
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: 2020-04-22 00:00:00.000000000 Z
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: '3.0'
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: '3.0'
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.1.2
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