sixarm_ruby_time_stamp 2.0.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6b08e5717215fd404b6a8d4162e4b8a191d5589408d806d75a5b9e7e2477684a
4
- data.tar.gz: a002cb920eef45a80f6084ca55949f1a4712279bcd4edc7a4f32caec7f4d877f
3
+ metadata.gz: c88e64f981af8574d50eebc183775814b94cdf318cb020c1726553988a7fc97c
4
+ data.tar.gz: 7aa50f2d6c27e1d29f9b19f10b14553d0e03924a98b7536ba2396380a9c2cd7e
5
5
  SHA512:
6
- metadata.gz: fa1e09f62b6dfe74287456c21a9e09c72df1e8911ab4c164fc41131db2c0ed29f0517886f3c9e4b91b5d911c77edd292066326ed46d4ecd9ebd5579576a0faee
7
- data.tar.gz: 72d45910e3f98057cab73c4c9e0e264b1d444730a6e4ea58fa252c27805a798202005c85554dfbf93190de59fbbe12267ff80f7078b2d40e034ae93d77759406
6
+ metadata.gz: 6b0486c8e4e5f194b4223fab95a7ad50bbf14ceb5dd43cefa3e38485ca21cbd7c541fc1816612d71b4d0c23d37c499a00d9f544e26056744cc524c7cedbde91c
7
+ data.tar.gz: a9b8e35c34ce8fb34873c4261d1ec579d39c5cb7b29f3cc2830eb34aff863d2d0b975a31f05b02a57ece414ab81c90d35d57070dba14e3f00866b8ea4f4e78e6
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -5,7 +5,7 @@ Please see README
5
5
 
6
6
  class Time
7
7
 
8
- # Create a time stamp string using the format "YYYY-MM-DDTHH:MM:SSZ"
8
+ # Create a time stamp string using the default format "YYYY-MM-DDTHH:MM:SSZ"
9
9
  #
10
10
  # This standard format is specified in IETF RFC 3339 and ISO 8601.
11
11
  #
@@ -14,13 +14,13 @@ class Time
14
14
  # Example:
15
15
  #
16
16
  # time = Time.now
17
- # time.stamp
18
- # => "2010-12-31 12:59:59Z"
17
+ # time.stamp
18
+ # => "2020-12-31T12:59:59Z"
19
19
  #
20
20
  # Return: [String] a time stamp string
21
21
  #
22
- def stamp
23
- getutc.strftime('%Y-%m-%dT%H:%M:%SZ')
22
+ def stamp(format = stamp_format)
23
+ getutc.strftime(format)
24
24
  end
25
25
 
26
26
  # Shorthand for Time.now.stamp
@@ -28,12 +28,70 @@ class Time
28
28
  # Example:
29
29
  #
30
30
  # Time.stamp
31
- # => "2010-12-31T12:59:59Z"
31
+ # => "2020-12-31T12:59:59Z"
32
32
  #
33
33
  # Return: [String] Time.now time stamp string
34
34
  #
35
- def self.stamp
36
- now.stamp
35
+ def self.stamp(format = self.stamp_format)
36
+ now.stamp(format)
37
+ end
38
+
39
+ # Get stamp format string
40
+ #
41
+ # Example:
42
+ #
43
+ # time.stamp_format => "%Y-%m-%dT%H:%M:%S.%NZ"
44
+ #
45
+ # Return: [String] stamp format string
46
+ #
47
+ def stamp_format
48
+ @stamp_format ||= '%Y-%m-%dT%H:%M:%S.%NZ'
49
+ end
50
+
51
+ # Set stamp format string
52
+ #
53
+ # Example:
54
+ #
55
+ # time.stamp_format = "%Y-%m-%dT%H:%M:%S.%NZ"
56
+ #
57
+ def stamp_format=(format)
58
+ @stamp_format = format
59
+ end
60
+
61
+ # Get class-scope stamp format string
62
+ #
63
+ # Example:
64
+ #
65
+ # Time.stamp_format => "%Y-%m-%dT%H:%M:%S.%NZ"
66
+ #
67
+ # Return: [String] stamp format string
68
+ #
69
+ def self.stamp_format
70
+ @@stamp_format ||= '%Y-%m-%dT%H:%M:%S.%NZ'
71
+ end
72
+
73
+ # Set class-scope stamp format string
74
+ #
75
+ # Example:
76
+ #
77
+ # Time.stamp_format = "%Y-%m-%dT%H:%M:%S.%NZ"
78
+ #
79
+ # Return: [String] stamp format string
80
+ #
81
+ def self.stamp_format=(format)
82
+ @@stamp_format = format
83
+ end
84
+
85
+ # Get class-scope stamp format default string
86
+ #
87
+ # Example:
88
+ #
89
+ # Time.stamp_format_default => "%Y-%m-%dT%H:%M:%S.%NZ"
90
+ #
91
+ # Return: [String] stamp format default string
92
+ #
93
+ def self.stamp_format_default
94
+ "%Y-%m-%dT%H:%M:%S.%NZ"
37
95
  end
38
96
 
39
97
  end
@@ -3,14 +3,117 @@ require "sixarm_ruby_time_stamp_test"
3
3
 
4
4
  describe Time do
5
5
 
6
- describe "#stamp" do
6
+ STAMP_FORMAT_MISSING = nil
7
+ STAMP_FORMAT_DEFAULT = "%Y-%m-%dT%H:%M:%S.%NZ"
8
+ STAMP_FORMAT_CUSTOM = "~%Y~%m~%d~%H~%M~%S~%N~"
7
9
 
8
- it "with class method" do
9
- Time.stamp.must_match /^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$/
10
+ describe "*stamp" do
11
+
12
+ describe "#stamp" do
13
+ before do
14
+ @time = Time.now
15
+ end
16
+
17
+ describe "with default format" do
18
+ before do
19
+ @time.stamp_format = STAMP_FORMAT_MISSING
20
+ end
21
+ it "return stamp" do
22
+ actual = @time.stamp
23
+ expect(actual).must_match(/^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d.\d\d\d\d\d\d\d\d\dZ$/)
24
+ end
25
+ end
26
+
27
+ describe "with custom format" do
28
+ before do
29
+ @time.stamp_format = STAMP_FORMAT_CUSTOM
30
+ end
31
+ it "return stamp" do
32
+ actual = @time.stamp
33
+ expect(actual).must_match(/^~\d\d\d\d~\d\d~\d\d~\d\d~\d\d~\d\d~\d\d\d\d\d\d\d\d\d~$/)
34
+ end
35
+ end
36
+
37
+ end
38
+
39
+ describe ".stamp" do
40
+
41
+ describe "with default format" do
42
+ before do
43
+ Time.stamp_format = STAMP_FORMAT_MISSING
44
+ end
45
+ it "return stamp" do
46
+ actual = Time.stamp
47
+ expect(actual).must_match(/^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d.\d\d\d\d\d\d\d\d\dZ$/)
48
+ end
49
+ end
50
+
51
+ describe "with custom format" do
52
+ before do
53
+ Time.stamp_format = STAMP_FORMAT_CUSTOM
54
+ end
55
+ it "return stamp" do
56
+ actual = Time.stamp
57
+ expect(actual).must_match(/^~\d\d\d\d~\d\d~\d\d~\d\d~\d\d~\d\d~\d\d\d\d\d\d\d\d\d~$/)
58
+ end
59
+ end
60
+
10
61
  end
11
62
 
12
- it "with instance method" do
13
- Time.now.stamp.must_match /^\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\dZ$/
63
+ end
64
+
65
+ describe "*stamp_format" do
66
+
67
+ describe "#stamp_format" do
68
+
69
+ before do
70
+ @time = Time.now
71
+ end
72
+
73
+ describe "with default format" do
74
+ before do
75
+ @time.stamp_format = STAMP_FORMAT_MISSING
76
+ end
77
+ it "return default value" do
78
+ actual = @time.stamp_format
79
+ expect(actual).must_equal(STAMP_FORMAT_DEFAULT)
80
+ end
81
+ end
82
+
83
+ describe "with custom format" do
84
+ before do
85
+ @time.stamp_format = STAMP_FORMAT_CUSTOM
86
+ end
87
+ it "return custom value" do
88
+ actual = @time.stamp_format
89
+ expect(actual).must_equal(STAMP_FORMAT_CUSTOM)
90
+ end
91
+ end
92
+
93
+ end
94
+
95
+ describe ".stamp_format" do
96
+
97
+ describe "with default value" do
98
+ before do
99
+ Time.stamp_format = STAMP_FORMAT_MISSING
100
+ end
101
+ it "return default value" do
102
+ actual = Time.stamp_format
103
+ expect(actual).must_equal(STAMP_FORMAT_DEFAULT)
104
+ end
105
+ end
106
+
107
+ describe "with custom value" do
108
+ before do
109
+ Time.stamp_format = STAMP_FORMAT_CUSTOM
110
+ end
111
+ it "return custom value" do
112
+ actual = Time.stamp_format
113
+ expect(actual).must_equal(STAMP_FORMAT_CUSTOM)
114
+ end
115
+ end
116
+
14
117
  end
15
118
 
16
119
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sixarm_ruby_time_stamp
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - SixArm
@@ -39,7 +39,7 @@ cert_chain:
39
39
  tzpk/VnZXj7Ek/earx+N/Z+Wtnl2xENm5IF8SFPeI1HFa9NH47pqtxF1YKpNIEVc
40
40
  2xa2BNHSePe7tys/2hbmZuyMu8X5ERmovsabSXB3a+YwtJh5c2jhA21wF7986s0q
41
41
  -----END CERTIFICATE-----
42
- date: 2018-06-22 00:00:00.000000000 Z
42
+ date: 2019-04-06 00:00:00.000000000 Z
43
43
  dependencies:
44
44
  - !ruby/object:Gem::Dependency
45
45
  name: minitest
@@ -47,7 +47,7 @@ dependencies:
47
47
  requirements:
48
48
  - - ">="
49
49
  - !ruby/object:Gem::Version
50
- version: 5.11.3
50
+ version: 5.11.1
51
51
  - - "<"
52
52
  - !ruby/object:Gem::Version
53
53
  version: '6'
@@ -57,7 +57,7 @@ dependencies:
57
57
  requirements:
58
58
  - - ">="
59
59
  - !ruby/object:Gem::Version
60
- version: 5.11.3
60
+ version: 5.11.1
61
61
  - - "<"
62
62
  - !ruby/object:Gem::Version
63
63
  version: '6'
@@ -87,7 +87,7 @@ dependencies:
87
87
  requirements:
88
88
  - - ">="
89
89
  - !ruby/object:Gem::Version
90
- version: 12.3.1
90
+ version: 12.3.0
91
91
  - - "<"
92
92
  - !ruby/object:Gem::Version
93
93
  version: '13'
@@ -97,7 +97,7 @@ dependencies:
97
97
  requirements:
98
98
  - - ">="
99
99
  - !ruby/object:Gem::Version
100
- version: 12.3.1
100
+ version: 12.3.0
101
101
  - - "<"
102
102
  - !ruby/object:Gem::Version
103
103
  version: '13'
@@ -107,7 +107,7 @@ dependencies:
107
107
  requirements:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
- version: 0.16.1
110
+ version: 0.14.1
111
111
  - - "<"
112
112
  - !ruby/object:Gem::Version
113
113
  version: '2'
@@ -117,7 +117,7 @@ dependencies:
117
117
  requirements:
118
118
  - - ">="
119
119
  - !ruby/object:Gem::Version
120
- version: 0.16.1
120
+ version: 0.14.1
121
121
  - - "<"
122
122
  - !ruby/object:Gem::Version
123
123
  version: '2'
@@ -127,7 +127,7 @@ dependencies:
127
127
  requirements:
128
128
  - - ">="
129
129
  - !ruby/object:Gem::Version
130
- version: 4.6.2
130
+ version: 4.6.1
131
131
  - - "<"
132
132
  - !ruby/object:Gem::Version
133
133
  version: '5'
@@ -137,7 +137,7 @@ dependencies:
137
137
  requirements:
138
138
  - - ">="
139
139
  - !ruby/object:Gem::Version
140
- version: 4.6.2
140
+ version: 4.6.1
141
141
  - - "<"
142
142
  - !ruby/object:Gem::Version
143
143
  version: '5'
@@ -147,7 +147,7 @@ dependencies:
147
147
  requirements:
148
148
  - - ">="
149
149
  - !ruby/object:Gem::Version
150
- version: 2.12.0
150
+ version: 2.10.0
151
151
  - - "<"
152
152
  - !ruby/object:Gem::Version
153
153
  version: '3'
@@ -157,7 +157,7 @@ dependencies:
157
157
  requirements:
158
158
  - - ">="
159
159
  - !ruby/object:Gem::Version
160
- version: 2.12.0
160
+ version: 2.10.0
161
161
  - - "<"
162
162
  - !ruby/object:Gem::Version
163
163
  version: '3'
@@ -167,7 +167,7 @@ dependencies:
167
167
  requirements:
168
168
  - - ">="
169
169
  - !ruby/object:Gem::Version
170
- version: 4.8.1
170
+ version: 4.7.3
171
171
  - - "<"
172
172
  - !ruby/object:Gem::Version
173
173
  version: '5'
@@ -177,7 +177,7 @@ dependencies:
177
177
  requirements:
178
178
  - - ">="
179
179
  - !ruby/object:Gem::Version
180
- version: 4.8.1
180
+ version: 4.7.3
181
181
  - - "<"
182
182
  - !ruby/object:Gem::Version
183
183
  version: '5'
@@ -187,7 +187,7 @@ dependencies:
187
187
  requirements:
188
188
  - - ">="
189
189
  - !ruby/object:Gem::Version
190
- version: 3.4.0
190
+ version: 3.3.0
191
191
  - - "<"
192
192
  - !ruby/object:Gem::Version
193
193
  version: '4'
@@ -197,7 +197,7 @@ dependencies:
197
197
  requirements:
198
198
  - - ">="
199
199
  - !ruby/object:Gem::Version
200
- version: 3.4.0
200
+ version: 3.3.0
201
201
  - - "<"
202
202
  - !ruby/object:Gem::Version
203
203
  version: '4'
@@ -207,7 +207,7 @@ dependencies:
207
207
  requirements:
208
208
  - - ">="
209
209
  - !ruby/object:Gem::Version
210
- version: 0.57.2
210
+ version: 0.52.1
211
211
  - - "<"
212
212
  - !ruby/object:Gem::Version
213
213
  version: '1'
@@ -217,12 +217,12 @@ dependencies:
217
217
  requirements:
218
218
  - - ">="
219
219
  - !ruby/object:Gem::Version
220
- version: 0.57.2
220
+ version: 0.52.1
221
221
  - - "<"
222
222
  - !ruby/object:Gem::Version
223
223
  version: '1'
224
- description: Time.stamp method to generate a string formatted with the RFC ISO date
225
- and time
224
+ description: Time stamp methods to generate a string with formating such as RFC ISO
225
+ datetime
226
226
  email: sixarm@sixarm.com
227
227
  executables: []
228
228
  extensions: []
@@ -257,11 +257,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
257
257
  - !ruby/object:Gem::Version
258
258
  version: '0'
259
259
  requirements: []
260
- rubyforge_project:
261
- rubygems_version: 2.7.7
260
+ rubygems_version: 3.0.3
262
261
  signing_key:
263
262
  specification_version: 4
264
- summary: SixArm.com → Ruby → Time.stamp method
263
+ summary: SixArm.com → Ruby → Timestamp methods
265
264
  test_files:
266
265
  - test/sixarm_ruby_time_stamp_test.rb
267
266
  - test/sixarm_ruby_time_stamp_test/time_test.rb
metadata.gz.sig CHANGED
Binary file