check-date 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.
@@ -1,10 +1,5 @@
1
- Gem.pre_install do |installer|
2
- today = Date.today
1
+ require "check-date"
3
2
 
4
- if (today - installer.spec.date).to_f > 365 then
5
- if !Gem::ConsoleUI.new.ask_yes_no("This gem was updated more than 1 years ago. (last update: #{installer.spec.date})\nInstall this gem?", true) then
6
- abort
7
- end
8
- end
3
+ Gem.pre_install do |installer|
4
+ CheckDate.check_date installer
9
5
  end
10
-
@@ -1,5 +1,5 @@
1
1
  module Check
2
2
  module Date
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
data/lib/check-date.rb CHANGED
@@ -1,7 +1,23 @@
1
1
  require "check-date/version"
2
2
 
3
- module Check
4
- module Date
5
- # Your code goes here...
3
+ module CheckDate
4
+ def self.check_date(installer)
5
+ if (Date.today - last_update(installer.spec.date)).to_f > 365 then
6
+ ask_install(installer.spec.date)
7
+ end
8
+ end
9
+
10
+ def self.last_update(date)
11
+ date.class == Time ? date.to_date : date
12
+ end
13
+
14
+ def self.ask_install(date)
15
+ unless Gem::ConsoleUI.new.ask_yes_no(
16
+ "This gem was updated more than 1 years ago. (last update: #{date})\n" \
17
+ "Install this gem?",
18
+ true)
19
+ then
20
+ abort
21
+ end
6
22
  end
7
23
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: check-date
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:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-07-26 00:00:00.000000000Z
12
+ date: 2011-08-01 00:00:00.000000000Z
13
13
  dependencies: []
14
14
  description: Check gem's date and warn if date is more than 1 years ago.
15
15
  email: