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 CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- vanity (2.0.0.beta6)
4
+ vanity (2.0.0.beta7)
5
5
  i18n
6
6
 
7
7
  GEM
@@ -7,7 +7,7 @@ GIT
7
7
  PATH
8
8
  remote: ..
9
9
  specs:
10
- vanity (2.0.0.beta6)
10
+ vanity (2.0.0.beta7)
11
11
  i18n
12
12
 
13
13
  GEM
@@ -7,7 +7,7 @@ GIT
7
7
  PATH
8
8
  remote: ..
9
9
  specs:
10
- vanity (2.0.0.beta6)
10
+ vanity (2.0.0.beta7)
11
11
  i18n
12
12
 
13
13
  GEM
@@ -7,7 +7,7 @@ GIT
7
7
  PATH
8
8
  remote: .././
9
9
  specs:
10
- vanity (2.0.0.beta6)
10
+ vanity (2.0.0.beta7)
11
11
  i18n
12
12
 
13
13
  GEM
@@ -7,7 +7,7 @@ GIT
7
7
  PATH
8
8
  remote: ..
9
9
  specs:
10
- vanity (2.0.0.beta6)
10
+ vanity (2.0.0.beta7)
11
11
  i18n
12
12
 
13
13
  GEM
@@ -1,7 +1,7 @@
1
1
  module Vanity
2
2
  class Templates
3
3
  def initialize
4
- @template_directory = load_paths.find { |dir| File.exists?(dir) }
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 load_paths
15
- [Vanity.playground.custom_templates_path, gem_templates_path].compact
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
@@ -1,5 +1,5 @@
1
1
  module Vanity
2
- VERSION = "2.0.0.beta6"
2
+ VERSION = "2.0.0.beta7"
3
3
 
4
4
  module Version
5
5
  version = VERSION.to_s.split(".").map { |i| i.to_i }
@@ -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.beta6
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-27 00:00:00.000000000 Z
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.beta6
208
+ - Vanity 2.0.0.beta7
209
209
  - --main
210
210
  - README.rdoc
211
211
  - --webcvs