Class: Synchroniser::Config::Params
- Inherits:
-
Object
- Object
- Synchroniser::Config::Params
- Defined in:
- lib/synchroniser/config.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
Instance Method Summary collapse
- #build_container(container) ⇒ Object
- #build_ingestors(container) ⇒ Object
- #get_sync ⇒ Object
-
#initialize(file_name, ingestor_name) ⇒ Params
constructor
A new instance of Params.
Constructor Details
#initialize(file_name, ingestor_name) ⇒ Params
Returns a new instance of Params.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/synchroniser/config.rb', line 7 def initialize(file_name, ingestor_name) file_path = RAILS_ROOT config = YAML::load(File.open("#{file_path}#{file_name}")) environment = RAILS_ENV if config[RAILS_ENV].nil? environment = "test" end begin @config = config[environment] rescue @config = nil raise ArgumentError, "Unable to find the #{environment} stanza for #{ingestor_name}' in the configuration file supplied" end if @config.nil? raise ArgumentError, "Unable to find the stanza '#{ingestor_name}' in the configuration file supplied" end end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
5 6 7 |
# File 'lib/synchroniser/config.rb', line 5 def config @config end |
Instance Method Details
#build_container(container) ⇒ Object
54 55 56 |
# File 'lib/synchroniser/config.rb', line 54 def build_container(container) eval "#{container['object']}.new(container['defaults'])" end |
#build_ingestors(container) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/synchroniser/config.rb', line 34 def build_ingestors(container) require @config['ingestor'] + "_ingestor.rb" @ingestor = eval("#{@config['ingestor'].camelize}Ingestor.new") strategies = [] @config['params']['url'].each { |url| @ingestor.load(url) strategies << @ingestor.clone puts url # not sure if this will actually work @ingestor.pagination.each do |url| @ingestor.load(url) strategies << @ingestor.clone puts url end } strategies end |
#get_sync ⇒ Object
28 29 30 31 32 |
# File 'lib/synchroniser/config.rb', line 28 def get_sync container = build_container(@config['params']['container']) ingestors = build_ingestors(container) Synchroniser.new(container, ingestors) end |