arel_extensions 1.2.15 → 1.2.23
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +102 -0
- data/.travis.yml +2 -0
- data/Gemfile +10 -10
- data/Rakefile +4 -4
- data/arel_extensions.gemspec +1 -1
- data/gemfiles/rails3.gemfile +9 -9
- data/gemfiles/rails4.gemfile +13 -13
- data/gemfiles/rails5_0.gemfile +13 -13
- data/gemfiles/rails5_1_4.gemfile +13 -13
- data/gemfiles/rails5_2.gemfile +13 -13
- data/gemfiles/rails6.gemfile +13 -13
- data/gemfiles/rails6_1.gemfile +30 -0
- data/gemspecs/arel_extensions-v1.gemspec +28 -0
- data/{gemspec_v2 → gemspecs}/arel_extensions-v2.gemspec +0 -0
- data/generate_gems.sh +4 -3
- data/lib/arel_extensions.rb +11 -5
- data/lib/arel_extensions/attributes.rb +0 -0
- data/lib/arel_extensions/boolean_functions.rb +21 -5
- data/lib/arel_extensions/common_sql_functions.rb +2 -4
- data/lib/arel_extensions/comparators.rb +11 -14
- data/lib/arel_extensions/date_duration.rb +4 -5
- data/lib/arel_extensions/insert_manager.rb +16 -17
- data/lib/arel_extensions/math.rb +8 -9
- data/lib/arel_extensions/math_functions.rb +22 -20
- data/lib/arel_extensions/nodes/abs.rb +0 -1
- data/lib/arel_extensions/nodes/aggregate_function.rb +0 -1
- data/lib/arel_extensions/nodes/blank.rb +0 -1
- data/lib/arel_extensions/nodes/case.rb +3 -4
- data/lib/arel_extensions/nodes/cast.rb +4 -2
- data/lib/arel_extensions/nodes/ceil.rb +1 -1
- data/lib/arel_extensions/nodes/change_case.rb +0 -0
- data/lib/arel_extensions/nodes/coalesce.rb +0 -1
- data/lib/arel_extensions/nodes/collate.rb +0 -1
- data/lib/arel_extensions/nodes/concat.rb +2 -4
- data/lib/arel_extensions/nodes/date_diff.rb +7 -8
- data/lib/arel_extensions/nodes/duration.rb +0 -1
- data/lib/arel_extensions/nodes/find_in_set.rb +0 -1
- data/lib/arel_extensions/nodes/floor.rb +1 -1
- data/lib/arel_extensions/nodes/format.rb +27 -1
- data/lib/arel_extensions/nodes/formatted_number.rb +0 -1
- data/lib/arel_extensions/nodes/function.rb +24 -17
- data/lib/arel_extensions/nodes/is_null.rb +0 -0
- data/lib/arel_extensions/nodes/json.rb +11 -17
- data/lib/arel_extensions/nodes/length.rb +0 -1
- data/lib/arel_extensions/nodes/levenshtein_distance.rb +0 -0
- data/lib/arel_extensions/nodes/locate.rb +0 -1
- data/lib/arel_extensions/nodes/log10.rb +1 -2
- data/lib/arel_extensions/nodes/matches.rb +0 -2
- data/lib/arel_extensions/nodes/md5.rb +0 -1
- data/lib/arel_extensions/nodes/power.rb +0 -1
- data/lib/arel_extensions/nodes/rand.rb +0 -1
- data/lib/arel_extensions/nodes/repeat.rb +0 -2
- data/lib/arel_extensions/nodes/replace.rb +0 -2
- data/lib/arel_extensions/nodes/round.rb +0 -1
- data/lib/arel_extensions/nodes/soundex.rb +0 -1
- data/lib/arel_extensions/nodes/std.rb +4 -5
- data/lib/arel_extensions/nodes/substring.rb +0 -1
- data/lib/arel_extensions/nodes/sum.rb +0 -0
- data/lib/arel_extensions/nodes/then.rb +0 -0
- data/lib/arel_extensions/nodes/trim.rb +0 -2
- data/lib/arel_extensions/nodes/union.rb +0 -2
- data/lib/arel_extensions/nodes/union_all.rb +0 -2
- data/lib/arel_extensions/nodes/wday.rb +0 -4
- data/lib/arel_extensions/null_functions.rb +3 -5
- data/lib/arel_extensions/predications.rb +5 -6
- data/lib/arel_extensions/railtie.rb +5 -5
- data/lib/arel_extensions/set_functions.rb +0 -2
- data/lib/arel_extensions/string_functions.rb +21 -22
- data/lib/arel_extensions/tasks.rb +1 -1
- data/lib/arel_extensions/version.rb +1 -1
- data/lib/arel_extensions/visitors.rb +68 -60
- data/lib/arel_extensions/visitors/convert_format.rb +37 -0
- data/lib/arel_extensions/visitors/ibm_db.rb +4 -11
- data/lib/arel_extensions/visitors/mssql.rb +49 -44
- data/lib/arel_extensions/visitors/mysql.rb +65 -67
- data/lib/arel_extensions/visitors/oracle.rb +58 -55
- data/lib/arel_extensions/visitors/oracle12.rb +1 -14
- data/lib/arel_extensions/visitors/postgresql.rb +41 -34
- data/lib/arel_extensions/visitors/sqlite.rb +23 -18
- data/lib/arel_extensions/visitors/to_sql.rb +59 -47
- data/test/arelx_test_helper.rb +0 -2
- data/test/database.yml +2 -0
- data/test/real_db_test.rb +27 -42
- data/test/support/fake_record.rb +1 -1
- data/test/test_comparators.rb +0 -4
- data/test/visitors/test_bulk_insert_oracle.rb +0 -1
- data/test/visitors/test_bulk_insert_sqlite.rb +0 -2
- data/test/visitors/test_oracle.rb +1 -2
- data/test/visitors/test_to_sql.rb +16 -25
- data/test/with_ar/all_agnostic_test.rb +141 -139
- data/test/with_ar/insert_agnostic_test.rb +0 -2
- data/test/with_ar/test_bulk_sqlite.rb +0 -4
- data/test/with_ar/test_math_sqlite.rb +4 -8
- data/test/with_ar/test_string_mysql.rb +1 -5
- data/test/with_ar/test_string_sqlite.rb +1 -5
- data/version_v1.rb +1 -1
- data/version_v2.rb +1 -1
- metadata +8 -4
File without changes
|
data/generate_gems.sh
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
|
2
|
-
gem uninstall arel_extensions
|
2
|
+
#gem uninstall arel_extensions
|
3
3
|
|
4
4
|
# VERSION ~> 1
|
5
5
|
cp ./version_v1.rb lib/arel_extensions/version.rb
|
6
|
+
cp ./gemspecs/arel_extensions-v1.gemspec ./arel_extensions.gemspec
|
6
7
|
gem build ./arel_extensions.gemspec
|
7
8
|
|
8
9
|
# VERSION ~> 2
|
9
10
|
cp ./version_v2.rb lib/arel_extensions/version.rb
|
10
11
|
mv ./arel_extensions.gemspec ./arel_extensions.gemspec.bck
|
11
|
-
cp ./
|
12
|
+
cp ./gemspecs/arel_extensions-v2.gemspec ./arel_extensions.gemspec
|
12
13
|
gem build ./arel_extensions.gemspec
|
13
14
|
cp ./version_v1.rb lib/arel_extensions/version.rb
|
14
|
-
cp ./arel_extensions.gemspec
|
15
|
+
cp ./gemspecs/arel_extensions-v1.gemspec ./arel_extensions.gemspec
|
data/lib/arel_extensions.rb
CHANGED
@@ -16,8 +16,10 @@ class Arel::Nodes::Casted
|
|
16
16
|
include Arel::AliasPredication
|
17
17
|
|
18
18
|
# They forget to define hash.
|
19
|
-
|
20
|
-
|
19
|
+
if Gem::Version.new(Arel::VERSION) < Gem::Version.new("10.0.0")
|
20
|
+
def hash
|
21
|
+
[self.class, self.val, self.attribute].hash
|
22
|
+
end
|
21
23
|
end
|
22
24
|
end
|
23
25
|
|
@@ -124,9 +126,13 @@ class Arel::Nodes::Function
|
|
124
126
|
include ArelExtensions::NullFunctions
|
125
127
|
include ArelExtensions::Predications
|
126
128
|
|
127
|
-
alias_method
|
129
|
+
alias_method(:old_as, :as) rescue nil
|
128
130
|
def as other
|
129
|
-
Arel::Nodes::As.new(self, Arel.sql(other))
|
131
|
+
res = Arel::Nodes::As.new(self.clone, Arel.sql(other))
|
132
|
+
if Gem::Version.new(Arel::VERSION) >= Gem::Version.new("9.0.0")
|
133
|
+
self.alias = Arel.sql(other)
|
134
|
+
end
|
135
|
+
res
|
130
136
|
end
|
131
137
|
end
|
132
138
|
|
@@ -178,7 +184,7 @@ class Arel::Nodes::As
|
|
178
184
|
end
|
179
185
|
|
180
186
|
class Arel::Table
|
181
|
-
alias_method
|
187
|
+
alias_method(:old_alias, :alias) rescue nil
|
182
188
|
def alias(name = "#{self.name}_2")
|
183
189
|
name.blank? ? self : Arel::Nodes::TableAlias.new(self,name)
|
184
190
|
end
|
File without changes
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
|
2
3
|
require 'arel_extensions/nodes/then'
|
3
4
|
|
4
5
|
module ArelExtensions
|
5
6
|
module BooleanFunctions
|
6
|
-
|
7
7
|
def ⋀(other)
|
8
8
|
self.and(other)
|
9
9
|
end
|
@@ -23,7 +23,6 @@ module ArelExtensions
|
|
23
23
|
def then(t, f = nil)
|
24
24
|
ArelExtensions::Nodes::Then.new [self, t, f]
|
25
25
|
end
|
26
|
-
|
27
26
|
end
|
28
27
|
end
|
29
28
|
|
@@ -34,10 +33,9 @@ class Arel::Nodes::And
|
|
34
33
|
children =
|
35
34
|
children.flatten.map { |c|
|
36
35
|
c.is_a?(self) ? c.children : c
|
37
|
-
|
36
|
+
}.flatten
|
38
37
|
super(children)
|
39
38
|
end
|
40
|
-
|
41
39
|
end
|
42
40
|
|
43
41
|
# For some reason, Arel's And is properly defined as variadic (it
|
@@ -55,7 +53,7 @@ class Arel::Nodes::Or
|
|
55
53
|
children =
|
56
54
|
children.flatten.map { |c|
|
57
55
|
c.is_a?(self) ? c.children : c
|
58
|
-
|
56
|
+
}.flatten
|
59
57
|
super(*children)
|
60
58
|
end
|
61
59
|
|
@@ -63,8 +61,26 @@ class Arel::Nodes::Or
|
|
63
61
|
@children = children
|
64
62
|
end
|
65
63
|
|
64
|
+
def initialize_copy(other)
|
65
|
+
super
|
66
|
+
@children = other.children.copy if other.children
|
67
|
+
end
|
68
|
+
|
69
|
+
def left
|
70
|
+
children.first
|
71
|
+
end
|
72
|
+
|
73
|
+
def right
|
74
|
+
children[1]
|
75
|
+
end
|
76
|
+
|
66
77
|
def hash
|
67
78
|
children.hash
|
68
79
|
end
|
69
80
|
|
81
|
+
def eql?(other)
|
82
|
+
self.class == other.class &&
|
83
|
+
children == other.children
|
84
|
+
end
|
85
|
+
alias :== :eql?
|
70
86
|
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
module ArelExtensions
|
2
2
|
class CommonSqlFunctions
|
3
|
-
|
4
3
|
def initialize(cnx)
|
5
4
|
@cnx = cnx
|
6
5
|
if cnx && cnx.adapter_name =~ /sqlite/i && !$load_extension_disabled
|
@@ -12,7 +11,7 @@ module ArelExtensions
|
|
12
11
|
db.enable_load_extension(0)
|
13
12
|
rescue => e
|
14
13
|
$load_extension_disabled = true
|
15
|
-
puts "
|
14
|
+
puts "cannot load extensions #{e.inspect}"
|
16
15
|
end
|
17
16
|
end
|
18
17
|
end
|
@@ -44,7 +43,7 @@ module ArelExtensions
|
|
44
43
|
begin
|
45
44
|
add_sqlite_functions
|
46
45
|
rescue => e
|
47
|
-
puts "
|
46
|
+
puts "cannot add sqlite functions #{e.inspect}"
|
48
47
|
end
|
49
48
|
end
|
50
49
|
if File.exist?("init/#{env_db}.sql")
|
@@ -62,6 +61,5 @@ module ArelExtensions
|
|
62
61
|
end
|
63
62
|
end
|
64
63
|
end
|
65
|
-
|
66
64
|
end
|
67
65
|
end
|
@@ -1,7 +1,5 @@
|
|
1
1
|
module ArelExtensions
|
2
2
|
module Comparators
|
3
|
-
|
4
|
-
|
5
3
|
def >(other)
|
6
4
|
Arel::Nodes::GreaterThan.new self, Arel::Nodes.build_quoted(other, self)
|
7
5
|
end
|
@@ -18,26 +16,26 @@ module ArelExtensions
|
|
18
16
|
Arel::Nodes::LessThanOrEqual.new self, Arel::Nodes.build_quoted(other, self)
|
19
17
|
end
|
20
18
|
|
21
|
-
|
22
|
-
#
|
23
|
-
#Pattern matching using regular expressions
|
19
|
+
# REGEXP function
|
20
|
+
# Pattern matching using regular expressions
|
24
21
|
def =~(other)
|
25
|
-
# arg = self.relation.engine.connection.schema_cache.columns_hash(self.relation.table_name)[self.name.to_s].type
|
26
|
-
# if arg == :string || arg == :text
|
22
|
+
# arg = self.relation.engine.connection.schema_cache.columns_hash(self.relation.table_name)[self.name.to_s].type
|
23
|
+
# if arg == :string || arg == :text
|
27
24
|
Arel::Nodes::Regexp.new self, convert_regexp(other)
|
28
|
-
# end
|
25
|
+
# end
|
29
26
|
end
|
30
27
|
|
31
|
-
#NOT_REGEXP function
|
32
|
-
#Negation of Regexp
|
28
|
+
# NOT_REGEXP function
|
29
|
+
# Negation of Regexp
|
33
30
|
def !~(other)
|
34
|
-
# arg = self.relation.engine.connection.schema_cache.columns_hash(self.relation.table_name)[self.name.to_s].type
|
35
|
-
# if arg == :string || arg == :text
|
31
|
+
# arg = self.relation.engine.connection.schema_cache.columns_hash(self.relation.table_name)[self.name.to_s].type
|
32
|
+
# if arg == :string || arg == :text
|
36
33
|
Arel::Nodes::NotRegexp.new self, convert_regexp(other)
|
37
|
-
# end
|
34
|
+
# end
|
38
35
|
end
|
39
36
|
|
40
37
|
private
|
38
|
+
|
41
39
|
# Function used for not_regexp.
|
42
40
|
def convert_regexp(other)
|
43
41
|
case other
|
@@ -56,6 +54,5 @@ module ArelExtensions
|
|
56
54
|
end
|
57
55
|
Arel::Nodes.build_quoted(other, self)
|
58
56
|
end
|
59
|
-
|
60
57
|
end
|
61
58
|
end
|
@@ -4,22 +4,22 @@ require 'arel_extensions/nodes/wday'
|
|
4
4
|
|
5
5
|
module ArelExtensions
|
6
6
|
module DateDuration
|
7
|
-
#function returns the year (as a number) given a date value.
|
7
|
+
# function returns the year (as a number) given a date value.
|
8
8
|
def year
|
9
9
|
ArelExtensions::Nodes::Duration.new "y", self
|
10
10
|
end
|
11
11
|
|
12
|
-
|
12
|
+
# function returns the month (as a number) given a date value.
|
13
13
|
def month
|
14
14
|
ArelExtensions::Nodes::Duration.new "m", self
|
15
15
|
end
|
16
16
|
|
17
|
-
#function returns the week (as a number) given a date value.
|
17
|
+
# function returns the week (as a number) given a date value.
|
18
18
|
def week
|
19
19
|
ArelExtensions::Nodes::Duration.new "w", self
|
20
20
|
end
|
21
21
|
|
22
|
-
#function returns the month (as a number) given a date value.
|
22
|
+
# function returns the month (as a number) given a date value.
|
23
23
|
def day
|
24
24
|
ArelExtensions::Nodes::Duration.new "d", self
|
25
25
|
end
|
@@ -43,6 +43,5 @@ module ArelExtensions
|
|
43
43
|
def format(tpl)
|
44
44
|
ArelExtensions::Nodes::Format.new [self, tpl]
|
45
45
|
end
|
46
|
-
|
47
46
|
end
|
48
47
|
end
|
@@ -2,34 +2,33 @@ require 'arel'
|
|
2
2
|
|
3
3
|
module ArelExtensions
|
4
4
|
module InsertManager
|
5
|
-
|
6
5
|
def bulk_insert(cols, data)
|
7
6
|
res_columns = []
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
end
|
19
|
-
when NilClass
|
20
|
-
res_columns = @ast.relation.columns
|
7
|
+
case cols.first
|
8
|
+
when String, Symbol
|
9
|
+
cols.each { |c|
|
10
|
+
res_columns << @ast.relation[c]
|
11
|
+
}
|
12
|
+
when Array
|
13
|
+
if String === cols.first.first
|
14
|
+
res_columns = cols.map {|c| [@ast.relation[c.first]] }
|
15
|
+
elsif Arel::Attributes::Attribute == cols.first.first
|
16
|
+
res_columns = cols
|
21
17
|
end
|
22
|
-
|
23
|
-
@ast.columns
|
18
|
+
when NilClass
|
19
|
+
res_columns = @ast.relation.columns
|
20
|
+
end
|
21
|
+
self.values = BulkValues.new(res_columns, data)
|
22
|
+
@ast.columns = res_columns
|
24
23
|
end
|
25
24
|
|
26
25
|
class BulkValues < Arel::Nodes::Node
|
27
26
|
attr_accessor :left, :cols
|
27
|
+
|
28
28
|
def initialize(cols, values)
|
29
29
|
@left = values
|
30
30
|
@cols = cols
|
31
31
|
end
|
32
32
|
end
|
33
|
-
|
34
33
|
end
|
35
34
|
end
|
data/lib/arel_extensions/math.rb
CHANGED
@@ -11,9 +11,9 @@ require 'arel_extensions/nodes/union_all'
|
|
11
11
|
|
12
12
|
module ArelExtensions
|
13
13
|
module Math
|
14
|
-
#function + between
|
15
|
-
#String and others (convert in string) allows you to concatenate 2 or more strings together.
|
16
|
-
#Date and integer adds or subtracts a specified time interval from a date.
|
14
|
+
# function + between
|
15
|
+
# String and others (convert in string) allows you to concatenate 2 or more strings together.
|
16
|
+
# Date and integer adds or subtracts a specified time interval from a date.
|
17
17
|
def +(other)
|
18
18
|
case self
|
19
19
|
when Arel::Nodes::Quoted
|
@@ -43,7 +43,7 @@ module ArelExtensions
|
|
43
43
|
rescue Exception
|
44
44
|
col = nil
|
45
45
|
end
|
46
|
-
if (!col) #if the column doesn't exist in the database
|
46
|
+
if (!col) # if the column doesn't exist in the database
|
47
47
|
Arel::Nodes::Grouping.new(Arel::Nodes::Addition.new(self, other))
|
48
48
|
else
|
49
49
|
arg = col.type
|
@@ -62,8 +62,8 @@ module ArelExtensions
|
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
|
-
#function returns the time between two dates
|
66
|
-
#function returns the substraction between two ints
|
65
|
+
# function returns the time between two dates
|
66
|
+
# function returns the substraction between two ints
|
67
67
|
def -(other)
|
68
68
|
case self
|
69
69
|
when Arel::Nodes::Grouping
|
@@ -91,7 +91,7 @@ module ArelExtensions
|
|
91
91
|
rescue Exception
|
92
92
|
col = nil
|
93
93
|
end
|
94
|
-
if (!col) #if the column doesn't exist in the database
|
94
|
+
if (!col) # if the column doesn't exist in the database
|
95
95
|
Arel::Nodes::Grouping.new(Arel::Nodes::Subtraction.new(self, other))
|
96
96
|
else
|
97
97
|
arg = col.type
|
@@ -103,7 +103,7 @@ module ArelExtensions
|
|
103
103
|
rescue Exception
|
104
104
|
col2 = nil
|
105
105
|
end
|
106
|
-
if (!col2) #if the column doesn't exist in the database
|
106
|
+
if (!col2) # if the column doesn't exist in the database
|
107
107
|
ArelExtensions::Nodes::DateSub.new [self, other]
|
108
108
|
else
|
109
109
|
arg2 = col2.type
|
@@ -133,6 +133,5 @@ module ArelExtensions
|
|
133
133
|
end
|
134
134
|
end
|
135
135
|
end
|
136
|
-
|
137
136
|
end
|
138
137
|
end
|
@@ -11,7 +11,6 @@ require 'arel_extensions/nodes/sum'
|
|
11
11
|
|
12
12
|
module ArelExtensions
|
13
13
|
module MathFunctions
|
14
|
-
|
15
14
|
# Arel does not handle Decimal literal properly
|
16
15
|
def * other
|
17
16
|
case other
|
@@ -47,7 +46,7 @@ module ArelExtensions
|
|
47
46
|
ArelExtensions::Nodes::Floor.new [self]
|
48
47
|
end
|
49
48
|
|
50
|
-
|
49
|
+
# function gives the base 10 log
|
51
50
|
def log10
|
52
51
|
ArelExtensions::Nodes::Log10.new [self]
|
53
52
|
end
|
@@ -64,24 +63,28 @@ module ArelExtensions
|
|
64
63
|
|
65
64
|
# Aggregate Functions
|
66
65
|
def std opts = {unbiased: true}
|
67
|
-
ArelExtensions::Nodes::Std.new self, opts
|
66
|
+
ArelExtensions::Nodes::Std.new self, **opts
|
68
67
|
end
|
69
68
|
|
70
69
|
def variance opts = {unbiased: true}
|
71
|
-
ArelExtensions::Nodes::Variance.new self, opts
|
70
|
+
ArelExtensions::Nodes::Variance.new self, **opts
|
72
71
|
end
|
73
72
|
|
74
73
|
def sum opts = {unbiased: true}
|
75
|
-
|
74
|
+
if Gem::Version.new(Arel::VERSION) >= Gem::Version.new("9.0.0")
|
75
|
+
Arel::Nodes::Sum.new [self]
|
76
|
+
else
|
77
|
+
ArelExtensions::Nodes::Sum.new self, **opts
|
78
|
+
end
|
76
79
|
end
|
77
80
|
|
78
|
-
#function that can be invoked to produce random numbers between 0 and 1
|
79
|
-
# def rand seed = nil
|
80
|
-
# ArelExtensions::Nodes::Rand.new [seed]
|
81
|
-
# end
|
82
|
-
alias_method
|
81
|
+
# function that can be invoked to produce random numbers between 0 and 1
|
82
|
+
# def rand seed = nil
|
83
|
+
# ArelExtensions::Nodes::Rand.new [seed]
|
84
|
+
# end
|
85
|
+
alias_method(:random, :rand) rescue nil
|
83
86
|
|
84
|
-
#function is used to round a numeric field to the number of decimals specified
|
87
|
+
# function is used to round a numeric field to the number of decimals specified
|
85
88
|
def round precision = nil
|
86
89
|
if precision
|
87
90
|
ArelExtensions::Nodes::Round.new [self, precision]
|
@@ -96,14 +99,14 @@ module ArelExtensions
|
|
96
99
|
sprintf(format_string,0) # this line is to get the right error message if the format_string is not correct
|
97
100
|
m = /^(.*)%([ #+\-0]*)([1-9][0-9]+|[1-9]?)[.]?([0-9]*)([a-zA-Z])(.*)$/.match(format_string)
|
98
101
|
opts = {
|
99
|
-
:
|
100
|
-
:
|
101
|
-
:
|
102
|
-
:
|
103
|
-
:
|
104
|
-
:
|
105
|
-
:
|
106
|
-
:
|
102
|
+
prefix: m[1],
|
103
|
+
flags: m[2].split(//).uniq.join,
|
104
|
+
width: m[3].to_i,
|
105
|
+
precision: m[4] != '' ? m[4].to_i : 6,
|
106
|
+
type: m[5],
|
107
|
+
suffix: m[6],
|
108
|
+
locale: locale,
|
109
|
+
original_string: format_string
|
107
110
|
}
|
108
111
|
# opts = {:locale => 'fr_FR', :type => "e"/"f"/"d", :prefix => "$ ", :suffix => " %", :flags => " +-#0", :width => 5, :precision => 6}
|
109
112
|
ArelExtensions::Nodes::FormattedNumber.new [self,opts]
|
@@ -111,6 +114,5 @@ module ArelExtensions
|
|
111
114
|
Arel::Nodes.build_quoted('Wrong Format')
|
112
115
|
end
|
113
116
|
end
|
114
|
-
|
115
117
|
end
|
116
118
|
end
|