Permalink
Browse files

small fixes

  • Loading branch information...
1 parent a893cbc commit e7f5500740155867478adce5a484028781851178 Matthew Van Horn committed Dec 1, 2008
Showing with 34 additions and 8 deletions.
  1. +19 −4 disqus.gemspec
  2. +6 −1 init.rb
  3. +5 −0 lib/disqus/author.rb
  4. +1 −1 lib/disqus/forum.rb
  5. +2 −1 lib/disqus/post.rb
  6. +1 −1 lib/disqus/thread.rb
View
23 disqus.gemspec
@@ -20,17 +20,32 @@ Gem::Specification.new do |s|
"lib/disqus/post.rb",
"lib/disqus/thread.rb",
"lib/disqus/view_helpers.rb",
- "lib/disqus/widget.rb"
- "Rakefile",
- ]
+ "lib/disqus/widget.rb",
+ "Rakefile"
+ ]
s.test_files = [
-
+ "test/test_helper.rb",
+ "test/config.yml.sample",
"test/api_test.rb",
"test/forum_test.rb",
+ "test/merb_test.rb",
+ "test/post_test.rb",
+ "test/rails_test.rb",
"test/thread_test.rb",
"test/view_helpers_test.rb",
"test/widget_test.rb",
+ "test/responses/bad_api_key.json",
+ "test/responses/create_post.json",
+ "test/responses/get_forum_api_key.json",
+ "test/responses/get_forum_list.json",
+ "test/responses/get_num_posts.json",
+ "test/responses/get_thread_by_url.json",
+ "test/responses/get_thread_list.json",
+ "test/responses/get_thread_posts.json",
+ "test/responses/thread_by_identifier.json",
+ "test/responses/update_thread.json"
]
s.rdoc_options = ["--main", "README.textile", "--inline-source", "--line-numbers"]
s.extra_rdoc_files = ["README.textile"]
end
+
View
7 init.rb
@@ -1 +1,6 @@
-require 'disqus'
+require 'disqus'
+require 'disqus/api'
+require 'disqus/author'
+require 'disqus/forum'
+require 'disqus/post'
+require 'disqus/thread'
View
5 lib/disqus/author.rb
@@ -8,6 +8,11 @@ class Author < BaseAuthor
def initialize(id, username, display_name, url, email_hash, has_avatar)
@id, @username, @display_name, @url, @email_hash, @has_avatar = id, username, display_name, url, email_hash, has_avatar
end
+
+ def name
+ @display_name.blank? ? @username : @display_name
+ end
+
end
class AnonymousAuthor < BaseAuthor
View
2 lib/disqus/forum.rb
@@ -4,7 +4,7 @@ class Forum
attr_reader :id, :shortname, :name, :created_at, :threads
def initialize(id, shortname, name, created_at)
- @id, @shortname, @name = id.to_i, shortname, name
+ @id, @shortname, @name, @created_at = id.to_i, shortname, name, Time.parse(created_at.to_s)
@key = nil
@threads = []
end
View
3 lib/disqus/post.rb
@@ -4,7 +4,7 @@ class Post
attr_reader :id, :forum, :thread, :created_at, :message, :parent_post, :shown, :is_anonymous, :author
def initialize(id, forum, thread, created_at, message, parent_post, shown, is_anonymous, author)
- @id, @forum, @thread, @created_at, @message, @parent_post, @shown, @is_anonymous, @author = id.to_i, forum, thread, created_at, message, parent_post, shown, is_anonymous, author
+ @id, @forum, @thread, @created_at, @message, @parent_post, @shown, @is_anonymous, @author = id.to_i, forum, thread, Time.parse(created_at.to_s), message, parent_post, shown, is_anonymous, author
end
def self.list(thread, opts = {})
@@ -34,6 +34,7 @@ def self.list(thread, opts = {})
post["is_anonymous"],
author )
end
+ posts.sort!{|a,b| a.created_at <=> b.created_at}
end
end
end
View
2 lib/disqus/thread.rb
@@ -4,7 +4,7 @@ class Thread
attr_reader :id, :forum, :slug, :title, :created_at, :allow_comments, :url, :identifier, :forum, :posts
def initialize(id, forum, slug, title, created_at, allow_comments, url, identifier)
- @id, @forum, @slug, @title, @created_at, @allow_comments, @url, @identifier = id.to_i, forum, slug, title, created_at, allow_comments, url, identifier
+ @id, @forum, @slug, @title, @created_at, @allow_comments, @url, @identifier = id.to_i, forum, slug, title, Time.parse(created_at.to_s), allow_comments, url, identifier
@posts = []
end

0 comments on commit e7f5500

Please sign in to comment.