merb-helpers 1.0.3 → 1.0.4

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.
@@ -40,7 +40,6 @@ class Time
40
40
  end
41
41
 
42
42
  def to_time; self; end
43
- public :to_date
44
43
  end
45
44
 
46
45
  # Truncates a string to the given length and appends the given suffix if the string is, in fact, truncated.
@@ -11,23 +11,28 @@ module DateAndTimeFormatting
11
11
  module InstanceMethods
12
12
 
13
13
 
14
- # Format a date/time instance using a defined format
14
+ # Formats a date/time instance using a defined format
15
15
  #
16
16
  # ==== Parameters
17
17
  # format<Symbol>:: of the format key from Date.date_formats
18
18
  #
19
19
  # ==== Returns
20
20
  # String:: formatted string
21
- #
21
+ #
22
22
  # ==== Example
23
23
  # Time.now.formatted(:rfc822) # => "Sun, 16 Nov 2007 00:21:16 -0800"
24
24
  # Time.now.formatted(:db) # => "2008-11-16 00:22:09"
25
25
  #
26
- # You can also add your own formats using +Date.add_format+
26
+ # You can also add your own formats using +Date.add_format+ when your app loads.
27
+ #
28
+ # # Add the following to your init.rb
29
+ # Merb::BootLoader.before_app_loads do
30
+ # Date.add_format(:matt, "%H:%M:%S %Y-%m-%d")
31
+ # end
27
32
  #
28
- # Date.add_format(:matt, "%H:%M:%S %Y-%m-%d")
33
+ # # Format a Time instance with the format you just specified
29
34
  # Time.now.formatted(:matt) # => "00:00:00 2007-11-02"
30
- #
35
+ #
31
36
  #--
32
37
  # @public
33
38
  def formatted(format = :default)
@@ -58,6 +63,13 @@ module DateAndTimeFormatting
58
63
  end
59
64
 
60
65
  # Adds a date and time format
66
+ #
67
+ # Because this operation is not thread safe, you should define
68
+ # custom formats when you load you application. The recommended way
69
+ # to do that, is to use the before_app_loads bootloader.
70
+ #
71
+ # If you want to add a format at runtime, you will need to use a mutex
72
+ # and synchronize it yourself.
61
73
  #
62
74
  # ==== Parameters
63
75
  # key<Symbol>:: name of the format
@@ -68,8 +80,10 @@ module DateAndTimeFormatting
68
80
  #
69
81
  # ==== Example
70
82
  #
71
- # Date.add_format(:matt, "%H:%M:%S %Y-%m-%d")
72
- # Time.now.formatted(:matt) # => "00:00:00 2007-11-02"
83
+ # Merb::BootLoader.before_app_loads do
84
+ # Date.add_format(:matt, "%H:%M:%S %Y-%m-%d")
85
+ # end
86
+ #
73
87
  #
74
88
  # --
75
89
  # @public
@@ -94,7 +108,7 @@ module Ordinalize
94
108
  # Ordinalize turns a number into an ordinal string used to denote the
95
109
  # position in an ordered sequence such as 1st, 2nd, 3rd, 4th.
96
110
  #
97
- # Examples
111
+ # ==== Examples
98
112
  # 1.ordinalize # => "1st"
99
113
  # 2.ordinalize # => "2nd"
100
114
  # 1002.ordinalize # => "1002nd"
@@ -128,7 +142,7 @@ module OrdinalizedFormatting
128
142
  # Gives you a relative date in an attractive format
129
143
  #
130
144
  # ==== Parameters
131
- # format<String>:: strftime string used to formatt a time/date object
145
+ # format<String>:: strftime string used to format a time/date object
132
146
  # locale<String, Symbol>:: An optional value which can be used by localization plugins
133
147
  #
134
148
  # ==== Returns
@@ -139,4 +153,4 @@ module OrdinalizedFormatting
139
153
  def strftime_ordinalized(fmt, format=nil)
140
154
  strftime(fmt.gsub(/(^|[^-])%d/, '\1_%d_')).gsub(/_(\d+)_/) { |s| s.to_i.ordinalize }
141
155
  end
142
- end
156
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: merb-helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael D. Ivey
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-11-25 00:00:00 -08:00
12
+ date: 2008-12-08 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 1.0.3
23
+ version: 1.0.4
24
24
  version:
25
25
  description: Helper support for Merb
26
26
  email: ivey@gweezlebur.com