simple-navigation 3.13.0 → 4.0.5

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.
Files changed (73) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +3 -0
  3. data/.rspec +1 -0
  4. data/.travis.yml +10 -3
  5. data/CHANGELOG.md +420 -0
  6. data/Guardfile +4 -2
  7. data/LICENSE +1 -1
  8. data/README.md +30 -7
  9. data/Rakefile +25 -2
  10. data/gemfiles/.bundle/config +2 -0
  11. data/gemfiles/rails-3-2-stable.gemfile +11 -0
  12. data/gemfiles/rails-4-1-stable.gemfile +7 -0
  13. data/gemfiles/rails-4-2-stable.gemfile +7 -0
  14. data/generators/navigation_config/navigation_config_generator.rb +0 -1
  15. data/generators/navigation_config/templates/config/navigation.rb +18 -15
  16. data/lib/simple_navigation.rb +25 -42
  17. data/lib/simple_navigation/adapters/padrino.rb +2 -2
  18. data/lib/simple_navigation/adapters/rails.rb +1 -24
  19. data/lib/simple_navigation/adapters/sinatra.rb +2 -11
  20. data/lib/simple_navigation/config_file.rb +36 -0
  21. data/lib/simple_navigation/config_file_finder.rb +42 -0
  22. data/lib/simple_navigation/{core/configuration.rb → configuration.rb} +7 -1
  23. data/lib/simple_navigation/{rendering/helpers.rb → helpers.rb} +0 -4
  24. data/lib/simple_navigation/{core/item.rb → item.rb} +76 -83
  25. data/lib/simple_navigation/{core/item_adapter.rb → item_adapter.rb} +3 -17
  26. data/lib/simple_navigation/{core/item_container.rb → item_container.rb} +23 -14
  27. data/lib/simple_navigation/{core/items_provider.rb → items_provider.rb} +0 -0
  28. data/lib/simple_navigation/railtie.rb +7 -0
  29. data/lib/simple_navigation/renderer.rb +12 -0
  30. data/lib/simple_navigation/{rendering/renderer → renderer}/base.rb +1 -1
  31. data/lib/simple_navigation/{rendering/renderer → renderer}/breadcrumbs.rb +0 -0
  32. data/lib/simple_navigation/{rendering/renderer → renderer}/json.rb +2 -0
  33. data/lib/simple_navigation/{rendering/renderer → renderer}/links.rb +0 -0
  34. data/lib/simple_navigation/{rendering/renderer → renderer}/list.rb +0 -0
  35. data/lib/simple_navigation/{rendering/renderer → renderer}/text.rb +0 -0
  36. data/lib/simple_navigation/version.rb +1 -1
  37. data/simple-navigation.gemspec +6 -5
  38. data/spec/fake_app/config/navigation.rb +6 -0
  39. data/spec/fake_app/rails_app.rb +35 -0
  40. data/spec/initializers/coveralls.rb +3 -0
  41. data/spec/initializers/have_css_matcher.rb +8 -3
  42. data/spec/initializers/memfs.rb +7 -0
  43. data/spec/initializers/rails.rb +4 -0
  44. data/spec/initializers/rspec.rb +7 -0
  45. data/spec/integration/rendering_navigation_spec.rb +14 -0
  46. data/spec/{lib/simple_navigation → simple_navigation}/adapters/padrino_spec.rb +0 -2
  47. data/spec/{lib/simple_navigation → simple_navigation}/adapters/rails_spec.rb +43 -94
  48. data/spec/{lib/simple_navigation → simple_navigation}/adapters/sinatra_spec.rb +4 -6
  49. data/spec/simple_navigation/config_file_finder_spec.rb +50 -0
  50. data/spec/simple_navigation/config_file_spec.rb +25 -0
  51. data/spec/{lib/simple_navigation/core → simple_navigation}/configuration_spec.rb +29 -19
  52. data/spec/{lib/simple_navigation/rendering → simple_navigation}/helpers_spec.rb +10 -13
  53. data/spec/{lib/simple_navigation/core → simple_navigation}/item_adapter_spec.rb +14 -11
  54. data/spec/{lib/simple_navigation/core → simple_navigation}/item_container_spec.rb +130 -42
  55. data/spec/simple_navigation/item_spec.rb +475 -0
  56. data/spec/{lib/simple_navigation/core → simple_navigation}/items_provider_spec.rb +1 -3
  57. data/spec/{lib/simple_navigation/rendering → simple_navigation}/renderer/base_spec.rb +34 -36
  58. data/spec/{lib/simple_navigation/rendering → simple_navigation}/renderer/breadcrumbs_spec.rb +4 -7
  59. data/spec/{lib/simple_navigation/rendering → simple_navigation}/renderer/json_spec.rb +5 -11
  60. data/spec/{lib/simple_navigation/rendering → simple_navigation}/renderer/links_spec.rb +5 -8
  61. data/spec/{lib/simple_navigation/rendering → simple_navigation}/renderer/list_spec.rb +4 -7
  62. data/spec/{lib/simple_navigation/rendering → simple_navigation}/renderer/text_spec.rb +4 -7
  63. data/spec/simple_navigation_spec.rb +190 -0
  64. data/spec/spec_helper.rb +29 -35
  65. metadata +128 -113
  66. data/CHANGELOG +0 -288
  67. data/lib/simple_navigation/core.rb +0 -5
  68. data/lib/simple_navigation/rails_controller_methods.rb +0 -164
  69. data/lib/simple_navigation/rendering.rb +0 -12
  70. data/rails/init.rb +0 -1
  71. data/spec/lib/simple_navigation/core/item_spec.rb +0 -703
  72. data/spec/lib/simple_navigation/rails_controller_methods_spec.rb +0 -270
  73. data/spec/lib/simple_navigation_spec.rb +0 -300
