cowtech-extensions 1.3.1.0 → 1.4.0
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/Gemfile +2 -2
- data/Rakefile +11 -11
- data/cowtech-extensions.gemspec +2 -2
- data/lib/cowtech-extensions.rb +63 -63
- data/lib/cowtech-extensions/boolean.rb +14 -14
- data/lib/cowtech-extensions/datetime.rb +122 -122
- data/lib/cowtech-extensions/hash.rb +13 -13
- data/lib/cowtech-extensions/math.rb +14 -14
- data/lib/cowtech-extensions/object.rb +69 -69
- data/lib/cowtech-extensions/pathname.rb +10 -10
- data/lib/cowtech-extensions/string.rb +22 -22
- data/lib/cowtech-extensions/version.rb +8 -9
- metadata +6 -6
data/Gemfile
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
source
|
1
|
+
source "http://rubygems.org"
|
2
2
|
|
3
|
-
gem
|
3
|
+
gem "jeweler"
|
data/Rakefile
CHANGED
@@ -1,17 +1,17 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "rubygems"
|
2
|
+
require "jeweler"
|
3
3
|
require "./lib/cowtech-extensions/version.rb"
|
4
4
|
|
5
5
|
Jeweler::Tasks.new do |gem|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
6
|
+
gem.name = "cowtech-extensions"
|
7
|
+
gem.homepage = "http://github.com/ShogunPanda/cowtech-extensions"
|
8
|
+
gem.license = "MIT"
|
9
|
+
gem.summary = %Q{Several Ruby object enhancements.}
|
10
|
+
gem.description = %Q{Several Ruby object enhancements.}
|
11
|
+
gem.email = "shogun_panda@me.com"
|
12
|
+
gem.authors = ["Shogun"]
|
13
|
+
gem.version = Cowtech::Extensions::Version::STRING
|
14
|
+
gem.add_dependency "actionpack"
|
15
15
|
end
|
16
16
|
|
17
17
|
Jeweler::RubygemsDotOrgTasks.new
|
data/cowtech-extensions.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "cowtech-extensions"
|
8
|
-
s.version = "1.
|
8
|
+
s.version = "1.4.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Shogun"]
|
12
|
-
s.date = "2012-
|
12
|
+
s.date = "2012-04-16"
|
13
13
|
s.description = "Several Ruby object enhancements."
|
14
14
|
s.email = "shogun_panda@me.com"
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/cowtech-extensions.rb
CHANGED
@@ -13,75 +13,75 @@ require "cowtech-extensions/math"
|
|
13
13
|
require "cowtech-extensions/pathname"
|
14
14
|
|
15
15
|
module Cowtech
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
module Extensions
|
17
|
+
def self.load!(what = [])
|
18
|
+
what = ["object", "boolean", "string", "hash", "datetime", "math", "pathname"] if what.count == 0
|
19
|
+
what.collect! { |w| w.to_s }
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
if what.include?("object") then
|
24
|
-
::Object.class_eval do
|
25
|
-
include Cowtech::Extensions::Object
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
if what.include?("boolean") then
|
30
|
-
::TrueClass.class_eval do
|
31
|
-
include Cowtech::Extensions::Object
|
32
|
-
include Cowtech::Extensions::Boolean
|
33
|
-
end
|
21
|
+
yield if block_given?
|
34
22
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
if what.include?("string") then
|
42
|
-
::String.class_eval do
|
43
|
-
include Cowtech::Extensions::String
|
44
|
-
end
|
45
|
-
end
|
23
|
+
if what.include?("object") then
|
24
|
+
::Object.class_eval do
|
25
|
+
include Cowtech::Extensions::Object
|
26
|
+
end
|
27
|
+
end
|
46
28
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
29
|
+
if what.include?("boolean") then
|
30
|
+
::TrueClass.class_eval do
|
31
|
+
include Cowtech::Extensions::Object
|
32
|
+
include Cowtech::Extensions::Boolean
|
33
|
+
end
|
52
34
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
::Date.class_eval do
|
59
|
-
include Cowtech::Extensions::DateTime
|
60
|
-
end
|
35
|
+
::FalseClass.class_eval do
|
36
|
+
include Cowtech::Extensions::Object
|
37
|
+
include Cowtech::Extensions::Boolean
|
38
|
+
end
|
39
|
+
end
|
61
40
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
::Time.setup_localization
|
68
|
-
::DateTime.setup_localization
|
69
|
-
end
|
41
|
+
if what.include?("string") then
|
42
|
+
::String.class_eval do
|
43
|
+
include Cowtech::Extensions::String
|
44
|
+
end
|
45
|
+
end
|
70
46
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
47
|
+
if what.include?("hash") then
|
48
|
+
::Hash.class_eval do
|
49
|
+
include Cowtech::Extensions::Hash
|
50
|
+
end
|
51
|
+
end
|
76
52
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
53
|
+
if what.include?("datetime") then
|
54
|
+
::Time.class_eval do
|
55
|
+
include Cowtech::Extensions::DateTime
|
56
|
+
end
|
57
|
+
|
58
|
+
::Date.class_eval do
|
59
|
+
include Cowtech::Extensions::DateTime
|
60
|
+
end
|
61
|
+
|
62
|
+
::DateTime.class_eval do
|
63
|
+
include Cowtech::Extensions::DateTime
|
64
|
+
end
|
65
|
+
|
66
|
+
::Date.setup_localization
|
67
|
+
::Time.setup_localization
|
68
|
+
::DateTime.setup_localization
|
69
|
+
end
|
70
|
+
|
71
|
+
if what.include?("math") then
|
72
|
+
::Math.class_eval do
|
73
|
+
include Cowtech::Extensions::Math
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
if what.include?("pathname") then
|
78
|
+
require "pathname"
|
79
|
+
|
80
|
+
::Pathname.class_eval do
|
81
|
+
include Cowtech::Extensions::Pathname
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
86
|
end
|
87
87
|
|
@@ -5,19 +5,19 @@
|
|
5
5
|
#
|
6
6
|
|
7
7
|
module Cowtech
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
module Extensions
|
9
|
+
module Boolean
|
10
|
+
extend ActiveSupport::Concern
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
12
|
+
module InstanceMethods
|
13
|
+
def to_i
|
14
|
+
(self == true) ? 1 : 0
|
15
|
+
end
|
16
|
+
|
17
|
+
def value
|
18
|
+
self
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
23
|
end
|
@@ -7,127 +7,127 @@
|
|
7
7
|
require "active_support/all"
|
8
8
|
|
9
9
|
module Cowtech
|
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
|
-
|
49
|
-
|
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
|
-
|
96
|
-
|
97
|
-
|
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
|
-
|
10
|
+
module Extensions
|
11
|
+
module DateTime
|
12
|
+
extend ActiveSupport::Concern
|
13
|
+
|
14
|
+
included do
|
15
|
+
cattr_accessor :default_localized_months
|
16
|
+
cattr_accessor :default_localized_short_months
|
17
|
+
cattr_accessor :default_localized_days
|
18
|
+
cattr_accessor :default_localized_short_days
|
19
|
+
cattr_accessor :localized_months
|
20
|
+
cattr_accessor :localized_short_months
|
21
|
+
cattr_accessor :localized_days
|
22
|
+
cattr_accessor :localized_short_days
|
23
|
+
end
|
24
|
+
|
25
|
+
module ClassMethods
|
26
|
+
def setup_localization
|
27
|
+
self.default_setup_locale
|
28
|
+
self.setup_locale
|
29
|
+
end
|
30
|
+
|
31
|
+
def default_setup_locale
|
32
|
+
self.default_localized_months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
|
33
|
+
self.default_localized_short_months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
|
34
|
+
self.default_localized_days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
|
35
|
+
self.default_localized_short_days = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
|
36
|
+
end
|
37
|
+
|
38
|
+
def setup_locale
|
39
|
+
self.localized_months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
|
40
|
+
self.localized_short_months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
|
41
|
+
self.localized_days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
|
42
|
+
self.localized_short_days = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
|
43
|
+
end
|
44
|
+
|
45
|
+
def months(short = true)
|
46
|
+
12.times.collect { |i| {value: (i + 1).to_s.rjust(2, "0"), description: self.send("localized_#{short ? "short_" : ""}months").at(i) } }
|
47
|
+
end
|
48
|
+
|
49
|
+
def years(offset = 10, also_future = true)
|
50
|
+
y = Date.today.year
|
51
|
+
(y - offset..(also_future ? y + offset : y)).collect { |year| {value: year} }
|
52
|
+
end
|
53
|
+
|
54
|
+
def custom_formats
|
55
|
+
@@custom_formats ||= {
|
56
|
+
"date" => "%d/%m/%Y",
|
57
|
+
"time" => "%H:%M:%S",
|
58
|
+
"date-8601" => "%Y-%m-%d",
|
59
|
+
"date-time-8601" => "%Y-%m-%d %H:%M:%S",
|
60
|
+
"iso-8601" => "%FT%T%z",
|
61
|
+
"update" => "%d/%m/%Y %H:%M"
|
62
|
+
}
|
63
|
+
end
|
64
|
+
|
65
|
+
def custom_format(key = "date")
|
66
|
+
self.custom_formats.fetch(key.to_s, "%d/%m/%Y")
|
67
|
+
end
|
68
|
+
|
69
|
+
def easter(year = nil)
|
70
|
+
day = 1
|
71
|
+
month = 3
|
72
|
+
year = Date.today.year if !year.is_integer?
|
73
|
+
|
74
|
+
# GAUSS METHOD
|
75
|
+
a = year % 19
|
76
|
+
d = ((19 * a) + 24) % 30
|
77
|
+
e = ((2 * (year % 4)) + (4 * (year % 7)) + (6 * d) + 5) % 7
|
78
|
+
|
79
|
+
if d + e < 10 then
|
80
|
+
day = d + e + 22
|
81
|
+
else
|
82
|
+
day = d + e - 9
|
83
|
+
month = 4
|
84
|
+
end
|
85
|
+
|
86
|
+
if day == 26 && month == 4 then
|
87
|
+
day = 19
|
88
|
+
elsif day == 25 && month == 4 && d == 28 && e == 6 && a > 10 then
|
89
|
+
day = 18
|
90
|
+
end
|
91
|
+
#END
|
92
|
+
|
93
|
+
Date.civil(year, month, day)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
module InstanceMethods
|
98
|
+
def lstrftime(format = nil)
|
99
|
+
format = self.class.custom_format($1) if format =~ /^custom::(.+)/
|
100
|
+
format ||= self.class.custom_format("update")
|
101
|
+
unlocal = self.strftime(format)
|
102
|
+
|
103
|
+
{ "%a" => "short_days", "%A" => "days", "%b" => "short_months", "%B" => "months" }.each_pair do |specifier, method|
|
104
|
+
if format.include?(specifier) then
|
105
|
+
from = self.class.send('default_localized_' + method)
|
106
|
+
to = self.class.send('localized_' + method)
|
107
|
+
unlocal.gsub!(/(#{from.join("|")})/i) { |s| to[from.index($1)] }
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
unlocal
|
112
|
+
end
|
113
|
+
|
114
|
+
def local_lstrftime(format = nil)
|
115
|
+
(self.respond_to?(:in_time_zone) ? self.in_time_zone : self).lstrftime(format)
|
116
|
+
end
|
117
|
+
|
118
|
+
def padded_month
|
119
|
+
self.month.to_s.rjust(2, "0")
|
120
|
+
end
|
121
|
+
|
122
|
+
def in_months
|
123
|
+
((self.year - 1) % 2000) * 12 + self.month
|
124
|
+
end
|
125
|
+
|
126
|
+
def utc_time
|
127
|
+
ua = (self.respond_to?(:utc) ? self : self.to_datetime).utc
|
128
128
|
::Time.utc(ua.year, ua.month, ua.day, ua.hour, ua.min, ua.sec)
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
133
|
end
|
@@ -5,19 +5,19 @@
|
|
5
5
|
#
|
6
6
|
|
7
7
|
module Cowtech
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
module Extensions
|
9
|
+
module Hash
|
10
|
+
extend ActiveSupport::Concern
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
module InstanceMethods
|
13
|
+
def method_missing(method, *args, &block)
|
14
|
+
(self.has_key?(method.to_sym) || self.has_key?(method.to_s)) ? (self[method.to_sym] || self[method.to_s]) : super(method, *args, &block)
|
15
|
+
end
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
17
|
+
def respond_to?(method)
|
18
|
+
(self.has_key?(method.to_sym) || self.has_key?(method.to_s)) ? true : super(method)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
23
|
end
|
@@ -5,19 +5,19 @@
|
|
5
5
|
#
|
6
6
|
|
7
7
|
module Cowtech
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
module ClassMethods
|
13
|
-
def self.max(a, b)
|
14
|
-
a > b ? a : b
|
15
|
-
end
|
8
|
+
module Extensions
|
9
|
+
module Math
|
10
|
+
extend ActiveSupport::Concern
|
16
11
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
12
|
+
module ClassMethods
|
13
|
+
def self.max(a, b)
|
14
|
+
a > b ? a : b
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.min(a, b)
|
18
|
+
a < b ? a : b
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
23
|
end
|
@@ -8,73 +8,73 @@ require "active_support/all"
|
|
8
8
|
require "action_view"
|
9
9
|
|
10
10
|
module Cowtech
|
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
|
-
|
49
|
-
|
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
|
-
|
11
|
+
module Extensions
|
12
|
+
module Object
|
13
|
+
include ActionView::Helpers::NumberHelper
|
14
|
+
extend ActiveSupport::Concern
|
15
|
+
|
16
|
+
module InstanceMethods
|
17
|
+
def is_number?
|
18
|
+
self.is_float?
|
19
|
+
end
|
20
|
+
|
21
|
+
def is_integer?
|
22
|
+
self.is_a?(Integer) || /^([+-]?)(\d+)$/.match(self.ensure_string.strip)
|
23
|
+
end
|
24
|
+
|
25
|
+
def is_float?
|
26
|
+
self.is_a?(Float) || /^([+-]?)(\d+)([.,]\d+)?$/.match(self.ensure_string.strip)
|
27
|
+
end
|
28
|
+
|
29
|
+
def is_boolean?
|
30
|
+
self.is_a?(TrueClass) || self.is_a?(FalseClass) || self.is_a?(NilClass) || /^(1|0|true|false|yes|no|t|f|y|n)$/i.match(self.ensure_string.strip)
|
31
|
+
end
|
32
|
+
|
33
|
+
def ensure_array
|
34
|
+
self.is_a?(Array) ? self : [self]
|
35
|
+
end
|
36
|
+
|
37
|
+
def ensure_string
|
38
|
+
self.present? ? self.to_s : ""
|
39
|
+
end
|
40
|
+
|
41
|
+
def to_float
|
42
|
+
self.is_float? ? Kernel.Float(self.respond_to?(:gsub) ? self.gsub(",", ".") : self) : 0.0
|
43
|
+
end
|
44
|
+
|
45
|
+
def to_integer
|
46
|
+
self.is_integer? ? Kernel.Integer(self, self.is_a?(String) ? 10 : 0) : 0
|
47
|
+
end
|
48
|
+
|
49
|
+
def to_boolean
|
50
|
+
(self.is_a?(TrueClass) || /^(1|on|true|yes|t|y)$/i.match(self.ensure_string.strip)) ? true : false
|
51
|
+
end
|
52
|
+
|
53
|
+
def round_to_precision(prec = 2)
|
54
|
+
number_with_precision(self, precision: prec)
|
55
|
+
end
|
56
|
+
|
57
|
+
def format_number(prec = 2, decimal_separator = ",", add_string = "€", k_separator = ".")
|
58
|
+
number_to_currency(self, {precision: prec, separator: decimal_separator, delimiter: k_separator, format: add_string.blank? ? "%n" : "%n %u", unit: add_string.blank? ? "" : add_string.strip})
|
59
|
+
end
|
60
|
+
|
61
|
+
def format_boolean
|
62
|
+
self.to_boolean ? "Yes" : "No"
|
63
|
+
end
|
64
|
+
|
65
|
+
def debug_dump(format = :yaml, must_raise = true)
|
66
|
+
rv = ""
|
67
|
+
|
68
|
+
begin
|
69
|
+
rv = self.send("to_#{format}")
|
70
|
+
rescue
|
71
|
+
rv = self.inspect
|
72
|
+
end
|
73
|
+
|
74
|
+
rv = "DEBUG DUMP:\n#{rv}"
|
75
|
+
must_raise ? raise(rv) : rv
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
80
|
end
|
@@ -5,15 +5,15 @@
|
|
5
5
|
#
|
6
6
|
|
7
7
|
module Cowtech
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
module Extensions
|
9
|
+
module Pathname
|
10
|
+
extend ActiveSupport::Concern
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
12
|
+
module InstanceMethods
|
13
|
+
def components
|
14
|
+
self.each_filename.collect { |p| p }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
19
|
end
|
@@ -7,27 +7,27 @@
|
|
7
7
|
require "active_support/all"
|
8
8
|
|
9
9
|
module Cowtech
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
module Extensions
|
11
|
+
module String
|
12
|
+
extend ActiveSupport::Concern
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
14
|
+
module InstanceMethods
|
15
|
+
def remove_accents
|
16
|
+
self.mb_chars.normalize(:kd).gsub(/[^\-x00-\x7F]/n, '').to_s
|
17
|
+
end
|
18
|
+
|
19
|
+
def untitleize
|
20
|
+
self.downcase.gsub(" ", "-")
|
21
|
+
end
|
22
|
+
|
23
|
+
def replace_ampersands
|
24
|
+
self.gsub(/&(\S+);/, "&\\1;")
|
25
|
+
end
|
26
|
+
|
27
|
+
def value
|
28
|
+
self
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
33
|
end
|
@@ -7,14 +7,13 @@
|
|
7
7
|
require "active_support"
|
8
8
|
|
9
9
|
module Cowtech
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
BUILD = 0
|
10
|
+
module Extensions
|
11
|
+
module Version
|
12
|
+
MAJOR = 1
|
13
|
+
MINOR = 4
|
14
|
+
PATCH = 0
|
16
15
|
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
STRING = [MAJOR, MINOR, PATCH].compact.join('.')
|
17
|
+
end
|
18
|
+
end
|
20
19
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cowtech-extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-04-16 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: jeweler
|
16
|
-
requirement: &
|
16
|
+
requirement: &70136363158700 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70136363158700
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: actionpack
|
27
|
-
requirement: &
|
27
|
+
requirement: &70136363156920 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70136363156920
|
36
36
|
description: Several Ruby object enhancements.
|
37
37
|
email: shogun_panda@me.com
|
38
38
|
executables: []
|