klaro-client 0.4.5 → 0.5.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 +4 -4
- data/lib/klaro/client.rb +4 -0
- data/lib/klaro/client/request_handler.rb +17 -7
- data/lib/klaro/client/resource/story.rb +16 -6
- data/lib/klaro/client/version.rb +2 -2
- metadata +5 -13
- 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: 861ca7e05a88b52d1a475a351a120f428d91ac21caacfbc06e12e5c6a9f84bc2
         | 
| 4 | 
            +
              data.tar.gz: 20d95370861307e0d5534fb698af187cb41882914962baeb99c478a1049881b3
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 28aee1dbfff5699f51493402a05c1bc7e973ea13912d8919b5719682e7cd904bffed37a72480b1179bb65df55f6ce47c7315440aa098971fb937b6f65c22d7be
         | 
| 7 | 
            +
              data.tar.gz: 7a9fb6bb70ddac52bfcdb1c424f7287c6fbf86adb6f6635cdba1ad1ce20f787bd2dfe493d54d5daa8f0c46a81a53494dc06e70297d11a07fd9c780edbb332bcd
         | 
    
        data/lib/klaro/client.rb
    CHANGED
    
    
| @@ -6,8 +6,9 @@ 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
         | 
| 11 12 | 
             
                  end
         | 
| 12 13 |  | 
| 13 14 | 
             
                  def authenticated?
         | 
| @@ -19,6 +20,11 @@ module Klaro | |
| 19 20 | 
             
                    self
         | 
| 20 21 | 
             
                  end
         | 
| 21 22 |  | 
| 23 | 
            +
                  def with_project(subdomain)
         | 
| 24 | 
            +
                    @subdomain = subdomain
         | 
| 25 | 
            +
                    self
         | 
| 26 | 
            +
                  end
         | 
| 27 | 
            +
             | 
| 22 28 | 
             
                  def authenticate(user, password)
         | 
| 23 29 | 
             
                    @token = get_token Http
         | 
| 24 30 | 
             
                    .headers({
         | 
| @@ -65,12 +71,16 @@ module Klaro | |
| 65 71 | 
             
                  end
         | 
| 66 72 |  | 
| 67 73 | 
             
                  def http
         | 
| 68 | 
            -
                    Http.headers(
         | 
| 69 | 
            -
             | 
| 70 | 
            -
             | 
| 71 | 
            -
             | 
| 72 | 
            -
             | 
| 73 | 
            -
             | 
| 74 | 
            +
                    Http.headers(http_headers)
         | 
| 75 | 
            +
                  end
         | 
| 76 | 
            +
             | 
| 77 | 
            +
                  def http_headers
         | 
| 78 | 
            +
                    hs = {
         | 
| 79 | 
            +
                      "Authorization" => @token,
         | 
| 80 | 
            +
                      "Content-Type" => "application/json"
         | 
| 81 | 
            +
                    }
         | 
| 82 | 
            +
                    hs['Klaro-Project-Subdomain'] = @subdomain if @subdomain
         | 
| 83 | 
            +
                    hs
         | 
| 74 84 | 
             
                  end
         | 
| 75 85 |  | 
| 76 86 | 
             
                  def info(msg)
         | 
| @@ -2,18 +2,27 @@ 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)
         | 
| 15 | 
            +
                  end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                  def details
         | 
| 18 | 
            +
                    details = self[:details] || self[:specification]
         | 
| 19 | 
            +
                    @specification ||= MdText.new(details, :details)
         | 
| 11 20 | 
             
                  end
         | 
| 21 | 
            +
                  alias :specification :details
         | 
| 12 22 |  | 
| 13 | 
            -
                  def  | 
| 14 | 
            -
                    @ | 
| 23 | 
            +
                  def linked_cards
         | 
| 24 | 
            +
                    @linked_cards ||= (self.linked || []).map{|s| Story.dress(s, @client) }
         | 
| 15 25 | 
             
                  end
         | 
| 16 | 
            -
                  alias :details :specification
         | 
| 17 26 |  | 
| 18 27 | 
             
                  def attachments
         | 
| 19 28 | 
             
                    @attachments || super.map{|a| Attachment.dress(a, @client) }
         | 
| @@ -38,7 +47,8 @@ module Klaro | |
| 38 47 | 
             
                      url = attachment.url
         | 
| 39 48 | 
             
                      url += "?n=" + URI.encode_www_form_component(attachment.filename) unless url =~ /\?n=/
         | 
| 40 49 | 
             
                      path = handle_image(url, root_path, target_folder, client)
         | 
| 41 | 
            -
                      attachment. | 
| 50 | 
            +
                      attachment.url = path
         | 
| 51 | 
            +
                      attachment
         | 
| 42 52 | 
             
                    end
         | 
| 43 53 | 
             
                    self.class.dress(self.to_h.merge(
         | 
| 44 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.4 | 
| 4 | 
            +
              version: 0.5.4
         | 
| 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-09 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,8 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 155 148 | 
             
                - !ruby/object:Gem::Version
         | 
| 156 149 | 
             
                  version: '0'
         | 
| 157 150 | 
             
            requirements: []
         | 
| 158 | 
            -
             | 
| 159 | 
            -
            rubygems_version: 2.7.6
         | 
| 151 | 
            +
            rubygems_version: 3.0.8
         | 
| 160 152 | 
             
            signing_key: 
         | 
| 161 153 | 
             
            specification_version: 4
         | 
| 162 154 | 
             
            summary: Klaro Client
         | 
    
        data/VERSION
    DELETED
    
    | @@ -1 +0,0 @@ | |
| 1 | 
            -
            0.3.0
         |