vanity 2.0.0 → 2.0.1

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: 0d7da7caf628667cd793e5a3191fa8f0975a7ae0
4
- data.tar.gz: 9a538d9f392b717675079c8ea35cfaf8b8457733
3
+ metadata.gz: 99e7f2261835eee5e49f1a1286c134f5329586be
4
+ data.tar.gz: 4de7123ddf75a32cd6228552e853db0228e29f85
5
5
  SHA512:
6
- metadata.gz: b8a5faf62c21f4562b5b4e17c78e340b53547e90d0a9b657c3fd8bc44b724fa813dc3a1e681e6fdf3617c9d70141819608e05f9c1221dc8ac137210d4d46dae5
7
- data.tar.gz: c23d96c189bae198ba68c60f5ff7ba93cd0aef614b40b746a217979be6f6ebf66966217693a6c753e0e560921461711956b89712b7d5fc002037b4ac04a21ebb
6
+ metadata.gz: 4f2d1673cb4ee38a6ef9622d1413fcf404fb47f2acfe2fb115ba4f03c15586da19e86267ce76ef1a683e3e864cbb0b079a489850f0f5442146b05a83aea45e50
7
+ data.tar.gz: f524dd7f7c260a4dc4c511d62aa9ae8b284525cae92afb7daf3f16fe09868e843817bf740438ceffdecbbbddefeed3a5ac884c94dff1493f78931c91f989a966
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ == 2.0.0 (2016-01-18)
2
+
3
+ Add back deprecated connection key for vanity.yml. (@phillbaker)
4
+
1
5
  == 2.0.0 (2015-12-14)
2
6
 
3
7
  Extract configuration from Vanity::Playground to Vanity::Configuration (@phillbaker)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- vanity (2.0.0)
4
+ vanity (2.0.1)
5
5
  i18n
6
6
 
7
7
  GEM
@@ -136,3 +136,6 @@ DEPENDENCIES
136
136
  vanity!
137
137
  webmock
138
138
  yard
139
+
140
+ BUNDLED WITH
141
+ 1.11.2
data/README.rdoc CHANGED
@@ -41,7 +41,7 @@ A sample <code>config/vanity.yml</code> might look like:
41
41
  collecting: false
42
42
  production:
43
43
  adapter: redis
44
- connection: redis://<%= ENV["REDIS_USER"] %>:<%= ENV["REDIS_PASSWORD"] %>@<%= ENV["REDIS_HOST"] %>:<%= ENV["REDIS_PORT"] %>/0
44
+ url: redis://<%= ENV["REDIS_USER"] %>:<%= ENV["REDIS_PASSWORD"] %>@<%= ENV["REDIS_HOST"] %>:<%= ENV["REDIS_PORT"] %>/0
45
45
 
46
46
  If you want to use your test environment with RSpec you will need to add an adapter to test:
47
47
 
@@ -7,7 +7,7 @@ GIT
7
7
  PATH
8
8
  remote: ..
9
9
  specs:
10
- vanity (2.0.0)
10
+ vanity (2.0.1)
11
11
  i18n
12
12
 
13
13
  GEM
@@ -226,3 +226,6 @@ DEPENDENCIES
226
226
  vanity!
227
227
  webmock
228
228
  yard
229
+
230
+ BUNDLED WITH
231
+ 1.11.2
@@ -7,7 +7,7 @@ GIT
7
7
  PATH
8
8
  remote: ..
9
9
  specs:
10
- vanity (2.0.0)
10
+ vanity (2.0.1)
11
11
  i18n
12
12
 
13
13
  GEM
@@ -174,3 +174,6 @@ DEPENDENCIES
174
174
  vanity!
175
175
  webmock
176
176
  yard
177
+
178
+ BUNDLED WITH
179
+ 1.11.2
@@ -7,7 +7,7 @@ GIT
7
7
  PATH
8
8
  remote: .././
9
9
  specs:
10
- vanity (2.0.0)
10
+ vanity (2.0.1)
11
11
  i18n
12
12
 
13
13
  GEM
@@ -222,3 +222,6 @@ DEPENDENCIES
222
222
  vanity!
223
223
  webmock
224
224
  yard
225
+
226
+ BUNDLED WITH
227
+ 1.11.2
@@ -7,7 +7,7 @@ GIT
7
7
  PATH
8
8
  remote: ..
9
9
  specs:
10
- vanity (2.0.0)
10
+ vanity (2.0.1)
11
11
  i18n
12
12
 
13
13
  GEM
@@ -248,3 +248,6 @@ DEPENDENCIES
248
248
  vanity!
