summaryrefslogtreecommitdiff
path: root/vendor/certificate_authority/lib/certificate_authority/core_extensions.rb
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2016-10-05 14:35:56 -0700
committerelijah <elijah@riseup.net>2016-10-05 14:35:56 -0700
commit7abfbd6abae14fa6a72350f7b75268ff561354ee (patch)
treeaf5c969c905a8d2a95f2b2aa7c4dd6f4b8763126 /vendor/certificate_authority/lib/certificate_authority/core_extensions.rb
parentcc57bc6c0ff99d88f3bfeff1b04297e9b91e6988 (diff)
parentf95e08ef7d8defbde4a19e138b1ac4ebc9677669 (diff)
Merge branch 'develop'
# Conflicts: # lib/leap_cli/version.rb
Diffstat (limited to 'vendor/certificate_authority/lib/certificate_authority/core_extensions.rb')
-rw-r--r--vendor/certificate_authority/lib/certificate_authority/core_extensions.rb46
1 files changed, 46 insertions, 0 deletions
diff --git a/vendor/certificate_authority/lib/certificate_authority/core_extensions.rb b/vendor/certificate_authority/lib/certificate_authority/core_extensions.rb
new file mode 100644
index 0000000..0508f9a
--- /dev/null
+++ b/vendor/certificate_authority/lib/certificate_authority/core_extensions.rb
@@ -0,0 +1,46 @@
+#
+# ActiveSupport has these modifications. Now that we don't use ActiveSupport,
+# these are added here as a kindness.
+#
+
+require 'date'
+
+unless nil.respond_to?(:blank?)
+ class NilClass
+ def blank?
+ true
+ end
+ end
+end
+
+unless String.respond_to?(:blank?)
+ class String
+ def blank?
+ self.empty?
+ end
+ end
+end
+
+class Date
+
+ def today
+ t = Time.now.utc
+ Date.new(t.year, t.month, t.day)
+ end
+
+ def utc
+ self.to_datetime.to_time.utc
+ end
+
+ unless Date.respond_to?(:advance)
+ def advance(options)
+ options = options.dup
+ d = self
+ d = d >> options.delete(:years) * 12 if options[:years]
+ d = d >> options.delete(:months) if options[:months]
+ d = d + options.delete(:weeks) * 7 if options[:weeks]
+ d = d + options.delete(:days) if options[:days]
+ d
+ end
+ end
+end