vanity 2.0.0.beta6 → 2.0.0.beta7
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/gemfiles/rails32.gemfile.lock +1 -1
- data/gemfiles/rails4.gemfile.lock +1 -1
- data/gemfiles/rails41.gemfile.lock +1 -1
- data/gemfiles/rails42.gemfile.lock +1 -1
- data/lib/vanity/templates.rb +15 -3
- data/lib/vanity/version.rb +1 -1
- data/test/templates_test.rb +14 -0
- metadata +3 -3
data/Gemfile.lock
CHANGED
data/lib/vanity/templates.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Vanity
|
2
2
|
class Templates
|
3
3
|
def initialize
|
4
|
-
@template_directory =
|
4
|
+
@template_directory = determine_template_directory
|
5
5
|
end
|
6
6
|
|
7
7
|
# Path to template.
|
@@ -11,8 +11,20 @@ module Vanity
|
|
11
11
|
|
12
12
|
private
|
13
13
|
|
14
|
-
def
|
15
|
-
|
14
|
+
def determine_template_directory
|
15
|
+
if custom_template_path_valid?
|
16
|
+
Vanity.playground.custom_templates_path
|
17
|
+
else
|
18
|
+
gem_templates_path
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# Check to make sure we set a custome path, it exists, and there are non-
|
23
|
+
# dotfiles in the directory.
|
24
|
+
def custom_template_path_valid?
|
25
|
+
Vanity.playground.custom_templates_path &&
|
26
|
+
File.exists?(Vanity.playground.custom_templates_path) &&
|
27
|
+
!Dir[File.join(Vanity.playground.custom_templates_path, '*')].empty?
|
16
28
|
end
|
17
29
|
|
18
30
|
def gem_templates_path
|
data/lib/vanity/version.rb
CHANGED
data/test/templates_test.rb
CHANGED
@@ -28,5 +28,19 @@ describe Vanity::Templates do
|
|
28
28
|
FileUtils.rm_rf(custom_view_path)
|
29
29
|
end
|
30
30
|
end
|
31
|
+
|
32
|
+
it "ignores an empty view directory" do
|
33
|
+
begin
|
34
|
+
custom_view_path = File.expand_path(File.join(Rails.root, 'app', 'views', 'vanity'))
|
35
|
+
FileUtils.mkpath(custom_view_path)
|
36
|
+
|
37
|
+
gem_view_path = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'vanity', 'templates'))
|
38
|
+
expected = File.join(gem_view_path, 'foo.html')
|
39
|
+
|
40
|
+
assert_equal expected, Vanity::Templates.new.path('foo.html')
|
41
|
+
ensure
|
42
|
+
FileUtils.rm_rf(custom_view_path)
|
43
|
+
end
|
44
|
+
end
|
31
45
|
end
|
32
46
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.0.beta7
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-04
|
12
|
+
date: 2015-05-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: i18n
|
@@ -205,7 +205,7 @@ licenses:
|
|
205
205
|
post_install_message: To get started run vanity --help
|
206
206
|
rdoc_options:
|
207
207
|
- --title
|
208
|
-
- Vanity 2.0.0.
|
208
|
+
- Vanity 2.0.0.beta7
|
209
209
|
- --main
|
210
210
|
- README.rdoc
|
211
211
|
- --webcvs
|