249
249
  webmock
250
250
  yard
251
+
252
+ BUNDLED WITH
253
+ 1.11.2
@@ -4,6 +4,7 @@ module Vanity
4
4
  class Configuration
5
5
  class MissingEnvironment < StandardError; end
6
6
 
7
+ LEGACY_CONNECTION_KEY = :connection
7
8
  LEGACY_REDIS_CONFIG_FILE = "redis.yml"
8
9
 
9
10
  class<<self
@@ -193,6 +194,26 @@ module Vanity
193
194
  end
194
195
  end
195
196
 
197
+ # @deprecated
198
+ def connection_url
199
+ connection_config = connection_params
200
+
201
+ return unless connection_config && connection_config.respond_to?(:has_key?)
202
+
203
+ connection_url = connection_config[LEGACY_CONNECTION_KEY]
204
+
205
+ if connection_url
206
+ logger.warn(%q{Deprecated: Please specify connection urls using the `url` key with a protocol prefix instead of `connection`. This fallback will be removed in a future version.})
207
+
208
+ # Legacy lack of protocol handling
209
+ if connection_url =~ /^\w+:/
210
+ connection_url
211
+ else
212
+ "redis://" + connection_url
213
+ end
214
+ end
215
+ end
216
+
196
217
  # @deprecated
197
218
  def redis_url_from_file
198
219
  connection_url = connection_params(LEGACY_REDIS_CONFIG_FILE)
@@ -208,4 +229,4 @@ module Vanity
208
229
  end
209
230
  end
210
231
  end
211
- end
232
+ end
data/lib/vanity/vanity.rb CHANGED
@@ -79,17 +79,21 @@ module Vanity
79
79
  def self.connect!(spec_or_nil=nil)
80
80
  spec_or_nil ||= configuration.connection_params
81
81
 
82
+ # Legacy special config variables permitted in connection spec
83
+ update_configuration_from_connection_params(spec_or_nil)
84
+
82
85
  # Legacy redis.yml fallback
83
86
  if spec_or_nil.nil?
84
87
  redis_url = configuration.redis_url_from_file
85
-
86
88
  if redis_url
87
89
  spec_or_nil = redis_url
88
90
  end
89
91
  end
90
92
 
91
- # Legacy special config variables permitted in connection spec
92
- update_configuration_from_connection_params(spec_or_nil)
93
+ # Legacy connection url fallback
94
+ if configuration.connection_url
95
+ spec_or_nil = configuration.connection_url
96
+ end
93
97
 
94
98
  @connection = Connection.new(spec_or_nil)
95
99
  end
@@ -159,7 +163,7 @@ module Vanity
159
163
 
160
164
  private
161
165
 
162
- def update_configuration_from_connection_params(spec_or_nil) # # :nodoc:
166
+ def update_configuration_from_connection_params(spec_or_nil) # :nodoc:
163
167
  return unless spec_or_nil.respond_to?(:has_key?)
164
168
 
165
169
  configuration.collecting = spec_or_nil[:collecting] if spec_or_nil.has_key?(:collecting)
@@ -1,5 +1,5 @@
1
1
  module Vanity
2
- VERSION = "2.0.0"
2
+ VERSION = "2.0.1"
3
3
 
4
4
  module Version
5
5
  version = VERSION.to_s.split(".").map { |i| i.to_i }
@@ -1,7 +1,11 @@
1
1
  require "test_helper"
2
2
 
3
3
  describe Vanity::Configuration do
4
- let(:config) { Vanity::Configuration.new }
4
+ let(:config) do
5
+ config = Vanity::Configuration.new
6
+ config.logger = $logger
7
+ config
8
+ end
5
9
 
6
10
  it "returns default values" do
7
11
  assert_equal Vanity::Configuration.new.collecting, Vanity::Configuration::DEFAULTS[:collecting]
@@ -56,6 +60,30 @@ describe Vanity::Configuration do
56
60
  assert_equal mock_connection_string, config.connection_params("redis.yml")
57
61
  end
58
62
 
63
+ it "pulls from the connection config key" do
64
+ connection_config = VanityTestHelpers::VANITY_CONFIGS["vanity.yml.redis"]
65
+
66
+ FileUtils.mkpath "./config"
67
+ File.open("./config/vanity.yml", "w") do |f|
68
+ f.write(connection_config)
69
+ end
70
+
71
+ assert_equal "redis://:p4ssw0rd@10.0.1.1:6380/15", config.connection_url
72
+ end
73
+
74
+ it "renders erb" do
75
+ connection_config = VanityTestHelpers::VANITY_CONFIGS["vanity.yml.redis-erb"]
76
+ ENV["VANITY_TEST_REDIS_URL"] = "redis://:p4ssw0rd@10.0.1.1:6380/15"
77
+
78
+ FileUtils.mkpath "./config"
79
+ File.open("./config/vanity.yml", "w") do |f|
80
+ f.write(connection_config)
81
+ end
82
+
83
+ connection_hash = { adapter: "redis", url: "redis://:p4ssw0rd@10.0.1.1:6380/15" }
84
+ assert_equal connection_hash, config.connection_params
85
+ end
86
+
59
87
  it "returns nil if the file doesn't exist" do
60
88
  FileUtils.mkpath "./config"
61
89
  assert_nil config.connection_params
@@ -1,5 +1,6 @@
1
1
  test:
2
2
  adapter: redis
3
3
  collecting: false
4
+ connection: "redis://:p4ssw0rd@10.0.1.1:6380/15"
4
5
  production:
5
6
  adapter: redis
@@ -1,3 +1,3 @@
1
- production:
1
+ test:
2
2
  adapter: redis
3
- connection: redis://<%= ENV["REDIS_USER"] %>:<%= ENV["REDIS_PASSWORD"] %>@<%= ENV["REDIS_HOST"] %>:<%= ENV["REDIS_PORT"] %>/0
3
+ url: <%= ENV['VANITY_TEST_REDIS_URL'] %>
data/test/test_helper.rb CHANGED
@@ -63,7 +63,7 @@ module VanityTestHelpers
63
63
  def teardown_after
64
64
  Vanity.context = nil
65
65
  FileUtils.rm_rf "tmp"
66
- Vanity.connection.adapter.flushdb if Vanity.connection.connected?
66
+ Vanity.connection.adapter.flushdb if Vanity.connection(false) && Vanity.connection.connected?
67
67
  WebMock.reset!
68
68
  end
69
69
 
data/test/vanity_test.rb CHANGED
@@ -65,6 +65,57 @@ describe Vanity do
65
65
  it "returns a new connection" do
66
66
  refute_same Vanity.connect!, Vanity.connect!
67
67
  end
68
+
69
+ describe "deprecated settings" do
70
+ before do
71
+ FakeFS.activate!
72
+ end
73
+
74
+ after do
75
+ FakeFS.deactivate!
76
+ FakeFS::FileSystem.clear
77
+ end
78
+
79
+ it "uses legacy connection key" do
80
+ connection_config = VanityTestHelpers::VANITY_CONFIGS["vanity.yml.redis"]
81
+
82
+ FileUtils.mkpath "./config"
83
+ File.open("./config/vanity.yml", "w") do |f|
84
+ f.write(connection_config)
85
+ end
86
+
87
+ Vanity::Connection.expects(:new).with("redis://:p4ssw0rd@10.0.1.1:6380/15")
88
+ Vanity.disconnect!
89
+ Vanity.connect!
90
+ end
91
+
92
+ it "uses redis.yml" do
93
+ FileUtils.mkpath "./config"
94
+ File.open("./config/redis.yml", "w") do |f|
95
+ f.write VanityTestHelpers::VANITY_CONFIGS["redis.yml.url"]
96
+ end
97
+
98
+ Vanity::Connection.expects(:new).with("localhost:6379/15")
99
+ Vanity.disconnect!
100
+ Vanity.connect!
101
+ end
102
+
103
+ it "uses legacy collecting key" do
104
+ connection_config = VanityTestHelpers::VANITY_CONFIGS["vanity.yml.redis"]
105
+
106
+ FileUtils.mkpath "./config"
107
+ File.open("./config/vanity.yml", "w") do |f|
108
+ f.write(connection_config)
109
+ end
110
+
111
+ Vanity.reset!
112
+ Vanity.disconnect!
113
+ Vanity::Connection.stubs(:new)
114
+ Vanity.connect!
115
+
116
+ assert_equal false, Vanity.configuration.collecting
117
+ end
118
+ end
68
119
  end
69
120
 
70
121
  describe "#disconnect!" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vanity
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Assaf Arkin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-23 00:00:00.000000000 Z
11
+ date: 2016-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
@@ -211,7 +211,7 @@ metadata: {}
211
211
  post_install_message: To get started run vanity --help
212
212
  rdoc_options:
213
213
  - --title
214
- - Vanity 2.0.0
214
+ - Vanity 2.0.1
215
215
  - --main
216
216
  - README.rdoc
217
217
  - --webcvs