sixarm_ruby_fab 1.0.0 → 1.0.1

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
  SHA1:
3
- metadata.gz: 2cfd05a4915d109badc07b3de31b368a094764e4
4
- data.tar.gz: b1308a6558b30ddd6f44f7003d93302ae5ddbc19
3
+ metadata.gz: 928df2312ff8a41a06835e0cd4f85d2e54144abb
4
+ data.tar.gz: 72519949a884dd6a82e7b06c1a79edca256644cc
5
5
  SHA512:
6
- metadata.gz: 9ce73304f967d12d5a7e24b37c8dd5a0666581fae01ff4b6a41b5ac7ed05b12704b497e90a325c53b542004e9b30c472f1070acec5464b1f5e5cdca64036895e
7
- data.tar.gz: 747bde33626df662131b4661c1df943890bd67fa175f35368c81e99ee49149b64e45475a1d2343211189d5dec69c3350596773d86b6c657bec5098d4f31a3573
6
+ metadata.gz: 9eeae5c0abd20644e0e67c29fa5880e57aed4326ef61f32ada4eb23e4d45dc04d7d3261560ff1bedcd1a2cafc1b530c3a47ef70794134feb17d7af27b94bf400
7
+ data.tar.gz: ab221a63c2879ffd4d500e6af4c10c528378f3ebddc7ea983323b1219bb5a77344fb6772200ae7e13547f1755be475af8269a357f9ac2cb9b56154462728461d
@@ -1 +1 @@
1
- ��*�j�������n�@��xsR`��rX’�Q֍B
1
+ ��p�:YN��YlBҕG�kp�S�uz p$W8���ᇄzc���+�ti�8���Hr�1C��Ť�)Se`��p9I�Ӕ���V�r�m��SqD�B5����8k&q��W7�j&��u�^��LID�
data.tar.gz.sig CHANGED
Binary file
data/README.md CHANGED
@@ -24,7 +24,7 @@ Install:
24
24
 
25
25
  Bundler:
26
26
 
27
- gem "sixarm_ruby_fab", "~>1.0.0"
27
+ gem "sixarm_ruby_fab", "~>1.0.0"
28
28
 
29
29
  Require:
30
30
 
@@ -59,6 +59,7 @@ Use it:
59
59
 
60
60
  ## Changes
61
61
 
62
+ * 2013-08-02 1.0.1 Add min & max to date, datetime, time.
62
63
  * 2013-08-01 1.0.0 Publish.
63
64
 
64
65
 
@@ -10,9 +10,29 @@ class Fab
10
10
  # @returns [Date] a random date min..max
11
11
  #
12
12
  def date(options = {})
13
- rand((options[:min] || Date.today - 1000)..(options[:max] || Date.today + 1000))
13
+ rand((options[:min] || date_min)..(options[:max] || date_max))
14
14
  end
15
15
 
16
+ # Get. The default is today - 1000.
17
+ def date_min
18
+ @date_min ||= Date.today - 1000
19
+ end
20
+
21
+ # Set.
22
+ def date_min=x
23
+ @date_min=x
24
+ end
25
+
26
+ # Get. The default is today + 1000.
27
+ def date_max
28
+ @date_max ||= Date.today + 1000
29
+ end
30
+
31
+ # Set.
32
+ def date_max=x
33
+ @date_max=x
34
+ end
35
+
16
36
  # Fab a random start date.
17
37
  # Delegates to #date.
18
38
  #
@@ -1,5 +1,5 @@
1
1
  class Fab
2
-
2
+
3
3
  # Fab a random datetime.
4
4
  #
5
5
  # Options:
@@ -10,9 +10,29 @@ class Fab
10
10
  # @returns [DateTime] a random datetime min..max
11
11
  #
12
12
  def datetime(options = {})
13
- rand((options[:min] || DateTime.now - 1000)..(options[:max] || DateTime.now + 1000))
13
+ rand((options[:min] || datetime_min)..(options[:max] || datetime_max))
14
+ end
15
+
16
+ # Get. The default is now - 1000.
17
+ def datetime_min
18
+ @datetime_min ||= DateTime.now - 1000
19
+ end
20
+
21
+ # Set.
22
+ def datetime_min=x
23
+ @datetime_min=x
14
24
  end
15
25
 
26
+ # Get. The default is now + 1000.
27
+ def datetime_max
28
+ @datetime_max ||= DateTime.now + 1000
29
+ end
30
+
31
+ # Set.
32
+ def datetime_max=x
33
+ @datetime_max=x
34
+ end
35
+
16
36
  # Fab a random start datetime.
17
37
  # Delegates to #datetime.
18
38
  #
@@ -4,13 +4,33 @@ class Fab
4
4
  #
5
5
  # Options:
6
6
  #
7
- # * min: now - 1000
8
- # * max: now + 1000
7
+ # * min
8
+ # * max
9
9
  #
10
10
  # @returns [Time] a random time min..max
11
11
  #
12
12
  def time(options = {})
13
- rand((options[:min] || Time.now - 1000)..(options[:max] || Time.now + 1000))
13
+ rand((options[:min] || time_min)..(options[:max] || time_max))
14
+ end
15
+
16
+ # Get. The default is now - 1000.
17
+ def time_min
18
+ @time_min ||= Time.now - 1000
19
+ end
20
+
21
+ # Set.
22
+ def time_min=x
23
+ @time_min=x
24
+ end
25
+
26
+ # Get. The default is now + 1000.
27
+ def time_max
28
+ @time_max ||= Time.now + 1000
29
+ end
30
+
31
+ # Set.
32
+ def time_max=x
33
+ @time_max=x
14
34
  end
15
35
 
16
36
  # Fab a random start time.
@@ -19,6 +19,56 @@ describe Fab do
19
19
 
20
20
  end
21
21
 
22
+ describe "#date_min" do
23
+
24
+ before do
25
+ @x = fab.date_min
26
+ end
27
+
28
+ it "returns a date" do
29
+ @x.must_be_kind_of Date
30
+ end
31
+
32
+ end
33
+
34
+ describe "#date_min=" do
35
+
36
+ before do
37
+ @x = Date.today
38
+ end
39
+
40
+ it "sets & gets" do
41
+ fab.date_min = @x
42
+ fab.date_min.must_equal @x
43
+ end
44
+
45
+ end
46
+
47
+ describe "#date_max" do
48
+
49
+ before do
50
+ @x = fab.date_max
51
+ end
52
+
53
+ it "returns a date" do
54
+ @x.must_be_kind_of Date
55
+ end
56
+
57
+ end
58
+
59
+ describe "#date_max=" do
60
+
61
+ before do
62
+ @x = Date.today
63
+ end
64
+
65
+ it "sets & gets" do
66
+ fab.date_max = @x
67
+ fab.date_max.must_equal @x
68
+ end
69
+
70
+ end
71
+
22
72
  describe "#start_date" do
23
73
 
24
74
  before do
@@ -18,6 +18,56 @@ describe Fab do
18
18
  end
19
19
  end
20
20
 
21
+ describe "#datetime_min" do
22
+
23
+ before do
24
+ @x = fab.datetime_min
25
+ end
26
+
27
+ it "returns a datetime" do
28
+ @x.must_be_kind_of DateTime
29
+ end
30
+
31
+ end
32
+
33
+ describe "#datetime_min=" do
34
+
35
+ before do
36
+ @x = DateTime.now
37
+ end
38
+
39
+ it "sets & gets" do
40
+ fab.datetime_min = @x
41
+ fab.datetime_min.must_equal @x
42
+ end
43
+
44
+ end
45
+
46
+ describe "#datetime_max" do
47
+
48
+ before do
49
+ @x = fab.datetime_max
50
+ end
51
+
52
+ it "returns a datetime" do
53
+ @x.must_be_kind_of DateTime
54
+ end
55
+
56
+ end
57
+
58
+ describe "#datetime_max=" do
59
+
60
+ before do
61
+ @x = DateTime.now
62
+ end
63
+
64
+ it "sets & gets" do
65
+ fab.datetime_max = @x
66
+ fab.datetime_max.must_equal @x
67
+ end
68
+
69
+ end
70
+
21
71
  describe "#start_datetime" do
22
72
 
23
73
  before do
@@ -19,6 +19,56 @@ describe Fab do
19
19
 
20
20
  end
21
21
 
22
+ describe "#time_min" do
23
+
24
+ before do
25
+ @x = fab.time_min
26
+ end
27
+
28
+ it "returns a time" do
29
+ @x.must_be_kind_of Time
30
+ end
31
+
32
+ end
33
+
34
+ describe "#time_min=" do
35
+
36
+ before do
37
+ @x = Time.now
38
+ end
39
+
40
+ it "sets & gets" do
41
+ fab.time_min = @x
42
+ fab.time_min.must_equal @x
43
+ end
44
+
45
+ end
46
+
47
+ describe "#time_max" do
48
+
49
+ before do
50
+ @x = fab.time_max
51
+ end
52
+
53
+ it "returns a time" do
54
+ @x.must_be_kind_of Time
55
+ end
56
+
57
+ end
58
+
59
+ describe "#time_max=" do
60
+
61
+ before do
62
+ @x = Time.now
63
+ end
64
+
65
+ it "sets & gets" do
66
+ fab.time_max = @x
67
+ fab.time_max.must_equal @x
68
+ end
69
+
70
+ end
71
+
22
72
  describe "#start_time" do
23
73
 
24
74
  before do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sixarm_ruby_fab
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - SixArm
@@ -28,7 +28,7 @@ cert_chain:
28
28
  ZDRQYMqru9TEMna6HD9zpcstF7vwThGovlOQ+3Y6plQ4nMzipXcZ9THqs65PIL0q
29
29
  eabwpCbAopo=
30
30
  -----END CERTIFICATE-----
31
- date: 2013-07-31 00:00:00.000000000 Z
31
+ date: 2013-08-01 00:00:00.000000000 Z
32
32
  dependencies:
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: forgery
metadata.gz.sig CHANGED
Binary file