data/Guardfile CHANGED
@@ -1,5 +1,7 @@
1
- guard :rspec do
1
+ guard :rspec, all_after_pass: true, failed_mode: :none do
2
2
  watch(%r{^spec/.+_spec\.rb$})
3
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
3
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
4
+ watch(%r{^spec/fake_app/.+\.rb$}) { 'spec/integration' }
5
+
4
6
  watch('spec/spec_helper.rb') { 'spec' }
5
7
  end
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014 codeplant GmbH
1
+ Copyright (c) 2017 codeplant GmbH
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  [![Code Climate](https://codeclimate.com/github/codeplant/simple-navigation.png)](https://codeclimate.com/github/codeplant/simple-navigation)
6
6
  [![Coverage Status](https://coveralls.io/repos/codeplant/simple-navigation/badge.png)](https://coveralls.io/r/codeplant/simple-navigation)
7
7
 
8
- Simple Navigation is a ruby library for creating navigations (with multiple levels) for your Rails 2, Rails 3, Rails 4, Sinatra or Padrino applications. It runs with all ruby versions (including ruby 2.0).
8
+ Simple Navigation is a ruby library for creating navigations (with multiple levels) for your Rails, Sinatra or Padrino applications. It runs with all ruby versions (including ruby 2.x).
9
9
 
10
10
  ## Documentation
11
11
 
@@ -29,12 +29,35 @@ Don't hesitate to come talk on the [project's group](http://groups.google.com/gr
29
29
 
30
30
  ## Contributing
31
31
 
32
- 1. Fork it (https://github.com/codeplant/simple-navigation/fork)
33
- 2. Create your feature branch (`git checkout -b my-new-feature`)
34
- 3. Commit your changes (`git commit -am 'Add some feature'`)
35
- 4. Push to the branch (`git push origin my-new-feature`)
36
- 5. Create new Pull Request
32
+ Fork, fix, then send a Pull Request.
33
+
34
+ To run the test suite locally against all supported frameworks:
35
+
36
+ % bundle install
37
+ % rake spec:all
38
+
39
+ To target the test suite against one framework:
40
+
41
+ % rake spec:rails-4-2-stable
42
+
43
+ You can find a list of supported spec tasks by running rake -T. You may also find it useful to run a specific test for a specific framework. To do so, you'll have to first make sure you have bundled everything for that configuration, then you can run the specific test:
44
+
45
+ % BUNDLE_GEMFILE='gemfiles/rails-4-2-stable.gemfile' bundle install -j 4
46
+ % BUNDLE_GEMFILE='gemfiles/rails-4-2-stable.gemfile' bundle exec rspec ./spec/requests/users_spec.rb
47
+
48
+ ### Rake and Bundler
49
+
50
+ If you use a shell plugin (like oh-my-zsh:bundler) that auto-prefixes commands with `bundle exec` using the `rake` command will fail.
51
+
52
+ Get the original command with `type -a rake`:
53
+
54
+ % type -a rake
55
+ rake is an alias for bundled_rake
56
+ rake is /Users/username/.rubies/ruby-2.2.3/bin/rake
57
+ rake is /usr/bin/rake
58
+
59
+ In this situation `/Users/username/.rubies/ruby-2.2.3/bin/rake` is the command you should use.
37
60
 
38
61
  ## License
39
62
 
40
- Copyright (c) 2014 codeplant GmbH, released under the MIT license
63
+ Copyright (c) 2017 codeplant GmbH, released under the MIT license
data/Rakefile CHANGED
@@ -1,10 +1,33 @@
1
- require 'bundler/gem_tasks'
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'rspec/core'
2
5
  require 'rspec/core/rake_task'
6
+
3
7
  require 'rdoc/task'
4
8
 
5
9
  RSpec::Core::RakeTask.new(:spec)
6
10
 
7
- task default: :spec
11
+ task default: 'spec'
12
+
13
+ namespace :spec do
14
+ mappers = %w[
15
+ rails-3-2-stable
16
+ rails-4-1-stable
17
+ rails-4-2-stable
18
+ ]
19
+
20
+ mappers.each do |gemfile|
21
+ desc "Run Tests against #{gemfile}"
22
+ task gemfile do
23
+ sh "BUNDLE_GEMFILE='gemfiles/#{gemfile}.gemfile' bundle -j 4 --quiet"
24
+ sh "BUNDLE_GEMFILE='gemfiles/#{gemfile}.gemfile' bundle exec rake -t spec"
25
+ end
26
+ end
27
+
28
+ desc 'Run Tests against all ORMs'
29
+ task all: mappers
30
+ end
8
31
 
9
32
  RDoc::Task.new do |rdoc|
10
33
  rdoc.rdoc_dir = 'rdoc'
@@ -0,0 +1,2 @@
1
+ ---
2
+ BUNDLE_JOBS: 4
@@ -0,0 +1,11 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rake', '< 11.0'
4
+ gem 'railties', '~> 3.2.0'
5
+ gem 'rspec-rails', '~> 3.2.1'
6
+
7
+ if RUBY_VERSION >= '2.2.0'
8
+ gem 'test-unit', '~> 3.0'
9
+ end
10
+
11
+ gemspec path: '../'
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rake', '< 11.0'
4
+ gem 'railties', '~> 4.1.0'
5
+ gem 'rspec-rails', '~> 3.2.1'
6
+
7
+ gemspec path: '../'
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rake', '< 11.0'
4
+ gem 'railties', '~> 4.2.0'
5
+ gem 'rspec-rails', '~> 3.2.1'
6
+
7
+ gemspec path: '../'
@@ -2,7 +2,6 @@ class NavigationConfigGenerator < Rails::Generator::Base
2
2
  def manifest
3
3
  record do |m|
4
4
  m.file 'config/navigation.rb', 'config/navigation.rb'
5
- m.readme '../../../README.md'
6
5
  end
7
6
  end
8
7
  end
@@ -4,35 +4,38 @@ SimpleNavigation::Configuration.run do |navigation|
4
4
  # Specify a custom renderer if needed.
5
5
  # The default renderer is SimpleNavigation::Renderer::List which renders HTML lists.
6
6
  # The renderer can also be specified as option in the render_navigation call.
7
- # navigation.renderer = Your::Custom::Renderer
7
+ #navigation.renderer = Your::Custom::Renderer
8
8
 
9
- # Specify the class that will be applied to active navigation items.
10
- # Defaults to 'selected' navigation.selected_class = 'your_selected_class'
9
+ # Specify the class that will be applied to active navigation items. Defaults to 'selected'
10
+ #navigation.selected_class = 'selected'
11
11
 
12
12
  # Specify the class that will be applied to the current leaf of
13
13
  # active navigation items. Defaults to 'simple-navigation-active-leaf'
14
- # navigation.active_leaf_class = 'your_active_leaf_class'
14
+ #navigation.active_leaf_class = 'simple-navigation-active-leaf'
15
15
 
16
- # Item keys are normally added to list items as id.
17
- # This setting turns that off
18
- # navigation.autogenerate_item_ids = false
16
+ # Specify if item keys are added to navigation items as id. Defaults to true
17
+ #navigation.autogenerate_item_ids = true
19
18
 
20
19
  # You can override the default logic that is used to autogenerate the item ids.
21
20
  # To do this, define a Proc which takes the key of the current item as argument.
22
21
  # The example below would add a prefix to each key.
23
- # navigation.id_generator = Proc.new {|key| "my-prefix-#{key}"}
22
+ #navigation.id_generator = Proc.new {|key| "my-prefix-#{key}"}
24
23
 
25
24
  # If you need to add custom html around item names, you can define a proc that
26
25
  # will be called with the name you pass in to the navigation.
27
26
  # The example below shows how to wrap items spans.
28
- # navigation.name_generator = Proc.new {|name, item| "<span>#{name}</span>"}
27
+ #navigation.name_generator = Proc.new {|name, item| "<span>#{name}</span>"}
29
28
 
30
- # The auto highlight feature is turned on by default.
31
- # This turns it off globally (for the whole plugin)
32
- # navigation.auto_highlight = false
29
+ # Specify if the auto highlight feature is turned on (globally, for the whole navigation). Defaults to true
30
+ #navigation.auto_highlight = true
31
+
32
+ # Specifies whether auto highlight should ignore query params and/or anchors when
33
+ # comparing the navigation items with the current URL. Defaults to true
34
+ #navigation.ignore_query_params_on_auto_highlight = true
35
+ #navigation.ignore_anchors_on_auto_highlight = true
33
36
 
34
37
  # If this option is set to true, all item names will be considered as safe (passed through html_safe). Defaults to false.
35
- # navigation.consider_item_names_as_safe = false
38
+ #navigation.consider_item_names_as_safe = false
36
39
 
37
40
  # Define the primary navigation
38
41
  navigation.items do |primary|
@@ -69,9 +72,9 @@ SimpleNavigation::Configuration.run do |navigation|
69
72
 
70
73
  # you can also specify html attributes to attach to this particular level
71
74
  # works for all levels of the menu
72
- # primary.dom_attributes = {id: 'menu-id', class: 'menu-class'}
75
+ #primary.dom_attributes = {id: 'menu-id', class: 'menu-class'}
73
76
 
74
77
  # You can turn off auto highlighting for a specific level
75
- # primary.auto_highlight = false
78
+ #primary.auto_highlight = false
76
79
  end
77
80
  end
@@ -4,9 +4,15 @@ require 'active_support/core_ext/hash'
4
4
  require 'active_support/core_ext/module/attribute_accessors'
5
5
 
6
6
  require 'simple_navigation/version'
7
- require 'simple_navigation/core'
8
- require 'simple_navigation/rendering'
7
+ require 'simple_navigation/configuration'
8
+ require 'simple_navigation/item_adapter'
9
+ require 'simple_navigation/item'
10
+ require 'simple_navigation/item_container'
11
+ require 'simple_navigation/items_provider'
12
+ require 'simple_navigation/renderer'
9
13
  require 'simple_navigation/adapters'
14
+ require 'simple_navigation/config_file_finder'
15
+ require 'simple_navigation/railtie' if defined?(::Rails::Railtie)
10
16
 
11
17
  require 'forwardable'
12
18
 
@@ -55,7 +61,7 @@ module SimpleNavigation
55
61
  def set_env(root, environment)
56
62
  self.root = root
57
63
  self.environment = environment
58
- config_file_paths << SimpleNavigation.default_config_file_path
64
+ config_file_paths << default_config_file_path
59
65
  end
60
66
 
61
67
  # Returns the current framework in which the plugin is running.
@@ -89,30 +95,6 @@ module SimpleNavigation
89
95
  File.join(root, 'config')
90
96
  end
91
97
 
92
- # Returns true if the config_file for specified context does exist.
93
- def config_file?(navigation_context = :default)
94
- !!config_file(navigation_context)
95
- end
96
-
97
- # Returns the path to the config file for the given navigation context or
98
- # nil if no matching config file can be found.
99
- # If multiple config_paths are set, it returns the first matching path.
100
- def config_file(navigation_context = :default)
101
- config_file_paths
102
- .map { |path| File.join(path, config_file_name(navigation_context)) }
103
- .find { |full_path| File.exist?(full_path) }
104
- end
105
-
106
- # Returns the name of the config file for the given navigation_context
107
- def config_file_name(navigation_context = :default)
108
- prefix = if navigation_context == :default
109
- ''
110
- else
111
- "#{navigation_context.to_s.underscore}_"
112
- end
113
- "#{prefix}navigation.rb"
114
- end
115
-
116
98
  # Resets the list of config_file_paths to the specified path
117
99
  def config_file_path=(path)
118
100
  self.config_file_paths = [path]
@@ -121,20 +103,10 @@ module SimpleNavigation
121
103
  # Reads the config_file for the specified navigation_context and stores it
122
104
  # for later evaluation.
123
105
  def load_config(navigation_context = :default)
124
- unless config_file?(navigation_context)
125
- fail "Config file '#{config_file_name(navigation_context)}' not " \
126
- "found in path(s) #{config_file_paths.join(', ')}!"
127
- end
128
-
129
- # FIXME: what about update_config and update_config! methods ?
130
106
  if environment == 'production'
131
- config_files[navigation_context] ||= begin
132
- IO.read(config_file(navigation_context))
133
- end
107
+ update_config(navigation_context)
134
108
  else
135
- config_files[navigation_context] = begin
136
- IO.read(config_file(navigation_context))
137
- end
109
+ update_config!(navigation_context)
138
110
  end
139
111
  end
140
112
 
@@ -186,9 +158,20 @@ module SimpleNavigation
186
158
 
187
159
  private
188
160
 
189
- def apply_defaults(options)
190
- options[:level] = options.delete(:levels) if options[:levels]
191
- { context: :default, level: :all }.merge(options)
161
+ def config_file(navigation_context)
162
+ ConfigFileFinder.new(config_file_paths).find(navigation_context)
163
+ end
164
+
165
+ def read_config(navigation_context)
166
+ File.read config_file(navigation_context)
167
+ end
168
+
169
+ def update_config(navigation_context)
170
+ config_files[navigation_context] ||= read_config(navigation_context)
171
+ end
172
+
173
+ def update_config!(navigation_context)
174
+ config_files[navigation_context] = read_config(navigation_context)
192
175
  end
193
176
  end
194
177
  end
@@ -1,8 +1,8 @@
1
1
  module SimpleNavigation
2
2
  module Adapters
3
3
  class Padrino < Sinatra
4
- def self.register
5
- SimpleNavigation.set_env(PADRINO_ROOT, PADRINO_ENV)
4
+ def self.register(app)
5
+ SimpleNavigation.set_env(::Padrino.root, ::Padrino.env)
6
6
  ::Padrino::Application.send(:helpers, SimpleNavigation::Helpers)
7
7
  end
8
8
 
@@ -4,7 +4,7 @@ module SimpleNavigation
4
4
  attr_reader :controller, :template
5
5
 
6
6
  def self.register
7
- SimpleNavigation.set_env(rails_root, rails_env)
7
+ SimpleNavigation.set_env(::Rails.root, ::Rails.env)
8
8
  ActionController::Base.send(:include, SimpleNavigation::Helpers)
9
9
  SimpleNavigation::Helpers.instance_methods.each do |m|
10
10
  ActionController::Base.send(:helper_method, m.to_sym)
@@ -51,18 +51,6 @@ module SimpleNavigation
51
51
 
52
52
  protected
53
53
 
54
- def self.rails_root
55
- gte_rails3? ? ::Rails.root : ::RAILS_ROOT
56
- end
57
-
58
- def self.rails_env
59
- gte_rails3? ? ::Rails.env : ::RAILS_ENV
60
- end
61
-
62
- def self.gte_rails3?
63
- ::Rails::VERSION::MAJOR >= 3
64
- end
65
-
66
54
  def template_from(controller)
67
55
  if controller.respond_to?(:view_context)
68
56
  controller.view_context
@@ -97,14 +85,3 @@ module SimpleNavigation
97
85
  end
98
86
  end
99
87
  end
100
-
101
- # Initializer for Rails3
102
- if defined?(Rails) && SimpleNavigation::Adapters::Rails.gte_rails3?
103
- module SimpleNavigation
104
- class Railtie < Rails::Railtie
105
- initializer 'simple_navigation.register' do |app|
106
- SimpleNavigation.register
107
- end
108
- end
109
- end
110
- end
@@ -3,9 +3,8 @@ require 'cgi'
3
3
  module SimpleNavigation
4
4
  module Adapters
5
5
  class Sinatra < Base
6
- def self.register
7
- SimpleNavigation.set_env(sinatra_root, sinatra_environment)
8
- ::Sinatra::Application.send(:helpers, SimpleNavigation::Helpers)
6
+ def self.register(app)
7
+ SimpleNavigation.set_env(app.root, app.environment)
9
8
  end
10
9
 
11
10
  def initialize(context)
@@ -50,14 +49,6 @@ module SimpleNavigation
50
49
 
51
50
  protected
52
51
 
53
- def self.sinatra_root
54
- ::Sinatra::Application.root
55
- end
56
-
57
- def self.sinatra_environment
58
- ::Sinatra::Application.environment
59
- end
60
-
61
52
  def to_attributes(options)
62
53
  options.map { |k, v| v.nil? ? '' : " #{k}='#{v}'" }.join
63
54
  end
@@ -0,0 +1,36 @@
1
+ require 'active_support/core_ext/string'
2
+
3
+ module SimpleNavigation
4
+ # Internal: Encapsulates the config file naming knowledge.
5
+ class ConfigFile
6
+ # Internal: Initializes a ConfigFile.
7
+ #
8
+ # context - The navigation context for this ConfigFile.
9
+ def initialize(context)
10
+ @prefix = prefix_for_context(context)
11
+ end
12
+
13
+ # Internal: Returns the name of the configuration file on disk.
14
+ #
15
+ # Based on the the initialization context the outcome may differ.
16
+ #
17
+ # Examples
18
+ #
19
+ # ConfigFile.new.name # => "navigation.rb"
20
+ # ConfigFile.new(:default).name # => "navigation.rb"
21
+ # ConfigFile.new(:other).name # => "other_navigation.rb"
22
+ #
23
+ # Returns a String representing the name of the configuration file on disk.
24
+ def name
25
+ @name ||= "#{prefix}navigation.rb"
26
+ end
27
+
28
+ private
29
+
30
+ attr_reader :prefix
31
+
32
+ def prefix_for_context(context)
33
+ context == :default ? '' : "#{context.to_s.underscore}_"
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,42 @@
1
+ require 'simple_navigation/config_file'
2
+
3
+ module SimpleNavigation
4
+ # Internal: Encapsulates the configuration file finding logic.
5
+ class ConfigFileFinder
6
+ # Internal: Initializes a ConfigFileFinder.
7
+ #
8
+ # paths - an enumerable list of paths in which to look for configuration
9
+ # files.
10
+ def initialize(paths)
11
+ @paths = paths
12
+ end
13
+
14
+ # Internal: Searches a configuration file for the given context in the
15
+ # initialization paths.
16
+ #
17
+ # context - The navigation context for which to look the configuration file.
18
+ #
19
+ # Returns a String representing the full path of the configuation file.
20
+ # Raises StandardError if no file is found.
21
+ def find(context)
22
+ config_file_name = config_file_name_for_context(context)
23
+
24
+ find_config_file(config_file_name) ||
25
+ fail("Config file '#{config_file_name}' not found in " \
26
+ "path(s) #{paths.join(', ')}!")
27
+ end
28
+
29
+ private
30
+
31
+ attr_reader :paths
32
+
33
+ def config_file_name_for_context(context)
34
+ ConfigFile.new(context).name
35
+ end
36
+
37
+ def find_config_file(config_file_name)
38
+ paths.map { |path| File.join(path, config_file_name) }
39
+ .find { |full_path| File.exist?(full_path) }
40
+ end
41
+ end
42
+ end