Skip to content

Loading…

Remove gorillib as a dependency. #113

Merged
merged 1 commit into from

2 participants

@gaffneyc

Gorillib was being required for a single method that was pretty easily
reimplemented internally. Also expanded the meta programming for loading
core extensions.

@gaffneyc gaffneyc Remove gorillib as a dependency.
Gorillib was being required for a single method that was pretty easily
reimplemented internally. Also expanded the meta programming for loading
core extensions.
95e2f87
@ezkl

@gaffneyc Feel free to open a pull request. :)

@ezkl Done and done! Finally got a chance to test the change against our app that uses feedzirra

@ezkl ezkl merged commit 318c3bd into feedjira:master
@ezkl

@gaffneyc Thanks! Merged.

@ezkl ezkl added a commit that referenced this pull request
@ezkl ezkl Add change from #113 [ci skip] 9681b63
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 3, 2012
  1. @gaffneyc

    Remove gorillib as a dependency.

    gaffneyc committed
    Gorillib was being required for a single method that was pretty easily
    reimplemented internally. Also expanded the meta programming for loading
    core extensions.
Showing with 32 additions and 5 deletions.
  1. +0 −1 feedzirra.gemspec
  2. +0 −1 lib/feedzirra.rb
  3. +3 −3 lib/feedzirra/core_ext.rb
  4. +29 −0 lib/feedzirra/core_ext/time.rb
View
1 feedzirra.gemspec
@@ -23,7 +23,6 @@ Gem::Specification.new do |s|
s.add_dependency 'sax-machine', '~> 0.1.0'
s.add_dependency 'curb', '~> 0.8.0'
s.add_dependency 'loofah', '~> 1.2.1'
- s.add_dependency 'gorillib', '~> 0.1.9'
s.add_development_dependency 'rspec', '~> 2.10.0'
end
View
1 lib/feedzirra.rb
@@ -3,7 +3,6 @@
require 'sax-machine'
require 'loofah'
require 'uri'
-require 'gorillib/datetime/parse'
require 'feedzirra/core_ext'
View
6 lib/feedzirra/core_ext.rb
@@ -1,3 +1,3 @@
-Dir["#{File.dirname(__FILE__)}/core_ext/*.rb"].sort.each do |path|
- require "feedzirra/core_ext/#{File.basename(path, '.rb')}"
-end
+require "feedzirra/core_ext/time"
+require "feedzirra/core_ext/date"
+require "feedzirra/core_ext/string"
View
29 lib/feedzirra/core_ext/time.rb
@@ -0,0 +1,29 @@
+require "time"
+require "date"
+
+class Time
+ # Parse a time string and convert it to UTC without raising errors.
+ # Parses a flattened 14-digit time (YYYYmmddHHMMMSS) as UTC.
+ #
+ # === Parameters
+ # [dt<String or Time>] Time definition to be parsed.
+ #
+ # === Returns
+ # A Time instance in UTC or nil if there were errors while parsing.
+ def self.parse_safely(dt)
+ if dt
+ case
+ when dt.is_a?(Time)
+ dt.utc
+ when dt.respond_to?(:empty?) && dt.empty?
+ nil
+ when dt.to_s =~ /\A\d{14}\z/
+ parse("#{dt.to_s}Z", true)
+ else
+ parse(dt.to_s, true).utc
+ end
+ end
+ rescue StandardError
+ nil
+ end unless method_defined?(:parse_safely)
+end
Something went wrong with that request. Please try again.