bcl 0.5.3 → 0.5.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.
- checksums.yaml +4 -4
- data/lib/bcl/base_xml.rb +33 -16
- data/lib/bcl/component.rb +388 -390
- data/lib/bcl/component_from_spreadsheet.rb +34 -37
- data/lib/bcl/component_methods.rb +864 -790
- data/lib/bcl/component_spreadsheet.rb +295 -309
- data/lib/bcl/core_ext.rb +38 -6
- data/lib/bcl/master_taxonomy.rb +533 -552
- data/lib/bcl/tar_ball.rb +78 -80
- data/lib/bcl/version.rb +2 -2
- data/lib/bcl.rb +41 -34
- metadata +84 -14
data/lib/bcl/core_ext.rb
CHANGED
@@ -1,15 +1,47 @@
|
|
1
|
+
######################################################################
|
2
|
+
# Copyright (c) 2008-2014, Alliance for Sustainable Energy.
|
3
|
+
# All rights reserved.
|
4
|
+
#
|
5
|
+
# This library is free software; you can redistribute it and/or
|
6
|
+
# modify it under the terms of the GNU Lesser General Public
|
7
|
+
# License as published by the Free Software Foundation; either
|
8
|
+
# version 2.1 of the License, or (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This library is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13
|
+
# Lesser General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU Lesser General Public
|
16
|
+
# License along with this library; if not, write to the Free Software
|
17
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18
|
+
######################################################################
|
19
|
+
|
1
20
|
class String
|
2
21
|
def to_underscore
|
3
|
-
|
22
|
+
gsub(/::/, '/').
|
4
23
|
gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
|
5
24
|
gsub(/([a-z\d])([A-Z])/, '\1_\2').
|
6
|
-
tr(
|
25
|
+
tr('-', '_').
|
7
26
|
downcase
|
8
27
|
end
|
9
28
|
|
10
|
-
# simple method to create titles
|
29
|
+
# simple method to create titles -- very custom to catch known inflections
|
11
30
|
def titleize
|
12
|
-
arr =
|
13
|
-
|
31
|
+
arr = %w(a an the by to)
|
32
|
+
upcase_arr = %w(DX EDA AEDG LPD COP)
|
33
|
+
r = gsub('_', ' ').gsub(/\w+/) { |match|
|
34
|
+
match_result = match
|
35
|
+
if upcase_arr.include?(match.upcase)
|
36
|
+
match_result = upcase_arr[upcase_arr.index(match.upcase)]
|
37
|
+
elsif arr.include?(match)
|
38
|
+
match_result = match
|
39
|
+
else
|
40
|
+
match_result = match.capitalize
|
41
|
+
end
|
42
|
+
match_result
|
43
|
+
}
|
44
|
+
|
45
|
+
r
|
14
46
|
end
|
15
|
-
end
|
47
|
+
end
|