institutions 0.0.3 → 0.0.4

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.
data/lib/institutions.rb CHANGED
@@ -11,7 +11,12 @@ module Institutions
11
11
  def self.loadpaths
12
12
  @loadpaths ||=
13
13
  [(defined?(::Rails) and ::Rails.version >= '3.0.1' ) ?
14
- "#{Rails.root}/config" : DEFAULT_LOADPATH]
14
+ self.rails_loadpath : DEFAULT_LOADPATH]
15
+ end
16
+
17
+ # Necessary to use a proc to generate the rails root a bit later.
18
+ def self.rails_loadpath
19
+ lambda {return "#{Rails.root}/config"}
15
20
  end
16
21
 
17
22
  def self.filenames
@@ -24,7 +29,7 @@ module Institutions
24
29
  if loadfiles.empty?
25
30
  loadpaths.each do |loadpath|
26
31
  filenames.each do |filename|
27
- loadfile = File.join(loadpath, filename)
32
+ loadfile = File.join((loadpath.is_a? Proc) ? loadpath.call : loadpath, filename)
28
33
  loadfiles<< loadfile if File.exists?(loadfile)
29
34
  end
30
35
  end
@@ -72,7 +77,7 @@ module Institutions
72
77
  @institutions.has_key?(code) ?
73
78
  @institutions[code].merge(elements) :
74
79
  @institutions[code] =
75
- Institution.new(code, elements["name"] ? elements["name"] : code, elements)
80
+ Institution.new(code, elements["name"] ? elements["name"] : code.to_s, elements)
76
81
  end
77
82
  end
78
83
  # Handle inheritance for institutions
@@ -29,7 +29,7 @@ module Institutions#:no_doc
29
29
  merge h unless h.nil?
30
30
  # If the institution is named default, take that as an
31
31
  # indication that it's the default institution
32
- @default = true if (name.eql? "default" or name.eql? "DEFAULT")
32
+ @default = true if name.downcase.eql? "default"
33
33
  # If default was never set, explicitly set default as false.
34
34
  @default = false if default.nil?
35
35
  end
@@ -1,3 +1,3 @@
1
1
  module Institutions
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -8,7 +8,6 @@
8
8
  # all options are neccesarily listed as examples here, see source
9
9
  # or source-generated docs for more info.
10
10
  default:
11
- name: Default
12
11
  auth:
13
12
  link_code: NYU
14
13
  views:
@@ -39,4 +39,10 @@ class InstitutionsTest < Test::Unit::TestCase
39
39
  institutions = Institutions.institutions
40
40
  assert_equal "NYU Libraries", institutions[:NYU].name
41
41
  end
42
+
43
+ def test_institutions_default_as_name
44
+ Institutions.loadpaths << File.join("test", "config")
45
+ institutions = Institutions.institutions
46
+ assert institutions[:default].default
47
+ end
42
48
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: institutions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -143,7 +143,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
143
143
  version: '0'
144
144
  segments:
145
145
  - 0
146
- hash: -4524913858757989027
146
+ hash: -3867727606638988063
147
147
  required_rubygems_version: !ruby/object:Gem::Requirement
148
148
  none: false
149
149
  requirements:
@@ -152,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
152
  version: '0'
153
153
  segments:
154
154
  - 0
155
- hash: -4524913858757989027
155
+ hash: -3867727606638988063
156
156
  requirements: []
157
157
  rubyforge_project:
158
158
  rubygems_version: 1.8.24