patch_life 0.0.3 → 0.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.
data/lib/patch_life.rb CHANGED
@@ -4,9 +4,10 @@ module PatchLife
4
4
  raise(ArgumentError, "define_patch requires a :patch argument to be set") unless options[:patch]
5
5
  raise(ArgumentError, "define_patch requires either a :message argument, a block to yield, or both") unless options[:message] || block_given?
6
6
 
7
- past_due_version = Gem::Version.new(ruby_version) >= Gem::Version.new(options[:version])
7
+ past_due_version = Gem::Version.new(ruby_version) > Gem::Version.new(options[:version])
8
+ equivalent_version = Gem::Version.new(ruby_version) == Gem::Version.new(options[:version])
8
9
  past_due_patch = ruby_patch_level >= options[:patch].to_i
9
- past_due = past_due_version && past_due_patch
10
+ past_due = past_due_version || (equivalent_version && past_due_patch)
10
11
 
11
12
  Kernel.warn(options[:message]) if past_due && options[:message]
12
13
  yield if !past_due && block_given?
data/lib/version.rb CHANGED
@@ -2,7 +2,7 @@ module PatchLife
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- PATCH = 3
5
+ PATCH = 4
6
6
 
7
7
  STRING = [ MAJOR, MINOR, PATCH ].join('.')
8
8
  end
@@ -34,52 +34,141 @@ describe PatchLife do
34
34
  context "when comparing ruby versions" do
35
35
  context "and the current ruby version is less than the declared version" do
36
36
  let (:version) {"9.9.9"}
37
- let (:patch) {999}
38
37
  let (:message) {"You're outdated"}
38
+ context "and the current ruby patch level is less than the declared patch" do
39
+ let (:patch) {999}
40
+ it "will not print a message if defined" do
41
+ Kernel.should_not_receive(:warn).with(message)
42
+ subject.define_patch_life(:version=>version, :patch=>patch, :message=>message) {nil}
43
+ end
44
+
45
+ it "will yield a block if given" do
46
+ block_called = false
47
+ subject.define_patch_life(:version=>version, :patch=>patch, :message=>message) {block_called=true}
48
+ block_called.should == true
49
+ end
50
+ end
39
51
 
40
- it "will not print a message if defined" do
41
- Kernel.should_not_receive(:warn).with(message)
42
- subject.define_patch_life(:version=>version, :patch=>patch, :message=>message) {nil}
52
+ context "and the current ruby patch level is equal to the declared patch" do
53
+ let (:patch) {RUBY_PATCHLEVEL}
54
+ it "will not print a message if defined" do
55
+ Kernel.should_not_receive(:warn).with(message)
56
+ subject.define_patch_life(:version=>version, :patch=>patch, :message=>message) {nil}
57
+ end
58
+
59
+ it "will yield a block if given" do
60
+ block_called = false
61
+ subject.define_patch_life(:version=>version, :patch=>patch, :message=>message) {block_called=true}
62
+ block_called.should == true
63
+ end
43
64
  end
44
65
 
45
- it "will yield a block if given" do
46
- block_called = false
47
- subject.define_patch_life(:version=>version, :patch=>patch, :message=>message) {block_called=true}
48
- block_called.should == true
66
+ context "and the current ruby patch level is greater than the declared patch" do
67
+ let (:patch) {0}
68
+ it "will not print a message if defined" do
69
+ Kernel.should_not_receive(:warn).with(message)
70
+ subject.define_patch_life(:version=>version, :patch=>patch, :message=>message) {nil}
71
+ end
72
+
73
+ it "will yield a block if given" do
74
+ block_called = false
75
+ subject.define_patch_life(:version=>version, :patch=>patch, :message=>message) {block_called=true}
76
+ block_called.should == true
77
+ end
49
78
  end
50
79
  end
51
80
 
52
81
  context "and the current ruby version is equal to the declared version" do
53
82
  let (:version) {RUBY_VERSION.dup}
54
- let (:patch) {RUBY_PATCHLEVEL}
55
83
  let (:message) {"You're outdated"}
