easy-resources 0.6.1 → 0.6.3

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: 64a20718aae7ffc73d9edfc4c85e72753304cf64f9b2f46110495188e69069fb
4
- data.tar.gz: 0b2b651ccb2de8b5e2f4c1dd621cccf99e09d6125bf03deaffa02ca1485ba7fb
3
+ metadata.gz: 4d9b6700f3653dd9566b5729a9d6e66ba4f907b3a9a0acbbcb04f87133ef5f17
4
+ data.tar.gz: 53bf19d9f64aeb138b5b3361d90e89195e9e33a03b162fdd22e1166b0fcb276f
5
5
  SHA512:
6
- metadata.gz: f7bbd2dfa99cd99f3ffe8b131915cd3f987a330dcbb3b4a670b5afd3c7fdc734b54bc4aef50a178fb551a7a2082bc0d74a88509085137eecaf6e1dacd8acb065
7
- data.tar.gz: fc51e66045ed5cd92619a30c0f0267fe4f9d3e35ec220f38bb905a1ca3628d9625ce5e77418d4471ed33991934493b498609f13ae4fefa8d04781ca523ba1f2a
6
+ metadata.gz: a3c19e4a0fb3d2164a58893ca0cfc0828c1d968e941777b4f5bac25386b4c925388f4426719b44fa35e94be9865f832e50ae606e3785488569205c92a41f42eb
7
+ data.tar.gz: 3100dd93d7c0fa71744b64b0734427bb753b70d981df18bc245c44bb576a1528e1ae31b75eabb9759ff079909d19237c43befcc5e8eb5fce375e4625d8c944c9
data/lib/easy/resource.rb CHANGED
@@ -2,8 +2,7 @@ module Easy
2
2
  class Resource < ActiveResource::Base
3
3
 
4
4
  def self.configure(conf)
5
- self.api_key = conf[:api_key]
6
- self.site = conf[:url]
5
+ self.site = conf[:url]
7
6
  end
8
7
 
9
8
  def becomes(entity_class)
@@ -8,18 +8,19 @@ module Easy
8
8
 
9
9
  module Resources
10
10
 
11
+ autoload :MicroserviceBase, "easy/resources/microservice_base"
12
+
11
13
  module Redmine
12
- extend ActiveSupport::Autoload
13
-
14
- autoload :RedmineBase
15
- autoload :EasyContact
16
- autoload :EasyCrmCase
17
- autoload :EasyServer
18
- autoload :EasyWebApplication
19
- autoload :EasyWebApplicationActivity
20
- autoload :Issue
21
- autoload :Project
22
- autoload :User
14
+
15
+ autoload :RedmineBase, "easy/resources/redmine/redmine_base"
16
+ autoload :EasyContact, "easy/resources/redmine/easy_contact"
17
+ autoload :EasyCrmCase, "easy/resources/redmine/easy_crm_case"
18
+ autoload :EasyServer, "easy/resources/redmine/easy_server"
19
+ autoload :EasyWebApplication, "easy/resources/redmine/easy_web_application"
20
+ autoload :EasyWebApplicationActivity, "easy/resources/redmine/easy_web_application_activity"
21
+ autoload :Issue, "easy/resources/redmine/issue"
22
+ autoload :Project, "easy/resources/redmine/project"
23
+ autoload :User, "easy/resources/redmine/user"
23
24
 
24
25
  end
25
26
 
@@ -0,0 +1,14 @@
1
+ module Easy
2
+ module Resources
3
+ class MicroserviceBase < ::Easy::Resource
4
+
5
+ def self.configure(conf)
6
+ super(conf)
7
+
8
+ self.connection.auth_type = :bearer
9
+ self.connection.bearer_token = conf[:token]
10
+ end
11
+
12
+ end
13
+ end
14
+ end
@@ -7,6 +7,10 @@ module Easy
7
7
 
8
8
  has_many :easy_web_applications, class_name: 'Easy::Resources::Redmine::EasyWebApplication'
9
9
 
10
+ def url
11
+ host_name
12
+ end
13
+
10
14
  end
11
15
  end
12
16
  end
@@ -15,13 +15,16 @@ module Easy
15
15
 
16
16
  # @param [Hash, nil] conf
17
17
  def configure(conf = nil)
18
- conf ||= Easy.config.sites.redmine
18
+ conf ||= ::Easy.config.sites.redmine
19
+
20
+ self.api_key = conf[:api_key]
21
+
19
22
  super(conf)
20
23
  end
21
24
 
22
25
  def headers
23
26
  h = super
24
- h['X-Redmine-API-Key'] ||= @api_key
27
+ h['X-Redmine-API-Key'] = @api_key
25
28
  h
26
29
  end
27
30
 
@@ -1,5 +1,5 @@
1
1
  module Easy
2
2
  module Resources
3
- VERSION = '0.6.1'
3
+ VERSION = '0.6.3'
4
4
  end
5
5
  end
@@ -5,4 +5,15 @@ RSpec.describe Easy::Resources::Redmine::RedmineBase do
5
5
  described_class.api_key = nil
6
6
  expect { described_class.find :first }.to raise_exception NoMethodError
7
7
  end
8
+
9
+ describe ".api_key=" do
10
+ it "change api_key on-fly, changed request headers" do
11
+ described_class.api_key = "secret1"
12
+ expect(described_class.headers).to include "X-Redmine-API-Key" => "secret1"
13
+
14
+ described_class.api_key = "xxxx"
15
+ expect(described_class.headers).to include "X-Redmine-API-Key" => "xxxx"
16
+ end
17
+ end
18
+
8
19
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easy-resources
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - petr
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-03 00:00:00.000000000 Z
11
+ date: 2019-07-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -134,6 +134,7 @@ files:
134
134
  - Rakefile
135
135
  - lib/easy/resource.rb
136
136
  - lib/easy/resources.rb
137
+ - lib/easy/resources/microservice_base.rb
137
138
  - lib/easy/resources/railtie.rb
138
139
  - lib/easy/resources/redmine/easy_contact.rb
139
140
  - lib/easy/resources/redmine/easy_crm_case.rb
@@ -198,8 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
198
199
  - !ruby/object:Gem::Version
199
200
  version: '0'
200
201
  requirements: []
201
- rubyforge_project:
202
- rubygems_version: 2.7.6
202
+ rubygems_version: 3.0.4
203
203
  signing_key:
204
204
  specification_version: 4
205
205
  summary: Summary of Easy::Resources.