Class: Configuration
- Includes:
- RubySync::Utilities
- Defined in:
- lib/ruby_sync.rb
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#require_all_in_dir(dir, glob = "*.rb") ⇒ Object
We find the first directory in the search path that is a parent of the specified directory and do our requires relative to that in order to increase the likelihood that duplicate requires will be recognised.
Methods included from RubySync::Utilities
#as_array, #base_path, #call_if_exists, #connector_called, #effective_operations, #ensure_dir_exists, #find_base_path, #get_preference, #get_preference_file_path, #include_in_search_path, #log_progress, #perform_operations, #pipeline_called, #set_preference, #something_called, #with_rescue
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/ruby_sync.rb', line 49 def initialize base_path and include_in_search_path "#{base_path}/pipelines" base_path and include_in_search_path "#{base_path}/connectors" base_path and include_in_search_path "#{base_path}/shared/connectors" base_path and include_in_search_path "#{base_path}/shared/pipelines" base_path and include_in_search_path "#{base_path}/shared/lib" lib_path = File.dirname(__FILE__) require_all_in_dir "#{lib_path}/ruby_sync/connectors", "*_connector.rb" base_path and require_all_in_dir "#{base_path}/shared/connectors", "*_connector.rb" require_all_in_dir "#{lib_path}/ruby_sync/pipelines", "*_pipeline.rb" base_path and require_all_in_dir "#{base_path}/shared/pipelines", "*_pipeline.rb" end |
Instance Method Details
#require_all_in_dir(dir, glob = "*.rb") ⇒ Object
We find the first directory in the search path that is a parent of the specified directory and do our requires relative to that in order to increase the likelihood that duplicate requires will be recognised.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/ruby_sync.rb', line 66 def require_all_in_dir(dir, glob="*.rb") = File. dir return unless File.directory? base = $:.detect do |path_dir| = File.(path_dir) [0, .length] == end prefix = (base && File.(base) != )? [File.(base).length+1, .length]+"/" : "" # puts $:.join "\n" # puts "expanded = '#{expanded}'" # puts "base = '#{base}'" # puts "prefix = '#{prefix}'" Dir.chdir dir do |cwd| Dir.glob(glob) do |filename| require prefix + filename end end end |