Skip to content

Commit

Permalink
Moving classes in lib each to their own class; I had some issues gett…
Browse files Browse the repository at this point in the history
…ing the constants to be recognized when running locally
  • Loading branch information
carols10cents committed Apr 15, 2012
1 parent eb22cf0 commit bc581b2
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 33 deletions.
23 changes: 23 additions & 0 deletions lib/converts_subscriber_to_feed_data.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
require_relative "queries_web_finger"

FeedData = Struct.new(:url, :finger_data)

class ConvertsSubscriberToFeedData
def self.get_feed_data(subscriber_url)
feed_data = FeedData.new

case subscriber_url
when /^feed:\/\//
# SAFARI!!!!1 /me shakes his first at the sky
feed_data.url = "http" + subscriber_url[4..-1]
when /@/
finger_data = QueriesWebFinger.query(subscriber_url)
feed_data.url = finger_data.url
feed_data.finger_data = finger_data
else
feed_data.url = subscriber_url
end

feed_data
end
end
23 changes: 1 addition & 22 deletions lib/finds_or_creates_feeds.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require_relative 'finger'
require_relative 'converts_subscriber_to_feed_data'

class FindsOrCreatesFeeds
def self.find_or_create(subscribe_to)
Expand All @@ -13,24 +13,3 @@ def self.find_or_create(subscribe_to)
end
end

FeedData = Struct.new(:url, :finger_data)

class ConvertsSubscriberToFeedData
def self.get_feed_data(subscriber_url)
feed_data = FeedData.new

case subscriber_url
when /^feed:\/\//
# SAFARI!!!!1 /me shakes his first at the sky
feed_data.url = "http" + subscriber_url[4..-1]
when /@/
finger_data = QueriesWebFinger.query(subscriber_url)
feed_data.url = finger_data.url
feed_data.finger_data = finger_data
else
feed_data.url = subscriber_url
end

feed_data
end
end
8 changes: 0 additions & 8 deletions lib/finger.rb → lib/finger_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,3 @@ def salmon_url
@xrd.links.find { |l| l['rel'].downcase == 'salmon' }.href
end
end

class QueriesWebFinger
def self.query(email)
# XXX: ensure caching of finger lookup.
xrd = Redfinger.finger(email)
FingerData.new(xrd)
end
end
9 changes: 9 additions & 0 deletions lib/queries_web_finger.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require_relative "finger_data"

class QueriesWebFinger
def self.query(email)
# XXX: ensure caching of finger lookup.
xrd = Redfinger.finger(email)
FingerData.new(xrd)
end
end
6 changes: 3 additions & 3 deletions test/lib/finger_test.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'minitest/autorun'
require 'mocha'

require_relative '../../lib/finger'
require_relative '../../lib/finger_data'

describe "when querying web finger" do

Expand All @@ -24,7 +24,7 @@ def href

module Redfinger
end

before do
url_link = Link.new('http://schemas.google.com/g/2010#updates-from', 'http://feed.url')
public_key_link = Link.new('magic-public-key', 'ignored,key')
Expand All @@ -41,7 +41,7 @@ module Redfinger
it "should get the remote url" do
assert_equal "http://feed.url", @finger_data.url
end

it "should get public key " do
assert_equal "key", @finger_data.public_key
end
Expand Down

0 comments on commit bc581b2

Please sign in to comment.