friendly_extensions 0.0.8 → 0.0.61
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/alphanumeric.rb +2 -23
- data/lib/array.rb +16 -91
- data/lib/friendly_extensions.rb +2 -2
- data/lib/nil_class.rb +2 -5
- data/lib/numbers.rb +37 -41
- data/lib/smart_currency.rb +2 -4
- data/lib/string_and_more.rb +118 -142
- data/test/array_test.rb +3 -25
- data/test/numeric_test.rb +1 -15
- metadata +8 -19
- data/app/helpers/friends_forms_helper.rb +0 -27
- data/app/helpers/friends_labeled_form_helper.rb +0 -124
- data/app/models/friends_label.rb +0 -22
- data/config/initializers/values.rb +0 -24
- data/db/migrate/20140326005600_create_labels.rb +0 -13
- data/lib/friendly_extensions/engine.rb +0 -10
- data/test/array_test.rb.orig +0 -221
- data/test/numeric_test.rb.orig +0 -94
data/test/numeric_test.rb.orig
DELETED
@@ -1,94 +0,0 @@
|
|
1
|
-
require "test/unit"
|
2
|
-
require "numbers"
|
3
|
-
|
4
|
-
|
5
|
-
class NumericTest < Test::Unit::TestCase
|
6
|
-
|
7
|
-
|
8
|
-
def test_number_to_euro
|
9
|
-
#assert_equal 0.29.to_euro, "0,29"
|
10
|
-
end
|
11
|
-
|
12
|
-
# Test Math Functions
|
13
|
-
def test_math_infla_defla
|
14
|
-
|
15
|
-
[2, 3.3].each do |f|
|
16
|
-
[40,250].each do |n|
|
17
|
-
i = 500
|
18
|
-
r_inf = r_def = i
|
19
|
-
|
20
|
-
n.times do |i|
|
21
|
-
r_inf = r_inf*(1+f/100.0)
|
22
|
-
r_def = r_def*(1-f/100.0)
|
23
|
-
end
|
24
|
-
|
25
|
-
assert_equal i.infla(n,f).round(5), r_inf.round(5)
|
26
|
-
assert_equal i.defla(n,f).round(5), r_def.round(5)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
def test_number_should_get_closest
|
33
|
-
# Test for wrong limit mode:
|
34
|
-
assert_raise ArgumentError do
|
35
|
-
1.get_closest([3,4], :zonk)
|
36
|
-
end
|
37
|
-
|
38
|
-
# Check to find closest
|
39
|
-
assert_equal 2.get_closest([0,3,4], :ceil), 3
|
40
|
-
assert_equal 2.get_closest([0,3,4], :floor), 3
|
41
|
-
assert_equal -2.88.get_closest([0,3,4], :floor), 0
|
42
|
-
|
43
|
-
# Check to find closest with :floor
|
44
|
-
assert_equal 1.get_closest([0,2], :floor), 0
|
45
|
-
assert_equal 5.5.get_closest([4.5,6.5], :floor), 4.5
|
46
|
-
|
47
|
-
# Check to find closest with :ceil
|
48
|
-
assert_equal 1.get_closest([0,2], :ceil), 2
|
49
|
-
assert_equal 5.5.get_closest([4.5,6.5], :ceil), 6.5
|
50
|
-
|
51
|
-
end
|
52
|
-
|
53
|
-
|
54
|
-
def test_numbers_min_and_max
|
55
|
-
assert_equal 1, 1.min(3)
|
56
|
-
assert_equal 3, 1.max(3)
|
57
|
-
assert_equal 2, 2.min_max(1,3)
|
58
|
-
assert_equal 1, -1.min_max(1,3)
|
59
|
-
assert_equal 3, 4.min_max(1,3)
|
60
|
-
end
|
61
|
-
|
62
|
-
def test_float_dividor
|
63
|
-
assert !1.fdiv(1).is_a?(Integer)
|
64
|
-
end
|
65
|
-
|
66
|
-
def test_to_q_faktor
|
67
|
-
assert_equal 2.to_q, 1.02
|
68
|
-
end
|
69
|
-
|
70
|
-
def test_time_should_be_calc_correct
|
71
|
-
assert_equal 23.to_time, "00:00:23"
|
72
|
-
assert_equal 64.to_time, "00:01:04"
|
73
|
-
|
74
|
-
assert_equal 17.to_time(:discard_hour => true), "00:17"
|
75
|
-
assert_equal 73.to_time(:discard_hour => true), "01:13"
|
76
|
-
|
77
|
-
assert_equal 3672.to_time, "01:01:12"
|
78
|
-
<<<<<<< HEAD
|
79
|
-
end
|
80
|
-
|
81
|
-
def test_prime_factors
|
82
|
-
|
83
|
-
[16,234,4568,34950,183649].each do |nr|
|
84
|
-
primes = nr.prime_factors
|
85
|
-
puts "#{nr} => #{primes.inspect}"
|
86
|
-
assert_equal nr, eval(primes.join("*"))
|
87
|
-
end
|
88
|
-
|
89
|
-
end
|
90
|
-
=======
|
91
|
-
end
|
92
|
-
>>>>>>> ad58e345c5de2638e34e44d69bb19b0ebebcd41e
|
93
|
-
|
94
|
-
end
|