56
-
57
- it "will print a message if defined" do
58
- Kernel.should_receive(:warn).with(message)
59
- subject.define_patch_life(:version=>version, :patch=>patch, :message=>message) {nil}
84
+
85
+ context "and the current ruby patch level is less than the declared patch" do
86
+ let (:patch) {999}
87
+ it "will not print a message if defined" do
88
+ Kernel.should_not_receive(:warn).with(message)
89
+ subject.define_patch_life(:version=>version, :patch=>patch, :message=>message) {nil}
90
+ end
91
+
92
+ it "will yield a block if given" do
93
+ block_called = false
94
+ subject.define_patch_life(:version=>version, :patch=>patch, :message=>message) {block_called=true}
95
+ block_called.should == true
96
+ end
97
+ end
98
+
99
+ context "and the current ruby patch level is equal to the declared patch" do
100
+ let (:patch) {RUBY_PATCHLEVEL}
101
+ it "will print a message if defined" do
102
+ Kernel.should_receive(:warn).with(message)
103
+ subject.define_patch_life(:version=>version, :patch=>patch, :message=>message) {nil}
104
+ end
105
+
106
+ it "will not yield a block if given" do
107
+ block_called = false
108
+ subject.define_patch_life(:version=>version, :patch=>patch, :message=>message) {block_called=true}
109
+ block_called.should == false
110
+ end
60
111
  end
61
112
 
62
- it "will not yield a block if given" do
63
- block_called = false
64
- subject.define_patch_life(:version=>version, :patch=>patch, :message=>message) {block_called=true}
65
- block_called.should == false
113
+ context "and the current ruby patch level is greater than the declared patch" do
114
+ let (:patch) {0}
115
+ it "will print a message if defined" do
116
+ Kernel.should_receive(:warn).with(message)
117
+ subject.define_patch_life(:version=>version, :patch=>patch, :message=>message) {nil}
118
+ end
119
+
120
+ it "will not yield a block if given" do
121
+ block_called = false
122
+ subject.define_patch_life(:version=>version, :patch=>patch, :message=>message) {block_called=true}
123
+ block_called.should == false
124
+ end
66
125
  end
67
126
  end
68
127
 
69
128
  context "and the current ruby version is greater than the declared version" do
70
129
  let (:version) {"1.0.0"}
71
- let (:patch) {1}
72
130
  let (:message) {"You're outdated"}
73
131
 
74
- it "will print a message if defined" do
75
- Kernel.should_receive(:warn).with(message)
76
- subject.define_patch_life(:version=>version, :patch=>patch, :message=>message) {nil}
132
+ context "and the current ruby patch level is less than the declared patch" do
133
+ let(:patch) {999}
134
+ it "will print a message if defined" do
135
+ Kernel.should_receive(:warn).with(message)
136
+ subject.define_patch_life(:version=>version, :patch=>patch, :message=>message) {nil}
137
+ end
138
+
139
+ it "will not yield a block if given" do
140
+ block_called = false
141
+ subject.define_patch_life(:version=>version, :patch=>patch, :message=>message) {block_called=true}
142
+ block_called.should == false
143
+ end
144
+ end
145
+
146
+ context "and the current ruby patch level is equal to the declared patch" do
147
+ let (:patch) {RUBY_PATCHLEVEL}
148
+ it "will print a message if defined" do
149
+ Kernel.should_receive(:warn).with(message)
150
+ subject.define_patch_life(:version=>version, :patch=>patch, :message=>message) {nil}
151
+ end
152
+
153
+ it "will not yield a block if given" do
154
+ block_called = false
155
+ subject.define_patch_life(:version=>version, :patch=>patch, :message=>message) {block_called=true}
156
+ block_called.should == false
157
+ end
77
158
  end
78
159
 
79
- it "will not yield a block if given" do
80
- block_called = false
81
- subject.define_patch_life(:version=>version, :patch=>patch, :message=>message) {block_called=true}
82
- block_called.should == false
160
+ context "and the current ruby patch level is greater than the declared patch" do
161
+ let (:patch) {0}
162
+ it "will print a message if defined" do
163
+ Kernel.should_receive(:warn).with(message)
164
+ subject.define_patch_life(:version=>version, :patch=>patch, :message=>message) {nil}
165
+ end
166
+
167
+ it "will not yield a block if given" do
168
+ block_called = false
169
+ subject.define_patch_life(:version=>version, :patch=>patch, :message=>message) {block_called=true}
170
+ block_called.should == false
171
+ end
83
172
  end
84
173
  end
85
174
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: patch_life
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: