cowtech-extensions 2.1.3 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/.yardopts +1 -0
- data/README.md +10 -0
- data/Rakefile +6 -3
- data/cowtech-extensions.gemspec +9 -5
- data/doc/Cowtech.html +128 -0
- data/doc/Cowtech/Extensions.html +546 -0
- data/doc/Cowtech/Extensions/Boolean.html +297 -0
- data/doc/Cowtech/Extensions/DateTime.html +787 -0
- data/doc/Cowtech/Extensions/DateTime/ClassMethods.html +1592 -0
- data/doc/Cowtech/Extensions/Exceptions.html +125 -0
- data/doc/Cowtech/Extensions/Exceptions/Dump.html +133 -0
- data/doc/Cowtech/Extensions/Hash.html +393 -0
- data/doc/Cowtech/Extensions/Math.html +130 -0
- data/doc/Cowtech/Extensions/Math/ClassMethods.html +362 -0
- data/doc/Cowtech/Extensions/Object.html +1565 -0
- data/doc/Cowtech/Extensions/Pathname.html +225 -0
- data/doc/Cowtech/Extensions/Settings.html +1249 -0
- data/doc/Cowtech/Extensions/String.html +471 -0
- data/doc/Cowtech/Extensions/TimeZone.html +1210 -0
- data/doc/Cowtech/Extensions/TimeZone/ClassMethods.html +925 -0
- data/doc/Cowtech/Extensions/Version.html +189 -0
- data/doc/_index.html +305 -0
- data/doc/class_list.html +53 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +57 -0
- data/doc/css/style.css +328 -0
- data/doc/file.README.html +103 -0
- data/doc/file_list.html +55 -0
- data/doc/frames.html +28 -0
- data/doc/index.html +103 -0
- data/doc/js/app.js +214 -0
- data/doc/js/full_list.js +173 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +620 -0
- data/doc/top-level-namespace.html +112 -0
- data/lib/cowtech-extensions.rb +47 -16
- data/lib/cowtech-extensions/boolean.rb +8 -1
- data/lib/cowtech-extensions/datetime.rb +377 -71
- data/lib/cowtech-extensions/exceptions.rb +16 -0
- data/lib/cowtech-extensions/hash.rb +20 -9
- data/lib/cowtech-extensions/math.rb +15 -8
- data/lib/cowtech-extensions/object.rb +84 -27
- data/lib/cowtech-extensions/pathname.rb +10 -1
- data/lib/cowtech-extensions/settings.rb +120 -0
- data/lib/cowtech-extensions/string.rb +30 -3
- data/lib/cowtech-extensions/version.rb +11 -2
- data/spec/coverage_helper.rb +19 -0
- data/spec/cowtech-extensions/boolean_spec.rb +4 -0
- data/spec/cowtech-extensions/datetime_spec.rb +238 -79
- data/spec/cowtech-extensions/hash_spec.rb +5 -2
- data/spec/cowtech-extensions/math_spec.rb +14 -4
- data/spec/cowtech-extensions/object_spec.rb +19 -1
- data/spec/cowtech-extensions/pathname_spec.rb +5 -1
- data/spec/cowtech-extensions/settings_spec.rb +101 -0
- data/spec/cowtech-extensions/string_spec.rb +13 -0
- data/spec/cowtech-extensions_spec.rb +33 -13
- data/spec/spec_helper.rb +2 -5
- metadata +182 -97
- data/lib/cowtech-extensions/utils.rb +0 -74
@@ -1,74 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
#
|
3
|
-
# This file is part of the cowtech-extensions gem. Copyright (C) 2011 and above Shogun <shogun_panda@me.com>.
|
4
|
-
# Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
|
5
|
-
#
|
6
|
-
|
7
|
-
module Cowtech
|
8
|
-
module Extensions
|
9
|
-
class Settings
|
10
|
-
attr_reader :format_number, :boolean_names, :date_names, :date_formats
|
11
|
-
|
12
|
-
def self.instance
|
13
|
-
@@instance ||= Cowtech::Extensions::Settings.new
|
14
|
-
end
|
15
|
-
|
16
|
-
def initialize
|
17
|
-
self.setup_format_number
|
18
|
-
self.setup_boolean_names
|
19
|
-
self.setup_date_formats
|
20
|
-
self.setup_date_names
|
21
|
-
end
|
22
|
-
|
23
|
-
def setup_format_number(prec = 2, decimal_separator = ".", add_string = "", k_separator = ",")
|
24
|
-
@format_number = {
|
25
|
-
:prec => prec,
|
26
|
-
:decimal_separator => decimal_separator,
|
27
|
-
:add_string => add_string,
|
28
|
-
:k_separator => k_separator
|
29
|
-
}
|
30
|
-
end
|
31
|
-
|
32
|
-
def setup_boolean_names(true_name = "Yes", false_name = "No")
|
33
|
-
@boolean_names = {true => true_name, false => false_name}
|
34
|
-
end
|
35
|
-
|
36
|
-
def setup_date_formats(formats = nil, replace = false)
|
37
|
-
formats = {
|
38
|
-
:ct_date => "%Y-%m-%d",
|
39
|
-
:ct_time => "%H:%M:%S",
|
40
|
-
:ct_date_time => "%F %T",
|
41
|
-
:ct_iso_8601 => "%FT%T%z"
|
42
|
-
} if formats.blank?
|
43
|
-
|
44
|
-
if !replace then
|
45
|
-
@date_formats ||= {}
|
46
|
-
@date_formats.merge!(formats)
|
47
|
-
else
|
48
|
-
@date_formats = formats
|
49
|
-
end
|
50
|
-
|
51
|
-
@date_formats.each_pair do |k, v| Time::DATE_FORMATS[k] = v end
|
52
|
-
end
|
53
|
-
|
54
|
-
def setup_date_names(long_months = nil, short_months = nil, long_days = nil, short_days = nil)
|
55
|
-
long_months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"] if long_months.blank?
|
56
|
-
short_months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] if short_months.blank?
|
57
|
-
long_days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] if long_days.blank?
|
58
|
-
short_days = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"] if short_days.blank?
|
59
|
-
|
60
|
-
@date_names = {
|
61
|
-
:long_months => long_months,
|
62
|
-
:short_months => short_months,
|
63
|
-
:long_days => long_days,
|
64
|
-
:short_days => short_days
|
65
|
-
}
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
module Exceptions
|
70
|
-
class Dump < ::RuntimeError
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|