flexirest 1.2.2 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f549201f0bdade7d62e8972d7015cdf04f0f2aaa
4
- data.tar.gz: b5ed62790c87fd8253bdb1d18bca02dfcbc8331c
3
+ metadata.gz: 0848a1654b64ccbc585f5dc619fb7c81611f0d7c
4
+ data.tar.gz: 8d65facc11bfe9413e2f2f61d79088f7cc7e22c0
5
5
  SHA512:
6
- metadata.gz: 4b6d0e9794750161edab543b97aec47a956f3bc570fa65e35c5216ed857fa8ed7830c661ce1fbc0092d0743298c68fc0734db9d38932597a9d3470d5164036a9
7
- data.tar.gz: 5297d2f938e3777a5264212465270792dbe7202f758d5c4cfa572ad7e6fa32fc244f66931623933e8bbc0cd7a62ac5202051245c2cd4b10fdfffbdf3216e6140
6
+ metadata.gz: 3793f05bd5e8707a704ad3f12fe5f6d725349d4e21a31d7f1a9701ffc4454cdfd5ce2a3c17985aa3dc50f2edb95ca67a1e2204e7e378acfe02a8e6ce6fe95829
7
+ data.tar.gz: e4aeb3fd76d09a52ab7f8efab500fb37f73b6824fb118e5ec49f80464379e791df97e9b851130ff7578ab23eb311441ba13ad99ab4b8fab0f17bd7644517cee4
@@ -13,11 +13,15 @@ module Flexirest
13
13
 
14
14
  def base_url(value = nil)
15
15
  if value.nil?
16
- if @base_url.nil?
16
+ value = if @base_url.nil?
17
17
  @@base_url
18
18
  else
19
19
  @base_url
20
20
  end
21
+ if value.nil? && superclass.respond_to?(:base_url)
22
+ value = superclass.base_url
23
+ end
24
+ value
21
25
  else
22
26
  value = value.gsub(/\/$/, '')
23
27
  @base_url = value
@@ -32,11 +36,15 @@ module Flexirest
32
36
 
33
37
  def username(value = nil)
34
38
  if value.nil?
35
- if @username.nil?
39
+ value = if @username.nil?
36
40
  @@username
37
41
  else
38
42
  @username
39
43
  end
44
+ if value.nil? && superclass.respond_to?(:username)
45
+ value = superclass.username
46
+ end
47
+ value
40
48
  else
41
49
  value = CGI::escape(value) if value.present? && !value.include?("%")
42
50
  @username = value
@@ -51,11 +59,15 @@ module Flexirest
51
59
 
52
60
  def password(value = nil)
53
61
  if value.nil?
54
- if @password.nil?
62
+ value = if @password.nil?
55
63
  @@password
56
64
  else
57
65
  @password
58
66
  end
67
+ if value.nil? && superclass.respond_to?(:password)
68
+ value = superclass.password
69
+ end
70
+ value
59
71
  else
60
72
  value = CGI::escape(value) if value.present? && !value.include?("%")
61
73
  @password = value
@@ -71,7 +83,11 @@ module Flexirest
71
83
  def request_body_type(value = nil)
72
84
  if value.nil?
73
85
  if @request_body_type.nil?
74
- @@request_body_type
86
+ if value.nil? && superclass.respond_to?(:request_body_type)
87
+ superclass.request_body_type
88
+ else
89
+ @@request_body_type || :form_encoded
90
+ end
75
91
  else
76
92
  @request_body_type
77
93
  end
@@ -170,7 +186,6 @@ module Flexirest
170
186
  @base_url = nil
171
187
  @@base_url = nil
172
188
  @request_body_type = nil
173
- @@request_body_type = :form_encoded
174
189
  @whiny_missing = nil
175
190
  @lazy_load = false
176
191
  @faraday_config = default_faraday_config
@@ -1,3 +1,3 @@
1
1
  module Flexirest
2
- VERSION = "1.2.2"
2
+ VERSION = "1.2.3"
3
3
  end
@@ -3,6 +3,7 @@ require 'spec_helper'
3
3
  describe Flexirest::Configuration do
4
4
  before :each do
5
5
  Object.send(:remove_const, :ConfigurationExample) if defined?(ConfigurationExample)
6
+ Object.send(:remove_const, :SubConfigurationExample) if defined?(SubConfigurationExample)
6
7
  Flexirest::Base._reset_configuration!
7
8
 
8
9
  class ConfigurationExample
@@ -13,6 +14,9 @@ describe Flexirest::Configuration do
13
14
  request_body_type :json
14
15
  end
15
16
 
17
+ class SubConfigurationExample < ConfigurationExample
18
+ end
19
+
16
20
  class ConfigurationExampleBare
17
21
  include Flexirest::Configuration
18
22
  end
@@ -39,6 +43,10 @@ describe Flexirest::Configuration do
39
43
  expect(ConfigurationExample.base_url).to eq("http://www.example.com")
40
44
  end
41
45
 
46
+ it "should remember the set base_url on a class, overriding a general one" do
47
+ expect(SubConfigurationExample.base_url).to eq("http://www.example.com")
48
+ end
49
+
42
50
  it "should remove a trailing slash from a globally configured base_url" do
43
51
  Flexirest::Base.base_url = "http://general.example.com/"
44
52
  expect(ConfigurationExample.base_url).to eq("http://www.example.com")
@@ -69,6 +77,10 @@ describe Flexirest::Configuration do
69
77
  Flexirest::Base.username = nil
70
78
  end
71
79
 
80
+ it "should remember the set username on a class, overriding a general one" do
81
+ expect(SubConfigurationExample.username).to eq("john")
82
+ end
83
+
72
84
  it "should escape the username" do
73
85
  Flexirest::Base.username = "bill@example.com"
74
86
  expect(Flexirest::Base.username).to eq("bill%40example.com")
@@ -91,6 +103,10 @@ describe Flexirest::Configuration do
91
103
  Flexirest::Base.password = nil
92
104
  end
93
105
 
106
+ it "should remember the set password on a class, overriding a general one" do
107
+ expect(SubConfigurationExample.password).to eq("smith")
108
+ end
109
+
94
110
  it "should escape the password" do
95
111
  Flexirest::Base.password = "something@else"
96
112
  expect(Flexirest::Base.password).to eq("something%40else")
@@ -111,12 +127,16 @@ describe Flexirest::Configuration do
111
127
  expect(ConfigurationExample.request_body_type).to eq(:json)
112
128
  end
113
129
 
114
- it "should remember the set base_url on a class, overriding a general one" do
130
+ it "should remember the set request_body_type on a class, overriding a general one" do
115
131
  Flexirest::Base.request_body_type = :unknown
116
132
  expect(Flexirest::Base.request_body_type).to eq(:unknown)
117
133
  expect(ConfigurationExample.request_body_type).to eq(:json)
118
134
  end
119
135
 
136
+ it "should remember the set username on a class, overriding a general one" do
137
+ expect(SubConfigurationExample.request_body_type).to eq(:json)
138
+ end
139
+
120
140
  it "should default to non-lazy loading" do
121
141
  class LazyLoadingConfigurationExample1
122
142
  include Flexirest::Configuration
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flexirest
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Jeffries
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-23 00:00:00.000000000 Z
11
+ date: 2015-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler