dohutil 0.2.25 → 0.2.26

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 74b9a376b86a9dfff72af9e38d607281161ea2e2
4
- data.tar.gz: c35b60cec15347e482ffd81877dc535f10dd946d
3
+ metadata.gz: 5cc48dc755e063824e8319710da5d1f8dbc1ed4d
4
+ data.tar.gz: 24d678ec7356b5d9f734d9914ec5e04c26c0c2eb
5
5
  SHA512:
6
- metadata.gz: b92bf38951022d19359cbb704c2bda9afe983a61accc561d04df5c37e1fbd163cf2b2b7dcc9f0c9d3a2bd9cc61b56d56726cff3d01f665df9ba014181e5beb35
7
- data.tar.gz: 40636a493f2095eb9cd2f0bbf265085956a7a5746f1b2e79b3941273e5f7739e15e50964b2ca44eb7d1f814c3d956bd0326372caca0bc95dc70be7c447aeda11
6
+ metadata.gz: 2832dd535bd832f54f37590b6a865c7cd781d05e200eb5c83781e3758f2a52243549d1a41e210dcb16ff9dc3e5239776c4437aebd02b53e7f58c1f67d3b78a7f
7
+ data.tar.gz: f80512c242c33100856bd921351b0cf832cfc28ca8c7eb12a469d26ea4f1304f499e2b14f95c5026a65bd69d94a7ae7c9c887843e43d1db4f03fe6cb71b26541
@@ -0,0 +1,8 @@
1
+ class Random
2
+ def self.current_seed
3
+ curseed = Random.srand(0)
4
+ Random.srand(curseed)
5
+ curseed
6
+ end
7
+ end
8
+
@@ -46,4 +46,13 @@ def date_as(date_obj)
46
46
  retval
47
47
  end
48
48
 
49
+ # keep the current date, but set the time
50
+ def time_as(hour, minute, second)
51
+ cdo = Doh.current_datetime
52
+ new_time = DateTime.new(cdo.year, cdo.month, cdo.day, hour, minute, second, cdo.zone)
53
+ date_as(new_time) do
54
+ yield
55
+ end
56
+ end
57
+
49
58
  end
@@ -0,0 +1,17 @@
1
+ require 'dohutil/current_date'
2
+
3
+ module Doh
4
+
5
+ class TestCurrentDate < DohTest::TestGroup
6
+ def test_date_as_and_time_as
7
+ cdo = DateTime.new(2016,1,1,1,1,1)
8
+ Doh.date_as(cdo) do
9
+ assert_equal(cdo, Doh.current_datetime)
10
+ Doh.time_as(10,5,3) do
11
+ assert_equal(DateTime.new(2016,1,1,10,5,3), Doh.current_datetime)
12
+ end
13
+ end
14
+ end
15
+ end
16
+
17
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dohutil
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.25
4
+ version: 0.2.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - Makani Mason
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-07-31 00:00:00.000000000 Z
12
+ date: 2016-04-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: dohroot
@@ -99,6 +99,7 @@ files:
99
99
  - lib/dohutil/core_ext/force_deep_copy.rb
100
100
  - lib/dohutil/core_ext/hash.rb
101
101
  - lib/dohutil/core_ext/inspect.rb
102
+ - lib/dohutil/core_ext/random.rb
102
103
  - lib/dohutil/core_ext/string.rb
103
104
  - lib/dohutil/current_date.rb
104
105
  - lib/dohutil/disable_verbose.rb
@@ -113,6 +114,7 @@ files:
113
114
  - test/core_ext/datewithtime.dt.rb
114
115
  - test/core_ext/force_deep_copy.dt.rb
115
116
  - test/core_ext/string.dt.rb
117
+ - test/current_date.dt.rb
116
118
  - test/exception.dt.rb
117
119
  - test/move_weekday.dt.rb
118
120
  homepage: https://github.com/atpsoft/dohutil
@@ -146,5 +148,6 @@ test_files:
146
148
  - test/core_ext/datewithtime.dt.rb
147
149
  - test/core_ext/force_deep_copy.dt.rb
148
150
  - test/core_ext/string.dt.rb
151
+ - test/current_date.dt.rb
149
152
  - test/exception.dt.rb
150
153
  - test/move_weekday.dt.rb