Class: EBSCO::EDS::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/ebsco/eds/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/ebsco/eds/configuration.rb', line 11

def initialize
  # Configuration defaults
  @config  = {
      :debug => false,
      :guest => true,
      :org => '',
      :auth => 'user',
      :auth_token => '',
      :session_token => '',
      :api_hosts_list => ['eds-api.ebscohost.com'],
      :uid_auth_url => '/authservice/rest/uidauth',
      :ip_auth_url => '/authservice/rest/ipauth',
      :create_session_url => '/edsapi/rest/CreateSession',
      :end_session_url => '/edsapi/rest/EndSession',
      :info_url => '/edsapi/rest/Info',
      :search_url => '/edsapi/rest/Search',
      :retrieve_url => '/edsapi/rest/Retrieve',
      :citation_exports_url => '/edsapi/rest/ExportFormat',
      :citation_exports_formats => 'all',
      :citation_styles_url => '/edsapi/rest/CitationStyles',
      :citation_styles_formats => 'all',
      :user_agent => 'EBSCO EDS GEM v0.0.1',
      :interface_id => 'edsapi_ruby_gem',
      :log => 'faraday.log',
      :log_level => 'INFO',
      :max_attempts => 3,
      :max_results_per_page => 100,
      :ebook_preferred_format => 'ebook-pdf',
      :use_cache => true,
      :eds_cache_dir => ENV['TMPDIR'] || '/tmp',
      :auth_cache_expires_in => 1500,
      :info_cache_expires_in => 86400,
      :retrieve_cache_expires_in => 1800,
      :search_cache_expires_in => 1800,
      :export_format_cache_expires_in => 86400,
      :citation_styles_cache_expires_in => 86400,
      :timeout => 60,
      :open_timeout => 12,
      :max_page_jumps => 6,
      :max_page_jump_attempts => 10,
      :recover_from_bad_source_type => false,
      :all_subjects_search_links => false,
      :decode_sanitize_html => false,
      :titleize_facets => false,
      :citation_link_find => '[.,]\s+(<i>EBSCOhost|viewed|Available|Retrieved from|http:\/\/search.ebscohost.com|Disponível em).+$',
      :citation_link_replace => '.',
      :citation_db_find => '',
      :citation_db_replace => '',
      :ris_link_find => '',
      :ris_link_replace => '',
      :ris_db_find => '',
      :ris_db_replace => '',
      :smarttext_failover => false
  }
  @valid_config_keys = @config.keys
end

Instance Attribute Details

#valid_config_keysObject (readonly)

Returns the value of attribute valid_config_keys.



9
10
11
# File 'lib/ebsco/eds/configuration.rb', line 9

def valid_config_keys
  @valid_config_keys
end

Instance Method Details

#configure(opts = {}) ⇒ Object



68
69
70
71
72
73
# File 'lib/ebsco/eds/configuration.rb', line 68

def configure(opts = {})
  opts.each do |k, v|
    @config[k] = v if @valid_config_keys.include? k
  end
  @config
end

#configure_with(file) ⇒ Object



75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/ebsco/eds/configuration.rb', line 75

def configure_with(file)
  begin
    config = YAML.load_file(file ||= 'eds.yaml').symbolize_keys
  rescue Errno::ENOENT
    #puts 'YAML configuration file couldn\'t be found. Using defaults.'
    return
  rescue Psych::SyntaxError
    #puts 'YAML configuration file contains invalid syntax. Using defaults'
    return
  end
  @config[:file] = file
  configure(config)
end