Skip to content

Commit

Permalink
Remove gorillib as a dependency.
Browse files Browse the repository at this point in the history
Gorillib was being required for a single method that was pretty easily
reimplemented internally. Also expanded the meta programming for loading
core extensions.
  • Loading branch information
gaffneyc committed Jun 3, 2012
1 parent 59ba34b commit 95e2f87
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 5 deletions.
1 change: 0 additions & 1 deletion feedzirra.gemspec
Expand Up @@ -23,7 +23,6 @@ Gem::Specification.new do |s|
s.add_dependency 'sax-machine', '~> 0.1.0' s.add_dependency 'sax-machine', '~> 0.1.0'
s.add_dependency 'curb', '~> 0.8.0' s.add_dependency 'curb', '~> 0.8.0'
s.add_dependency 'loofah', '~> 1.2.1' s.add_dependency 'loofah', '~> 1.2.1'
s.add_dependency 'gorillib', '~> 0.1.9'


s.add_development_dependency 'rspec', '~> 2.10.0' s.add_development_dependency 'rspec', '~> 2.10.0'
end end
1 change: 0 additions & 1 deletion lib/feedzirra.rb
Expand Up @@ -3,7 +3,6 @@
require 'sax-machine' require 'sax-machine'
require 'loofah' require 'loofah'
require 'uri' require 'uri'
require 'gorillib/datetime/parse'


require 'feedzirra/core_ext' require 'feedzirra/core_ext'


Expand Down
6 changes: 3 additions & 3 deletions lib/feedzirra/core_ext.rb
@@ -1,3 +1,3 @@
Dir["#{File.dirname(__FILE__)}/core_ext/*.rb"].sort.each do |path| require "feedzirra/core_ext/time"
require "feedzirra/core_ext/#{File.basename(path, '.rb')}" require "feedzirra/core_ext/date"
end require "feedzirra/core_ext/string"
29 changes: 29 additions & 0 deletions 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

2 comments on commit 95e2f87

@ezkl
Copy link

@ezkl ezkl commented on 95e2f87 Jun 4, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@gaffneyc
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Please sign in to comment.