vanity 2.0.0 → 2.0.1
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/CHANGELOG +4 -0
- data/Gemfile.lock +4 -1
- data/README.rdoc +1 -1
- data/gemfiles/rails32.gemfile.lock +4 -1
- data/gemfiles/rails4.gemfile.lock +4 -1
- data/gemfiles/rails41.gemfile.lock +4 -1
- data/gemfiles/rails42.gemfile.lock +4 -1
- data/lib/vanity/configuration.rb +22 -1
- data/lib/vanity/vanity.rb +8 -4
- data/lib/vanity/version.rb +1 -1
- data/test/configuration_test.rb +29 -1
- data/test/data/vanity.yml.redis +1 -0
- data/test/data/vanity.yml.redis-erb +2 -2
- data/test/test_helper.rb +1 -1
- data/test/vanity_test.rb +51 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 99e7f2261835eee5e49f1a1286c134f5329586be
|
4
|
+
data.tar.gz: 4de7123ddf75a32cd6228552e853db0228e29f85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f2d1673cb4ee38a6ef9622d1413fcf404fb47f2acfe2fb115ba4f03c15586da19e86267ce76ef1a683e3e864cbb0b079a489850f0f5442146b05a83aea45e50
|
7
|
+
data.tar.gz: f524dd7f7c260a4dc4c511d62aa9ae8b284525cae92afb7daf3f16fe09868e843817bf740438ceffdecbbbddefeed3a5ac884c94dff1493f78931c91f989a966
|
data/CHANGELOG
CHANGED
data/Gemfile.lock
CHANGED
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
|
-
|
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
|
|
data/lib/vanity/configuration.rb
CHANGED
@@ -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
|
92
|
-
|
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) #
|
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)
|
data/lib/vanity/version.rb
CHANGED
data/test/configuration_test.rb
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
require "test_helper"
|
2
2
|
|
3
3
|
describe Vanity::Configuration do
|
4
|
-
let(:config)
|
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
|
data/test/data/vanity.yml.redis
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
|
1
|
+
test:
|
2
2
|
adapter: redis
|
3
|
-
|
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.
|
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:
|
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.
|
214
|
+
- Vanity 2.0.1
|
215
215
|
- --main
|
216
216
|
- README.rdoc
|
217
217
|
- --webcvs
|