fossil 0.2.3 → 0.2.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/VERSION +1 -1
- data/fossil.gemspec +7 -2
- data/lib/fos_schema/FOS_SCHEMA_3.8.22.r3.csv +8211 -0
- data/lib/fos_schema/FOS_SCHEMA_3.8.27.r1.csv +8696 -0
- data/lib/fos_schema/FOS_SCHEMA_3.9.0.csv +8746 -0
- data/lib/fos_schema/fos_schema_snapshot.rb +47 -0
- data/lib/fos_schema/fos_table_gen.rb +124 -0
- data/lib/number_helper.rb +214 -287
- data/lib/sequel/model_patch.rb +1 -1
- metadata +7 -2
data/lib/number_helper.rb
CHANGED
|
@@ -1,303 +1,230 @@
|
|
|
1
|
-
module
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
end
|
|
1
|
+
module Fossil
|
|
2
|
+
# Provides methods for converting numbers into formatted strings.
|
|
3
|
+
# Methods are provided for phone numbers, currency, percentage,
|
|
4
|
+
# precision, positional notation, and file size.
|
|
5
|
+
module NumberHelper
|
|
6
|
+
# Formats a +number+ into a US phone number (e.g., (555) 123-9876). You can customize the format
|
|
7
|
+
# in the +options+ hash.
|
|
8
|
+
#
|
|
9
|
+
# ==== Options
|
|
10
|
+
# * <tt>:area_code</tt> - Adds parentheses around the area code.
|
|
11
|
+
# * <tt>:delimiter</tt> - Specifies the delimiter to use (defaults to "-").
|
|
12
|
+
# * <tt>:extension</tt> - Specifies an extension to add to the end of the
|
|
13
|
+
# generated number.
|
|
14
|
+
# * <tt>:country_code</tt> - Sets the country code for the phone number.
|
|
15
|
+
#
|
|
16
|
+
# ==== Examples
|
|
17
|
+
# number_to_phone(5551234) # => 555-1234
|
|
18
|
+
# number_to_phone(1235551234) # => 123-555-1234
|
|
19
|
+
# number_to_phone(1235551234, :area_code => true) # => (123) 555-1234
|
|
20
|
+
# number_to_phone(1235551234, :delimiter => " ") # => 123 555 1234
|
|
21
|
+
# number_to_phone(1235551234, :area_code => true, :extension => 555) # => (123) 555-1234 x 555
|
|
22
|
+
# number_to_phone(1235551234, :country_code => 1) # => +1-123-555-1234
|
|
23
|
+
#
|
|
24
|
+
# number_to_phone(1235551234, :country_code => 1, :extension => 1343, :delimiter => ".")
|
|
25
|
+
# => +1.123.555.1234 x 1343
|
|
26
|
+
def number_to_phone(number, options = {})
|
|
27
|
+
number = number.to_s.strip unless number.nil?
|
|
28
|
+
options = options.symbolize_keys
|
|
29
|
+
area_code = options[:area_code] || nil
|
|
30
|
+
delimiter = options[:delimiter] || "-"
|
|
31
|
+
extension = options[:extension].to_s.strip || nil
|
|
32
|
+
country_code = options[:country_code] || nil
|
|
33
|
+
|
|
34
|
+
begin
|
|
35
|
+
str = ""
|
|
36
|
+
str << "+#{country_code}#{delimiter}" unless country_code.blank?
|
|
37
|
+
str <<
|
|
38
|
+
if area_code
|
|
39
|
+
number.gsub!(/([0-9]{1,3})([0-9]{3})([0-9]{4}$)/, "(\\1) \\2#{delimiter}\\3")
|
|
40
|
+
else
|
|
41
|
+
number.gsub!(/([0-9]{0,3})([0-9]{3})([0-9]{4})$/, "\\1#{delimiter}\\2#{delimiter}\\3")
|
|
42
|
+
number.starts_with?('-') ? number.slice!(1..-1) : number
|
|
43
|
+
end
|
|
44
|
+
str << " x #{extension}" unless extension.blank?
|
|
45
|
+
str
|
|
46
|
+
rescue
|
|
47
|
+
number
|
|
49
48
|
end
|
|
49
|
+
end
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
51
|
+
# Formats a +number+ into a currency string (e.g., $13.65). You can customize the format
|
|
52
|
+
# in the +options+ hash.
|
|
53
|
+
#
|
|
54
|
+
# ==== Options
|
|
55
|
+
# * <tt>:precision</tt> - Sets the level of precision (defaults to 2).
|
|
56
|
+
# * <tt>:unit</tt> - Sets the denomination of the currency (defaults to "$").
|
|
57
|
+
# * <tt>:separator</tt> - Sets the separator between the units (defaults to ".").
|
|
58
|
+
# * <tt>:delimiter</tt> - Sets the thousands delimiter (defaults to ",").
|
|
59
|
+
# * <tt>:format</tt> - Sets the format of the output string (defaults to "%u%n"). The field types are:
|
|
60
|
+
#
|
|
61
|
+
# %u The currency unit
|
|
62
|
+
# %n The number
|
|
63
|
+
#
|
|
64
|
+
# ==== Examples
|
|
65
|
+
# number_to_currency(1234567890.50) # => $1,234,567,890.50
|
|
66
|
+
# number_to_currency(1234567890.506) # => $1,234,567,890.51
|
|
67
|
+
# number_to_currency(1234567890.506, :precision => 3) # => $1,234,567,890.506
|
|
68
|
+
#
|
|
69
|
+
# number_to_currency(1234567890.50, :unit => "£", :separator => ",", :delimiter => "")
|
|
70
|
+
# # => £1234567890,50
|
|
71
|
+
# number_to_currency(1234567890.50, :unit => "£", :separator => ",", :delimiter => "", :format => "%n %u")
|
|
72
|
+
# # => 1234567890,50 £
|
|
73
|
+
|
|
74
|
+
def number_to_currency(number, options = {})
|
|
75
|
+
options.symbolize_keys!
|
|
76
|
+
|
|
77
|
+
defaults = I18n.translate(:'number.format', :locale => options[:locale], :raise => true) rescue {}
|
|
78
|
+
currency = I18n.translate(:'number.currency.format', :locale => options[:locale], :raise => true) rescue {}
|
|
79
|
+
defaults = defaults.merge(currency)
|
|
80
|
+
|
|
81
|
+
precision = options[:precision] || defaults[:precision]
|
|
82
|
+
unit = options[:unit] || defaults[:unit]
|
|
83
|
+
separator = options[:separator] || defaults[:separator]
|
|
84
|
+
delimiter = options[:delimiter] || defaults[:delimiter]
|
|
85
|
+
format = options[:format] || defaults[:format]
|
|
86
|
+
separator = '' if precision == 0
|
|
87
|
+
|
|
88
|
+
begin
|
|
89
|
+
format.gsub(/%n/, number_with_precision(number,
|
|
90
|
+
:precision => precision,
|
|
91
|
+
:delimiter => delimiter,
|
|
92
|
+
:separator => separator)
|
|
93
|
+
).gsub(/%u/, unit)
|
|
94
|
+
rescue
|
|
95
|
+
number
|
|
96
96
|
end
|
|
97
|
+
end
|
|
97
98
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
99
|
+
# Formats a +number+ as a percentage string (e.g., 65%). You can customize the
|
|
100
|
+
# format in the +options+ hash.
|
|
101
|
+
#
|
|
102
|
+
# ==== Options
|
|
103
|
+
# * <tt>:precision</tt> - Sets the level of precision (defaults to 3).
|
|
104
|
+
# * <tt>:separator</tt> - Sets the separator between the units (defaults to ".").
|
|
105
|
+
# * <tt>:delimiter</tt> - Sets the thousands delimiter (defaults to "").
|
|
106
|
+
#
|
|
107
|
+
# ==== Examples
|
|
108
|
+
# number_to_percentage(100) # => 100.000%
|
|
109
|
+
# number_to_percentage(100, :precision => 0) # => 100%
|
|
110
|
+
# number_to_percentage(1000, :delimiter => '.', :separator => ',') # => 1.000,000%
|
|
111
|
+
# number_to_percentage(302.24398923423, :precision => 5) # => 302.24399%
|
|
112
|
+
|
|
113
|
+
def number_to_percentage(number, options = {})
|
|
114
|
+
options.symbolize_keys!
|
|
115
|
+
|
|
116
|
+
defaults = I18n.translate(:'number.format', :locale => options[:locale], :raise => true) rescue {}
|
|
117
|
+
percentage = I18n.translate(:'number.percentage.format', :locale => options[:locale], :raise => true) rescue {}
|
|
118
|
+
defaults = defaults.merge(percentage)
|
|
119
|
+
|
|
120
|
+
precision = options[:precision] || defaults[:precision]
|
|
121
|
+
separator = options[:separator] || defaults[:separator]
|
|
122
|
+
delimiter = options[:delimiter] || defaults[:delimiter]
|
|
123
|
+
|
|
124
|
+
begin
|
|
125
|
+
number_with_precision(number,
|
|
126
|
+
:precision => precision,
|
|
127
|
+
:separator => separator,
|
|
128
|
+
:delimiter => delimiter) + "%"
|
|
129
|
+
rescue
|
|
130
|
+
number
|
|
130
131
|
end
|
|
132
|
+
end
|
|
131
133
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
delimiter ||= (options[:delimiter] || defaults[:delimiter])
|
|
166
|
-
separator ||= (options[:separator] || defaults[:separator])
|
|
167
|
-
|
|
168
|
-
begin
|
|
169
|
-
parts = number.to_s.split('.')
|
|
170
|
-
parts[0].gsub!(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1#{delimiter}")
|
|
171
|
-
parts.join(separator)
|
|
172
|
-
rescue
|
|
173
|
-
number
|
|
174
|
-
end
|
|
134
|
+
# Formats a +number+ with grouped thousands using +delimiter+ (e.g., 12,324). You can
|
|
135
|
+
# customize the format in the +options+ hash.
|
|
136
|
+
#
|
|
137
|
+
# ==== Options
|
|
138
|
+
# * <tt>:delimiter</tt> - Sets the thousands delimiter (defaults to ",").
|
|
139
|
+
# * <tt>:separator</tt> - Sets the separator between the units (defaults to ".").
|
|
140
|
+
#
|
|
141
|
+
# ==== Examples
|
|
142
|
+
# number_with_delimiter(12345678) # => 12,345,678
|
|
143
|
+
# number_with_delimiter(12345678.05) # => 12,345,678.05
|
|
144
|
+
# number_with_delimiter(12345678, :delimiter => ".") # => 12.345.678
|
|
145
|
+
# number_with_delimiter(12345678, :separator => ",") # => 12,345,678
|
|
146
|
+
# number_with_delimiter(98765432.98, :delimiter => " ", :separator => ",")
|
|
147
|
+
# # => 98 765 432,98
|
|
148
|
+
#
|
|
149
|
+
# You can still use <tt>number_with_delimiter</tt> with the old API that accepts the
|
|
150
|
+
# +delimiter+ as its optional second and the +separator+ as its
|
|
151
|
+
# optional third parameter:
|
|
152
|
+
# number_with_delimiter(12345678, " ") # => 12 345.678
|
|
153
|
+
# number_with_delimiter(12345678.05, ".", ",") # => 12.345.678,05
|
|
154
|
+
|
|
155
|
+
def number_with_delimiter(number, *args)
|
|
156
|
+
options = args.extract_options!
|
|
157
|
+
options.symbolize_keys!
|
|
158
|
+
|
|
159
|
+
defaults = I18n.translate(:'number.format', :locale => options[:locale], :raise => true) rescue {}
|
|
160
|
+
|
|
161
|
+
unless args.empty?
|
|
162
|
+
ActiveSupport::Deprecation.warn('number_with_delimiter takes an option hash ' +
|
|
163
|
+
'instead of separate delimiter and precision arguments.', caller)
|
|
164
|
+
delimiter = args[0] || defaults[:delimiter]
|
|
165
|
+
separator = args[1] || defaults[:separator]
|
|
175
166
|
end
|
|
176
167
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
#
|
|
180
|
-
# ==== Options
|
|
181
|
-
# * <tt>:precision</tt> - Sets the level of precision (defaults to 3).
|
|
182
|
-
# * <tt>:separator</tt> - Sets the separator between the units (defaults to ".").
|
|
183
|
-
# * <tt>:delimiter</tt> - Sets the thousands delimiter (defaults to "").
|
|
184
|
-
#
|
|
185
|
-
# ==== Examples
|
|
186
|
-
# number_with_precision(111.2345) # => 111.235
|
|
187
|
-
# number_with_precision(111.2345, :precision => 2) # => 111.23
|
|
188
|
-
# number_with_precision(13, :precision => 5) # => 13.00000
|
|
189
|
-
# number_with_precision(389.32314, :precision => 0) # => 389
|
|
190
|
-
# number_with_precision(1111.2345, :precision => 2, :separator => ',', :delimiter => '.')
|
|
191
|
-
# # => 1.111,23
|
|
192
|
-
#
|
|
193
|
-
# You can still use <tt>number_with_precision</tt> with the old API that accepts the
|
|
194
|
-
# +precision+ as its optional second parameter:
|
|
195
|
-
# number_with_precision(number_with_precision(111.2345, 2) # => 111.23
|
|
196
|
-
def number_with_precision(number, *args)
|
|
197
|
-
options = args.extract_options!
|
|
198
|
-
options.symbolize_keys!
|
|
168
|
+
delimiter ||= (options[:delimiter] || defaults[:delimiter])
|
|
169
|
+
separator ||= (options[:separator] || defaults[:separator])
|
|
199
170
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
ActiveSupport::Deprecation.warn('number_with_precision takes an option hash ' +
|
|
207
|
-
'instead of a separate precision argument.', caller)
|
|
208
|
-
precision = args[0] || defaults[:precision]
|
|
209
|
-
end
|
|
210
|
-
|
|
211
|
-
precision ||= (options[:precision] || defaults[:precision])
|
|
212
|
-
separator ||= (options[:separator] || defaults[:separator])
|
|
213
|
-
delimiter ||= (options[:delimiter] || defaults[:delimiter])
|
|
214
|
-
|
|
215
|
-
begin
|
|
216
|
-
rounded_number = (Float(number) * (10 ** precision)).round.to_f / 10 ** precision
|
|
217
|
-
number_with_delimiter("%01.#{precision}f" % rounded_number,
|
|
218
|
-
:separator => separator,
|
|
219
|
-
:delimiter => delimiter)
|
|
220
|
-
rescue
|
|
221
|
-
number
|
|
222
|
-
end
|
|
171
|
+
begin
|
|
172
|
+
parts = number.to_s.split('.')
|
|
173
|
+
parts[0].gsub!(/(\d)(?=(\d\d\d)+(?!\d))/, "\\1#{delimiter}")
|
|
174
|
+
parts.join(separator)
|
|
175
|
+
rescue
|
|
176
|
+
number
|
|
223
177
|
end
|
|
178
|
+
end
|
|
224
179
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
defaults = I18n.translate(:'number.format', :locale => options[:locale], :raise => true) rescue {}
|
|
260
|
-
human = I18n.translate(:'number.human.format', :locale => options[:locale], :raise => true) rescue {}
|
|
261
|
-
defaults = defaults.merge(human)
|
|
262
|
-
|
|
263
|
-
unless args.empty?
|
|
264
|
-
ActiveSupport::Deprecation.warn('number_to_human_size takes an option hash ' +
|
|
265
|
-
'instead of a separate precision argument.', caller)
|
|
266
|
-
precision = args[0] || defaults[:precision]
|
|
267
|
-
end
|
|
268
|
-
|
|
269
|
-
precision ||= (options[:precision] || defaults[:precision])
|
|
270
|
-
separator ||= (options[:separator] || defaults[:separator])
|
|
271
|
-
delimiter ||= (options[:delimiter] || defaults[:delimiter])
|
|
272
|
-
|
|
273
|
-
storage_units_format = I18n.translate(:'number.human.storage_units.format', :locale => options[:locale], :raise => true)
|
|
274
|
-
|
|
275
|
-
if number.to_i < 1024
|
|
276
|
-
unit = I18n.translate(:'number.human.storage_units.units.byte', :locale => options[:locale], :count => number.to_i, :raise => true)
|
|
277
|
-
storage_units_format.gsub(/%n/, number.to_i.to_s).gsub(/%u/, unit)
|
|
278
|
-
else
|
|
279
|
-
max_exp = STORAGE_UNITS.size - 1
|
|
280
|
-
number = Float(number)
|
|
281
|
-
exponent = (Math.log(number) / Math.log(1024)).to_i # Convert to base 1024
|
|
282
|
-
exponent = max_exp if exponent > max_exp # we need this to avoid overflow for the highest unit
|
|
283
|
-
number /= 1024 ** exponent
|
|
284
|
-
|
|
285
|
-
unit_key = STORAGE_UNITS[exponent]
|
|
286
|
-
unit = I18n.translate(:"number.human.storage_units.units.#{unit_key}", :locale => options[:locale], :count => number, :raise => true)
|
|
180
|
+
# Formats a +number+ with the specified level of <tt>:precision</tt> (e.g., 112.32 has a precision of 2).
|
|
181
|
+
# You can customize the format in the +options+ hash.
|
|
182
|
+
#
|
|
183
|
+
# ==== Options
|
|
184
|
+
# * <tt>:precision</tt> - Sets the level of precision (defaults to 3).
|
|
185
|
+
# * <tt>:separator</tt> - Sets the separator between the units (defaults to ".").
|
|
186
|
+
# * <tt>:delimiter</tt> - Sets the thousands delimiter (defaults to "").
|
|
187
|
+
#
|
|
188
|
+
# ==== Examples
|
|
189
|
+
# number_with_precision(111.2345) # => 111.235
|
|
190
|
+
# number_with_precision(111.2345, :precision => 2) # => 111.23
|
|
191
|
+
# number_with_precision(13, :precision => 5) # => 13.00000
|
|
192
|
+
# number_with_precision(389.32314, :precision => 0) # => 389
|
|
193
|
+
# number_with_precision(1111.2345, :precision => 2, :separator => ',', :delimiter => '.')
|
|
194
|
+
# # => 1.111,23
|
|
195
|
+
#
|
|
196
|
+
# You can still use <tt>number_with_precision</tt> with the old API that accepts the
|
|
197
|
+
# +precision+ as its optional second parameter:
|
|
198
|
+
# number_with_precision(number_with_precision(111.2345, 2) # => 111.23
|
|
199
|
+
|
|
200
|
+
def number_with_precision(number, *args)
|
|
201
|
+
options = args.extract_options!
|
|
202
|
+
options.symbolize_keys!
|
|
203
|
+
|
|
204
|
+
defaults = I18n.translate(:'number.format', :locale => options[:locale], :raise => true) rescue {}
|
|
205
|
+
precision_defaults = I18n.translate(:'number.precision.format', :locale => options[:locale],
|
|
206
|
+
:raise => true) rescue {}
|
|
207
|
+
defaults = defaults.merge(precision_defaults)
|
|
208
|
+
|
|
209
|
+
unless args.empty?
|
|
210
|
+
ActiveSupport::Deprecation.warn('number_with_precision takes an option hash ' +
|
|
211
|
+
'instead of a separate precision argument.', caller)
|
|
212
|
+
precision = args[0] || defaults[:precision]
|
|
213
|
+
end
|
|
287
214
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
end
|
|
215
|
+
precision ||= (options[:precision] || defaults[:precision])
|
|
216
|
+
separator ||= (options[:separator] || defaults[:separator])
|
|
217
|
+
delimiter ||= (options[:delimiter] || defaults[:delimiter])
|
|
218
|
+
|
|
219
|
+
begin
|
|
220
|
+
rounded_number = (Float(number) * (10 ** precision)).round.to_f / 10 ** precision
|
|
221
|
+
number_with_delimiter("%01.#{precision}f" % rounded_number,
|
|
222
|
+
:separator => separator,
|
|
223
|
+
:delimiter => delimiter)
|
|
224
|
+
rescue
|
|
225
|
+
number
|
|
300
226
|
end
|
|
301
227
|
end
|
|
228
|
+
|
|
302
229
|
end
|
|
303
230
|
end
|
data/lib/sequel/model_patch.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fossil
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Patrick Lardin, Daniel Sudol
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
11
|
|
|
12
|
-
date: 2010-01-
|
|
12
|
+
date: 2010-01-15 00:00:00 -08:00
|
|
13
13
|
default_executable:
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
@@ -54,6 +54,11 @@ files:
|
|
|
54
54
|
- Rakefile
|
|
55
55
|
- VERSION
|
|
56
56
|
- fossil.gemspec
|
|
57
|
+
- lib/fos_schema/FOS_SCHEMA_3.8.22.r3.csv
|
|
58
|
+
- lib/fos_schema/FOS_SCHEMA_3.8.27.r1.csv
|
|
59
|
+
- lib/fos_schema/FOS_SCHEMA_3.9.0.csv
|
|
60
|
+
- lib/fos_schema/fos_schema_snapshot.rb
|
|
61
|
+
- lib/fos_schema/fos_table_gen.rb
|
|
57
62
|
- lib/fossil.rb
|
|
58
63
|
- lib/hash_extentions.rb
|
|
59
64
|
- lib/models/ac_qualification.rb
|