friendly_extensions 0.2.8 → 0.4.5
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 +5 -5
- data/app/helpers/friends_forms_helper.rb +0 -0
- data/app/helpers/friends_labeled_form_helper.rb +0 -0
- data/config/locales/friendly_extensions.de.yml +0 -0
- data/config/locales/friendly_extensions.en.yml +0 -0
- data/lib/friendly_extensions/engine.rb +0 -0
- data/lib/numbers.rb +0 -4
- data/lib/smart_currency.rb +35 -26
- data/lib/string_and_more.rb +9 -7
- data/lib/tasks/friendly_extentions.rake +0 -0
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 30c5f4e1c4f1b02013e1b91772f9ebbad3b58719f3c8cf9767471dfa9cec0391
|
4
|
+
data.tar.gz: 810d97bf0b90d1df838ec462196d70debb146602d57153b5062dbb5fec2307eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c4025e4afe7a9d1433737a1fb42cc10facf1ce59998fe6a4502f67f4854d34b71126e2cb27085bc586455e8fb12534b37280766da362dbeea7b7a09ef640e64
|
7
|
+
data.tar.gz: 6154eb6f819ef17b2aaa0fea3ca3383edac78ba17bed272a73fb326e72e41e63a762fc585ab15dd067211823ed2e841a44cc2daa41514eb0597fffaf2c7ffb92
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/lib/numbers.rb
CHANGED
data/lib/smart_currency.rb
CHANGED
@@ -1,43 +1,52 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
2
|
module SmartCurrency
|
3
|
-
|
3
|
+
|
4
4
|
def self.included(base)
|
5
5
|
base.extend ClassMethods
|
6
6
|
end
|
7
|
-
|
7
|
+
|
8
8
|
module ClassMethods
|
9
|
-
def smart_currency
|
10
|
-
|
9
|
+
def smart_currency(skip_on: [])
|
10
|
+
begin
|
11
|
+
if !smart_currency? && table_exists?
|
11
12
|
include InstanceMethods
|
12
13
|
auto_attributes = []
|
14
|
+
|
13
15
|
self.skip_time_zone_conversion_for_attributes = []
|
16
|
+
|
17
|
+
self.send(:attr_accessor, :disable_smart_currency)
|
18
|
+
|
14
19
|
attributes = self.columns.select {|c| (c.type == :integer || c.type == :decimal) && !c.name.match("id") }
|
15
|
-
|
20
|
+
|
16
21
|
attributes.each do |a|
|
22
|
+
|
23
|
+
next if skip_on.include?(a.name.to_s.to_sym) || skip_on.include?(a.name.to_s)
|
17
24
|
define_method("#{a.name}=") do |val|
|
18
|
-
self[a.name.to_sym] = currency_to_db(val)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
|
25
|
+
self[a.name.to_sym] = (disable_smart_currency == true ? val : currency_to_db(val))
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
rescue ActiveRecord::NoDatabaseError => e
|
30
|
+
puts "SKIPPING smart_currency on #{self.name} - NoDatabase"
|
31
|
+
end
|
23
32
|
end
|
24
|
-
|
33
|
+
|
25
34
|
def smart_currency?
|
26
35
|
self.included_modules.include?(InstanceMethods)
|
27
36
|
end
|
28
|
-
|
29
|
-
end
|
30
37
|
|
31
|
-
|
32
|
-
|
38
|
+
end
|
39
|
+
|
40
|
+
module InstanceMethods
|
41
|
+
|
33
42
|
def currency_to_db(string)
|
34
|
-
if string.is_a?(String)
|
43
|
+
if string.is_a?(String)
|
35
44
|
return (string.gsub(/\./, '').gsub(/,/, '.')).to_f
|
36
45
|
elsif string.nil?
|
37
46
|
return 0
|
38
|
-
else
|
47
|
+
else
|
39
48
|
return string
|
40
|
-
end
|
49
|
+
end
|
41
50
|
end
|
42
51
|
|
43
52
|
def currency_to_view(decimal)
|
@@ -50,17 +59,17 @@ module SmartCurrency
|
|
50
59
|
if str[0].size == 5 || str[0].size == 6
|
51
60
|
str[0].gsub!(/\B([0-9]{3})\b/,'.\1')
|
52
61
|
elsif str[0].size > 7
|
53
|
-
str[0].gsub!(/([0-9]{3})\b/,'.\1').gsub!(/([0-9]{3}\.)/, '.\1')
|
62
|
+
str[0].gsub!(/([0-9]{3})\b/,'.\1').gsub!(/([0-9]{3}\.)/, '.\1')
|
54
63
|
else
|
55
|
-
str[0].gsub!(/\B([0-9]{3})/,'.\1')
|
64
|
+
str[0].gsub!(/\B([0-9]{3})/,'.\1')
|
56
65
|
end
|
57
|
-
|
58
|
-
return (str[0] + "," + str[1]).to_s
|
59
|
-
else
|
66
|
+
|
67
|
+
return (str[0] + "," + str[1]).to_s
|
68
|
+
else
|
60
69
|
return "keine Angabe"
|
61
|
-
end
|
70
|
+
end
|
62
71
|
end
|
63
|
-
|
72
|
+
|
64
73
|
end
|
65
|
-
|
74
|
+
|
66
75
|
end
|
data/lib/string_and_more.rb
CHANGED
@@ -147,13 +147,9 @@ module StringAndMore
|
|
147
147
|
return new_text
|
148
148
|
end
|
149
149
|
|
150
|
-
def to_model
|
151
|
-
|
152
|
-
end
|
153
|
-
|
154
|
-
def to_a
|
155
|
-
return [self]
|
156
|
-
end
|
150
|
+
#def to_model
|
151
|
+
# self.singularize.camelize.constantize
|
152
|
+
#end
|
157
153
|
|
158
154
|
#== HTML Styling
|
159
155
|
# as the function names say
|
@@ -208,11 +204,17 @@ module StringAndMore
|
|
208
204
|
colorize(33)
|
209
205
|
end
|
210
206
|
|
207
|
+
def blue
|
208
|
+
colorize(34)
|
209
|
+
end
|
210
|
+
|
211
211
|
def pink
|
212
212
|
colorize(35)
|
213
213
|
end
|
214
214
|
|
215
215
|
|
216
|
+
|
217
|
+
|
216
218
|
#== Numerische encription
|
217
219
|
# cool thing for simple encrypt and decrypt strings
|
218
220
|
|
File without changes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: friendly_extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Eck
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-12-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -54,9 +54,10 @@ files:
|
|
54
54
|
- test/numeric_test.rb
|
55
55
|
- test/string_test.rb
|
56
56
|
homepage: https://github.com/florianeck/rails_friendly_extensions
|
57
|
-
licenses:
|
57
|
+
licenses:
|
58
|
+
- MIT
|
58
59
|
metadata: {}
|
59
|
-
post_install_message:
|
60
|
+
post_install_message:
|
60
61
|
rdoc_options: []
|
61
62
|
require_paths:
|
62
63
|
- lib
|
@@ -71,14 +72,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
71
72
|
- !ruby/object:Gem::Version
|
72
73
|
version: '0'
|
73
74
|
requirements: []
|
74
|
-
|
75
|
-
|
76
|
-
signing_key:
|
75
|
+
rubygems_version: 3.0.8
|
76
|
+
signing_key:
|
77
77
|
specification_version: 4
|
78
78
|
summary: Collection of useful features for Ruby/Rails Classes
|
79
79
|
test_files:
|
80
|
-
- test/array_test.rb
|
81
80
|
- test/dummy_class.rb
|
81
|
+
- test/array_test.rb
|
82
82
|
- test/hash_test.rb
|
83
|
-
- test/numeric_test.rb
|
84
83
|
- test/string_test.rb
|
84
|
+
- test/numeric_test.rb
|